summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xBUILD/compile-solaris-sparc-fortre19
-rwxr-xr-xBUILD/compile-solaris-sparc-purify8
-rwxr-xr-xBuild-tools/Do-compile44
-rw-r--r--Docs/Makefile.am6
-rw-r--r--Docs/manual.texi53611
-rw-r--r--bdb/lock/lock_region.c1
-rw-r--r--client/Makefile.am11
-rw-r--r--client/mysql.cc38
-rw-r--r--client/mysqladmin.c12
-rw-r--r--client/mysqlbinlog.cc5
-rw-r--r--client/mysqldump.c91
-rw-r--r--client/mysqlimport.c13
-rw-r--r--client/mysqltest.c45
-rwxr-xr-xconfig.guess68
-rwxr-xr-xconfig.sub198
-rw-r--r--configure.in66
-rw-r--r--dbug/dbug.c181
-rw-r--r--dbug/factorial.c4
-rw-r--r--heap/heapdef.h4
-rw-r--r--include/config-os2.h822
-rw-r--r--include/config-win.h1
-rw-r--r--include/errmsg.h4
-rw-r--r--include/global.h39
-rw-r--r--include/heap.h4
-rw-r--r--include/m_string.h4
-rw-r--r--include/my_pthread.h64
-rw-r--r--include/my_sys.h1
-rw-r--r--include/mysql_com.h6
-rw-r--r--include/mysqld_error.h17
-rw-r--r--include/thr_alarm.h2
-rw-r--r--innobase/btr/btr0btr.c4
-rw-r--r--innobase/btr/btr0cur.c286
-rw-r--r--innobase/btr/btr0sea.c5
-rw-r--r--innobase/buf/buf0buf.c21
-rw-r--r--innobase/buf/buf0flu.c2
-rw-r--r--innobase/data/data0data.c25
-rw-r--r--innobase/fil/fil0fil.c11
-rw-r--r--innobase/ibuf/ibuf0ibuf.c2
-rw-r--r--innobase/include/btr0cur.h70
-rw-r--r--innobase/include/buf0buf.h11
-rw-r--r--innobase/include/data0data.h7
-rw-r--r--innobase/include/srv0srv.h16
-rw-r--r--innobase/include/trx0sys.h3
-rw-r--r--innobase/include/trx0trx.h24
-rw-r--r--innobase/include/ut0ut.h2
-rw-r--r--innobase/lock/lock0lock.c72
-rw-r--r--innobase/os/os0file.c34
-rw-r--r--innobase/row/row0mysql.c97
-rw-r--r--innobase/row/row0purge.c8
-rw-r--r--innobase/row/row0sel.c21
-rw-r--r--innobase/row/row0uins.c4
-rw-r--r--innobase/row/row0umod.c33
-rw-r--r--innobase/row/row0upd.c79
-rw-r--r--innobase/srv/srv0srv.c80
-rw-r--r--innobase/srv/srv0start.c7
-rw-r--r--innobase/sync/sync0arr.c40
-rw-r--r--innobase/trx/trx0roll.c8
-rw-r--r--innobase/trx/trx0sys.c3
-rw-r--r--innobase/trx/trx0trx.c103
-rw-r--r--isam/isamchk.c103
-rw-r--r--isam/isamlog.c208
-rw-r--r--isam/test1.c8
-rw-r--r--isam/test2.c59
-rw-r--r--isam/test_all.res207
-rw-r--r--libmysql/get_password.c7
-rw-r--r--libmysql/libmysql.c7
-rw-r--r--libmysql/net.c23
-rwxr-xr-xltconfig25
-rw-r--r--merge/_locking.c4
-rw-r--r--merge/close.c3
-rw-r--r--merge/create.c3
-rw-r--r--merge/extra.c6
-rw-r--r--merge/open.c8
-rw-r--r--merge/panic.c4
-rw-r--r--merge/rsame.c8
-rw-r--r--merge/update.c6
-rw-r--r--myisam/ft_eval.c8
-rw-r--r--myisam/ft_eval.h5
-rw-r--r--myisam/ft_search.c2
-rw-r--r--myisam/ft_test1.c7
-rw-r--r--myisam/ftdefs.h2
-rw-r--r--myisam/mi_cache.c4
-rw-r--r--myisam/mi_check.c37
-rw-r--r--myisam/mi_packrec.c2
-rw-r--r--myisam/mi_test1.c3
-rw-r--r--myisam/mi_test2.c46
-rw-r--r--myisam/myisamchk.c10
-rw-r--r--myisam/myisamlog.c13
-rw-r--r--myisam/myisampack.c72
-rw-r--r--myisam/sort.c13
-rw-r--r--myisammrg/myrg_delete.c6
-rw-r--r--myisammrg/myrg_locking.c6
-rw-r--r--myisammrg/myrg_open.c23
-rw-r--r--myisammrg/myrg_panic.c3
-rw-r--r--mysql-test/misc/select.tst4015
-rw-r--r--mysql-test/r/func_time.result4
-rw-r--r--mysql-test/r/gemini.result6
-rw-r--r--mysql-test/r/innodb.result4
-rw-r--r--mysql-test/r/rpl_get_lock.result4
-rw-r--r--mysql-test/std_data/gemini.dat5
-rw-r--r--mysql-test/t/backup.test2
-rw-r--r--mysql-test/t/func_time.test3
-rw-r--r--mysql-test/t/gemini.test15
-rw-r--r--mysql-test/t/innodb.test40
-rw-r--r--mysql-test/t/merge.test6
-rw-r--r--mysql-test/t/rpl_get_lock.test16
-rw-r--r--mysql-test/t/show_check.test2
-rw-r--r--mysys/charset.c16
-rw-r--r--mysys/default.c4
-rw-r--r--mysys/getopt.c4
-rw-r--r--mysys/getopt1.c2
-rw-r--r--mysys/hash.c5
-rw-r--r--mysys/list.c8
-rw-r--r--mysys/mf_casecnv.c32
-rw-r--r--mysys/mf_dirname.c2
-rw-r--r--mysys/mf_format.c2
-rw-r--r--mysys/mf_path.c2
-rw-r--r--mysys/mf_qsort.c4
-rw-r--r--mysys/mf_tempfile.c17
-rw-r--r--mysys/my_clock.c4
-rw-r--r--mysys/my_copy.c2
-rw-r--r--mysys/my_create.c4
-rw-r--r--mysys/my_getwd.c14
-rw-r--r--mysys/my_init.c2
-rw-r--r--mysys/my_lib.c15
-rw-r--r--mysys/my_lock.c58
-rw-r--r--mysys/my_malloc.c2
-rw-r--r--mysys/my_mkdir.c4
-rw-r--r--mysys/my_open.c4
-rw-r--r--mysys/my_os2cond.c188
-rw-r--r--mysys/my_os2dirsrch.c182
-rw-r--r--mysys/my_os2dirsrch.h77
-rw-r--r--mysys/my_os2dlfcn.c74
-rw-r--r--mysys/my_os2dlfcn.h039
-rw-r--r--mysys/my_os2file64.c341
-rw-r--r--mysys/my_os2mutex.c98
-rw-r--r--mysys/my_os2thread.c126
-rw-r--r--mysys/my_os2tls.c144
-rw-r--r--mysys/my_pthread.c2
-rw-r--r--mysys/my_realloc.c2
-rw-r--r--mysys/my_redel.c2
-rw-r--r--mysys/my_static.c2
-rw-r--r--mysys/my_tempnam.c17
-rw-r--r--mysys/my_thr_init.c6
-rw-r--r--mysys/my_write.c40
-rw-r--r--mysys/test_charset.c2
-rw-r--r--mysys/thr_alarm.c14
-rw-r--r--mysys/thr_lock.c31
-rw-r--r--mysys/tree.c2
-rw-r--r--os2/ChangeLog.os223
-rw-r--r--os2/MySQL-All.icc13
-rw-r--r--os2/MySQL-Client.icc87
-rw-r--r--os2/MySQL-Client.irs2335
-rw-r--r--os2/MySQL-Lib.icc72
-rw-r--r--os2/MySQL-Opt.icc53
-rw-r--r--os2/MySQL-ReadLine.icc27
-rw-r--r--os2/MySQL-Source.icc298
-rw-r--r--os2/MySQL-Sql.icc117
-rw-r--r--os2/MySQL-Util.icc134
-rw-r--r--os2/MySQL-Util.irs3067
-rw-r--r--os2/MySQL-binlog.icc68
-rw-r--r--os2/MySQL-binlog.irs7
-rw-r--r--os2/MySQL-sql.irs13
-rw-r--r--os2/build-all.cmd11
-rw-r--r--os2/build-all.log39
-rw-r--r--os2/mysql.base127
-rw-r--r--os2/mysql.ih7
-rw-r--r--os2/readme.os2190
-rw-r--r--os2/rint.cmd4
-rw-r--r--os2/rint.objbin0 -> 334 bytes
-rw-r--r--os2/rint.s32
-rw-r--r--sql-bench/bench-init.pl.sh31
-rw-r--r--sql-bench/test-insert.sh77
-rw-r--r--sql-bench/test-select.sh6
-rw-r--r--sql/field.cc4
-rw-r--r--sql/field.h26
-rw-r--r--sql/filesort.cc2
-rw-r--r--sql/gen_lex_hash.cc2
-rw-r--r--sql/ha_gemini.cc15
-rw-r--r--sql/ha_gemini.h1
-rw-r--r--sql/ha_innobase.cc126
-rw-r--r--sql/ha_innobase.h2
-rw-r--r--sql/ha_myisam.cc8
-rw-r--r--sql/ha_myisammrg.cc6
-rw-r--r--sql/handler.cc2
-rw-r--r--sql/handler.h2
-rw-r--r--sql/hostname.cc2
-rw-r--r--sql/item_func.cc92
-rw-r--r--sql/item_strfunc.cc6
-rw-r--r--sql/lex.h1
-rw-r--r--sql/log.cc10
-rw-r--r--sql/log_event.cc6
-rw-r--r--sql/md5.c37
-rw-r--r--sql/mini_client.cc66
-rw-r--r--sql/mysql_priv.h4
-rw-r--r--sql/mysqld.cc133
-rw-r--r--sql/net_serv.cc20
-rw-r--r--sql/share/czech/errmsg.txt375
-rw-r--r--sql/share/danish/errmsg.txt1
-rw-r--r--sql/share/dutch/errmsg.txt1
-rw-r--r--sql/share/english/errmsg.txt1
-rw-r--r--sql/share/estonian/errmsg.txt1
-rw-r--r--sql/share/french/errmsg.txt1
-rw-r--r--sql/share/german/errmsg.txt1
-rw-r--r--sql/share/greek/errmsg.txt1
-rw-r--r--sql/share/hungarian/errmsg.txt1
-rw-r--r--sql/share/italian/errmsg.txt1
-rw-r--r--sql/share/japanese/errmsg.txt1
-rw-r--r--sql/share/korean/errmsg.txt1
-rw-r--r--sql/share/norwegian-ny/errmsg.txt1
-rw-r--r--sql/share/norwegian/errmsg.txt1
-rw-r--r--sql/share/polish/errmsg.txt1
-rw-r--r--sql/share/portuguese/errmsg.txt51
-rw-r--r--sql/share/romanian/errmsg.txt1
-rw-r--r--sql/share/russian/errmsg.txt1
-rw-r--r--sql/share/slovak/errmsg.txt1
-rw-r--r--sql/share/spanish/errmsg.txt1
-rw-r--r--sql/share/swedish/errmsg.txt5
-rw-r--r--sql/slave.cc2
-rw-r--r--sql/sql_acl.cc2
-rw-r--r--sql/sql_base.cc13
-rw-r--r--sql/sql_class.cc41
-rw-r--r--sql/sql_class.h7
-rw-r--r--sql/sql_db.cc4
-rw-r--r--sql/sql_delete.cc2
-rw-r--r--sql/sql_insert.cc34
-rw-r--r--sql/sql_load.cc12
-rw-r--r--sql/sql_parse.cc31
-rw-r--r--sql/sql_repl.cc26
-rw-r--r--sql/sql_select.cc2
-rw-r--r--sql/sql_show.cc16
-rw-r--r--sql/sql_string.cc6
-rw-r--r--sql/sql_table.cc32
-rw-r--r--sql/sql_test.cc3
-rw-r--r--sql/sql_udf.cc2
-rw-r--r--sql/sql_update.cc2
-rw-r--r--sql/sql_yacc.yy2
-rw-r--r--sql/stacktrace.c11
-rw-r--r--sql/stacktrace.h7
-rw-r--r--strings/conf_to_src.c4
-rw-r--r--strings/ctype-big5.c4
-rw-r--r--strings/ctype-gbk.c4
-rw-r--r--strings/ctype-sjis.c6
-rw-r--r--strings/ctype-tis620.c4
-rw-r--r--strings/ctype.c4
-rw-r--r--strings/strnlen.c2
-rw-r--r--strings/strto.c14
-rw-r--r--strings/strtoll.c4
-rw-r--r--strings/strtoul.c2
-rw-r--r--strings/strtoull.c4
250 files changed, 39486 insertions, 31819 deletions
diff --git a/BUILD/compile-solaris-sparc-fortre b/BUILD/compile-solaris-sparc-fortre
new file mode 100755
index 00000000000..dca0412c979
--- /dev/null
+++ b/BUILD/compile-solaris-sparc-fortre
@@ -0,0 +1,19 @@
+#! /bin/sh
+
+gmake -k clean || true
+/bin/rm -f */.deps/*.P config.cache
+
+aclocal && autoheader && aclocal && automake && autoconf
+(cd bdb/dist && sh s_all)
+(cd innobase && aclocal && autoheader && aclocal && automake && autoconf)
+if [ -d gemini ]
+then
+ (cd gemini && aclocal && autoheader && aclocal && automake && autoconf)
+fi
+
+PATH=/opt/SUNWspro/bin/:$PATH
+CC=cc CFLAGS="-Xa -fast -xO4 -native -xstrconst -mt -D_FORTREC_" \
+CXX=CC CXXFLAGS="-noex -xO4 -mt" \
+./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client
+
+gmake -j 4
diff --git a/BUILD/compile-solaris-sparc-purify b/BUILD/compile-solaris-sparc-purify
index b5c898bff30..8bb53bba876 100755
--- a/BUILD/compile-solaris-sparc-purify
+++ b/BUILD/compile-solaris-sparc-purify
@@ -6,8 +6,12 @@ aclocal && autoheader && aclocal && automake && autoconf
(cd bdb/dist && sh s_all)
(cd innobase && aclocal && autoheader && aclocal && automake && autoconf)
-CFLAGS="-Wimplicit -Wreturn-type -Wid-clash-51 -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wimplicit-function-dec -Wimplicit-int -Wparentheses -Wsign-compare -Wwrite-strings -Wunused -DHAVE_purify -DEXTRA_DEBUG -O2" CXX=gcc CXXLD=g++ CXXFLAGS="-Wimplicit -Wreturn-type -Wid-clash-51 -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wimplicit-function-dec -Wimplicit-int -Wparentheses -Wsign-compare -Wwrite-strings -Woverloaded-virtual -Wextern-inline -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor -felide-constructors -fno-exceptions -fno-rtti -DHAVE_purify -DEXTRA_DEBUG -O2" ./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-debug=full --with-berkeley-db --with-innodb
+CFLAGS="-g -Wimplicit -Wreturn-type -Wid-clash-51 -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wimplicit-function-dec -Wimplicit-int -Wparentheses -Wsign-compare -Wwrite-strings -Wunused -DHAVE_purify -DEXTRA_DEBUG -O2" CXX=gcc CXXLD=g++ CXXFLAGS="-g -Wimplicit -Wreturn-type -Wid-clash-51 -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wimplicit-function-dec -Wimplicit-int -Wparentheses -Wsign-compare -Wwrite-strings -Woverloaded-virtual -Wextern-inline -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor -felide-constructors -fno-exceptions -fno-rtti -DHAVE_purify -DEXTRA_DEBUG -O2" ./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-berkeley-db --with-innodb
gmake -j 4
-cd sql ; rm mysqld ; make CXXLD="purify -best-effort g++" mysqld
+cd sql ; rm mysqld ;
+make CXXLD="purify -best-effort g++" mysqld ; mv mysqld mysqld-purify
+make CXXLD="quantify -best-effort g++" mysqld ; mv mysqld mysqld-quantify
+make CXXLD="purecov -best-effort g++" mysqld ; mv mysqld mysqld-purecov
+
diff --git a/Build-tools/Do-compile b/Build-tools/Do-compile
index 78b06ed04f3..4cf2477f5bd 100755
--- a/Build-tools/Do-compile
+++ b/Build-tools/Do-compile
@@ -4,10 +4,10 @@ use Getopt::Long;
$opt_distribution=$opt_user=$opt_result=$opt_config_options=$opt_config_env="";
$opt_dbd_options=$opt_perl_options=$opt_suffix="";
$opt_tmp=$version_suffix="";
-$opt_help=$opt_Information=$opt_no_delete=$opt_debug=$opt_stage=$opt_rsh_mail=$opt_no_test=$opt_no_perl=$opt_with_low_memory=$opt_fast_benchmark=$opt_static_client=$opt_static_server=$opt_static_perl=$opt_sur=$opt_with_small_disk=$opt_local_perl=$opt_tcpip=$opt_build_thread=$opt_no_mysqltest=$opt_use_old_distribution=$opt_enable_shared=$opt_no_crash_me=$opt_no_strip=0;
+$opt_help=$opt_Information=$opt_no_delete=$opt_delete=$opt_debug=$opt_stage=$opt_rsh_mail=$opt_no_test=$opt_no_perl=$opt_with_low_memory=$opt_fast_benchmark=$opt_static_client=$opt_static_server=$opt_static_perl=$opt_sur=$opt_with_small_disk=$opt_local_perl=$opt_tcpip=$opt_build_thread=$opt_no_mysqltest=$opt_use_old_distribution=$opt_enable_shared=$opt_no_crash_me=$opt_no_strip=0;
$opt_innodb=$opt_bdb=0;
-GetOptions("Information","help","distribution=s","user=s","result=s","no-delete","no-test","no-mysqltest","perl-files=s","debug","config-options=s","config-env=s","stage=i","rsh-mail","with-low-memory","fast-benchmark","tmp=s","static-client","static-server","static-perl","no-perl","local-perl","perl-options=s","sur","with-small-disk","dbd-options=s","tcpip","suffix=s","build-thread=i","innodb","bdb","use-old-distribution","enable-shared","no-crash-me","no-strip") || usage();
+GetOptions("Information","help","distribution=s","user=s","result=s","no-delete","delete","no-test","no-mysqltest","perl-files=s","debug","config-options=s","config-env=s","stage=i","rsh-mail","with-low-memory","fast-benchmark","tmp=s","static-client","static-server","static-perl","no-perl","local-perl","perl-options=s","sur","with-small-disk","dbd-options=s","tcpip","suffix=s","build-thread=i","innodb","bdb","use-old-distribution","enable-shared","no-crash-me","no-strip") || usage();
usage() if ($opt_help || $opt_Information);
usage() if (!$opt_distribution);
@@ -68,17 +68,20 @@ delete $ENV{'MY_BASEDIR_VERSION'};
$ENV{'MYSQL_TCP_PORT'}= $mysql_tcp_port= 3334 + $opt_build_thread;
$ENV{'MYSQL_UNIX_PORT'}=$mysql_unix_port="$opt_tmp/mysql$opt_suffix.build";
$ENV{"PERL5LIB"}="$pwd/$host/perl5:$pwd/$host/perl5/site_perl";
+$slave_port=$mysql_tcp_port+16;
+
+if (-x "$host/bin/mysqladmin")
+{
+ log_system("$host/bin/mysqladmin --no-defaults -u root -S $mysql_unix_port -s shutdown");
+ log_system("$host/bin/mysqladmin --no-defaults -u root -P $mysql_tcp_port -h $host -s shutdown");
+ log_system("$host/bin/mysqladmin --no-defaults -u root -P $slave_port -h $host -s shutdown");
+ log_system("$host/bin/mysqladmin --no-defaults -u root -P 9306 -h $host -s shutdown");
+ log_system("$host/bin/mysqladmin --no-defaults -u root -P 9307 -h $host -s shutdown");
+}
if ($opt_stage == 0)
{
print "$host: Removing old distribution\n" if ($opt_debug);
- if (-x "$host/bin/mysqladmin")
- {
- log_system("$host/bin/mysqladmin --no-defaults -u root -S $mysql_unix_port -s shutdown");
- log_system("$host/bin/mysqladmin --no-defaults -u root -P $mysql_tcp_port -h $host -s shutdown");
- log_system("$host/bin/mysqladmin --no-defaults -u root -P 9306 -h $host -s shutdown");
- log_system("$host/bin/mysqladmin --no-defaults -u root -P 9307 -h $host -s shutdown");
- }
if (!$opt_use_old_distribution)
{
system("mkdir $host") if (! -d $host);
@@ -86,7 +89,6 @@ if ($opt_stage == 0)
rm_all(<$host/mysql-*>);
system("mkdir $host/bin") if (! -d "$host/bin");
}
- system("mkdir $bench_tmpdir") if (! -d $bench_tmpdir);
rm_all("$host/test");
system("mkdir $host/test") if (! -d "$host/test");
system("mkdir Logs") if (! -d "Logs");
@@ -109,6 +111,7 @@ safe_cd($ver);
if ($opt_stage <= 1)
{
$opt_config_options.=" --with-low-memory" if ($opt_with_low_memory);
+ # Fix files if this is in another timezone than work.mysql.com
unlink("config.cache");
log_system("$make clean") if ($opt_use_old_distribution);
if ($opt_static_server)
@@ -140,7 +143,7 @@ if ($opt_stage <= 1)
if ($opt_stage <= 2)
{
- unlink($opt_distribution) if (!$opt_no_delete && !$opt_use_old_distribution);
+ unlink($opt_distribution) if (!$opt_delete && !$opt_use_old_distribution);
safe_system("$make");
}
@@ -157,7 +160,14 @@ if ($opt_stage <= 3)
$flags.="--no-strip" if ($opt_no_strip);
check_system("scripts/make_binary_distribution --tmp=$opt_tmp --suffix=$opt_suffix $flags",".tar.gz created");
safe_system("mv mysql*.tar.gz $pwd/$host");
- safe_system("cp client/mysqladmin $pwd/$host/bin");
+ if (-f "client/.libs/mysqladmin")
+ {
+ safe_system("cp client/.libs/mysqladmin $pwd/$host/bin");
+ }
+ else
+ {
+ safe_system("cp client/mysqladmin $pwd/$host/bin");
+ }
safe_system("$make clean") if ($opt_with_small_disk);
}
@@ -184,13 +194,14 @@ $ENV{"LD_LIBRARY_PATH"}= "$testdir/lib:" . $ENV{"LD_LIBRARY_PATH"};
if ($opt_stage <= 5 && !$opt_no_test && !$opt_no_mysqltest)
{
- my ($slave_port);
- $slave_port=$mysql_tcp_port+16;
+ system("mkdir $bench_tmpdir") if (! -d $bench_tmpdir);
safe_cd("${test_dir}/mysql-test");
check_system("./mysql-test-run --tmpdir=$bench_tmpdir --master_port=$mysql_tcp_port --slave_port=$slave_port --sleep=10", "tests were successful");
}
-if ($opt_stage <= 6 && !$opt_no_test)
+# Start the server if we are going to run any of the benchmarks
+
+if (!$opt_no_test)
{
my $extra;
safe_cd($test_dir);
@@ -207,10 +218,11 @@ if ($opt_stage <= 6 && !$opt_no_test)
{
$extra.=" --innodb_data_file_path=ibdata1:100M";
}
- safe_system("./bin/mysqld --no-defaults --basedir . --datadir ./data --skip-locking $extra >> $log 2>&1 &");
+ safe_system("./bin/mysqld --no-defaults --basedir . --datadir ./data --skip-l\ocking $extra >> $log 2>&1 &");
sleep(2);
}
+
if ($opt_stage <= 7 && $opt_perl_files && !$opt_no_perl && !$opt_no_test)
{
safe_cd($test_dir);
diff --git a/Docs/Makefile.am b/Docs/Makefile.am
index c4da4e9d0d3..17def904875 100644
--- a/Docs/Makefile.am
+++ b/Docs/Makefile.am
@@ -7,7 +7,7 @@
# and BSD makes
# If you know how to fix any of this more elegantly please mail
-# david@mysql.com
+# docs@mysql.com
TEXI2HTML_FLAGS = -iso -number
DVIPS = dvips
@@ -93,6 +93,10 @@ nusphere.pdf: manual.texi
rm -f manual-tmp.*
touch $@
+# Target to produce DocBook XML
+mysql.xml: manual.texi include.texi
+ $(MAKEINFO) --force --no-ifinfo --docbook manual.texi
+
# The texi2dvi gives a lot of harmless errors. Just ignore them unless
# you want to help with the typesetting part.
# This is the European papersize version
diff --git a/Docs/manual.texi b/Docs/manual.texi
index 1a7abb44841..47e2f79887a 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -34,7 +34,7 @@
@c yellow. From Steeve Buehler <ahr@YogElements.com>
@set _extra_head <style> code {color:purple} tt {color:green} samp {color:navy} pre {color:maroon} </style>
-@settitle @strong{MySQL} Reference Manual for version @value{mysql_version}.
+@settitle MySQL Reference Manual for version @value{mysql_version}.
@c We want single-sided heading format, with chapters on new pages. To
@c get double-sided format change 'on' below to 'odd'
@@ -52,22 +52,19 @@
@smallbook
@end ifset
-@c We want the contents at the beginning, where it's supposed to be.
-@setcontentsaftertitlepage
-
@c %**end of header
@ifinfo
@format
START-INFO-DIR-ENTRY
-* mysql: (mysql). @strong{MySQL} documentation.
+* mysql: (mysql). MySQL documentation.
END-INFO-DIR-ENTRY
@end format
@end ifinfo
@titlepage
@sp 10
-@center @titlefont{@strong{MySQL} Reference Manual}
+@center @titlefont{MySQL Reference Manual}
@sp 10
@center Copyright @copyright{} 1997-2001 MySQL AB
@c blank page after title page makes page 1 be a page front.
@@ -75,6 +72,13 @@ END-INFO-DIR-ENTRY
@page
@end titlepage
+@c Short contents, blank page, long contents.
+@c until i can figure out the blank page, no short contents.
+@c @shortcontents
+@c @page
+@c @page
+@contents
+
@c This should be added. The HTML conversion also needs a MySQL version
@c number somewhere.
@@ -83,18 +87,12 @@ END-INFO-DIR-ENTRY
@c printing
@headings single
-@ifclear nusphere
-@everyheading @thispage @| @| @thischapter
-@everyfooting @| @| Version: @value{mysql_version} Printed: @today{}
-@end ifclear
-
-@ifset nusphere
@oddheading @thischapter @| @| @thispage
@evenheading @thispage @| @| MySQL Technical Reference for Version @value{mysql_version}
-@end ifset
@end iftex
+
@node Top, Introduction, (dir), (dir)
@c @ifhtml
@@ -103,1067 +101,52 @@ END-INFO-DIR-ENTRY
@c @end ifhtml
@ifinfo
-This is a manual for @strong{MySQL}. This version is about the
-@value{mysql_version} version of @strong{MySQL}. You can find a manual
-about any older version of @strong{MySQL} in the binary or source
+This is a manual for MySQL. This version is about the
+@value{mysql_version} version of MySQL. You can find a manual
+about any older version of MySQL in the binary or source
distribution for that version.
@end ifinfo
@menu
-* Introduction:: General Information about @strong{MySQL}
-* Questions:: @strong{MySQL} mailing lists and how to ask questions or report errors (bugs)
-* Licensing and Support:: @strong{MySQL} licensing and support
-* Installing:: Installing @strong{MySQL}
-* Compatibility:: How standards-compatible is @strong{MySQL}?
-* Privilege system:: The @strong{MySQL} access privilege system
-* Reference:: @strong{MySQL} language reference
-* Table types:: @strong{MySQL} table types
-* Tutorial:: @strong{MySQL} Tutorial
-* Server:: @strong{MySQL} Server
-* Replication:: Replication
-* Fulltext Search:: Fulltext Search
-* Performance:: Getting maximum performance from @strong{MySQL}
-* MySQL Benchmarks:: The @strong{MySQL} benchmark suite
-* Tools:: @strong{MySQL} Utilities
-* Maintenance:: Maintaining a @strong{MySQL} installation
-* Adding functions:: Adding new functions to @strong{MySQL}
-* Adding procedures:: Adding new procedures to @strong{MySQL}
-* ODBC:: @strong{MySQL} ODBC Support
-* Common programs:: Using @strong{MySQL} with some common programs
+* Introduction:: General Information about MySQL
+* Installing:: Installing MySQL
+* Tutorial:: MySQL Tutorial
+* MySQL Database Administration:: MySQL Database Administration
+* MySQL Optimization:: MySQL Optimization
+* Reference:: MySQL language reference
+* Table types:: MySQL table types
+* Clients:: MySQL client tools and APIs
+* Extending MySQL:: Extending MySQL
* 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
-* Environment variables:: @strong{MySQL} environment variables
-* Users:: Some @strong{MySQL} users
-* MySQL customer usage::
+* Users:: Some MySQL users
+* MySQL customer usage:: MySQL customer usage
* Contrib:: Contributed programs
-* Credits:: Contributors to @strong{MySQL}
-* News:: @strong{MySQL} change history
-* Bugs:: Known errors and design deficiencies in @strong{MySQL}
-* TODO:: List of things we want to add to @strong{MySQL} in the future (The TODO)
+* Credits:: Contributors to MySQL
+* News:: MySQL change history
* Porting:: Comments on porting to other systems
-* Regexp:: Description of @strong{MySQL} regular expression syntax
+* Environment variables:: MySQL environment variables
+* Regexp:: Description of MySQL regular expression syntax
* Unireg:: What is Unireg?
* GPL license:: GNU General Public License
* LGPL license:: GNU Library General Public License
+* Placeholder:: Pieces of the manual in transit
* Function Index:: SQL command, type and function index
* Concept Index:: Concept Index
+@end menu
-@detailmenu
- --- The Detailed Node Listing ---
-
-General Information About MySQL
-
-* What-is:: What is @strong{MySQL}?
-* What is MySQL AB::
-* Manual-info:: About this manual
-* History:: History of @strong{MySQL}
-* MySQL-Books:: Books about MySQL
-* Features:: The main features of @strong{MySQL}
-* Stability:: How stable is @strong{MySQL}?
-* Year 2000 compliance:: Year 2000 compliance
-* General-SQL:: General SQL information and tutorials
-* Useful Links:: Useful @strong{MySQL}-related links
-
-About This Manual
-
-* Manual conventions:: Conventions used in this manual
-
-MySQL Mailing Lists
-
-* Mailing-list:: The @strong{MySQL} mailing lists
-* Asking questions:: Asking questions or reporting bugs
-* Bug reports:: How to report bugs or problems
-* Answering questions:: Guidelines for answering questions on the mailing list
-
-MySQL Licensing and Support
-
-* Licensing policy:: @strong{MySQL} licensing policy
-* Copyright:: Copyrights used by @strong{MySQL}
-* Licensing examples:: Example licensing situations
-* Cost:: @strong{MySQL} licensing and support costs
-* Support:: Types of commercial support
-
-Copyrights Used by MySQL
-
-* Copyright changes:: Possible future copyright changes
-
-Example Licensing Situations
-
-* Products that use MySQL:: Selling products that use @strong{MySQL}
-* ISP:: ISP @strong{MySQL} services
-* Web server:: Running a web server using @strong{MySQL}.
-
-MySQL Licensing and Support Costs
-
-* Payment information:: Payment information
-* Contact information:: Contact information
-
-Types of Commercial Support
-
-* Basic email support:: Basic email support
-* Extended email support:: Extended email support
-* Login support:: Login support
-* Extended login support:: Extended login support
-* Telephone support:: Telephone support
-* Table handler support:: Support for other table handlers
-
-Installing MySQL
-
-* Getting MySQL:: How to get @strong{MySQL}
-* Which OS:: Operating systems supported by @strong{MySQL}
-* Which version:: Which @strong{MySQL} version to use
-* Many versions:: How and when updates are released
-* Installation layouts:: Installation layouts
-* Installing binary:: Installing a @strong{MySQL} binary distribution
-* Installing source:: Installing a @strong{MySQL} source distribution
-* Installing source tree:: Installing @strong{MySQL} from development source tree
-* Compilation problems:: Problems compiling?
-* MIT-pthreads:: MIT-pthreads notes
-* Perl support:: Perl installation comments
-* Source install system issues:: System-specific issues
-* Windows:: Windows notes
-* OS/2:: OS/2 notes
-* MySQL binaries:: MySQL binaries
-* Post-installation:: Post-installation setup and testing
-* Installing many servers:: Installing many servers on the same machine
-* Upgrade:: Upgrading/Downgrading MySQL
-
-Installing a MySQL Binary Distribution
-
-* Linux-RPM:: Linux RPM files
-* Building clients:: Building client programs
-* Binary install system issues:: System-specific issues
-
-System-specific Issues
-
-* Binary notes-Linux:: Linux notes for binary distribution
-* Binary notes-HP-UX:: HP-UX notes for binary distribution
-
-Installing a MySQL Source Distribution
-
-* Quick install:: Quick installation overview
-* Applying patches:: Applying patches
-* configure options:: Typical @code{configure} options
-
-Perl Installation Comments
-
-* Perl installation:: Installing Perl on Unix
-* ActiveState Perl:: Installing ActiveState Perl on Windows
-* Windows Perl:: Installing the @strong{MySQL} Perl distribution on Windows
-* Perl support problems:: Problems using the Perl @code{DBI}/@code{DBD} interface
-
-System-specific Issues
-
-* Solaris:: Solaris notes
-* Solaris 2.7:: Solaris 2.7 / 2.8 notes
-* Solaris x86:: Solaris x86 notes
-* SunOS:: SunOS 4 notes
-* Linux:: Linux notes (all Linux versions)
-* Alpha-DEC-UNIX:: Alpha-DEC-UNIX notes
-* Alpha-DEC-OSF1:: Alpha-DEC-OSF1 notes
-* SGI-Irix:: SGI-Irix notes
-* FreeBSD:: FreeBSD notes
-* NetBSD:: NetBSD notes
-* OpenBSD:: OpenBSD 2.5 notes
-* BSDI:: BSD/OS notes
-* SCO:: SCO notes
-* SCO Unixware:: SCO Unixware 7.0 notes
-* IBM-AIX:: IBM-AIX notes
-* HP-UX 10.20:: HP-UX 10.20 notes
-* HP-UX 11.x:: HP-UX 11.x notes
-* Mac OS X:: Mac OS X notes
-* BEOS:: BeOS Notes
-
-Linux Notes (All Linux Versions)
-
-* Linux-x86:: Linux-x86 notes
-* Linux-RedHat50:: RedHat 5.0 notes
-* Linux-RedHat51:: RedHat 5.1 notes
-* Linux-SPARC:: Linux-SPARC notes
-* Linux-Alpha:: Linux-Alpha notes
-* MKLinux:: MkLinux notes
-* Qube2:: Qube2 Linux notes
-* Linux-Ia64:: Linux-Ia64 notes
-
-OpenBSD Notes
-
-* OpenBSD 2.5:: OpenBSD 2.5 Notes
-* OpenBSD 2.8:: OpenBSD 2.8 Notes
-
-BSD/OS Notes
-
-* BSDI2:: BSD/OS 2.x notes
-* BSDI3:: BSD/OS 3.x notes
-* BSDI4:: BSD/OS 4.x notes
-
-Mac OS X Notes
-
-* Mac OS X Public Data::
-* Mac OS X Server::
-
-Windows Notes
-
-* Windows installation:: Installing @strong{MySQL} on Windows
-* Win95 start:: Starting @strong{MySQL} on Win95 / Win98
-* NT start:: Starting @strong{MySQL} on NT / Win2000
-* Windows running:: Running @strong{MySQL} on Windows
-* Windows and SSH:: Connecting to a remote @strong{MySQL} from Windows with SSH
-* Windows symbolic links:: Splitting data across different disks under Win32
-* Windows compiling:: Compiling MySQL clients on Windows.
-* Windows vs Unix:: @strong{MySQL}-Windows compared to Unix @strong{MySQL}
-
-Post-installation Setup and Testing
-
-* mysql_install_db:: Problems running @code{mysql_install_db}
-* Starting server:: Problems starting the @strong{MySQL} server
-* Automatic start:: Starting and stopping @strong{MySQL} automatically
-* Command-line options:: Command-line options
-* Option files:: Option files
-
-Upgrading/Downgrading MySQL
-
-* Upgrading-from-3.23::
-* Upgrading-from-3.22:: Upgrading from a 3.22 version to 3.23
-* Upgrading-from-3.21:: Upgrading from a 3.21 version to 3.22
-* Upgrading-from-3.20:: Upgrading from a 3.20 version to 3.21
-* Upgrading-to-arch:: Upgrading to another architecture
-
-How Standards-compatible Is MySQL?
-
-* Extensions to ANSI:: @strong{MySQL} extensions to ANSI SQL92
-* ANSI mode:: Running @strong{MySQL} in ANSI mode
-* Differences from ANSI:: @strong{MySQL} differences compared to ANSI SQL92
-* Missing functions:: Functionality missing from @strong{MySQL}
-* Standards:: What standards does @strong{MySQL} follow?
-* Commit-rollback:: How to cope without @code{COMMIT}-@code{ROLLBACK}
-
-Functionality Missing from MySQL
-
-* Missing Sub-selects:: Sub-selects
-* Missing SELECT INTO TABLE:: @code{SELECT INTO TABLE}
-* Missing Transactions:: Transactions
-* Missing Triggers:: Triggers
-* Missing Foreign Keys:: Foreign Keys
-* Missing Views:: Views
-* Missing comments:: @samp{--} as the start of a comment
-
-Foreign Keys
-
-* Broken Foreign KEY:: Reasons NOT to use foreign keys constraints
-
-The MySQL Access Privilege System
-
-* General security:: General security
-* Security:: How to make @strong{MySQL} secure against crackers
-* Privileges options::
-* What Privileges:: What the privilege system does
-* User names:: @strong{MySQL} user names and passwords
-* Connecting:: Connecting to the @strong{MySQL} server
-* Password security:: Keeping your password secure
-* Privileges provided:: Privileges provided by @strong{MySQL}
-* Privileges:: How the privilege system works
-* Connection access:: Access control, stage 1: Connection verification
-* Request access:: Access control, stage 2: Request verification
-* Privilege changes:: When privilege changes take effect
-* Default privileges:: Setting up the initial @strong{MySQL} privileges
-* Adding users:: Adding new users to @strong{MySQL}
-* Passwords:: How to set up passwords
-* Access denied:: Causes of @code{Access denied} errors
-
-MySQL Language Reference
-
-* Literals:: Literals: How to write strings and numbers
-* Variables:: User variables
-* Column types:: Column types
-* Functions:: Functions
-* CREATE DATABASE:: @code{CREATE DATABASE} syntax
-* DROP DATABASE:: @code{DROP DATABASE} syntax
-* CREATE TABLE:: @code{CREATE TABLE} syntax
-* ALTER TABLE:: @code{ALTER TABLE} syntax
-* RENAME TABLE:: @code{RENAME TABLE} syntax
-* DROP TABLE:: @code{DROP TABLE} syntax
-* OPTIMIZE TABLE:: @code{OPTIMIZE TABLE} syntax
-* CHECK TABLE:: @code{CHECK TABLE} syntax
-* BACKUP TABLE:: @code{BACKUP TABLE} syntax
-* RESTORE TABLE:: @code{RESTORE TABLE} syntax
-* ANALYZE TABLE:: @code{ANALYZE TABLE} syntax
-* REPAIR TABLE:: @code{REPAIR TABLE} syntax
-* DELETE:: @code{DELETE} syntax
-* TRUNCATE:: @code{TRUNCATE} syntax
-* SELECT:: @code{SELECT} syntax
-* JOIN:: @code{JOIN} syntax
-* INSERT:: @code{INSERT} syntax
-* REPLACE:: @code{REPLACE} syntax
-* LOAD DATA:: @code{LOAD DATA INFILE} syntax
-* UPDATE:: @code{UPDATE} syntax
-* USE:: @code{USE} syntax
-* FLUSH:: @code{FLUSH} syntax (clearing caches)
-* KILL:: @code{KILL} syntax
-* SHOW:: @code{SHOW} syntax (Get information about tables, columns, ...)
-* EXPLAIN:: @code{EXPLAIN} syntax (Get information about a @code{SELECT})
-* DESCRIBE:: @code{DESCRIBE} syntax (Get information about names of columns)
-* COMMIT:: @code{BEGIN/COMMIT/ROLLBACK} syntax
-* LOCK TABLES:: @code{LOCK TABLES/UNLOCK TABLES} syntax
-* SET OPTION:: @code{SET OPTION} syntax
-* SET TRANSACTION:: @code{SET TRANSACTION} syntax
-* GRANT:: @code{GRANT} and @code{REVOKE} syntax
-* HANDLER:: @code{HANDLER} syntax
-* CREATE INDEX:: @code{CREATE INDEX} syntax
-* DROP INDEX:: @code{DROP INDEX} syntax
-* Comments:: Comment syntax
-* CREATE FUNCTION:: @code{CREATE FUNCTION} syntax
-* Reserved words:: Is @strong{MySQL} picky about reserved words?
-
-Literals: How to Write Strings and Numbers
-
-* String syntax:: Strings
-* Number syntax:: Numbers
-* Hexadecimal values:: Hexadecimal values
-* NULL values:: @code{NULL} values
-* Legal names:: Database, Table, Index, Column, and Alias Names
-
-Database, Table, Index, Column, and Alias Names
-
-* Name case sensitivity:: Case sensitivity in names
-
-Column Types
-
-* Storage requirements:: Column type storage requirements
-* Numeric types:: Numeric types
-* Date and time types:: Date and time types
-* String types:: String types
-* Choosing types:: Choosing the right type for a column
-* Indexes:: Column indexes
-* Multiple-column indexes:: Multiple-column indexes
-* Other-vendor column types:: Using column types from other database engines
-
-Date and Time Types
-
-* Y2K issues:: Y2K issues and date types
-* DATETIME:: The @code{DATETIME}, @code{DATE} and @code{TIMESTAMP} types
-* TIME:: The @code{TIME} type
-* YEAR:: The @code{YEAR} type
-
-String Types
-
-* CHAR:: The @code{CHAR} and @code{VARCHAR} types
-* BLOB:: The @code{BLOB} and @code{TEXT} types
-* ENUM:: The @code{ENUM} type
-* SET:: The @code{SET} type
-
-Functions for Use in @code{SELECT} and @code{WHERE} Clauses
-
-* Grouping functions:: Grouping functions
-* Arithmetic functions:: Normal arithmetic operations
-* Bit functions:: Bit functions
-* Logical functions:: Logical operations
-* Comparison functions:: Comparison operators
-* String comparison functions:: String comparison functions
-* Casts:: Cast operators
-* Control flow functions:: Control flow functions
-* Mathematical functions:: Mathematical functions
-* String functions:: String functions
-* Date and time functions:: Date and time functions
-* Miscellaneous functions:: Miscellaneous functions
-* Group by functions:: Functions for @code{GROUP BY} clause
-
-@code{CREATE TABLE} Syntax
-
-* Silent column changes:: Silent column changes
-
-@code{INSERT} Syntax
-
-* INSERT SELECT::
-* INSERT DELAYED::
-
-@code{SHOW} Syntax
-
-* SHOW DATABASE INFO::
-* SHOW TABLE STATUS::
-* SHOW STATUS::
-* SHOW VARIABLES::
-* SHOW LOGS::
-* SHOW PROCESSLIST::
-* SHOW GRANTS::
-* SHOW CREATE TABLE::
-
-MySQL Table Types
-
-* MyISAM:: MyISAM tables
-* MERGE:: MERGE tables
-* ISAM:: ISAM tables
-* HEAP:: HEAP tables
-* InnoDB:: InnoDB tables
-* BDB:: BDB or Berkeley_db tables
-
-MyISAM Tables
-
-* Key space:: Space needed for keys
-* MyISAM table formats:: MyISAM table formats
-* MyISAM table problems::
-
-MyISAM Table Formats
-
-* Static format:: Static (Fixed-length) table characteristics
-* Dynamic format:: Dynamic table characteristics
-* Compressed format:: Compressed table characteristics
-
-MyISAM table problems.
-
-* Corrupted MyISAM tables::
-* MyISAM table close::
-
-InnoDB Tables
-
-* InnoDB overview:: InnoDB tables overview
-* InnoDB start:: InnoDB startup options
-* InnoDB init:: Creating InnoDB table space.
-* Using InnoDB tables:: Creating InnoDB tables
-* Adding and removing:: Adding and removing InnoDB data and log files
-* Backing up:: Backing up and recovering an InnoDB database
-* Moving:: Moving an InnoDB database to another machine
-* InnoDB transaction model:: InnoDB transaction model.
-* Implementation:: Implementation of multiversioning
-* Table and index:: Table and index structures
-* File space management:: File space management and disk i/o
-* Error handling:: Error handling
-* InnoDB restrictions:: Some restrictions on InnoDB tables
-* InnoDB contact information:: InnoDB contact information.
-
-Creating InnoDB table space
-
-* Error creating InnoDB::
-
-Backing up and recovering an InnoDB database
-
-* InnoDB checkpoints::
-
-InnoDB transaction model
-
-* InnoDB consistent read::
-* InnoDB locking reads::
-* InnoDB Next-key locking::
-* InnoDB Locks set::
-* InnoDB Deadlock detection::
-
-Table and index structures
-
-* InnoDB physical structure::
-* InnoDB Insert buffering::
-* InnoDB Adaptive hash::
-* InnoDB Physical record::
-
-File space management and disk i/o
-
-* InnoDB Disk i/o::
-* InnoDB File space::
-* InnoDB File Defragmenting::
-
-BDB or Berkeley_DB Tables
-
-* BDB overview:: Overview of BDB Tables
-* BDB install:: Installing BDB
-* BDB start:: BDB startup options
-* BDB characteristic:: Some characteristic of @code{BDB} tables:
-* BDB TODO:: Some things we need to fix for BDB in the near future:
-* BDB portability:: Operating systems supported by @strong{BDB}
-* BDB errors:: Errors You May Get When Using BDB Tables
-
-MySQL Tutorial
-
-* Connecting-disconnecting:: Connecting to and disconnecting from the server
-* Entering queries:: Entering queries
-* Database use:: Creating and using a database
-* Getting information:: Getting information about databases and tables
-* Examples:: Examples
-* Batch mode:: Using @code{mysql} in batch mode
-* Twin:: Queries from twin project
-
-Creating and Using a Database
-
-* Creating database:: Creating a database
-* Creating tables:: Creating a table
-* Loading tables:: Loading data into a table
-* Retrieving data:: Retrieving information from a table
-
-Retrieving Information from a Table
-
-* Selecting all:: Selecting all data
-* Selecting rows:: Selecting particular rows
-* Selecting columns:: Selecting particular columns
-* Sorting rows:: Sorting rows
-* Date calculations:: Date calculations
-* Working with NULL:: Working with @code{NULL} values
-* Pattern matching:: Pattern matching
-* Counting rows:: Counting rows
-* Multiple tables::
-
-Examples of Common Queries
-
-* example-Maximum-column:: The maximum value for a column
-* example-Maximum-row:: The row holding the maximum of a certain column
-* example-Maximum-column-group:: Maximum of column per group
-* example-Maximum-column-group-row:: The rows holding the group-wise maximum of a certain field
-* example-user-variables:: Using user variables
-* example-Foreign keys:: Using foreign keys
-* Searching on two keys::
-* Calculating days::
-
-Queries from Twin Project
-
-* Twin pool:: Find all non-distributed twins
-* Twin event:: Show a table on twin pair status
-
-MySQL Server Functions
-
-* Languages:: What languages are supported by @strong{MySQL}?
-* Table size:: How big @strong{MySQL} tables can be
-
-What Languages Are Supported by MySQL?
-
-* Character sets:: The character set used for data and sorting
-* Adding character set:: Adding a new character set
-* Character arrays:: The character definition arrays
-* String collating:: String collating support
-* Multi-byte characters:: Multi-byte character support
-
-Replication in MySQL
-
-* Replication Intro:: Introduction
-* Replication Implementation:: Replication Implementation Overview
-* Replication HOWTO:: HOWTO
-* Replication Features:: Replication Features
-* Replication Options:: Replication Options in my.cnf
-* Replication SQL:: SQL Commands related to replication
-* Replication FAQ:: Frequently Asked Questions about replication
-* Replication Problems:: Troubleshooting Replication.
-
-MySQL Full-text Search
-
-* Fulltext Fine-tuning::
-* Fulltext Features to Appear in MySQL 4.0::
-* Fulltext TODO::
-
-Getting Maximum Performance from MySQL
-
-* Optimize Basics:: Optimization overview
-* System:: System/Compile time and startup parameter tuning
-* Data size:: Get your data as small as possible
-* MySQL indexes:: How @strong{MySQL} uses indexes
-* Query Speed:: Speed of queries that access or update data
-* Tips:: Other optimization tips
-* Benchmarks:: Using your own benchmarks
-* Design:: Design choices
-* Design Limitations:: MySQL design limitations/tradeoffs
-* Portability:: Portability
-* Internal use:: What have we used MySQL for?
-
-System/Compile Time and Startup Parameter Tuning
-
-* Compile and link options:: How compiling and linking affects the speed of MySQL
-* Disk issues:: Disk issues
-* Symbolic links:: Using Symbolic Links
-* Server parameters:: Tuning server parameters
-* Table cache:: How MySQL opens and closes tables
-* Creating many tables:: Drawbacks of creating large numbers of tables in the same database
-* Open tables:: Why so many open tables?
-* Memory use:: How MySQL uses memory
-* Internal locking:: How MySQL locks tables
-* Table locking:: Table locking issues
-* DNS::
-
-Using Symbolic Links
-
-* Symbolic links to database::
-* Symbolic links to tables::
-
-Speed of Queries that Access or Update Data
-
-* Estimating performance:: Estimating query performance
-* SELECT speed:: Speed of @code{SELECT} queries
-* Where optimizations:: How MySQL optimizes @code{WHERE} clauses
-* DISTINCT optimization:: How MySQL Optimizes @code{DISTINCT}
-* LEFT JOIN optimization:: How MySQL optimizes @code{LEFT JOIN}
-* LIMIT optimization:: How MySQL optimizes @code{LIMIT}
-* Insert speed:: Speed of @code{INSERT} queries
-* Update speed:: Speed of @code{UPDATE} queries
-* Delete speed:: Speed of @code{DELETE} queries
-
-MySQL Utilites
-
-* Programs:: What do the executables do?
-* mysqld-max:: mysqld-max, An extended mysqld server
-* safe_mysqld:: safe_mysqld, the wrapper around mysqld
-* mysqld_multi:: Program for managing multiple @strong{MySQL} servers
-* mysql:: The command line tool
-* mysqladmin:: Administering a @strong{MySQL} server
-* mysqldump:: Dumping the structure and data from @strong{MySQL} databases and tables
-* mysqlhotcopy:: Copying @strong{MySQL} Databases and Tables
-* mysqlimport:: Importing data from text files
-* perror:: Displaying error messages
-* mysqlshow:: Showing databases, tables and columns
-* myisampack:: The @strong{MySQL} compressed read-only table generator
-
-Maintaining a MySQL Installation
-
-* Table maintenance:: Table maintenance and crash recovery
-* Using mysqlcheck:: Using mysqlcheck for maintenance and recovery
-* Maintenance regimen:: Setting up a table maintenance regimen
-* Table-info:: Getting information about a table
-* Crash recovery:: Using @code{myisamchk} for crash recovery
-* Log file maintenance:: Log file maintenance
-
-Using @code{myisamchk} for Table Maintenance and Crash Recovery
-
-* myisamchk syntax:: @code{myisamchk} invocation syntax
-* myisamchk memory:: @code{myisamchk} memory usage
-
-@code{myisamchk} Invocation Syntax
-
-* myisamchk general options::
-* myisamchk check options::
-* myisamchk repair options::
-* myisamchk other options::
-
-Using @code{myisamchk} for Crash Recovery
-
-* Check:: How to check tables for errors
-* Repair:: How to repair tables
-* Optimization:: Table optimization
-
-Adding New Functions to MySQL
-
-* Adding UDF:: Adding a new user-definable function
-* Adding native function:: Adding a new native function
-
-Adding a New User-definable Function
-
-* UDF calling sequences:: UDF calling sequences
-* UDF arguments:: Argument processing
-* UDF return values:: Return values and error handling
-* UDF compiling:: Compiling and installing user-definable functions
-
-Adding New Procedures to MySQL
-
-* procedure analyse:: Procedure analyse
-* Writing a procedure:: Writing a procedure.
-
-MySQL ODBC Support
-
-* Installing MyODBC:: How to install MyODBC
-* ODBC administrator:: How to fill in the various fields in the ODBC administrator program
-* MyODBC connect parameters::
-* ODBC Problems:: How to report problems with @strong{MySQL} ODBC
-* MyODBC clients:: Programs known to work with @strong{MyODBC}
-* ODBC and last_insert_id:: How to get the value of an @code{AUTO_INCREMENT} column in ODBC
-* MyODBC bug report:: Reporting problems with MyODBC
-
-Using MySQL with Some Common Programs
-
-* Apache:: Using @strong{MySQL} with Apache
-* Borland C++::
-
-Problems and Common Errors
-
-* What is crashing:: How to determine what is causing problems
-* Crashing:: What to do if @strong{MySQL} keeps crashing
-* Link errors:: Problems when linking with the @strong{MySQL} client library
-* Common errors:: Some common errors when using @strong{MySQL}
-* Full disk:: How @strong{MySQL} handles a full disk
-* Multiple sql commands:: How to run SQL commands from a text file
-* Temporary files:: Where @strong{MySQL} stores temporary files
-* Problems with mysql.sock:: How to protect @file{/tmp/mysql.sock}
-* Changing MySQL user:: How to run @strong{MySQL} as a normal user
-* Resetting permissions:: How to reset a forgotten password.
-* File permissions :: Problems with file permissions
-* Not enough file handles:: File not found
-* Using DATE:: Problems using @code{DATE} columns
-* Timezone problems:: Timezone problems
-* Case sensitivity:: Case sensitivity in searches
-* Problems with NULL:: Problems with @code{NULL} values
-* Problems with alias:: Problems with @code{alias}
-* Deleting from related tables:: Deleting rows from related tables
-* No matching rows:: Solving problems with no matching rows
-* ALTER TABLE problems:: Problems with @code{ALTER TABLE}.
-* Change column order:: How to change the order of columns in a table
-* Temporary table problems::
-
-Some Common Errors When Using MySQL
-
-* Error Access denied:: @code{Access denied} Error
-* Gone away:: @code{MySQL server has gone away} error
-* Can not connect to server:: @code{Can't connect to [local] MySQL server} error
-* Blocked host:: @code{Host '...' is blocked} error
-* Too many connections:: @code{Too many connections} error
-* Non-transactional tables:: @code{Some non-transactional changed tables couldn't be rolled back} Error
-* Out of memory:: @code{Out of memory} error
-* Packet too large:: @code{Packet too large} error
-* Communication errors:: Communication errors / Aborted connection
-* Full table:: @code{The table is full} error
-* Cannot create:: @code{Can't create/write to file} Error
-* Commands out of sync:: @code{Commands out of sync} error in client
-* Ignoring user:: @code{Ignoring user} error
-* Cannot find table:: @code{Table 'xxx' doesn't exist} error
-* Cannot initialize character set::
-
-Solving Some Common Problems with MySQL
-
-* Log Replication:: Database replication with update log
-* Backup:: Database backups
-* 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 APIs
-
-* C:: @strong{MySQL} C API
-* Perl:: @strong{MySQL} Perl API
-* Eiffel:: @strong{MySQL} Eiffel wrapper
-* Java:: @strong{MySQL} Java connectivity (JDBC)
-* PHP:: @strong{MySQL} PHP API
-* Cplusplus:: @strong{MySQL} C++ APIs
-* Python:: @strong{MySQL} Python APIs
-* Tcl:: @strong{MySQL} Tcl APIs
-
-MySQL C API
-
-* C API datatypes:: C API Datatypes
-* C API function overview:: C API Function Overview
-* C API functions:: C API Function Descriptions
-* C API problems::
-* Thread-safe clients::
-
-C API Function Descriptions
-
-* mysql_affected_rows:: @code{mysql_affected_rows()}
-* mysql_close:: @code{mysql_close()}
-* mysql_connect:: @code{mysql_connect()}
-* mysql_change_user:: @code{mysql_change_user()}
-* mysql_character_set_name:: @code{mysql_character_set_name()}
-* mysql_create_db:: @code{mysql_create_db()}
-* mysql_data_seek:: @code{mysql_data_seek()}
-* mysql_debug:: @code{mysql_debug()}
-* mysql_drop_db:: @code{mysql_drop_db()}
-* mysql_dump_debug_info:: @code{mysql_dump_debug_info()}
-* mysql_eof:: @code{mysql_eof()}
-* mysql_errno:: @code{mysql_errno()}
-* mysql_error:: @code{mysql_error()}
-* mysql_escape_string:: @code{mysql_escape_string()}
-* mysql_fetch_field:: @code{mysql_fetch_field()}
-* mysql_fetch_fields:: @code{mysql_fetch_fields()}
-* mysql_fetch_field_direct:: @code{mysql_fetch_field_direct()}
-* mysql_fetch_lengths:: @code{mysql_fetch_lengths()}
-* mysql_fetch_row:: @code{mysql_fetch_row()}
-* mysql_field_count:: @code{mysql_field_count()}
-* mysql_field_seek:: @code{mysql_field_seek()}
-* mysql_field_tell:: @code{mysql_field_tell()}
-* mysql_free_result:: @code{mysql_free_result()}
-* mysql_get_client_info:: @code{mysql_get_client_info()}
-* mysql_get_host_info:: @code{mysql_get_host_info()}
-* mysql_get_proto_info:: @code{mysql_get_proto_info()}
-* mysql_get_server_info:: @code{mysql_get_server_info()}
-* mysql_info:: @code{mysql_info()}
-* mysql_init:: @code{mysql_init()}
-* mysql_insert_id:: @code{mysql_insert_id()}
-* mysql_kill:: @code{mysql_kill()}
-* mysql_list_dbs:: @code{mysql_list_dbs()}
-* mysql_list_fields:: @code{mysql_list_fields()}
-* mysql_list_processes:: @code{mysql_list_processes()}
-* mysql_list_tables:: @code{mysql_list_tables()}
-* mysql_num_fields:: @code{mysql_num_fields()}
-* mysql_num_rows:: @code{mysql_num_rows()}
-* mysql_options:: @code{mysql_options()}
-* mysql_ping:: @code{mysql_ping()}
-* mysql_query:: @code{mysql_query()}
-* mysql_real_connect:: @code{mysql_real_connect()}
-* mysql_real_escape_string:: @code{mysql_real_escape_string()}
-* mysql_real_query:: @code{mysql_real_query()}
-* mysql_reload:: @code{mysql_reload()}
-* mysql_row_seek:: @code{mysql_row_seek()}
-* mysql_row_tell:: @code{mysql_row_tell()}
-* mysql_select_db:: @code{mysql_select_db()}
-* mysql_shutdown:: @code{mysql_shutdown()}
-* mysql_stat:: @code{mysql_stat()}
-* mysql_store_result:: @code{mysql_store_result()}
-* mysql_thread_id:: @code{mysql_thread_id()}
-* mysql_use_result:: @code{mysql_use_result()}
-
-Common questions and problems when using the C API
-
-* NULL mysql_store_result::
-* Query results::
-* Getting unique ID::
-* C API linking problems::
-
-Why Is It that After @code{mysql_query()} Returns Success, @code{mysql_store_result()} Sometimes Returns @code{NULL?}
-
-* Query results::
-* Getting unique ID::
-* C API linking problems::
-
-MySQL Perl API
-
-* DBI with DBD:: @code{DBI} with @code{DBD::mysql}
-* Perl DBI Class:: The @code{DBI} interface
-* DBI-info:: More @code{DBI}/@code{DBD} information
-
-MySQL PHP API
-
-* PHP problems:: Common problems with MySQL and PHP
-
-How MySQL Compares to Other Databases
-
-* Compare mSQL:: How @strong{MySQL} compares to @code{mSQL}
-* Compare PostgreSQL:: How @strong{MySQL} compares with PostgreSQL
-
-How MySQL Compares to @code{mSQL}
-
-* Using mSQL tools:: How to convert @code{mSQL} tools for @strong{MySQL}
-* Protocol differences:: How @code{mSQL} and @strong{MySQL} client/server communications protocols differ
-* Syntax differences:: How @code{mSQL} 2.0 SQL syntax differs from @strong{MySQL}
-
-How MySQL Compares to PostgreSQL
-
-* MySQL-PostgreSQL goals:: MySQL and PostgreSQL development strategies
-* MySQL-PostgreSQL features:: Featurevise Comparison of MySQL and PostgreSQL
-* MySQL-PostgreSQL benchmarks:: Benchmarking MySQL and PostgreSQL
-
-MySQL Internals
-
-* MySQL threads:: MySQL threads
-* MySQL test suite:: MySQL test suite
-
-MySQL Test Suite
-
-* running mysqltest::
-* extending mysqltest::
-* Reporting mysqltest bugs::
-
-Credits
-
-* Developers::
-* Contributors::
-* Supporters::
-
-MySQL change history
-
-* News-4.0.x:: Changes in release 4.0.x (Development; Alpha)
-* News-3.23.x:: Changes in release 3.23.x (Stable)
-* News-3.22.x:: Changes in release 3.22.x (Older; Still supported)
-* News-3.21.x:: Changes in release 3.21.x
-* News-3.20.x:: Changes in release 3.20.x
-* News-3.19.x:: Changes in release 3.19.x
-
-Changes in release 4.0.x (Development; Alpha)
-
-* News-4.0.0:: Changes in release 4.0.0
-
-Changes in release 3.23.x (Stable)
-
-* News-3.23.40:: Changes in release 3.23.40
-* News-3.23.39:: Changes in release 3.23.39
-* News-3.23.38:: Changes in release 3.23.38
-* News-3.23.37:: Changes in release 3.23.37
-* News-3.23.36:: Changes in release 3.23.36
-* News-3.23.35:: Changes in release 3.23.35
-* News-3.23.34a:: Changes in release 3.23.34a
-* News-3.23.34:: Changes in release 3.23.34
-* News-3.23.33:: Changes in release 3.23.33
-* News-3.23.32:: Changes in release 3.23.32
-* News-3.23.31:: Changes in release 3.23.31
-* News-3.23.30:: Changes in release 3.23.30
-* News-3.23.29:: Changes in release 3.23.29
-* News-3.23.28:: Changes in release 3.23.28
-* News-3.23.27:: Changes in release 3.23.27
-* News-3.23.26:: Changes in release 3.23.26
-* News-3.23.25:: Changes in release 3.23.25
-* News-3.23.24:: Changes in release 3.23.24
-* News-3.23.23:: Changes in release 3.23.23
-* News-3.23.22:: Changes in release 3.23.22
-* News-3.23.21:: Changes in release 3.23.21
-* News-3.23.20:: Changes in release 3.23.20
-* News-3.23.19:: Changes in release 3.23.19
-* News-3.23.18:: Changes in release 3.23.18
-* News-3.23.17:: Changes in release 3.23.17
-* News-3.23.16:: Changes in release 3.23.16
-* News-3.23.15:: Changes in release 3.23.15
-* News-3.23.14:: Changes in release 3.23.14
-* News-3.23.13:: Changes in release 3.23.13
-* News-3.23.12:: Changes in release 3.23.12
-* News-3.23.11:: Changes in release 3.23.11
-* News-3.23.10:: Changes in release 3.23.10
-* News-3.23.9:: Changes in release 3.23.9
-* News-3.23.8:: Changes in release 3.23.8
-* News-3.23.7:: Changes in release 3.23.7
-* News-3.23.6:: Changes in release 3.23.6
-* News-3.23.5:: Changes in release 3.23.5
-* News-3.23.4:: Changes in release 3.23.4
-* News-3.23.3:: Changes in release 3.23.3
-* News-3.23.2:: Changes in release 3.23.2
-* News-3.23.1:: Changes in release 3.23.1
-* News-3.23.0:: Changes in release 3.23.0
-
-Changes in release 3.22.x (Older; Still supported)
-
-* News-3.22.35:: Changes in release 3.22.35
-* News-3.22.34:: Changes in release 3.22.34
-* News-3.22.33:: Changes in release 3.22.33
-* News-3.22.32:: Changes in release 3.22.32
-* News-3.22.31:: Changes in release 3.22.31
-* News-3.22.30:: Changes in release 3.22.30
-* News-3.22.29:: Changes in release 3.22.29
-* News-3.22.28:: Changes in release 3.22.28
-* News-3.22.27:: Changes in release 3.22.27
-* News-3.22.26:: Changes in release 3.22.26
-* News-3.22.25:: Changes in release 3.22.25
-* News-3.22.24:: Changes in release 3.22.24
-* News-3.22.23:: Changes in release 3.22.23
-* News-3.22.22:: Changes in release 3.22.22
-* News-3.22.21:: Changes in release 3.22.21
-* News-3.22.20:: Changes in release 3.22.20
-* News-3.22.19:: Changes in release 3.22.19
-* News-3.22.18:: Changes in release 3.22.18
-* News-3.22.17:: Changes in release 3.22.17
-* News-3.22.16:: Changes in release 3.22.16
-* News-3.22.15:: Changes in release 3.22.15
-* News-3.22.14:: Changes in release 3.22.14
-* News-3.22.13:: Changes in release 3.22.13
-* News-3.22.12:: Changes in release 3.22.12
-* News-3.22.11:: Changes in release 3.22.11
-* News-3.22.10:: Changes in release 3.22.10
-* News-3.22.9:: Changes in release 3.22.9
-* News-3.22.8:: Changes in release 3.22.8
-* News-3.22.7:: Changes in release 3.22.7
-* News-3.22.6:: Changes in release 3.22.6
-* News-3.22.5:: Changes in release 3.22.5
-* News-3.22.4:: Changes in release 3.22.4
-* News-3.22.3:: Changes in release 3.22.3
-* News-3.22.2:: Changes in release 3.22.2
-* News-3.22.1:: Changes in release 3.22.1
-* News-3.22.0:: Changes in release 3.22.0
-
-Changes in release 3.21.x
-
-* News-3.21.33:: Changes in release 3.21.33
-* News-3.21.32:: Changes in release 3.21.32
-* News-3.21.31:: Changes in release 3.21.31
-* News-3.21.30:: Changes in release 3.21.30
-* News-3.21.29:: Changes in release 3.21.29
-* News-3.21.28:: Changes in release 3.21.28
-* News-3.21.27:: Changes in release 3.21.27
-* News-3.21.26:: Changes in release 3.21.26
-* News-3.21.25:: Changes in release 3.21.25
-* News-3.21.24:: Changes in release 3.21.24
-* News-3.21.23:: Changes in release 3.21.23
-* News-3.21.22:: Changes in release 3.21.22
-* News-3.21.21a:: Changes in release 3.21.21a
-* News-3.21.21:: Changes in release 3.21.21
-* News-3.21.20:: Changes in release 3.21.20
-* News-3.21.19:: Changes in release 3.21.19
-* News-3.21.18:: Changes in release 3.21.18
-* News-3.21.17:: Changes in release 3.21.17
-* News-3.21.16:: Changes in release 3.21.16
-* News-3.21.15:: Changes in release 3.21.15
-* News-3.21.14b:: Changes in release 3.21.14b
-* News-3.21.14a:: Changes in release 3.21.14a
-* News-3.21.13:: Changes in release 3.21.13
-* News-3.21.12:: Changes in release 3.21.12
-* News-3.21.11:: Changes in release 3.21.11
-* News-3.21.10:: Changes in release 3.21.10
-* News-3.21.9:: Changes in release 3.21.9
-* News-3.21.8:: Changes in release 3.21.8
-* News-3.21.7:: Changes in release 3.21.7
-* News-3.21.6:: Changes in release 3.21.6
-* News-3.21.5:: Changes in release 3.21.5
-* News-3.21.4:: Changes in release 3.21.4
-* News-3.21.3:: Changes in release 3.21.3
-* News-3.21.2:: Changes in release 3.21.2
-* News-3.21.0:: Changes in release 3.21.0
-
-Changes in release 3.20.x
-
-* News-3.20.18:: Changes in release 3.20.18
-* News-3.20.17:: Changes in release 3.20.17
-* News-3.20.16:: Changes in release 3.20.16
-* News-3.20.15:: Changes in release 3.20.15
-* News-3.20.14:: Changes in release 3.20.14
-* News-3.20.13:: Changes in release 3.20.13
-* News-3.20.11:: Changes in release 3.20.11
-* News-3.20.10:: Changes in release 3.20.10
-* News-3.20.9:: Changes in release 3.20.9
-* News-3.20.8:: Changes in release 3.20.8
-* News-3.20.7:: Changes in release 3.20.7
-* News-3.20.6:: Changes in release 3.20.6
-* News-3.20.3:: Changes in release 3.20.3
-* News-3.20.0:: Changes in releases 3.20.0
-
-Changes in release 3.19.x
-
-* News-3.19.5:: Changes in release 3.19.5
-* News-3.19.4:: Changes in release 3.19.4
-* News-3.19.3:: Changes in release 3.19.3
-
-MySQL and the future (The TODO)
-
-* TODO MySQL 4.0:: Things that should be in Version 4.0
-* TODO future:: Things that must be done in the near future
-* TODO sometime:: Things that have to be done sometime
-* TODO unplanned:: Some things we don't have any plans to do
-
-Comments on porting to other systems
-
-* Debugging server:: Debugging a @strong{MySQL} server
-* Debugging client:: Debugging a @strong{MySQL} client
-* The DBUG package:: The DBUG package
-* Locking methods:: Locking methods
-* RTS-threads:: Comments about RTS threads
-* Thread packages:: Differences between different thread packages
-Debugging a MySQL server
-* Compiling for debugging::
-* Making trace files::
-* Using gdb on mysqld::
-* Using stack trace::
-* Using log files::
-* Reproduceable test case::
-@end detailmenu
-@end menu
+@node Introduction, Installing, Top, Top
+@chapter General Information About MySQL
@cindex overview
@cindex general information
@cindex online location of manual
@cindex manual, online location
-@node Introduction, Questions, Top, Top
-@chapter General Information About MySQL
-
-@menu
-* What-is:: What is @strong{MySQL}?
-* What is MySQL AB::
-* Manual-info:: About this manual
-* History:: History of @strong{MySQL}
-* MySQL-Books:: Books about MySQL
-* Features:: The main features of @strong{MySQL}
-* Stability:: How stable is @strong{MySQL}?
-* Year 2000 compliance:: Year 2000 compliance
-* General-SQL:: General SQL information and tutorials
-* Useful Links:: Useful @strong{MySQL}-related links
-@end menu
-
-This is the @strong{MySQL} reference manual; it documents @strong{MySQL}
-Version @value{mysql_version}. As @strong{MySQL} is work in progress,
+This is the MySQL reference manual; it documents MySQL
+Version @value{mysql_version}. As MySQL is work in progress,
the manual gets updated frequently. There is a very good chance that
this version is out of date, unless you are looking at it online. The
most recent version of this manual is available at
@@ -1171,31 +154,31 @@ most recent version of this manual is available at
have a hard time finding information in the manual, you can try the
searchable PHP version at @uref{http://www.mysql.com/documentation/manual.php}.
-@strong{MySQL} is a very fast, multi-threaded, multi-user, and robust SQL
+MySQL is a very fast, multi-threaded, multi-user, and robust SQL
(Structured Query Language) database server.
-@strong{MySQL} is free software. It is licensed with the @strong{GNU
+MySQL is free software. It is licensed with the @strong{GNU
GENERAL PUBLIC LICENSE} @uref{http://www.gnu.org/}.
@xref{Licensing and Support}.
-@uref{http://www.mysql.com/, The @strong{MySQL} home page}
-provides the latest information about @strong{MySQL}.
+@uref{http://www.mysql.com/, The MySQL home page}
+provides the latest information about MySQL.
The following list describes some useful sections of the manual:
@itemize @bullet
@item
-For information about the company behind @strong{MySQL}, see
+For information about the company behind MySQL, see
@ref{What is MySQL AB}.
@item
-For a discussion of @strong{MySQL}'s capabilities, see @ref{Features}.
+For a discussion of MySQL's capabilities, see @ref{Features}.
@item
For installation instructions, see @ref{Installing}.
@item
-For tips on porting @strong{MySQL} to new architectures or operating
+For tips on porting MySQL to new architectures or operating
systems, see @ref{Porting}.
@item
@@ -1203,7 +186,7 @@ For information about upgrading from a Version 3.22 release, see
@ref{Upgrading-from-3.22}.
@item
-For a tutorial introduction to @strong{MySQL}, see @ref{Tutorial}.
+For a tutorial introduction to MySQL, see @ref{Tutorial}.
@item
For examples of SQL and benchmarking information, see the benchmarking
@@ -1232,7 +215,7 @@ The @code{mysqlbug} script should be used to generate bug reports.
For source distributions, the @code{mysqlbug} script can be found in the
@file{scripts} directory. For binary distributions, @code{mysqlbug} can
be found in the @file{bin} directory. If you have found a sensitive
-security bug in @strong{MySQL}, you should send an email to
+security bug in MySQL, you should send an email to
@email{security@@mysql.com}.
@cindex errors, reporting
@@ -1246,117 +229,148 @@ manual, please send them to the manual team at @email{docs@@mysql.com}.
This is a reference manual; it does not provide general instruction on SQL
or relational database concepts. If you want general information about SQL,
see @ref{General-SQL}. For books that focus more specifically on
-@strong{MySQL}, see @ref{MySQL-Books}.
+MySQL, see @ref{MySQL-Books}.
+
+
+@menu
+* MySQL and MySQL AB:: MySQL, MySQL AB, and Open Source
+* MySQL Information Sources:: MySQL Information Sources
+* Licensing and Support:: MySQL Licensing and Support
+* Compatibility:: How Standards-compatible Is MySQL?
+* Comparisons:: How MySQL Compares to Other Databases
+* TODO:: MySQL and the future (The TODO)
+@end menu
+
+
+@node MySQL and MySQL AB, MySQL Information Sources, Introduction, Introduction
+@section MySQL, MySQL AB, and Open Source
+
+@menu
+* What-is:: What is MySQL?
+* What is MySQL AB:: What is MySQL AB?
+* Manual-info:: About this manual
+* Manual conventions:: Conventions used in this manual
+* History:: History of MySQL
+* Features:: The main features of MySQL
+* Stability:: How stable is MySQL?
+* Table size:: How Big Can MySQL Tables Be?
+* Year 2000 compliance:: Year 2000 compliance
+@end menu
+
+
+@node What-is, What is MySQL AB, MySQL and MySQL AB, MySQL and MySQL AB
+@subsection What Is MySQL
@cindex MySQL, defined
@cindex MySQL, introduction
-@node What-is, What is MySQL AB, Introduction, Introduction
-@section What Is MySQL
-@strong{MySQL}, the most popular Open Source SQL database, is provided
-by @strong{MySQL AB}. @strong{MySQL AB} is a commercial company that
-builds its business providing services around the @strong{MySQL} database.
+MySQL, the most popular Open Source SQL database, is provided
+by MySQL AB. MySQL AB is a commercial company that
+builds its business providing services around the MySQL database.
@xref{What is MySQL AB}.
@table @asis
-@item @strong{MySQL} is a database management system.
+@item MySQL is a database management system.
A database is a structured collection of data. It may be anything from a
simple shopping list to a picture gallery or the vast amounts of
information in a corporate network. To add, access, and process data
stored in a computer database, you need a database management system
-such as @strong{MySQL}. Since computers are very good at handling large
+such as MySQL. Since computers are very good at handling large
amounts of data, database management plays a central role in computing,
as stand-alone utilities, or as parts of other applications.
@cindex databases, defined
-@item @strong{MySQL} is a relational database management system.
+@item MySQL is a relational database management system.
A relational database stores data in separate tables rather than putting
all the data in one big storeroom. This adds speed and flexibility. The
tables are linked by defined relations making it possible to combine
-data from several tables on request. The SQL part of @strong{MySQL}
+data from several tables on request. The SQL part of MySQL
stands for "Structured Query Language" - the most common standardized
language used to access databases.
@cindex relational databases, defined
@cindex SQL, defined
-@item @strong{MySQL} is Open Source Software.
+@item MySQL is Open Source Software.
Open Source means that it is possible for anyone to use and modify.
-Anybody can download @strong{MySQL} from the Internet and use it
+Anybody can download MySQL from the Internet and use it
without paying anything. Anybody so inclined can study the source code
-and change it to fit their needs. @strong{MySQL} uses the GPL (GNU
+and change it to fit their needs. MySQL uses the GPL (GNU
General Public License) @uref{http://www.gnu.org}, to define what you
may and may not do with the software in different situations. If you
-feel uncomfortable with the GPL or need to embed @strong{MySQL} into a
+feel uncomfortable with the GPL or need to embed MySQL into a
commercial application you can buy a commercially licensed version from
us.
@cindex open source, defined
@cindex General Public License
-@item Why use @strong{MySQL}?
+@item Why use MySQL?
-@strong{MySQL} is very fast, reliable, and easy to use. If that is what
-you are looking for, you should give it a try. @strong{MySQL} also has a
+MySQL is very fast, reliable, and easy to use. If that is what
+you are looking for, you should give it a try. MySQL also has a
very practical set of features developed in very close cooperation with
-our users. You can find a performance comparison of @strong{MySQL}
-to some other database managers on our benchmark page. @xref{Benchmarks}.
+our users. You can find a performance comparison of MySQL
+to some other database managers on our benchmark page.
+@xref{MySQL Benchmarks}.
-@strong{MySQL} was originally developed to handle very large databases
+MySQL was originally developed to handle very large databases
much faster than existing solutions and has been successfully used in
highly demanding production environments for several years. Though
-under constant development, @strong{MySQL} today offers a rich and very
+under constant development, MySQL today offers a rich and very
useful set of functions. The connectivity, speed, and security make
-@strong{MySQL} highly suited for accessing databases on the Internet.
+MySQL highly suited for accessing databases on the Internet.
-@item The technical features of @strong{MySQL}
+@item The technical features of MySQL
-For advanced technical information, see @ref{Reference}. @strong{MySQL} is
+For advanced technical information, see @ref{Reference}. MySQL is
a client/server system that consists of a multi-threaded SQL server
that supports different backends, several different client programs and
libraries, administrative tools, and several programming interfaces.
-We also provide @strong{MySQL} as a multi-threaded library which you can
+We also provide MySQL as a multi-threaded library which you can
link into your application to get a smaller, faster, easier to manage
product.
-@item @strong{MySQL} has a lot of contributed software available.
+@item MySQL has a lot of contributed software available.
It is very likely that you will find that your favorite application or
-language already supports @strong{MySQL}.
+language already supports MySQL.
@end table
@cindex pronunciation, MySQL
@cindex MySQL, pronunciation
@cindex goals of MySQL
-The official way to pronounce @strong{MySQL} is ``My Ess Que Ell'' (not
+The official way to pronounce MySQL is ``My Ess Que Ell'' (not
MY-SEQUEL). But we try to avoid correcting people who say MY-SEQUEL.
+
+@node What is MySQL AB, Manual-info, What-is, MySQL and MySQL AB
+@subsection What Is MySQL AB
+
@cindex MySQL AB, defined
-@node What is MySQL AB, Manual-info, What-is, Introduction
-@section What Is MySQL AB
-@strong{MySQL AB} is the Swedish company owned and run by the @strong{MySQL}
-founders and main developers. We are dedicated to developing @strong{MySQL}
-and spreading our database to new users. @strong{MySQL AB} owns the copyright
-to the @strong{MySQL} server source code and the @strong{MySQL} trademark.
+MySQL AB is the Swedish company owned and run by the MySQL
+founders and main developers. We are dedicated to developing MySQL
+and spreading our database to new users. MySQL AB owns the copyright
+to the MySQL server source code and the MySQL trademark.
A significant amount of revenues from our services goes to developing
-@strong{MySQL}. @xref{What-is}.
+MySQL. @xref{What-is}.
-@strong{MySQL AB} has been profitable providing @strong{MySQL} from the start.
+MySQL AB has been profitable providing MySQL from the start.
We don't get any outside funding, but have earned all our money ourselves.
We are searching after partners that would like to support our development
-of @strong{MySQL} so that we could accelerate the development pace. If you
+of MySQL so that we could accelerate the development pace. If you
are interested in doing this, you can email @email{partner@@mysql.com} about
this!
-@strong{MySQL AB} has currently 20+ people
+MySQL AB has currently 20+ people
(@uref{http://www.mysql.com/development/team.html}) on its payroll and is growing rapidly.
@@ -1364,26 +378,26 @@ Our main sources of income are:
@itemize @bullet
@item
-Commercial high quality support for @strong{MySQL} provided by the
-@strong{MySQL} developers themselves. If you are interested in purchasing
+Commercial high quality support for MySQL provided by the
+MySQL developers themselves. If you are interested in purchasing
a support contract, please visit @uref{https://order.mysql.com/} to view our
support options or to order support.
@item
Consulting services. We have developers and consultants in 12 countries
and partners in many other countries that can help you with almost any
-@strong{MySQL} related issues. If you need consulting services, please
+MySQL related issues. If you need consulting services, please
email a good description of your needs to @email{info@@mysql.com}! If we
can't handle this ourselves we can usually find a partner or a developer
that can help you with your problems.
@item
-We sell licenses for using @strong{MySQL} as an embedded database.
+We sell licenses for using MySQL as an embedded database.
@xref{Cost}. If you have a commercial product for which you need a fast,
high quality database, but you can't afford to make your product Open Source,
-you can buy the right to use the @strong{MySQL} server under a normal
+you can buy the right to use the MySQL server under a normal
commercial copyright. If you are interested in this you can buy
-@strong{MySQL} licenses at @uref{https://order.mysql.com/} or contact us
+MySQL licenses at @uref{https://order.mysql.com/} or contact us
at @email{licensing@@mysql.com}.
@item
@@ -1394,27 +408,27 @@ in the Open source, Linux and database community. If you are interested
in this email @email{advertising@@mysql.com}.
@item
-We are building a partner program to be able to provide @strong{MySQL}
+We are building a partner program to be able to provide MySQL
services in every country. If you are interested in becoming a partner
-of @strong{MySQL AB} please visit
+of MySQL AB please visit
@uref{http://www.mysql.com/information/partners.html} or email
@email{partner@@mysql.com}.
@item
-We provide @strong{MySQL} training through our partner programs. For more
+We provide MySQL training through our partner programs. For more
information, please email @email{info@@mysql.com}.
@item
-The @strong{MySQL} brand has, since 1995, been associated with speed and
+The MySQL brand has, since 1995, been associated with speed and
reliability, and is known to be something you can depend upon. If you are
-interested in using the @strong{MySQL} trademark in your marketing, you
+interested in using the MySQL trademark in your marketing, you
can email @email{info@@mysql.com} about this.
@end itemize
-The @strong{MySQL} core values show our dedication to @strong{MySQL} and
+The MySQL core values show our dedication to MySQL and
Open Source.
-We want @strong{MySQL} to be:
+We want MySQL to be:
@itemize @bullet
@item
@@ -1431,7 +445,7 @@ Fun to use and improve.
Free from bugs.
@end itemize
-@strong{MySQL AB} and the people of @strong{MySQL AB}:
+MySQL AB and the people of MySQL AB:
@itemize @bullet
@item
@@ -1448,12 +462,9 @@ Are a virtual company, networking with others.
Work against software patents.
@end itemize
-@node Manual-info, History, What is MySQL AB, Introduction
-@section About This Manual
-@menu
-* Manual conventions:: Conventions used in this manual
-@end menu
+@node Manual-info, Manual conventions, What is MySQL AB, MySQL and MySQL AB
+@subsection About This Manual
This manual is currently available in Texinfo, plain text, Info, HTML,
PostScript, and PDF versions. The primary document is the Texinfo file.
@@ -1469,7 +480,8 @@ This manual is written and maintained by David Axmark, Michael (Monty)
Widenius, Jeremy Cole, and Paul DuBois. For other contributors,
see @ref{Credits}.
-@node Manual conventions, , Manual-info, Manual-info
+
+@node Manual conventions, History, Manual-info, MySQL and MySQL AB
@subsection Conventions Used in This Manual
This manual uses certain typographical conventions:
@@ -1593,12 +605,14 @@ alternatives are listed within braces (@samp{@{} and @samp{@}}):
@{DESCRIBE | DESC@} tbl_name @{col_name | wild@}
@end example
+
+@node History, Features, Manual conventions, MySQL and MySQL AB
+@subsection History of MySQL
+
@cindex MySQL history
@cindex history of MySQL
@cindex MySQL name
@cindex My, derivation
-@node History, MySQL-Books, Manual-info, Introduction
-@section History of MySQL
We once started out with the intention of using @code{mSQL} to connect to our
tables using our own fast low-level (ISAM) routines. However, after some
@@ -1607,375 +621,21 @@ flexible enough for our needs. This resulted in a new SQL interface to our
database but with almost the same API interface as @code{mSQL}. This API was
chosen to ease porting of third-party code.
-The derivation of the name @strong{MySQL} is not perfectly clear. Our base
+The derivation of the name MySQL is not perfectly clear. Our base
directory and a large number of our libraries and tools have had the prefix
``my'' for well over 10 years. However, Monty's daughter (some years younger)
-is also named My. Which of the two gave its name to @strong{MySQL} is
+is also named My. Which of the two gave its name to MySQL is
still a mystery, even for us.
-@node MySQL-Books, Features, History, Introduction
-@section Books About MySQL
-
-@cindex books, about MySQL
-@cindex manuals, about MySQL
-
-While this manual is still the right place for up to date technical
-information, its primary goal is to contain everything there is to know
-about @strong{MySQL}. It is sometimes nice to have a bound book to read
-in bed or while you travel. Here is a list of books about @strong{MySQL} and
-related subjects (in English).
-
-By purchasing a book through these hyperlinks provided herein, you are
-contributing to the development of @strong{MySQL}.
-
-@emph{MySQL}
-@multitable @columnfractions .3 .7
-@item Available @tab @uref{http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0735709211&bfmtype=book, Barnes and Noble}
-@item Publisher @tab New Riders
-@item Author @tab Paul DuBois
-@item Pub Date @tab 1st Edition December 1999
-@item ISBN @tab 0735709211
-@item Pages @tab 800
-@item Price @tab $49.99 US
-@item Downloadable examples @tab
- @uref{http://www.kitebird.com/mysql-book/, @code{samp_db} distribution}
-@item Errata @tab
-@uref{http://www.kitebird.com/mysql-book/errata.html, are available here}
-@end multitable
-
-Foreword by Michael ``Monty'' Widenius, @strong{MySQL} Moderator.
-@*
-
-In @emph{MySQL}, Paul DuBois provides you with a comprehensive guide to
-one of the most popular relational database systems. Paul has
-contributed to the online documentation for @strong{MySQL} and is an
-active member of the @strong{MySQL} community. The principal @strong{MySQL}
-developer, Monty Widenius, and a network of his fellow developers
-reviewed the manuscript, and provided Paul with the kind of insight
-no one else could supply.
-@*
-
-Instead of merely giving you a general overview of @strong{MySQL}, Paul
-teaches you how to make the most of its capabilities. Through two
-sample database applications that run throughout the book, he
-gives you solutions to problems you're sure to face. He helps you
-integrate @strong{MySQL} efficiently with third-party tools, such as PHP
-and Perl, enabling you to generate dynamic Web pages through
-database queries. He teaches you to write programs that access
-@strong{MySQL} databases, and also provides a comprehensive set of
-references to column types, operators, functions, SQL syntax,
-@strong{MySQL} programming, C API, Perl @code{DBI}, and PHP API.
-@emph{MySQL} simply gives you the kind of information you won't find
-anywhere else.
-@*
-
-If you use @strong{MySQL}, this book provides you with:
-@itemize @bullet
-@item
-An introduction to @strong{MySQL} and SQL.
-@item
-Coverage of @strong{MySQL}'s data types and how to use them.
-@item
-Thorough treatment of how to write client programs in C.
-@item
-A guide to using the Perl @code{DBI} and PHP APIs for developing
-command-line and Web-based applications.
-@item
-Tips on administrative issues such as user accounts, backup,
-crash recovery, and security.
-@item
-Help in choosing an ISP for @strong{MySQL} access.
-@item
-A comprehensive reference for @strong{MySQL}'s data types, operators,
-functions, and SQL statements and utilities.
-@item
-Complete reference guides for @strong{MySQL}'s C API, the Perl @code{DBI} API,
-and PHP's @strong{MySQL}-related functions.
-@end itemize
-@*
-@emph{MySQL & mSQL}
-@multitable @columnfractions .3 .7
-@item Available @tab @uref{http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=1565924347&bfmtype=book, Barnes and Noble}
-@item Publisher @tab O'Reilly
-@item Authors @tab Randy Jay Yarger, George Reese & Tim King
-@item Pub Date @tab 1st Edition July 1999
-@item ISBN @tab 1-56592-434-7, Order Number: 4347
-@item Pages @tab 506
-@item Price @tab $34.95
-@end multitable
-
-This book teaches you how to use @strong{MySQL} and @code{mSQL}, two popular
-and robust database products that support key subsets of SQL on both Linux
-and Unix systems. Anyone who knows basic C, Java, Perl, or Python can
-write a program to interact with a database, either as a stand-alone
-application or through a Web page. This book takes you through the
-whole process, from installation and configuration to programming
-interfaces and basic administration. Includes plenty of tutorial
-material.
-@*
-
-@emph{Sams' Teach Yourself MySQL in 21 Days}
-@multitable @columnfractions .3 .7
-@item Available @tab @uref{http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0672319144&bfmtype=book, Barnes and Noble}
-@item Publisher @tab Sams
-@item Authors @tab Mark Maslakowski and Tony Butcher
-@item Pub Date @tab June 2000
-@item ISBN @tab 0672319144
-@item Pages @tab 650
-@item Price @tab $39.99
-@end multitable
-
-Sams' @emph{Teach Yourself MySQL in 21 Days} is for intermediate Linux users
-who want to move into databases. A large share of the audience is Web
-developers who need a database to store large amounts of information that
-can be retrieved via the Web.
-
-Sams' @emph{Teach Yourself MySQL in 21 Days} is a practical, step-by-step
-tutorial. The reader will learn to design and employ this open source
-database technology into his or her Web site using practical, hands-on
-examples to follow.
-@*
-
-@emph{E-Commerce Solutions with MySQL}
-@multitable @columnfractions .3 .7
-@item Available @tab @uref{http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0761524452&bfmtype=book, Barnes and Noble}
-@item Publisher @tab Prima Communications, Inc.
-@item Authors @tab N/A
-@item Pub Date @tab January 2000
-@item ISBN @tab 0761524452
-@item Pages @tab 500
-@item Price @tab $39.99
-@end multitable
-
-No description available.
-@*
-
-@emph{MySQL and PHP from Scratch}
-@multitable @columnfractions .3 .7
-@item Available @tab @uref{http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0789724405&bfmtype=book, Barnes and Noble}
-@item Publisher @tab Que
-@item Authors @tab N/A
-@item Pub Date @tab September 2000
-@item ISBN @tab 0789724405
-@item Pages @tab 550
-@item Price @tab $34.99
-@end multitable
-
-This book puts together information on installing, setting up, and
-troubleshooting Apache, @strong{MySQL}, PHP3, and IMP into one complete
-volume. You also learn how each piece is part of a whole by learning,
-step-by-step, how to create a web-based e-mail system. Learn to run
-the equivalent of Active Server Pages (ASP) using PHP3, set up an
-e-commerce site using a database and the Apache web server, and create
-a data entry system (such as sales, product quality tracking, customer
-preferences, etc) that no installation in the PC.
-@*
-
-@emph{Professional MySQL Programming}
-@multitable @columnfractions .3 .7
-@item Available @tab @uref{http://shop.barnesandnoble.com/bookSearch/isbnInquiry.asp?isbn=1861005164, Barnes and Noble}
-@item Publisher @tab Wrox Press, Inc.
-@item Authors @tab N/A
-@item Pub Date @tab Late 2001
-@item ISBN @tab 1861005164
-@item Pages @tab 1000
-@item Price @tab $49.99
-@end multitable
-
-No description available.
-@*
-
-@emph{Professional Linux Programming}
-@multitable @columnfractions .3 .7
-@item Available @tab @uref{http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=1861003013&bfmtype=book, Barnes and Noble}
-@item Publisher @tab Wrox Press, Inc.
-@item Authors @tab N/A
-@item Pub Date @tab September 2000
-@item ISBN @tab 1861003013
-@item Pages @tab 1155
-@item Price @tab $47.99
-@end multitable
-
-In this follow-up to the best-selling @emph{Beginning Linux Programming},
-you will learn from the authors' real-world knowledge and experience of
-developing software for Linux; you'll be taken through the development
-of a sample 'DVD Store' application, with 'theme' chapters addressing
-different aspects of its implementation. Meanwhile, individual
-``take-a-break'' chapters cover important topics that go beyond the
-bounds of the central theme. All focus on the practical aspects of
-programming, showing how crucial it is to choose the right tools for
-the job, use them as they should be used, and get things right first
-time.
-@*
-
-@emph{PHP and MySQL Web Development}
-@multitable @columnfractions .3 .7
-@item Available @tab @uref{http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0672317842&bfmtype=book, Barnes and Noble}
-@item Publisher @tab Sams
-@item Authors @tab Luke Welling, Laura Thomson
-@item Pub Date @tab March 2001
-@item ISBN @tab 0672317842
-@item Pages @tab 700
-@item Price @tab $49.99
-@end multitable
-
-@emph{PHP and MySQL Web Development} introduces you to the advantages
-of implementing both @strong{MySQL} and PHP. These advantages are detailed
-through the provision of both statistics and several case studies. A
-practical web application is developed throughout the book, providing
-you with the tools necessary to implement a functional online
-database. Each function is developed separately, allowing you the
-choice to incorporate only those parts that you would like to
-implement. Programming concepts of the PHP language are highlighted,
-including functions which tie @strong{MySQL} support into a PHP script and
-advanced topics regarding table manipulation.
-@*
-
-@strong{Books recommended by the MySQL Developers}
-
-@emph{SQL-99 Complete, Really}
-@multitable @columnfractions .3 .7
-@item Available @tab @uref{http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0879305681&bfmtype=book, Barnes and Noble}
-@item Publisher @tab CMP Books
-@item Authors @tab Peter Gulutzan, Trudy Pelzer
-@item Pub Date @tab April 1999
-@item ISBN @tab 0879305681
-@item Pages @tab 1104
-@item Price @tab $55.96
-@end multitable
-
-This book contains complete descriptions of the new standards for
-syntax, data structures, and retrieval processes of SQL databases. As
-an example-based reference manual, it includes all of the CLI
-functions, information, schema tables, and status codes, as well as a
-working SQL database provided on the companion disk.
-@*
-
-@emph{C, A reference manual}
-@multitable @columnfractions .3 .7
-@item Available @tab @uref{http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0133262243&bfmtype=book, Barnes and Noble}
-@item Publisher @tab Prentice Hall
-@item Authors @tab Samuel P. Harbison, Guy L. Steele
-@item Pub Date @tab September 1994
-@item ISBN @tab 0133262243
-@item Pages @tab 480
-@item Price @tab $35.99
-@end multitable
-
-A new and improved revision of the bestselling C language
-reference. This manual introduces the notion of "Clean C", writing C
-code that can be compiled as a C++ program, C programming style that
-emphasizes correctness, portability, maintainability, and
-incorporates the ISO C Amendment 1 (1994) which specifies new
-facilities for writing portable, international programs in C.
-@*
-
-@emph{C++ for Real Programmers}
-@multitable @columnfractions .3 .7
-@item Available @tab @uref{http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0120499428&bfmtype=book, Barnes and Noble}
-@item Publisher @tab Academic Press, Incorporated
-@item Authors @tab Jeff Alger, Jim Keogh
-@item Pub Date @tab February 1998
-@item ISBN @tab 0120499428
-@item Pages @tab 388
-@item Price @tab $39.95
-@end multitable
-
-@emph{C++ For Real Programmers} bridges the gap between C++ as described
-in beginner and intermediate-level books and C++ as it is practiced by
-experts. Numerous valuable techniques are described, organized into
-three simple themes: indirection, class hierarchies, and memory
-management. It also provides in-depth coverage of template creation,
-exception handling, pointers and optimization techniques. The focus of
-the book is on ANSI C++ and, as such, is compiler independent.
-
-@emph{C++ For Real Programmers} is a revision of
-@emph{Secrets of the C++ Masters} and includes a new appendix comparing C++
-with Java. The book comes with a 3.5" disk for Windows with source code.
-@*
-
-@emph{Algorithms in C}
-@multitable @columnfractions .3 .7
-@item Available @tab @uref{http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0201514257&bfmtype=book, Barnes and Noble}
-@item Publisher @tab Addison Wesley Longman, Inc.
-@item Authors @tab Robert Sedgewick
-@item Pub Date @tab April 1990
-@item ISBN @tab 0201514257
-@item Pages @tab 648
-@item Price @tab $45.75
-@end multitable
-
-@emph{Algorithms in C} describes a variety of algorithms in a number of
-areas of interest, including: sorting, searching, string-processing, and
-geometric, graph and mathematical algorithms. The book emphasizes
-fundamental techniques, providing readers with the tools to confidently
-implement, run, and debug useful algorithms.
-@*
-
-@emph{Multithreaded Programming with Pthreads}
-@multitable @columnfractions .3 .7
-@item Available @tab @uref{http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0136807291&bfmtype=book, Barnes and Noble}
-@item Publisher @tab Prentice Hall
-@item Authors @tab Bil Lewis, Daniel J. Berg
-@item Pub Date @tab October 1997
-@item ISBN @tab 0136807291
-@item Pages @tab 432
-@item Price @tab $34.95
-@end multitable
-
-Based on the best-selling @emph{Threads Primer},
-@emph{Multithreaded Programming with Pthreads} gives you a solid
-understanding of Posix threads: what they are, how they work, when to use
-them, and how to optimize them. It retains the clarity and humor of
-@emph{Threads Primer}, but includes expanded comparisons to Win32 and OS/2
-implementations. Code examples tested on all of the major UNIX platforms
-are featured along with detailed explanations of how and why they use threads.
-@*
-
-@emph{Programming the PERL DBI: Database Programming with PERL}
-@multitable @columnfractions .3 .7
-@item Available @tab @uref{http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=1565926994&bfmtype=book, Barnes and Noble}
-@item Publisher @tab O'Reilly & Associates, Incorporated
-@item Authors @tab Alligator Descartes, Tim Bunce
-@item Pub Date @tab February 2000
-@item ISBN @tab 1565926994
-@item Pages @tab 400
-@item Price @tab $27.96
-@end multitable
-
-@emph{Programming the Perl DBI} is coauthored by Alligator Descartes, one
-of the most active members of the DBI community, and by Tim Bunce, the
-inventor of DBI. For the uninitiated, the book explains the architecture
-of DBI and shows you how to write DBI-based programs. For the experienced
-DBI dabbler, this book explains DBI's nuances and the peculiarities of each
-individual DBD.
-
-The book includes:
-@itemize @bullet
-@item
-An introduction to DBI and its design.
-@item
-How to construct queries and bind parameters.
-@item
-Working with database, driver, and statement handles.
-@item
-Debugging techniques.
-@item
-Coverage of each existing DBD.
-@item
-A complete reference to DBI.
-@end itemize
-@*
-
-@node Features, Stability, MySQL-Books, Introduction
-@section The Main Features of MySQL
+@node Features, Stability, History, MySQL and MySQL AB
+@subsection The Main Features of MySQL
@cindex main features of MySQL
@cindex features of MySQL
The following list describes some of the important characteristics
-of @strong{MySQL}:
+of MySQL:
@c This list is too technical and should be divided into one feature
@c list comparable to commercial competition and a very technical on
@@ -2036,7 +696,7 @@ password traffic is encrypted when you connect to a server.
@item
ODBC (Open-DataBase-Connectivity) support for Win32 (with source). All
ODBC 2.5 functions and many others. For example, you can use MS Access to
-connect to your @strong{MySQL} server. @xref{ODBC}.
+connect to your MySQL server. @xref{ODBC}.
@item
Very fast B-tree disk tables with index compression.
@@ -2044,7 +704,7 @@ Very fast B-tree disk tables with index compression.
@item
Up to 32 indexes per table are allowed. Each index may consist of 1 to 16
columns or parts of columns. The maximum index length is 500 bytes (this
-may be changed when compiling @strong{MySQL}). An index may use a prefix
+may be changed when compiling MySQL). An index may use a prefix
of a @code{CHAR} or @code{VARCHAR} field.
@item
@@ -2054,9 +714,9 @@ Fixed-length and variable-length records.
In-memory hash tables which are used as temporary tables.
@item
-Handles large databases. We are using @strong{MySQL} with some
+Handles large databases. We are using MySQL with some
databases that contain 50,000,000 records and we know of users that
-uses @strong{MySQL} with 60,000 tables and about 5,000,000,000 rows
+uses MySQL with 60,000 tables and about 5,000,000,000 rows
@item
All columns have default values. You can use @code{INSERT} to insert a
@@ -2073,13 +733,14 @@ Written in C and C++. Tested with a broad range of different compilers.
A very fast thread-based memory allocation system.
@item
-No memory leaks. @strong{MySQL} has been tested with Purify, a commercial
+No memory leaks. MySQL has been tested with Purify, a commercial
memory leakage detector.
@item
Includes @code{myisamchk}, a very fast utility for table checking,
optimization, and repair. All of the functionality of @code{myisamchk}
-is also available through the SQL interface as well. @xref{Maintenance}.
+is also available through the SQL interface as well.
+@xref{MySQL Database Administration}.
@item
Full support for several different character sets, including
@@ -2093,9 +754,9 @@ string columns are case insensitive.
@item
Sorting is done according to the chosen character set (the Swedish
-way by default). It is possible to change this when the @strong{MySQL} server
+way by default). It is possible to change this when the MySQL server
is started up. To see an example of very advanced sorting, look at the
-Czech sorting code. @strong{MySQL} supports many different character sets
+Czech sorting code. MySQL supports many different character sets
that can be specified at compile and run time.
@item
@@ -2114,7 +775,7 @@ function call, no spaces are allowed between the function name and the
@samp{(} that follows it. @xref{Reserved words}.
@item
-All @strong{MySQL} programs can be invoked with the @code{--help} or @code{-?}
+All MySQL programs can be invoked with the @code{--help} or @code{-?}
options to obtain online assistance.
@item
@@ -2122,43 +783,43 @@ The server can provide error messages to clients in many languages.
@xref{Languages}.
@item
-Clients may connect to the @strong{MySQL} server using TCP/IP Sockets,
+Clients may connect to the MySQL server using TCP/IP Sockets,
Unix Sockets (Unix), or Named Pipes (NT).
@item
-The @strong{MySQL}-specific @code{SHOW} command can be used to retrieve
+The MySQL-specific @code{SHOW} command can be used to retrieve
information about databases, tables, and indexes. The @code{EXPLAIN} command
can be used to determine how the optimizer resolves a query.
@end itemize
+
+@node Stability, Table size, Features, MySQL and MySQL AB
+@subsection How Stable Is MySQL?
+
@cindex stability
-@node Stability, Year 2000 compliance, Features, Introduction
-@section How Stable Is MySQL?
-This section addresses the questions ``How stable is @strong{MySQL}?'' and
-``Can I depend on @strong{MySQL} in this project?'' We will try to clarify
+This section addresses the questions ``How stable is MySQL?'' and
+``Can I depend on MySQL in this project?'' We will try to clarify
some issues and to answer some of the more important questions that seem to
concern many people. This section has been put together from information
gathered from the mailing list (which is very active in reporting bugs).
-At TcX, @strong{MySQL} has worked without any problems in our projects since
-mid-1996. When @strong{MySQL} was released to a wider public, we noticed that
+At TcX, MySQL has worked without any problems in our projects since
+mid-1996. When MySQL was released to a wider public, we noticed that
there were some pieces of ``untested code'' that were quickly found by the
new users who made queries in a manner different than our own. Each new
release has had fewer portability problems than the previous one (even though
each has had many new features).
-@c FIX We've been stable for quite a while now. :) (jcole)
-
-Each release of @strong{MySQL} has been usable, and there have been problems
+Each release of MySQL has been usable, and there have been problems
only when users start to use code from the ``gray zones.'' Naturally, outside
users don't know what the gray zones are; this section attempts to indicate
those that are currently known. The descriptions deal with Version 3.23
-of @strong{MySQL}. All known and reported bugs are fixed in the latest
+of MySQL. All known and reported bugs are fixed in the latest
version, with the exception of the bugs listed in the bugs section, which
are things that are design-related. @xref{Bugs}.
-@strong{MySQL} is written in multiple layers and different independent
+MySQL is written in multiple layers and different independent
modules. These modules are listed below with an indication of how
well-tested each of them is:
@@ -2166,13 +827,13 @@ well-tested each of them is:
@table @strong
@item The ISAM table handler --- Stable
-This manages storage and retrieval of all data in @strong{MySQL} Version 3.22
-and earlier. In all @strong{MySQL} releases there hasn't been a single
+This manages storage and retrieval of all data in MySQL Version 3.22
+and earlier. In all MySQL releases there hasn't been a single
(reported) bug in this code. The only known way to get a corrupted table
is to kill the server in the middle of an update. Even that is unlikely
to destroy any data beyond rescue, because all data are flushed to disk
between each query. There hasn't been a single bug report about lost data
-because of bugs in @strong{MySQL}.
+because of bugs in MySQL.
@cindex ISAM table handler
@cindex storing, data
@@ -2180,7 +841,7 @@ because of bugs in @strong{MySQL}.
@cindex data, ISAM table handler
@item The MyISAM table handler --- Stable
-This is new in @strong{MySQL} Version 3.23. It's largely based on the ISAM
+This is new in MySQL Version 3.23. It's largely based on the ISAM
table code but has a lot of new and very useful features.
@item The parser and lexical analyser --- Stable
@@ -2208,7 +869,7 @@ handling. Not a single reported bug in this system.
@item Locking --- Gamma
This is very system-dependent. On some systems there are big problems
using standard OS locking (@code{fcntl()}). In these cases, you should run the
-@strong{MySQL} daemon with the @code{--skip-locking} flag. Problems are known
+MySQL daemon with the @code{--skip-locking} flag. Problems are known
to occur on some Linux systems, and on SunOS when using NFS-mounted file
systems.
@@ -2236,7 +897,7 @@ be a mutex locking/thread juggling.
@item Other thread implementions --- Beta - Gamma
The ports to other systems are still very new and may have bugs, possibly
-in @strong{MySQL}, but most often in the thread implementation itself.
+in MySQL, but most often in the thread implementation itself.
@item @code{LOAD DATA ...}, @code{INSERT ... SELECT} --- Stable
Some people thought they had found bugs here, but these usually have
@@ -2255,19 +916,19 @@ Written and maintained by Yves Carlier
(@email{Yves.Carlier@@rug.ac.be}). Thanks!
@item @code{GRANT} --- Stable
-Big changes made in @strong{MySQL} Version 3.22.12.
+Big changes made in MySQL Version 3.22.12.
@item @strong{MyODBC} (uses ODBC SDK 2.5) --- Gamma
It seems to work well with some programs.
@item Replication -- Beta / Gamma
We are still working on replication, so don't expect this to be rock
-solid yet. On the other hand, some @strong{MySQL} users are already
+solid yet. On the other hand, some MySQL users are already
using this with good results.
@item BDB Tables -- Beta
The Berkeley DB code is very stable, but we are still improving the interface
-between @strong{MySQL} and BDB tables, so it will take some time before this
+between MySQL and BDB tables, so it will take some time before this
is as tested as the other table types.
@item InnoDB Tables -- Beta
@@ -2287,37 +948,96 @@ Text search seems to work, but is still not widely used.
@end table
-@strong{MySQL AB} provides e-mail support for paying customers, but the
-@strong{MySQL} mailing list usually provides answers to common questions.
+MySQL AB provides e-mail support for paying customers, but the
+MySQL mailing list usually provides answers to common questions.
Bugs are usually fixed right away with a patch; for serious bugs, there is
almost always a new release.
+
+@node Table size, Year 2000 compliance, Stability, MySQL and MySQL AB
+@subsection How Big Can MySQL Tables Be?
+
+@cindex tables, maximum size
+@cindex size of tables
+@cindex operating systems, file size limits
+@cindex limits, file size
+@cindex files, size limits
+
+MySQL Version 3.22 has a 4G limit on table size. With the new
+@code{MyISAM} in MySQL Version 3.23 the maximum table size is
+pushed up to 8 million terabytes (2 ^ 63 bytes).
+
+Note, however, that operating systems have their own file size
+limits. Here are some examples:
+
+@multitable @columnfractions .5 .5
+@item @strong{Operating System} @tab @strong{File Size Limit}
+@item Linux-Intel 32 bit @tab 2G, 4G or more, depends on Linux version
+@item Linux-Alpha @tab 8T (?)
+@item Solaris 2.5.1 @tab 2G (possible 4G with patch)
+@item Solaris 2.6 @tab 4G
+@item Solaris 2.7 Intel @tab 4G
+@item Solaris 2.7 ULTRA-SPARC @tab 8T (?)
+@end multitable
+
+On Linux 2.2 you can get bigger tables than 2G by using the LFS patch for
+the ext2 file system. On Linux 2.4 there exists also patches for ReiserFS
+to get support for big files.
+
+This means that the table size for MySQL is normally limited by
+the operating system.
+
+By default, MySQL tables have a maximum size of about 4G. You can
+check the maximum table size for a table with the @code{SHOW TABLE STATUS}
+command or with the @code{myisamchk -dv table_name}.
+@xref{SHOW}.
+
+If you need bigger tables than 4G (and your operating system supports
+this), you should set the @code{AVG_ROW_LENGTH} and @code{MAX_ROWS}
+parameter when you create your table. @xref{CREATE TABLE}. You can
+also set these later with @code{ALTER TABLE}. @xref{ALTER TABLE}.
+
+If your big table is going to be read-only, you could use
+@code{myisampack} to merge and compress many tables to one.
+@code{myisampack} usually compresses a table by at least 50%, so you can
+have, in effect, much bigger tables. @xref{myisampack, ,
+@code{myisampack}}.
+
+You can go around the operating system file limit for @code{MyISAM} data
+files by using the @code{RAID} option. @xref{CREATE TABLE}.
+
+Another solution can be the included MERGE library, which allows you to
+handle a collection of identical tables as one. @xref{MERGE, MERGE
+tables}.
+
+
+@node Year 2000 compliance, , Table size, MySQL and MySQL AB
+@subsection Year 2000 Compliance
+
@cindex Year 2000 compliance
@cindex compliance, Y2K
@cindex date functions, Y2K compliance
-@node Year 2000 compliance, General-SQL, Stability, Introduction
-@section Year 2000 Compliance
-@strong{MySQL} itself has no problems with Year 2000 (Y2K) compliance:
+MySQL itself has no problems with Year 2000 (Y2K) compliance:
@itemize @bullet
@item
-@strong{MySQL} uses Unix time functions and has no problems with dates
+MySQL uses Unix time functions and has no problems with dates
until @code{2069}; all 2-digit years are regarded to be in the range
@code{1970} to @code{2069}, which means that if you store @code{01} in a
-@code{year} column, @strong{MySQL} treats it as @code{2001}.
+@code{year} column, MySQL treats it as @code{2001}.
@item
-All @strong{MySQL} date functions are stored in one file @file{sql/time.cc}
+All MySQL date functions are stored in one file @file{sql/time.cc}
and coded very carefully to be year 2000-safe.
@item
-In @strong{MySQL} Version 3.22 and later, the new @code{YEAR} column type
+In MySQL Version 3.22 and later, the new @code{YEAR} column type
can store years @code{0} and @code{1901} to @code{2155} in 1 byte and display
them using 2 or 4 digits.
@end itemize
-You may run into problems with applications that use @strong{MySQL} in a
+You may run into problems with applications that use MySQL in a
way that is not Y2K-safe. For example, many old applications store
or manipulate years using 2-digit values (which are ambiguous) rather than
4-digit values. This problem may be compounded by applications that use
@@ -2327,7 +1047,7 @@ Unfortunately, these problems may be difficult to fix, because different
applications may be written by different programmers, each of whom may
use a different set of conventions and date-handling functions.
-Here is a simple demonstration illustrating that @strong{MySQL} doesn't have
+Here is a simple demonstration illustrating that MySQL doesn't have
any problems with dates until the year 2030:
@example
@@ -2385,17 +1105,386 @@ range up to only @code{2030-01-01}. @code{TIMESTAMP} has a range of
@code{1970} to @code{2030} on 32-bit machines (signed value). On 64-bit
machines it handles times up to @code{2106} (unsigned value).
-Even though @strong{MySQL} is Y2K-compliant, it is your responsibility to
-provide unambiguous input. See @ref{Y2K issues} for @strong{MySQL}'s rules
+Even though MySQL is Y2K-compliant, it is your responsibility to
+provide unambiguous input. See @ref{Y2K issues} for MySQL's rules
for dealing with ambiguous date input data (data containing 2-digit year
values).
-@cindex manuals, about @strong{MySQL}
-@cindex books, about @strong{MySQL}
-@node General-SQL, Useful Links, Year 2000 compliance, Introduction
-@section General SQL Information and Tutorials
-The following book has been recommended by several people on the @strong{MySQL}
+@node MySQL Information Sources, Licensing and Support, MySQL and MySQL AB, Introduction
+@section MySQL Information Sources
+
+@cindex manuals, about MySQL
+@cindex books, about MySQL
+
+@menu
+* MySQL-Books:: Books About MySQL
+* General-SQL:: General SQL Information and Tutorials
+* Useful Links:: Useful MySQL-related Links
+* Questions:: MySQL Mailing Lists
+@end menu
+
+
+@node MySQL-Books, General-SQL, MySQL Information Sources, MySQL Information Sources
+@subsection Books About MySQL
+
+For the latest book information, with user comments, please visit
+@uref{http://www.mysql.com/portal/books/html/index.html}.
+
+While this manual is still the right place for up to date technical
+information, its primary goal is to contain everything there is to know
+about MySQL. It is sometimes nice to have a bound book to read
+in bed or while you travel. Here is a list of books about MySQL and
+related subjects (in English).
+
+By purchasing a book through these hyperlinks provided herein, you are
+contributing to the development of MySQL.
+
+@emph{MySQL}
+@multitable @columnfractions .3 .7
+@item Available @tab @uref{http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0735709211&bfmtype=book, Barnes and Noble}
+@item Publisher @tab New Riders
+@item Author @tab Paul DuBois
+@item Pub Date @tab 1st Edition December 1999
+@item ISBN @tab 0735709211
+@item Pages @tab 800
+@item Price @tab $49.99 US
+@item Downloadable examples @tab
+ @uref{http://www.kitebird.com/mysql-book/, @code{samp_db} distribution}
+@item Errata @tab
+@uref{http://www.kitebird.com/mysql-book/errata.html, are available here}
+@end multitable
+
+Foreword by Michael ``Monty'' Widenius, MySQL Moderator.
+@*
+
+In @emph{MySQL}, Paul DuBois provides you with a comprehensive guide to
+one of the most popular relational database systems. Paul has
+contributed to the online documentation for MySQL and is an
+active member of the MySQL community. The principal MySQL
+developer, Monty Widenius, and a network of his fellow developers
+reviewed the manuscript, and provided Paul with the kind of insight
+no one else could supply.
+@*
+
+Instead of merely giving you a general overview of MySQL, Paul
+teaches you how to make the most of its capabilities. Through two
+sample database applications that run throughout the book, he
+gives you solutions to problems you're sure to face. He helps you
+integrate MySQL efficiently with third-party tools, such as PHP
+and Perl, enabling you to generate dynamic Web pages through
+database queries. He teaches you to write programs that access
+MySQL databases, and also provides a comprehensive set of
+references to column types, operators, functions, SQL syntax,
+MySQL programming, C API, Perl @code{DBI}, and PHP API.
+@emph{MySQL} simply gives you the kind of information you won't find
+anywhere else.
+@*
+
+If you use MySQL, this book provides you with:
+@itemize @bullet
+@item
+An introduction to MySQL and SQL.
+@item
+Coverage of MySQL's data types and how to use them.
+@item
+Thorough treatment of how to write client programs in C.
+@item
+A guide to using the Perl @code{DBI} and PHP APIs for developing
+command-line and Web-based applications.
+@item
+Tips on administrative issues such as user accounts, backup,
+crash recovery, and security.
+@item
+Help in choosing an ISP for MySQL access.
+@item
+A comprehensive reference for MySQL's data types, operators,
+functions, and SQL statements and utilities.
+@item
+Complete reference guides for MySQL's C API, the Perl @code{DBI} API,
+and PHP's MySQL-related functions.
+@end itemize
+@*
+
+@emph{MySQL & mSQL}
+@multitable @columnfractions .3 .7
+@item Available @tab @uref{http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=1565924347&bfmtype=book, Barnes and Noble}
+@item Publisher @tab O'Reilly
+@item Authors @tab Randy Jay Yarger, George Reese & Tim King
+@item Pub Date @tab 1st Edition July 1999
+@item ISBN @tab 1-56592-434-7, Order Number: 4347
+@item Pages @tab 506
+@item Price @tab $34.95
+@end multitable
+
+This book teaches you how to use MySQL and @code{mSQL}, two popular
+and robust database products that support key subsets of SQL on both Linux
+and Unix systems. Anyone who knows basic C, Java, Perl, or Python can
+write a program to interact with a database, either as a stand-alone
+application or through a Web page. This book takes you through the
+whole process, from installation and configuration to programming
+interfaces and basic administration. Includes plenty of tutorial
+material.
+@*
+
+@emph{Sams' Teach Yourself MySQL in 21 Days}
+@multitable @columnfractions .3 .7
+@item Available @tab @uref{http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0672319144&bfmtype=book, Barnes and Noble}
+@item Publisher @tab Sams
+@item Authors @tab Mark Maslakowski and Tony Butcher
+@item Pub Date @tab June 2000
+@item ISBN @tab 0672319144
+@item Pages @tab 650
+@item Price @tab $39.99
+@end multitable
+
+Sams' @emph{Teach Yourself MySQL in 21 Days} is for intermediate Linux users
+who want to move into databases. A large share of the audience is Web
+developers who need a database to store large amounts of information that
+can be retrieved via the Web.
+
+Sams' @emph{Teach Yourself MySQL in 21 Days} is a practical, step-by-step
+tutorial. The reader will learn to design and employ this open source
+database technology into his or her Web site using practical, hands-on
+examples to follow.
+@*
+
+@emph{E-Commerce Solutions with MySQL}
+@multitable @columnfractions .3 .7
+@item Available @tab @uref{http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0761524452&bfmtype=book, Barnes and Noble}
+@item Publisher @tab Prima Communications, Inc.
+@item Authors @tab N/A
+@item Pub Date @tab January 2000
+@item ISBN @tab 0761524452
+@item Pages @tab 500
+@item Price @tab $39.99
+@end multitable
+
+No description available.
+@*
+
+@emph{MySQL and PHP from Scratch}
+@multitable @columnfractions .3 .7
+@item Available @tab @uref{http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0789724405&bfmtype=book, Barnes and Noble}
+@item Publisher @tab Que
+@item Authors @tab N/A
+@item Pub Date @tab September 2000
+@item ISBN @tab 0789724405
+@item Pages @tab 550
+@item Price @tab $34.99
+@end multitable
+
+This book puts together information on installing, setting up, and
+troubleshooting Apache, MySQL, PHP3, and IMP into one complete
+volume. You also learn how each piece is part of a whole by learning,
+step-by-step, how to create a web-based e-mail system. Learn to run
+the equivalent of Active Server Pages (ASP) using PHP3, set up an
+e-commerce site using a database and the Apache web server, and create
+a data entry system (such as sales, product quality tracking, customer
+preferences, etc) that no installation in the PC.
+@*
+
+@emph{Professional MySQL Programming}
+@multitable @columnfractions .3 .7
+@item Available @tab @uref{http://shop.barnesandnoble.com/bookSearch/isbnInquiry.asp?isbn=1861005164, Barnes and Noble}
+@item Publisher @tab Wrox Press, Inc.
+@item Authors @tab N/A
+@item Pub Date @tab Late 2001
+@item ISBN @tab 1861005164
+@item Pages @tab 1000
+@item Price @tab $49.99
+@end multitable
+
+No description available.
+@*
+
+@emph{Professional Linux Programming}
+@multitable @columnfractions .3 .7
+@item Available @tab @uref{http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=1861003013&bfmtype=book, Barnes and Noble}
+@item Publisher @tab Wrox Press, Inc.
+@item Authors @tab N/A
+@item Pub Date @tab September 2000
+@item ISBN @tab 1861003013
+@item Pages @tab 1155
+@item Price @tab $47.99
+@end multitable
+
+In this follow-up to the best-selling @emph{Beginning Linux Programming},
+you will learn from the authors' real-world knowledge and experience of
+developing software for Linux; you'll be taken through the development
+of a sample 'DVD Store' application, with 'theme' chapters addressing
+different aspects of its implementation. Meanwhile, individual
+``take-a-break'' chapters cover important topics that go beyond the
+bounds of the central theme. All focus on the practical aspects of
+programming, showing how crucial it is to choose the right tools for
+the job, use them as they should be used, and get things right first
+time.
+@*
+
+@emph{PHP and MySQL Web Development}
+@multitable @columnfractions .3 .7
+@item Available @tab @uref{http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0672317842&bfmtype=book, Barnes and Noble}
+@item Publisher @tab Sams
+@item Authors @tab Luke Welling, Laura Thomson
+@item Pub Date @tab March 2001
+@item ISBN @tab 0672317842
+@item Pages @tab 700
+@item Price @tab $49.99
+@end multitable
+
+@emph{PHP and MySQL Web Development} introduces you to the advantages
+of implementing both MySQL and PHP. These advantages are detailed
+through the provision of both statistics and several case studies. A
+practical web application is developed throughout the book, providing
+you with the tools necessary to implement a functional online
+database. Each function is developed separately, allowing you the
+choice to incorporate only those parts that you would like to
+implement. Programming concepts of the PHP language are highlighted,
+including functions which tie MySQL support into a PHP script and
+advanced topics regarding table manipulation.
+@*
+
+@strong{Books recommended by the MySQL Developers}
+
+@emph{SQL-99 Complete, Really}
+@multitable @columnfractions .3 .7
+@item Available @tab @uref{http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0879305681&bfmtype=book, Barnes and Noble}
+@item Publisher @tab CMP Books
+@item Authors @tab Peter Gulutzan, Trudy Pelzer
+@item Pub Date @tab April 1999
+@item ISBN @tab 0879305681
+@item Pages @tab 1104
+@item Price @tab $55.96
+@end multitable
+
+This book contains complete descriptions of the new standards for
+syntax, data structures, and retrieval processes of SQL databases. As
+an example-based reference manual, it includes all of the CLI
+functions, information, schema tables, and status codes, as well as a
+working SQL database provided on the companion disk.
+@*
+
+@emph{C, A reference manual}
+@multitable @columnfractions .3 .7
+@item Available @tab @uref{http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0133262243&bfmtype=book, Barnes and Noble}
+@item Publisher @tab Prentice Hall
+@item Authors @tab Samuel P. Harbison, Guy L. Steele
+@item Pub Date @tab September 1994
+@item ISBN @tab 0133262243
+@item Pages @tab 480
+@item Price @tab $35.99
+@end multitable
+
+A new and improved revision of the bestselling C language
+reference. This manual introduces the notion of "Clean C", writing C
+code that can be compiled as a C++ program, C programming style that
+emphasizes correctness, portability, maintainability, and
+incorporates the ISO C Amendment 1 (1994) which specifies new
+facilities for writing portable, international programs in C.
+@*
+
+@emph{C++ for Real Programmers}
+@multitable @columnfractions .3 .7
+@item Available @tab @uref{http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0120499428&bfmtype=book, Barnes and Noble}
+@item Publisher @tab Academic Press, Incorporated
+@item Authors @tab Jeff Alger, Jim Keogh
+@item Pub Date @tab February 1998
+@item ISBN @tab 0120499428
+@item Pages @tab 388
+@item Price @tab $39.95
+@end multitable
+
+@emph{C++ For Real Programmers} bridges the gap between C++ as described
+in beginner and intermediate-level books and C++ as it is practiced by
+experts. Numerous valuable techniques are described, organized into
+three simple themes: indirection, class hierarchies, and memory
+management. It also provides in-depth coverage of template creation,
+exception handling, pointers and optimization techniques. The focus of
+the book is on ANSI C++ and, as such, is compiler independent.
+
+@emph{C++ For Real Programmers} is a revision of
+@emph{Secrets of the C++ Masters} and includes a new appendix comparing C++
+with Java. The book comes with a 3.5" disk for Windows with source code.
+@*
+
+@emph{Algorithms in C}
+@multitable @columnfractions .3 .7
+@item Available @tab @uref{http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0201514257&bfmtype=book, Barnes and Noble}
+@item Publisher @tab Addison Wesley Longman, Inc.
+@item Authors @tab Robert Sedgewick
+@item Pub Date @tab April 1990
+@item ISBN @tab 0201514257
+@item Pages @tab 648
+@item Price @tab $45.75
+@end multitable
+
+@emph{Algorithms in C} describes a variety of algorithms in a number of
+areas of interest, including: sorting, searching, string-processing, and
+geometric, graph and mathematical algorithms. The book emphasizes
+fundamental techniques, providing readers with the tools to confidently
+implement, run, and debug useful algorithms.
+@*
+
+@emph{Multithreaded Programming with Pthreads}
+@multitable @columnfractions .3 .7
+@item Available @tab @uref{http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0136807291&bfmtype=book, Barnes and Noble}
+@item Publisher @tab Prentice Hall
+@item Authors @tab Bil Lewis, Daniel J. Berg
+@item Pub Date @tab October 1997
+@item ISBN @tab 0136807291
+@item Pages @tab 432
+@item Price @tab $34.95
+@end multitable
+
+Based on the best-selling @emph{Threads Primer},
+@emph{Multithreaded Programming with Pthreads} gives you a solid
+understanding of Posix threads: what they are, how they work, when to use
+them, and how to optimize them. It retains the clarity and humor of
+@emph{Threads Primer}, but includes expanded comparisons to Win32 and OS/2
+implementations. Code examples tested on all of the major UNIX platforms
+are featured along with detailed explanations of how and why they use threads.
+@*
+
+@emph{Programming the PERL DBI: Database Programming with PERL}
+@multitable @columnfractions .3 .7
+@item Available @tab @uref{http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=1565926994&bfmtype=book, Barnes and Noble}
+@item Publisher @tab O'Reilly & Associates, Incorporated
+@item Authors @tab Alligator Descartes, Tim Bunce
+@item Pub Date @tab February 2000
+@item ISBN @tab 1565926994
+@item Pages @tab 400
+@item Price @tab $27.96
+@end multitable
+
+@emph{Programming the Perl DBI} is coauthored by Alligator Descartes, one
+of the most active members of the DBI community, and by Tim Bunce, the
+inventor of DBI. For the uninitiated, the book explains the architecture
+of DBI and shows you how to write DBI-based programs. For the experienced
+DBI dabbler, this book explains DBI's nuances and the peculiarities of each
+individual DBD.
+
+The book includes:
+@itemize @bullet
+@item
+An introduction to DBI and its design.
+@item
+How to construct queries and bind parameters.
+@item
+Working with database, driver, and statement handles.
+@item
+Debugging techniques.
+@item
+Coverage of each existing DBD.
+@item
+A complete reference to DBI.
+@end itemize
+@*
+
+
+@node General-SQL, Useful Links, MySQL-Books, MySQL Information Sources
+@subsection General SQL Information and Tutorials
+
+The following book has been recommended by several people on the MySQL
mailing list:
@example
@@ -2407,7 +1496,7 @@ ISBN 0-201-62623-3
http://www.awl.com
@end example
-The following book has also received some recommendations by @strong{MySQL}
+The following book has also received some recommendations by MySQL
users:
@example
@@ -2421,63 +1510,64 @@ Alameda, CA USA
A SQL tutorial is available on the net at
http://w3.one.net/~jhoffman/sqltut.htm
-@node Useful Links, , General-SQL, Introduction
-@section Useful MySQL-related Links
+
+@node Useful Links, Questions, General-SQL, MySQL Information Sources
+@subsection Useful MySQL-related Links
Apart from the following links, you can find and download a lot of
-@strong{MySQL} programs, tools and APIs from the
+MySQL programs, tools and APIs from the
@uref{http://www.mysql.com/Downloads/Contrib/, Contrib directory}.
@cindex @code{Contrib} directory
@cindex URLs to MySQL information
@cindex related information URLs
-@strong{MySQL}
+MySQL
@subheading Tutorials and Manuals
@table @asis
-@item @uref{http://netgraft.com/~mbac/research/mysqlmyths.html, MySQL Myths Debunked}
-@strong{MySQL} used in the real world.
+@item @uref{http://michael.bacarella.com/research/mysqlmyths.html, MySQL Myths Debunked}
+MySQL used in the real world.
@item @uref{http://www.4t2.com/mysql}
Information about the German MySQL mailing list.
@item @uref{http://www2.rent-a-database.de/mysql/}
-@strong{MySQL} handbook in German.
+MySQL handbook in German.
@item @uref{http://www.bitmover.com:8888//home/bk/mysql}
-Web access to the @strong{MySQL} BitKeeper repository.
+Web access to the MySQL BitKeeper repository.
@item @uref{http://www.analysisandsolutions.com/code/mybasic.htm}
-Beginners @strong{MySQL} Tutorial on how to install and set up
-@strong{MySQL} on a Windows machine.
+Beginners MySQL Tutorial on how to install and set up
+MySQL on a Windows machine.
@item @uref{http://www.devshed.com/Server_Side/MySQL/}
-A lot of @strong{MySQL} tutorials.
+A lot of MySQL tutorials.
@item @uref{http://mysql.hitstar.com/}
MySQL manual in Chinese.
@item @uref{http://www.linuxplanet.com/linuxplanet/tutorials/1046/1/}
-Setting Up a @strong{MySQL}-based Web site.
+Setting Up a MySQL-based Web site.
@item @uref{http://www.hotwired.com/webmonkey/backend/tutorials/tutorial1.html}
-@strong{MySQL}-Perl tutorial.
+MySQL-Perl tutorial.
@item @uref{http://www.iserver.com/support/contrib/perl5/modules.html}
Installing new Perl modules that require locally installed modules.
@item @uref{http://www.hotwired.com/webmonkey/databases/tutorials/tutorial4.html}
-PHP/@strong{MySQL} Tutorial.
+PHP/MySQL Tutorial.
@item @uref{http://www.useractive.com/}
-Hands on tutorial for @strong{MySQL}.
+Hands on tutorial for MySQL.
@end table
@subheading Porting MySQL/Using MySQL on Different Systems
@table @asis
@item @uref{http://xclave.macnn.com/MySQL/}
-The Mac OS Xclave. Running @strong{MySQL} on Mac OS X.
+The Mac OS Xclave. Running MySQL on Mac OS X.
@item @uref{http://www.prnet.de/RegEx/mysql.html}
MySQL for Mac OS X Server.
@@ -2499,14 +1589,14 @@ MySQL for Amiga
@table @asis
@item @uref{http://dbimysql.photoflux.com/}
-Perl DBI with @strong{MySQL} FAQ.
+Perl DBI with MySQL FAQ.
@end table
@subheading MySQL Discussion Forums
@table @asis
@item @uref{http://www.weberdev.com/}
-Examples using @strong{MySQL}; (check Top 20)
+Examples using MySQL; (check Top 20)
@item @uref{http://futurerealm.com/forum/futureforum.htm}
FutureForum Web Discussion Software.
@@ -2518,7 +1608,7 @@ FutureForum Web Discussion Software.
@table @asis
@item @uref{http://www.supportwizard.com/}
SupportWizard; Interactive helpdesk on the Web (This product includes a
-licensed copy of @strong{MySQL}.)
+licensed copy of MySQL.)
@item @uref{http://www.sonork.com/}
Sonork, Instant Messenger that is not only Internet oriented. It's
@@ -2529,7 +1619,7 @@ is free, server is free for up to 5 seats.
StWeb - Stratos Web and Application server - An easy-to-use, cross
platform, Internet/Intranet development and deployment system for
development of web-enabled applications. The standard version of StWeb
-has a native interface to @strong{MySQL} database.
+has a native interface to MySQL database.
@item @uref{http://www.rightnowtech.com/}
Right Now Web; Web automation for customer service.
@@ -2555,44 +1645,44 @@ which services were discovered on which dial-up numbers in your organization.
@table @asis
@item @uref{http://www.urbanresearch.com/software/utils/urbsql/index.html, urSQL}
SQL Editor and Query Utility. Custom syntax highlighting, editable
-results grid, exportable result-sets, basic @strong{MySQL} admin functions,
+results grid, exportable result-sets, basic MySQL admin functions,
Etc.. For Windows.
@item @uref{http://www.edatanew.com/, MySQL Data Manager}
-@strong{MySQL} Data Manager * is platform independent web client
-(written in perl) for @strong{MySQL} server over TCP/IP.
+MySQL Data Manager * is platform independent web client
+(written in perl) for MySQL server over TCP/IP.
@item @uref{http://ksql.sourceforge.net/}
-KDE @strong{MySQL} client.
+KDE MySQL client.
@item @uref{http://www.ecker-software.de}
A Windows GUI client by David Ecker.
@item @uref{http://www.icaap.org/software/kiosk/}
-Kiosk; a @strong{MySQL} client for database management. Written in Perl.
+Kiosk; a MySQL client for database management. Written in Perl.
Will be a part of Bazaar.
@item @uref{http://www.casestudio.com/}
Db design tool that supports MySQL 3.23.
@item @uref{http://home.skif.net/~voland/zeos/eng/index.html}
-Zeos - A client that supports @strong{MySQL}, Interbase and PostgreSQL.
+Zeos - A client that supports MySQL, Interbase and PostgreSQL.
@item @uref{http://www.geocities.com/SiliconValley/Ridge/4280/GenericReportWriter/grwhome.html}
A free report writer in Java
@item @uref{http://www.javaframework.de}
-MySQLExport - Export of @strong{MySQL} create statements and data in a lot of
+MySQLExport - Export of MySQL create statements and data in a lot of
different formats (SQL, HTML, CVS, text, ZIP, GZIP...)
@item @uref{http://dlabs.4t2.com}
-M2D, a @strong{MySQL} Administration client for Windows. M2D supports
-administration of @strong{MySQL} databases, creation of new databases and
+M2D, a MySQL Administration client for Windows. M2D supports
+administration of MySQL databases, creation of new databases and
tables, editing, and more.
@item @uref{http://dlabs.4t2.com}
Dexter, a small server written in Perl which can be used as a proxy server for
-@strong{MySQL} or as a database extender.
+MySQL or as a database extender.
@item @uref{http://www.scibit.com/Products/Software/Utils/Mascon.asp}
Mascon is a powerful Win32 GUI for administering MySQL databases.
@@ -2616,7 +1706,7 @@ RedHat Linux (7.0 and above)
Conectiva Linux (4.0 and above)
@end table
-@subheading Web Development Tools that Support @strong{MySQL}
+@subheading Web Development Tools that Support MySQL
@table @asis
@item @uref{http://www.php.net/}
@@ -2624,7 +1714,7 @@ PHP: A server-side HTML-embedded scripting language.
@item @uref{http://www.midgard-project.org}
The Midgard Application Server; a powerful Web development environment
-based on @strong{MySQL} and PHP.
+based on MySQL and PHP.
@item @uref{http://www.smartworker.org}
SmartWorker is a platform for Web application development.
@@ -2643,13 +1733,13 @@ client will stop you. It works as standalone server or as Java servlet.
Platform independent ASP from Chili!Soft
@item @uref{http://www.voicenet.com/~zellert/tjFM}
-A JDBC driver for @strong{MySQL}.
+A JDBC driver for MySQL.
@item @uref{http://www.wernhart.priv.at/php/}
-@strong{MySQL} + PHP demos.
+MySQL + PHP demos.
@item @uref{http://www.dbwww.com/}
-ForwardSQL: HTML interface to manipulate @strong{MySQL} databases.
+ForwardSQL: HTML interface to manipulate MySQL databases.
@item @uref{http://www.daa.com.au/~james/www-sql/}
WWW-SQL: Display database information.
@@ -2674,7 +1764,7 @@ Network Database Connection For Linux
@item @uref{http://www.wdbi.net/}
WDBI: Web browser as a universal front end to databases which supports
-@strong{MySQL} well.
+MySQL well.
@item @uref{http://www.webgroove.com/}
WebGroove Script: HTML compiler and server-side scripting language.
@@ -2683,22 +1773,22 @@ WebGroove Script: HTML compiler and server-side scripting language.
A server-side Web site scripting language.
@item @uref{ftp://ftp.igc.apc.org/pub/myodbc/README}
-How to use @strong{MySQL} with ColdFusion on Solaris.
+How to use MySQL with ColdFusion on Solaris.
@item @uref{http://calistra.com/MySQL/}
-Calistra's ODBC @strong{MySQL} Administrator.
+Calistra's ODBC MySQL Administrator.
@cindex Webmerger
@item @uref{http://www.webmerger.com}
Webmerger - This CGI tool interprets files and generates dynamic output
-based on a set of simple tags. Ready-to-run drivers for @strong{MySQL} and
+based on a set of simple tags. Ready-to-run drivers for MySQL and
PostgreSQL through ODBC.
@item @uref{http://phpclub.net/}
PHPclub - Tips and tricks for PHP.
@item @uref{http://www.penguinservices.com/scripts}
-@strong{MySQL} and Perl Scripts.
+MySQL and Perl Scripts.
@item @uref{http://www.widgetchuck.com}
The Widgetchuck; Web Site Tools and Gadgets
@@ -2732,7 +1822,7 @@ complicated, low-level, and time-consuming CGI programs.
entity relationship diagram (ERD).
@end table
-@subheading Web Servers with @strong{MySQL} Tools
+@subheading Web Servers with MySQL Tools
@table @asis
@item @uref{ftp://ftp.kcilink.com/pub/}
@@ -2746,17 +1836,17 @@ The Roxen Challenger Web server.
@table @asis
@item @uref{http://www.seawood.org/msql_bind/}
-@strong{MySQL} support for BIND (The Internet Domain Name Server).
+MySQL support for BIND (The Internet Domain Name Server).
@item @uref{http://www.inet-interactive.com/sendmail/}
-@strong{MySQL} support for Sendmail and Procmail.
+MySQL support for Sendmail and Procmail.
@end table
-@subheading Using @strong{MySQL} with Other Programs
+@subheading Using MySQL with Other Programs
@table @asis
@item @uref{http://www.iserver.com/support/addonhelp/database/mysql/msaccess.html}
-Using @strong{MySQL} with Access.
+Using MySQL with Access.
@item @uref{http://www.iserver.com/support/contrib/perl5/modules.html}
Installing new Perl modules that require locally installed modules.
@@ -2777,19 +1867,19 @@ definitive standard for ODBC on the Linux platform. This is to include GUI
support for KDE.
@item @uref{http://www.sw-soft.com/products/BtrieveODBC/}
-A @strong{MySQL}-based ODBC driver for Btrieve.
+A MySQL-based ODBC driver for Btrieve.
@end table
@subheading @strong{API}-related Links
@table @asis
@item @uref{http://www.jppp.com/}
-Partially implemented TDataset-compatible components for @strong{MySQL}.
+Partially implemented TDataset-compatible components for MySQL.
@item @uref{http://www.riverstyx.net/qpopmysql/}
-qpopmysql - A patch to allow POP3 authentication from a @strong{MySQL}
+qpopmysql - A patch to allow POP3 authentication from a MySQL
database. There's also a link to Paul Khavkine's patch for Procmail to
-allow any MTA to deliver to users in a @strong{MySQL} database.
+allow any MTA to deliver to users in a MySQL database.
@item @uref{http://www.pbc.ottawa.on.ca}
Visual Basic class generator for Active X.
@@ -2805,18 +1895,18 @@ Plugin for REALbasic (for Macintosh)
@item @uref{http://www.iis.ee.ethz.ch/~neeri/macintosh/gusi-qa.html}
A library that emulates BSD sockets and pthreads on Macintosh. This can
-be used if you want to compile the @strong{MySQL} client library on Mac.
-It could probably even be sued to port @strong{MySQL} to Macintosh, but we
+be used if you want to compile the MySQL client library on Mac.
+It could probably even be sued to port MySQL to Macintosh, but we
don't know of anyone that has tried that.
@cindex SCMDB
@item @uref{http://www.dedecker.net/jessie/scmdb/}
-SCMDB - an add-on for SCM that ports the @strong{MySQL} C library to scheme
+SCMDB - an add-on for SCM that ports the MySQL C library to scheme
(SCM). With this library scheme developers can make connections to a
-@strong{MySQL} database and use embedded SQL in their programs.
+MySQL database and use embedded SQL in their programs.
@end table
-@subheading Other @strong{MySQL}-related Links
+@subheading Other MySQL-related Links
@table @asis
@item @uref{http://www.satisoft.com/, SAT}
@@ -2826,13 +1916,13 @@ applications in a (Microsoft -or- X) Windows Client / Unix Server
environment.
@item @uref{http://www.wix.com/mysql-hosting/}
-Registry of Web providers who support @strong{MySQL}.
+Registry of Web providers who support MySQL.
@item @uref{http://www.softagency.co.jp/mysql/index.en.html}
-Links about using @strong{MySQL} in Japan/Asia.
+Links about using MySQL in Japan/Asia.
@item @uref{http://abattoir.cc.ndsu.nodak.edu/~nem/mysql/udf/}
-@strong{MySQL} UDF Registry.
+MySQL UDF Registry.
@item @uref{http://www.open.com.au/products.html}
Commercial Web defect tracking system.
@@ -2847,13 +1937,13 @@ Job and software tracking system.
ExportSQL: A script to export data from Access95+.
@item @uref{http://SAL.KachinaTech.COM/H/1/MYSQL.html}
-SAL (Scientific Applications on Linux) @strong{MySQL} entry.
+SAL (Scientific Applications on Linux) MySQL entry.
@item @uref{http://www.infotech-nj.com/itech/index.shtml}
-A consulting company which mentions @strong{MySQL} in the right company.
+A consulting company which mentions MySQL in the right company.
@item @uref{http://www.pmpcs.com/}
-PMP Computer Solutions. Database developers using @strong{MySQL} and
+PMP Computer Solutions. Database developers using MySQL and
@code{mSQL}.
@item @uref{http://www.aewa.org/}
@@ -2896,22 +1986,22 @@ SQL Reference Page with a lot of interesting links.
@c EMAIL: thuss@little6.com (Todd Huss)
@item @uref{http://www.little6.com/about/linux/}
Little6 Inc., An online contract and job finding site that is powered by
-@strong{MySQL}, PHP3, and Linux.
+MySQL, PHP3, and Linux.
@c Added 990521
@c EMAIL: nh@delec.com (Hillbrecht Nicole)
@item @uref{http://www.delec.com/is/products/prep/examples/BookShelf/index.html}
DELECis - A tool that makes it very easy to create an automatically generated
-table documentation. They have used @strong{MySQL} as an example.
+table documentation. They have used MySQL as an example.
@c Added 990521
@c EMAIL: info@worldrecords.com (Jim Rota)
@item @uref{http://www.worldrecords.com}
World Records - A search engine for information about music that uses
-@strong{MySQL} and PHP.
+MySQL and PHP.
@item @uref{http://www.webtechniques.com/archives/1998/01/note/}
-A Contact Database using @strong{MySQL} and PHP.
+A Contact Database using MySQL and PHP.
@item @uref{http://modems.rosenet.net/mysql/}
Web based interface and Community Calendar with PHP.
@@ -2942,18 +2032,18 @@ the quality of its results over time. Pluribus works by recording
which pages a user prefers among those returned for a query. A user
votes for a page by selecting it; Pluribus then uses that knowledge
to improve the quality of the results when someone else submits the
-same (or similar) query. Uses PHP and @strong{MySQL}.
+same (or similar) query. Uses PHP and MySQL.
@c EMAIL: paul@sword.damocles.com (Paul Bannister)
@item @uref{http://www.stopbit.com/}
-Stopbit - A technology news site using @strong{MySQL} and PHP.
+Stopbit - A technology news site using MySQL and PHP.
@item @uref{http://www.linuxsupportline.com/~kalendar/}
KDE based calendar manager - The calendar manager has both single user
-(file based) and multi-user (@strong{MySQL} database) support.
+(file based) and multi-user (MySQL database) support.
@item @uref{http://tim.desert.net/~tim/imger/}
-Example of storing/retrieving images with @strong{MySQL} and CGI.
+Example of storing/retrieving images with MySQL and CGI.
@item @uref{http://www.penguinservices.com/scripts}
Online shopping cart system.
@@ -2962,11 +2052,11 @@ Online shopping cart system.
@cindex Old Photo Album
@item @uref{http://www.city-gallery.com/album/}
Old Photo Album - The album is a collaborative popular history of photography
-project that generates all pages from data stored in a @strong{MySQL}
+project that generates all pages from data stored in a MySQL
database. Pages are dynamically generated through a php3 interface to the
database content. Users contribute images and descriptions. Contributed
images are stored on the web server to avoid storing them in the database
-as BLOBs. All other information is stored on the shared @strong{MySQL} server.
+as BLOBs. All other information is stored on the shared MySQL server.
@end table
@subheading General Database Links
@@ -3003,37 +2093,40 @@ B-Trees: Balanced Tree Data Structures.
A lecture about B-Trees.
@end table
-There are also many Web pages that use @strong{MySQL}. @xref{Users}.
+There are also many Web pages that use MySQL. @xref{Users}.
Send any additions to this list to @email{webmaster@@mysql.com}. We now
-require that you show a @strong{MySQL} logo somewhere if you wish your
+require that you show a MySQL logo somewhere if you wish your
site to be added. It is okay to have it on a ``used tools'' page or
something similar.
+
+@node Questions, , Useful Links, MySQL Information Sources
+@subsection MySQL Mailing Lists
+
@cindex reporting, errors
@cindex MySQL mailing lists
-@node Questions, Licensing and Support, Introduction, Top
-@chapter MySQL Mailing Lists
@menu
-* Mailing-list:: The @strong{MySQL} mailing lists
+* Mailing-list:: The MySQL mailing lists
* Asking questions:: Asking questions or reporting bugs
* Bug reports:: How to report bugs or problems
* Answering questions:: Guidelines for answering questions on the mailing list
@end menu
-This chapter introduces you to the @strong{MySQL} mailing lists, and gives
+This section introduces you to the MySQL mailing lists, and gives
some guidelines as to how to use them.
+
@node Mailing-list, Asking questions, Questions, Questions
-@section The MySQL Mailing Lists
+@subsubsection The MySQL Mailing Lists
@cindex mailing lists
@cindex email lists
-To subscribe to the main @strong{MySQL} mailing list, send a message to the
+To subscribe to the main MySQL mailing list, send a message to the
electronic mail address @email{mysql-subscribe@@lists.mysql.com}.
-To unsubscribe from the main @strong{MySQL} mailing list, send a message to
+To unsubscribe from the main MySQL mailing list, send a message to
the electronic mail address @email{mysql-unsubscribe@@lists.mysql.com}.
Only the address to which you send your messages is significant. The
@@ -3063,23 +2156,23 @@ Your local site may have many subscribers to @email{mysql@@lists.mysql.com}.
If so, it may have a local mailing list, so that messages sent from
@code{lists.mysql.com} to your site are propagated to the local list. In such
cases, please contact your system administrator to be added to or dropped
-from the local @strong{MySQL} list.
+from the local MySQL list.
If you wish to have traffic for a mailing list go to a separate mailbox in
your mail program, set up a filter based on the message headers. You can
use either the @code{List-ID:} or @code{Delivered-To:} headers to identify
list messages.
-The following @strong{MySQL} mailing lists exist:
+The following MySQL mailing lists exist:
@table @code
@item @email{announce-subscribe@@lists.mysql.com} announce
-This is for announcement of new versions of @strong{MySQL} and related
-programs. This is a low volume list all @strong{MySQL} users should
+This is for announcement of new versions of MySQL and related
+programs. This is a low volume list all MySQL users should
subscribe to.
@item @email{mysql-subscribe@@lists.mysql.com} mysql
-The main list for general @strong{MySQL} discussion. Please note that some
+The main list for general MySQL discussion. Please note that some
topics are better discussed on the more-specialized lists. If you post to the
wrong list, you may not get an answer!
@@ -3090,51 +2183,51 @@ messages, sent as one large mail message once a day.
@item @email{bugs-subscribe@@lists.mysql.com} bugs
On this list you should only post a full, repeatable bug report using
the @code{mysqlbug} script (if you are running on Windows, you should
-include a description of the operating system and the @strong{MySQL} version).
+include a description of the operating system and the MySQL version).
Preferably, you should test the problem using the latest stable or development
-version of @strong{MySQL} before posting! Anyone should be able to repeat the
+version of MySQL before posting! Anyone should be able to repeat the
bug by just using @code{mysql test < script} on the included test case. All
bugs posted on this list will be corrected or documented in the next
-@strong{MySQL} release! If there are only small code changes involved, we
+MySQL release! If there are only small code changes involved, we
will also post a patch that fixes the problem.
@item @email{bugs-digest-subscribe@@lists.mysql.com} bugs-digest
The @code{bugs} list in digest form.
@item @email{internals-subscribe@@lists.mysql.com} internals
-A list for people who work on the @strong{MySQL} code. On this list one
-can also discuss @strong{MySQL} development and post patches.
+A list for people who work on the MySQL code. On this list one
+can also discuss MySQL development and post patches.
@item @email{internals-digest-subscribe@@lists.mysql.com} internals-digest
A digest version of the @code{internals} list.
@item @email{java-subscribe@@lists.mysql.com} java
-Discussion about @strong{MySQL} and Java. Mostly about the JDBC drivers.
+Discussion about MySQL and Java. Mostly about the JDBC drivers.
@item @email{java-digest-subscribe@@lists.mysql.com} java-digest
A digest version of the @code{java} list.
@item @email{win32-subscribe@@lists.mysql.com} win32
-All things concerning @strong{MySQL} on Microsoft operating systems such as
+All things concerning MySQL on Microsoft operating systems such as
Win95, Win98, NT, and Win2000.
@item @email{win32-digest-subscribe@@lists.mysql.com} win32-digest
A digest version of the @code{win32} list.
@item @email{myodbc-subscribe@@lists.mysql.com} myodbc
-All things about connecting to @strong{MySQL} with ODBC.
+All things about connecting to MySQL with ODBC.
@item @email{myodbc-digest-subscribe@@lists.mysql.com} myodbc-digest
A digest version of the @code{myodbc} list.
@item @email{plusplus-subscribe@@lists.mysql.com} plusplus
-All things concerning programming with the C++ API to @strong{MySQL}.
+All things concerning programming with the C++ API to MySQL.
@item @email{plusplus-digest-subscribe@@lists.mysql.com} plusplus-digest
A digest version of the @code{plusplus} list.
@item @email{msql-mysql-modules-subscribe@@lists.mysql.com} msql-mysql-modules
-A list about the Perl support in @strong{MySQL}. msql-mysql-modules
+A list about the Perl support in MySQL. msql-mysql-modules
@item @email{msql-mysql-modules-digest-subscribe@@lists.mysql.com} msql-mysql-modules-digest
A digest version of the @code{msql-mysql-modules} list.
@@ -3148,11 +2241,11 @@ unsubscribe from the @code{myodbc} list, send a message to
@email{myodbc-unsubscribe@@lists.mysql.com}.
If you can't get an answer for your questions from the mailing list, one
-option is to pay for support from @strong{MySQL AB}, which will put you
-in direct contact with @strong{MySQL} developers. @xref{Support}.
+option is to pay for support from MySQL AB, which will put you
+in direct contact with MySQL developers. @xref{Support}.
-The following table shows some @strong{MySQL} mailing in other languages than
-English. Note that these are not operated by @strong{MySQL AB}, so we can't
+The following table shows some MySQL mailing in other languages than
+English. Note that these are not operated by MySQL AB, so we can't
guarantee the quality on these.
@table @code
@@ -3169,17 +2262,19 @@ Email @code{subscribe mysql-br your@@email.address} to this list.
Email @code{subscribe mysql your@@email.address} to this list.
@end table
+
+@node Asking questions, Bug reports, Mailing-list, Questions
+@subsubsection Asking Questions or Reporting Bugs
+
@cindex net etiquette
@cindex mailing lists, archive location
@cindex searching, MySQL webpages
-@node Asking questions, Bug reports, Mailing-list, Questions
-@section Asking Questions or Reporting Bugs
Before posting a bug report or question, please do the following:
@itemize @bullet
@item
-Start by searching the @strong{MySQL} online manual at:
+Start by searching the MySQL online manual at:
@*
@uref{http://www.mysql.com/documentation/manual.php}
@*
@@ -3187,7 +2282,7 @@ We try to keep the manual up to date by updating it frequently with
solutions to newly found problems!
@item
-Search the @strong{MySQL} mailing list archives:
+Search the MySQL mailing list archives:
@*
@uref{http://www.mysql.com/documentation/}
@*
@@ -3198,10 +2293,14 @@ Web pages (including the manual) that are located at
@end itemize
If you can't find an answer in the manual or the archives, check with your
-local @strong{MySQL} expert. If you still can't find an answer to your
+local MySQL expert. If you still can't find an answer to your
question, go ahead and read the next section about how to send mail to
@email{mysql@@lists.mysql.com}.
+
+@node Bug reports, Answering questions, Asking questions, Questions
+@subsubsection How to Report Bugs or Problems
+
@cindex bugs, reporting
@cindex reporting, bugs
@cindex problems, reporting
@@ -3209,8 +2308,6 @@ question, go ahead and read the next section about how to send mail to
@cindex @code{mysqlbug} script
@cindex creating, bug reports
@cindex scripts, @code{mysqlbug}
-@node Bug reports, Answering questions, Asking questions, Questions
-@section How to Report Bugs or Problems
Writing a good bug report takes patience, but doing it right the first
time saves time for us and for you. A good bug report containing a full
@@ -3222,7 +2319,7 @@ or at all.
We encourage everyone to use the @code{mysqlbug} script to generate a bug
report (or a report about any problem), if possible. @code{mysqlbug} can be
found in the @file{scripts} directory in the source distribution, or, for a
-binary distribution, in the @file{bin} directory under your @strong{MySQL}
+binary distribution, in the @file{bin} directory under your MySQL
installation directory. If you are unable to use @code{mysqlbug}, you should
still include all the necessary information listed in this section.
@@ -3239,13 +2336,13 @@ demonstrates the bug, you should post it to the @email{bugs@@lists.mysql.com}
list. Note that on this list you should only post a full, repeatable bug
report using the @code{mysqlbug} script. If you are running on Windows,
you should include a description of the operating system and the
-@strong{MySQL} version. Preferably, you should test the problem using
-the latest stable or development version of @strong{MySQL} before
+MySQL version. Preferably, you should test the problem using
+the latest stable or development version of MySQL before
posting! Anyone should be able to repeat the bug by just using
``@code{mysql test < script}'' on the included test case or run the
shell or perl script that is included in the bug report. All bugs
posted on the @code{bugs} list will be corrected or documented in the next
-@strong{MySQL} release! If there are only small code changes involved
+MySQL release! If there are only small code changes involved
to correct this problem, we will also post a patch that fixes the
problem.
@@ -3259,20 +2356,20 @@ and wait for the answer because you didn't include enough information the
first time.
The most common errors are that people don't indicate the version number of
-the @strong{MySQL} distribution they are using, or don't indicate what
-platform they have @strong{MySQL} installed on (including the platform
+the MySQL distribution they are using, or don't indicate what
+platform they have MySQL installed on (including the platform
version number). This is highly relevant information, and in 99 cases out of
100 the bug report is useless without it! Very often we get questions like,
``Why doesn't this work for me?'' then we find that the feature
-requested wasn't implemented in that @strong{MySQL} version, or that a bug
-described in a report has been fixed already in newer @strong{MySQL}
+requested wasn't implemented in that MySQL version, or that a bug
+described in a report has been fixed already in newer MySQL
versions. Sometimes the error is platform dependent; in such cases, it is
next to impossible to fix anything without knowing the operating system and
the version number of the platform.
Remember also to provide information about your compiler, if it is related to
the problem. Often people find bugs in compilers and think the problem is
-@strong{MySQL}-related. Most compilers are under development all the time and
+MySQL-related. Most compilers are under development all the time and
become better version by version. To determine whether or not your
problem depends on your compiler, we need to know what compiler is used.
Note that every compiling problem should be regarded as a bug report and
@@ -3307,10 +2404,10 @@ Please include the following information in your report:
@itemize @bullet
@item
-The version number of the @strong{MySQL} distribution you are using (for
-example, @strong{MySQL} Version 3.22.22). You can find out which version you
+The version number of the MySQL distribution you are using (for
+example, MySQL Version 3.22.22). You can find out which version you
are running by executing @code{mysqladmin version}. @code{mysqladmin} can be
-found in the @file{bin} directory under your @strong{MySQL} installation
+found in the @file{bin} directory under your MySQL installation
directory.
@item
@@ -3325,7 +2422,7 @@ Sometimes the amount of memory (real and virtual) is relevant. If in doubt,
include these values.
@item
-If you are using a source distribution of @strong{MySQL}, the name and
+If you are using a source distribution of MySQL, the name and
version number of the compiler used is needed. If you have a binary
distribution, the distribution name is needed.
@@ -3394,7 +2491,7 @@ archive to @uref{ftp://support.mysql.com/pub/mysql/secret/}. Then send a
short description of the problem to @email{bugs@@lists.mysql.com}.
@item
-If you think that @strong{MySQL} produces a strange result from a query,
+If you think that MySQL produces a strange result from a query,
include not only the result, but also your opinion of what the result
should be, and an account describing the basis for your opinion.
@@ -3413,7 +2510,7 @@ an example using other names, but please regard this as the last choice.
@item
Include all the options given to the relevant programs, if possible. For
example, indicate the options that you use when you start the @code{mysqld}
-daemon and that you use to run any @strong{MySQL} client programs. The
+daemon and that you use to run any MySQL client programs. The
options to programs like @code{mysqld} and @code{mysql}, and to the
@code{configure} script, are often keys to answers and are very relevant!
It is never a bad idea to include them anyway! If you use any modules, such
@@ -3426,7 +2523,7 @@ the error messages you get when trying to connect! When you test your
privileges, you should first run @code{mysqlaccess}. After this, execute
@code{mysqladmin reload version} and try to connect with the program that
gives you trouble. @code{mysqlaccess} can be found in the @file{bin}
-directory under your @strong{MySQL} installation directory.
+directory under your MySQL installation directory.
@item
If you have a patch for a bug, that is good, but don't assume the patch is
@@ -3442,7 +2539,7 @@ where the patch won't work, it may be useless.
@item
Guesses about what the bug is, why it occurs, or what it depends on,
-are usually wrong. Even the @strong{MySQL} team can't guess such things
+are usually wrong. Even the MySQL team can't guess such things
without first using a debugger to determine the real cause of a bug.
@item
@@ -3453,23 +2550,23 @@ problem yourself.
@item
If you get a @code{parse error}, please check your syntax closely! If
you can't find something wrong with it, it's extremely likely that your
-current version of @strong{MySQL} doesn't support the query you are
+current version of MySQL doesn't support the query you are
using. If you are using the current version and the manual at
@uref{http://www.mysql.com/documentation/manual.php} doesn't cover the
-syntax you are using, @strong{MySQL} doesn't support your query. In this
+syntax you are using, MySQL doesn't support your query. In this
case, your only options are to implement the syntax yourself or e-mail
@email{mysql-licensing@@mysql.com} and ask for an offer to implement it!
If the manual covers the syntax you are using, but you have an older version
-of @strong{MySQL}, you should check the @strong{MySQL} change history to see
+of MySQL, you should check the MySQL change history to see
when the syntax was implemented. In this case, you have the option of
-upgrading to a newer version of @strong{MySQL}. @xref{News}.
+upgrading to a newer version of MySQL. @xref{News}.
@item
If you have a problem such that your data appears corrupt or you get
errors when you access some particular table, you should first check and then
try repairing your tables with @code{myisamchk} or @code{CHECK TABLE} and
-@code{REPAIR TABLE}. @xref{Maintenance}.
+@code{REPAIR TABLE}. @xref{MySQL Database Administration}.
@item
If you often get corrupted tables you should try to find out when and why this
@@ -3482,11 +2579,11 @@ it's much easier for us to provide you with a fix for the problem!
@xref{What is crashing}.
@item
-If possible, download and install the most recent version of @strong{MySQL}
+If possible, download and install the most recent version of MySQL
and check whether or not it solves your problem. All versions of
-@strong{MySQL} are thoroughly tested and should work without problems! We
+MySQL are thoroughly tested and should work without problems! We
believe in making everything as backward compatible as possible, and you
-should be able to switch @strong{MySQL} versions in minutes!
+should be able to switch MySQL versions in minutes!
@xref{Which version}.
@end itemize
@@ -3508,12 +2605,14 @@ it is considered good etiquette to summarize the answers and send the
summary to the mailing list so that others may have the benefit of
responses you received that helped you solve your problem!
+
+@node Answering questions, , Bug reports, Questions
+@subsubsection Guidelines for Answering Question on the Mailing List
+
@cindex net etiquette
@cindex questions, answering
@cindex answering questions, etiquette
@cindex mailing lists, guidelines
-@node Answering questions, , Bug reports, Questions
-@section Guidelines for Answering Question on the Mailing List
If you consider your answer to have broad interest, you may want to post it
to the mailing list instead of replying directly to the individual who
@@ -3527,25 +2626,27 @@ obliged to quote the entire original message.
Please don't post mail messages from your browser with HTML mode turned on!
Many users don't read mail with a browser!
+
+@node Licensing and Support, Compatibility, MySQL Information Sources, Introduction
+@section MySQL Licensing and Support
+
@cindex licensing terms
@cindex support terms
-@node Licensing and Support, Installing, Questions, Top
-@chapter MySQL Licensing and Support
@menu
-* Licensing policy:: @strong{MySQL} licensing policy
-* Copyright:: Copyrights used by @strong{MySQL}
+* Licensing policy:: MySQL licensing policy
+* Copyright:: Copyrights used by MySQL
* Licensing examples:: Example licensing situations
-* Cost:: @strong{MySQL} licensing and support costs
+* Cost:: MySQL licensing and support costs
* Support:: Types of commercial support
@end menu
-This chapter describes @strong{MySQL} support and licensing
+This section describes MySQL support and licensing
arrangements:
@itemize @bullet
-@item The copyrights under which @strong{MySQL} is distributed
+@item The copyrights under which MySQL is distributed
(@pxref{Copyright})
@item Sample situations illustrating when a license is required
@@ -3557,23 +2658,25 @@ arrangements:
@item Commercial licensing costs
@end itemize
+
+@node Licensing policy, Copyright, Licensing and Support, Licensing and Support
+@subsection MySQL Licensing Policy
+
@cindex licensing policy
@cindex technical support, licensing
@cindex support, licensing
@cindex General Public License, MySQL
-@node Licensing policy, Copyright, Licensing and Support, Licensing and Support
-@section MySQL Licensing Policy
The formal terms of the GPL license can be found at @ref{GPL license}.
Basically, our licensing policy and interpretation of the GPL is as follows:
-Note that older versions of @strong{MySQL} are still using a more
+Note that older versions of MySQL are still using a more
@uref{http://www.mysql.com/support/arrangements/mypl.html, strict license}.
See the documentation for that version for more information. If you need a
-commercial @strong{MySQL} license, because the GPL license doesn't suit your
+commercial MySQL license, because the GPL license doesn't suit your
application, you can buy one at @uref{https://order.mysql.com/}.
-For normal internal use, @strong{MySQL} costs nothing. You do not have
+For normal internal use, MySQL costs nothing. You do not have
to pay us if you do not want to.
A license is required if:
@@ -3581,22 +2684,22 @@ A license is required if:
@itemize @minus
@item
You link a program, that is not free software, with code from the
-@strong{MySQL} server or clients that has the GPL copyright. This
-happens for example when you use @strong{MySQL} as an embedded server
+MySQL server or clients that has the GPL copyright. This
+happens for example when you use MySQL as an embedded server
in your applications or when you add not free extensions to the
-@strong{MySQL} server. In this case your application/code would also
+MySQL server. In this case your application/code would also
become GPL through the GPL license that acts as a virus. By licensing
-@strong{MySQL} server from @strong{MySQL AB} under a commercial
+MySQL server from MySQL AB under a commercial
license you will avoid this problem.
See @uref{http://www.gnu.org/copyleft/gpl-faq.html}.
@item
-You have a commercial application that ONLY works with @strong{MySQL}
-and ships the application with the @strong{MySQL} server. This is
+You have a commercial application that ONLY works with MySQL
+and ships the application with the MySQL server. This is
because we view this as linking even if it is done over the network.
@item
-You have a distribution of @strong{MySQL} and you don't provide the
-source code for your copy of the @strong{MySQL} server, as defined in
+You have a distribution of MySQL and you don't provide the
+source code for your copy of the MySQL server, as defined in
the GPL license.
@end itemize
@@ -3606,55 +2709,57 @@ A license is @strong{NOT} required if:
@item
You do not need a license to include the client code in commercial
-programs. The client part of @strong{MySQL} licensed with the
+programs. The client part of MySQL licensed with the
LGPL @code{GNU Library General Public License}. The @code{mysql} command-line
client includes code from the @code{readline} library that is under
the @code{GPL}.
@item
-If your use of @strong{MySQL} does not require a license, but you
-like @strong{MySQL} and want to encourage further development, you are
-certainly welcome to purchase a license or @strong{MySQL} support anyway.
+If your use of MySQL does not require a license, but you
+like MySQL and want to encourage further development, you are
+certainly welcome to purchase a license or MySQL support anyway.
@item
-If you use @strong{MySQL} in a commercial context such that you profit by
-its use, we ask that you further the development of @strong{MySQL} by
-purchasing some level of support. We feel that if @strong{MySQL} helps
-your business, it is reasonable to ask that you help @strong{MySQL}.
+If you use MySQL in a commercial context such that you profit by
+its use, we ask that you further the development of MySQL by
+purchasing some level of support. We feel that if MySQL helps
+your business, it is reasonable to ask that you help MySQL.
(Otherwise, if you ask us support questions, you are not only using for
free something into which we've put a lot a work, you're asking us to
provide free support, too.)
@end itemize
-For circumstances under which a @strong{MySQL} license is required, you
+For circumstances under which a MySQL license is required, you
need a license per machine that runs the @code{mysqld} server. However,
a multiple-CPU machine counts as a single machine, and there is no
-restriction on the number of @strong{MySQL} servers that run on one
+restriction on the number of MySQL servers that run on one
machine, or on the number of clients concurrently connected to a server
running on that machine!
If you have any questions as to whether or not a license is required for
-your particular use of @strong{MySQL}, please read this again and then
+your particular use of MySQL, please read this again and then
contact us. @xref{Contact information}.
-If you require a @strong{MySQL} license, the easiest way to pay for it
-is to use the license form on @strong{MySQL}'s secure server at
+If you require a MySQL license, the easiest way to pay for it
+is to use the license form on MySQL's secure server at
@uref{https://order.mysql.com/}. Other forms of payment are
discussed in @ref{Payment information}.
-@cindex copyrights
+
@node Copyright, Licensing examples, Licensing policy, Licensing and Support
-@section Copyrights Used by MySQL
+@subsection Copyrights Used by MySQL
+
+@cindex copyrights
@menu
* Copyright changes:: Possible future copyright changes
@end menu
-There are several different copyrights on the @strong{MySQL} distribution:
+There are several different copyrights on the MySQL distribution:
@enumerate
@item
-The @strong{MySQL}-specific source needed to build the
+The MySQL-specific source needed to build the
@code{mysqlclient} library is licensed under the @code{LGPL} and
programs in the @file{client} directory is GPL. Each file has a header
that shows which copyright is used for that file.
@@ -3673,33 +2778,35 @@ This is also available as the file @file{COPYING} in the distributions.
@end enumerate
One goal is that the SQL client library should be free enough that it is
-possible to add @strong{MySQL} support into commercial products
+possible to add MySQL support into commercial products
without a license. For this reason, we chose the LGPL license for the
client code.
@cindex licensing, free
@cindex free licensing
-This means that you can use @strong{MySQL} for free with any program that uses
-any of the free software licenses. @strong{MySQL} is also free for any end
+This means that you can use MySQL for free with any program that uses
+any of the free software licenses. MySQL is also free for any end
user for his own or company usage.
-However, if you use @strong{MySQL} for something important to you, you may
+However, if you use MySQL for something important to you, you may
want to help secure its development by purchasing licenses or a support
contract. @xref{Support}.
+
@node Copyright changes, , Copyright, Copyright
-@subsection Copyright Changes
+@subsubsection Copyright Changes
-Version 3.22 of @strong{MySQL} is still using a more strict license.
+Version 3.22 of MySQL is still using a more strict license.
See the documentation for that version for more information.
+
@node Licensing examples, Cost, Copyright, Licensing and Support
-@section Example Licensing Situations
+@subsection Example Licensing Situations
@menu
-* Products that use MySQL:: Selling products that use @strong{MySQL}
-* ISP:: ISP @strong{MySQL} services
-* Web server:: Running a web server using @strong{MySQL}.
+* Products that use MySQL:: Selling products that use MySQL
+* ISP:: ISP MySQL services
+* Web server:: Running a web server using MySQL.
@end menu
@cindex licensing, examples
@@ -3707,102 +2814,108 @@ See the documentation for that version for more information.
@cindex products, selling
This section describes some situations illustrating whether or not you
-must license the @strong{MySQL} server. Generally these examples
-involve providing @strong{MySQL} as an integral part of a product.
+must license the MySQL server. Generally these examples
+involve providing MySQL as an integral part of a product.
-Note that a single @strong{MySQL} license covers any number of CPUs and
+Note that a single MySQL license covers any number of CPUs and
@code{mysqld} servers on a machine! There is no artificial limit on the
number of clients that connect to the server in any way.
+
@node Products that use MySQL, ISP, Licensing examples, Licensing examples
-@subsection Selling Products that use MySQL
+@subsubsection Selling Products that use MySQL
-To determine whether or not you need a @strong{MySQL} license when
+To determine whether or not you need a MySQL license when
selling your application, you should ask whether the proper functioning
-of your application is dependent on the use of @strong{MySQL} and
-whether you include the @strong{MySQL} server with your product. There
+of your application is dependent on the use of MySQL and
+whether you include the MySQL server with your product. There
are several cases to consider:
@itemize @bullet
@item
-Does your application require @strong{MySQL} to function properly?
+Does your application require MySQL to function properly?
@item
-If your product requires @strong{MySQL}, you need a license for any
+If your product requires MySQL, you need a license for any
machine that runs the @code{mysqld} server. For example, if you've
-designed your application around @strong{MySQL}, then you've really made
+designed your application around MySQL, then you've really made
a commercial product that requires the engine, so you need a license.
@item
-If your application does not require @strong{MySQL}, you do not need to obtain
-a license. For example, if using @strong{MySQL} just adds some new optional
+If your application does not require MySQL, you do not need to obtain
+a license. For example, if using MySQL just adds some new optional
features to your product (such as adding logging to a database if
-@strong{MySQL} is used rather than logging to a text file), it should
+MySQL is used rather than logging to a text file), it should
fall within normal use, and a license would not be required.
@item
In other words, you need a license if you sell a product designed
-specifically for use with @strong{MySQL} or that requires the
-@strong{MySQL} server to function at all. This is true whether or not
-you provide @strong{MySQL} for your client as part of your product
+specifically for use with MySQL or that requires the
+MySQL server to function at all. This is true whether or not
+you provide MySQL for your client as part of your product
distribution.
@item
It also depends on what you're doing for the client. Do you plan to
provide your client with detailed instructions on installing
-@strong{MySQL} with your software? Then your product may be contingent
-on the use of @strong{MySQL}; if so, you need to buy a license. If you
+MySQL with your software? Then your product may be contingent
+on the use of MySQL; if so, you need to buy a license. If you
are simply tying into a database that you expect already to have been
installed by the time your software is purchased, then you probably
don't need a license.
@end itemize
+
@node ISP, Web server, Products that use MySQL, Licensing examples
-@subsection ISP MySQL Services
+@subsubsection ISP MySQL Services
@cindex ISP services
@cindex services, ISP
@cindex services, web
@cindex Internet Service Providers
-Internet Service Providers (ISPs) often host @strong{MySQL} servers for
+Internet Service Providers (ISPs) often host MySQL servers for
their customers. With the GPL license this does not require a license.
On the other hand, we do encourage people to use ISPs that have
-@strong{MySQL} support, as this will give them the confidence that if
-they have some problem with their @strong{MySQL} installation, their ISP
+MySQL support, as this will give them the confidence that if
+they have some problem with their MySQL installation, their ISP
will be able to solve the problem for them (in some cases with the help
-from the @strong{MySQL} development team).
+from the MySQL development team).
All ISPs that want to keep themselves up-to-date should subscribe
to our @code{announce} mailing list so that they can be aware of fatal issues
-that may be relevant for their @strong{MySQL} installations.
+that may be relevant for their MySQL installations.
-Note that if the ISP doesn't have a license for @strong{MySQL},
+Note that if the ISP doesn't have a license for MySQL,
it should give its customers at least read access to the source of
-the @strong{MySQL} installation so that its customer can verify that
+the MySQL installation so that its customer can verify that
it is patched correctly.
+
+@node Web server, , ISP, Licensing examples
+@subsubsection Running a Web Server Using MySQL
+
@cindex web server, running
@cindex running, a web server
-@node Web server, , ISP, Licensing examples
-@subsection Running a Web Server Using MySQL
-If you use @strong{MySQL} in conjunction with a Web server on Unix, you
+If you use MySQL in conjunction with a Web server on Unix, you
don't have to pay for a license.
This is true even if you run a commercial Web server that uses
-@strong{MySQL}, because you are not selling an embedded @strong{MySQL}
+MySQL, because you are not selling an embedded MySQL
version yourself. However, in this case we would like you to purchase
-@strong{MySQL} support, because @strong{MySQL} is helping your enterprise.
+MySQL support, because MySQL is helping your enterprise.
+
+
+@node Cost, Support, Licensing examples, Licensing and Support
+@subsection MySQL Licensing and Support Costs
@cindex costs, licensing and support
@cindex licensing costs
@cindex support costs
@cindex prices, licensing and support
-@node Cost, Support, Licensing examples, Licensing and Support
-@section MySQL Licensing and Support Costs
@menu
* Payment information:: Payment information
@@ -3833,8 +2946,8 @@ For OEM purchases, you must act as the middle-man for eventual problems
or extension requests from your users. We also require that OEM
customers have at least an extended e-mail support contract. Note that
OEM licenses only apply for products where the user doesn't have direct
-access to the @strong{MySQL} server (embedded system). In other words,
-the @strong{MySQL} server should only be used with the application
+access to the MySQL server (embedded system). In other words,
+the MySQL server should only be used with the application
that was supplied you.
If you have a low-margin, high-volume product, you can always talk to us
@@ -3878,13 +2991,16 @@ Note that as our sales staff is very busy, it may take some time until
your request is handled. Our support staff does however always answer
promptly to support questions!
-@cindex payment information
+
@node Payment information, Contact information, Cost, Cost
-@subsection Payment information
+@subsubsection Payment information
+
+@cindex payment information
Currently we can take SWIFT payments, checks, or credit cards.
Payment should be made to:
+
@example
Postgirot Bank AB
105 06 STOCKHOLM, SWEDEN
@@ -3924,27 +3040,30 @@ us'' in the comment field. You can also mail a message to
@email{sales@@mysql.com} (@strong{not} @code{mysql@@lists.mysql.com}!)
with your company information and ask us to bill you.
+
+@node Contact information, , Payment information, Cost
+@subsubsection Contact Information
+
@cindex contact information
@cindex licensing, contact information
-@cindex partnering, with MySQL
+@cindex advertising, contact information
+@cindex employment, contact information
+@cindex partnering with MySQL
@cindex employment with MySQL
@cindex jobs at MySQL
-@node Contact information, , Payment information, Cost
-@subsection Contact Information
-
-For commercial licensing, please contact the @strong{MySQL} licensing
+For commercial licensing, please contact the MySQL licensing
team. The much preferred method is by e-mail to
@email{licensing@@mysql.com}. Fax is also possible but handling of
these may take much longer (Fax +46-8-729 69 05).
If you represent a business that is interested in partnering with
-@strong{MySQL}, please send e-mail to @email{partner@@mysql.com}.
+MySQL, please send e-mail to @email{partner@@mysql.com}.
-For timely, precise answers to technical questions about @strong{MySQL}
+For timely, precise answers to technical questions about MySQL
you should @uref{https://order.mysql.com/, order} one of our
@uref{http://www.mysql.com/support/arrangements/types.html, support contracts}.
-@strong{MySQL} support is provided by the @strong{MySQL} developers so the
+MySQL support is provided by the MySQL developers so the
standard is extremely high.
If you are interested in placing a banner advertisement on our Web site,
@@ -3964,11 +3083,13 @@ For general information inquires, please send e-mail to
For questions or comments about the workings or content of the Web site,
please send e-mail to @email{webmaster@@mysql.com}.
+
+@node Support, , Cost, Licensing and Support
+@subsection Types of Commercial Support
+
@cindex support, types
@cindex types, of support
@cindex commercial support, types
-@node Support, , Cost, Licensing and Support
-@section Types of Commercial Support
@menu
* Basic email support:: Basic email support
@@ -4001,27 +3122,29 @@ if you have login support (2000 EURO), you can expect us to work up to
10 hours to help you with things like this.
@end itemize
+
+@node Basic email support, Extended email support, Support, Support
+@subsubsection Basic E-mail Support
+
@cindex email, technical support
@cindex technical support, by email
-@node Basic email support, Extended email support, Support, Support
-@subsection Basic E-mail Support
Basic e-mail support is a very inexpensive support option and should be
-thought of more as a way to support our development of @strong{MySQL}
-than as a real support option. We at @strong{MySQL} do give a lot of free
-support in all the different @strong{MySQL} lists, and the money we get from
+thought of more as a way to support our development of MySQL
+than as a real support option. We at MySQL do give a lot of free
+support in all the different MySQL lists, and the money we get from
basic e-mail support is largely used to make this possible.
-At this support level, the @strong{MySQL} mailing lists are the preferred
+At this support level, the MySQL mailing lists are the preferred
means of communication. Questions normally should be mailed to the primary
mailing list (@email{mysql@@lists.mysql.com}) or one of the other regular
lists (for example, @email{win32@@lists.mysql.com} for Windows-related
-@strong{MySQL} questions), as someone else already may have experienced and
+MySQL questions), as someone else already may have experienced and
solved the problem you have. @xref{Asking questions}.
However, by purchasing basic e-mail support, you also have access to the
support address @email{mysql-support@@mysql.com}, which is not available
-as part of the minimal support that you get by purchasing a @strong{MySQL}
+as part of the minimal support that you get by purchasing a MySQL
license. This means that for especially critical questions, you can
cross-post your message to @email{mysql-support@@mysql.com}. (If the
message contains sensitive data, you should post only to
@@ -4049,23 +3172,23 @@ that we can solve any problem, but at least you will receive an answer if we
can contact you by e-mail.
@item
-We will help with unexpected problems when you install @strong{MySQL} from a
+We will help with unexpected problems when you install MySQL from a
binary distribution on supported platforms. This level of support does not
-cover installing @strong{MySQL} from a source distribution. Supported
-platforms are those for which @strong{MySQL} is known to work.
+cover installing MySQL from a source distribution. Supported
+platforms are those for which MySQL is known to work.
@xref{Which OS}.
@item
We will help you with bugs and missing features. Any bugs that are found are
-fixed for the next @strong{MySQL} release. If the bug is critical for
+fixed for the next MySQL release. If the bug is critical for
you, we will mail you a patch for it as soon the bug is fixed. Critical
bugs always have the highest priority for us, and we ensure that they are
fixed as soon as possible.
@item
-Your suggestions for the further development of @strong{MySQL} will be
+Your suggestions for the further development of MySQL will be
taken into consideration. By taking email support you have already
-helped the further development of @strong{MySQL}. If you want to have
+helped the further development of MySQL. If you want to have
more input, upgrade to a higher level of support.
@item
@@ -4073,9 +3196,11 @@ If you want us to help optimize your system, you must upgrade to a
higher level of support.
@end itemize
-@cindex extended email support
+
@node Extended email support, Login support, Basic email support, Support
-@subsection Extended E-mail Support
+@subsubsection Extended E-mail Support
+
+@cindex extended email support
Extended e-mail support includes everything in basic e-mail support with
these additions:
@@ -4086,11 +3211,11 @@ Your e-mail will be dealt with before mail from basic e-mail support users and
non-registered users.
@item
-Your suggestions for the further development of @strong{MySQL} will
+Your suggestions for the further development of MySQL will
receive strong consideration. Simple extensions that suit the basic
-goals of @strong{MySQL} are implemented in a matter of days. By taking
+goals of MySQL are implemented in a matter of days. By taking
extended e-mail support you have already helped the further development
-of @strong{MySQL}.
+of MySQL.
@item
Typical situations that are covered by extended e-mail support are:
@@ -4098,11 +3223,11 @@ Typical situations that are covered by extended e-mail support are:
@itemize @minus
@item
We will answer and (within reason) solve questions that relate to possible
-bugs in @strong{MySQL}. As soon as the bug is found and corrected, we
+bugs in MySQL. As soon as the bug is found and corrected, we
will mail a patch for it.
@item
-We will help with unexpected problems when you install @strong{MySQL} from a
+We will help with unexpected problems when you install MySQL from a
source or binary distribution on supported platforms.
@item
@@ -4114,14 +3239,16 @@ We will provide hints on optimizing @code{mysqld} for your situation.
@end itemize
@item
-You are allowed to influence the priority of items on the @strong{MySQL}
+You are allowed to influence the priority of items on the MySQL
TODO List. @xref{TODO}. This will ensure that the features you really need
will be implemented sooner than they might be otherwise.
@end itemize
-@cindex login support
+
@node Login support, Extended login support, Extended email support, Support
-@subsection Login Support
+@subsubsection Login Support
+
+@cindex login support
Login support includes everything in extended e-mail support with
these additions:
@@ -4132,10 +3259,10 @@ Your e-mail will be dealt with even before e-mail from extended e-mail
support users.
@item
-Your suggestions for the further development of @strong{MySQL} will
+Your suggestions for the further development of MySQL will
be taken into very high consideration. Realistic extensions that can be
implemented in a couple of hours and that suit the basic goals of
-@strong{MySQL} will be implemented as soon as possible.
+MySQL will be implemented as soon as possible.
@item
If you have a very specific problem, we can try to log in on your system
@@ -4144,7 +3271,7 @@ to solve the problem ``in place.''
@item
Like any database vendor, we can't guarantee that we can rescue any data from
crashed tables, but if the worst happens, we will help you rescue as much as
-possible. @strong{MySQL} has proven itself very reliable, but anything is
+possible. MySQL has proven itself very reliable, but anything is
possible due to circumstances beyond our control (for example, if your system
crashes or someone kills the server by executing a @code{kill -9} command).
@@ -4152,8 +3279,8 @@ crashes or someone kills the server by executing a @code{kill -9} command).
We will provide hints on optimizing your system and your queries.
@item
-You are allowed to call a @strong{MySQL} developer (in moderation) and
-discuss your @strong{MySQL}-related problems. This option is however
+You are allowed to call a MySQL developer (in moderation) and
+discuss your MySQL-related problems. This option is however
only to be used as a last result during an emergency after we have
failed to grasp the total problem with email. To make efficient
use of our time we need to first get all facts about the problem,
@@ -4161,8 +3288,9 @@ before talking on phone, to be able to work as efficiently as possible on
solving the problem.
@end itemize
+
@node Extended login support, Telephone support, Login support, Support
-@subsection Extended Login Support
+@subsubsection Extended Login Support
Extended login support includes everything in login support with these
additions:
@@ -4173,7 +3301,7 @@ Your e-mail has the highest possible priority.
@item
We will actively examine your system and help you optimize it and your
-queries. We may also optimize and/or extend @strong{MySQL} to better
+queries. We may also optimize and/or extend MySQL to better
suit your needs.
@item
@@ -4183,14 +3311,14 @@ mysql> select MY_FUNC(col1,col2) from table;
@end example
@item
-We will provide a binary distribution of all important @strong{MySQL}
+We will provide a binary distribution of all important MySQL
releases for your system, as long as we can get an account on a
similar system. In the worst case, we may require access to your system
to be able to create a binary distribution.
@item
If you can provide accommodations and pay for traveler fares, you can
-even get a @strong{MySQL} developer to visit you and offer you help with
+even get a MySQL developer to visit you and offer you help with
your troubles. Extended login support entitles you to one personal
encounter per year, but we are always very flexible towards our
customers! If the visit takes 16 hours or more, the first 8 hours is
@@ -4198,8 +3326,9 @@ without charge. For the hours above 8 hours, you will be charged with a
rate that is at least 20 % less than our standard rates.
@end itemize
+
@node Telephone support, Table handler support, Extended login support, Support
-@subsection Telephone Support
+@subsubsection Telephone Support
Telephone support includes everything in extended login support with
these additions:
@@ -4210,19 +3339,20 @@ We will provide you with a dynamic web page showing the current list of
@code{MySQL} developers that you can phone when you have a critical
problem.
@item
-For non critical problem, you can request a @strong{MySQL} developer to
+For non critical problem, you can request a MySQL developer to
phone back within 48 hours to discuss @code{MySQL} related issues.
@end itemize
+
+@node Table handler support, , Telephone support, Support
+@subsubsection Support for other table handlers
+
@cindex support, BDB Tables
@cindex support, InnoDB Tables
-@node Table handler support, , Telephone support, Support
-@subsection Support for other table handlers
-To get support for @code{BDB} tables or @code{InnoDB} tables
-you have to pay an additional 30% on the standard
-support price for each of the table handlers you would like to have
-support for.
+To get support for @code{BDB} tables, @code{InnoDB} tables you have
+to pay an additional 30% on the standard support price for each of
+the table handlers you would like to have support for.
We at @code{MySQL AB} will help you create a proper bug report for the
table handler and submit it to the developers for the specific table
@@ -4235,46 +3365,2811 @@ can get with the different table handlers. We will however do our best
to help you get the problem solved.
-@node Installing, Compatibility, Licensing and Support, Top
-@chapter Installing MySQL
+@node Compatibility, Comparisons, Licensing and Support, Introduction
+@section How Standards-compatible Is MySQL?
+
+@cindex compatibility, with ANSI SQL
+@cindex standards compatibility
+@cindex extensions, to ANSI SQL
+@cindex ANSI SQL92, extensions to
+
+@menu
+* Extensions to ANSI:: MySQL extensions to ANSI SQL92
+* Differences from ANSI:: MySQL differences compared to ANSI SQL92
+* ANSI mode:: Running MySQL in ANSI mode
+* Missing functions:: Functionality missing from MySQL
+* Standards:: What standards does MySQL follow?
+* Commit-rollback:: How to cope without @code{COMMIT}-@code{ROLLBACK}
+* Bugs:: Known errors and design deficiencies in MySQL
+@end menu
+
+This section describes how MySQL relates to the ANSI SQL standards.
+MySQL has many extensions to the ANSI SQL standards, and here you
+will find out what they are, and how to use them. You will also find
+information about functionality missing from MySQL, and how to work
+around some differences.
+
+
+@node Extensions to ANSI, Differences from ANSI, Compatibility, Compatibility
+@subsection MySQL Extensions to ANSI SQL92
+
+MySQL includes some extensions that you probably will not find in
+other SQL databases. Be warned that if you use them, your code will not be
+portable to other SQL servers. In some cases, you can write code that
+includes MySQL extensions, but is still portable, by using comments
+of the form @code{/*! ... */}. In this case, MySQL will parse and
+execute the code within the comment as it would any other MySQL
+statement, but other SQL servers will ignore the extensions. For example:
+
+@example
+SELECT /*! STRAIGHT_JOIN */ col_name FROM table1,table2 WHERE ...
+@end example
+
+If you add a version number after the @code{'!'}, the syntax will only be
+executed if the MySQL version is equal to or newer than the used
+version number:
+
+@example
+CREATE /*!32302 TEMPORARY */ TABLE (a int);
+@end example
+
+The above means that if you have Version 3.23.02 or newer, then MySQL
+will use the @code{TEMPORARY} keyword.
+
+MySQL extensions are listed below:
+
+@itemize @bullet
+@item
+The field types @code{MEDIUMINT}, @code{SET}, @code{ENUM}, and the
+different @code{BLOB} and @code{TEXT} types.
+
+@item
+The field attributes @code{AUTO_INCREMENT}, @code{BINARY}, @code{NULL},
+@code{UNSIGNED}, and @code{ZEROFILL}.
+
+@item
+All string comparisons are case insensitive by default, with sort
+ordering determined by the current character set (ISO-8859-1 Latin1 by
+default). If you don't like this, you should declare your columns with
+the @code{BINARY} attribute or use the @code{BINARY} cast, which causes
+comparisons to be done according to the ASCII order used on the
+MySQL server host.
+
+@item
+MySQL maps each database to a directory under the MySQL
+data directory, and tables within a database to filenames in the database
+directory.
+
+This has a few implications:
+
+@cindex database names, case sensitivity
+@cindex table names, case sensitivity
+@cindex case sensitivity, of database names
+@cindex case sensitivity, of table names
+
+@itemize @minus
+
+@item
+Database names and table names are case sensitive in MySQL on
+operating systems that have case-sensitive filenames (like most Unix
+systems). @xref{Name case sensitivity}.
+
+@item
+Database, table, index, column, or alias names may begin with a digit
+(but may not consist solely of digits).
+
+@item
+You can use standard system commands to backup, rename, move, delete, and copy
+tables. For example, to rename a table, rename the @file{.MYD}, @file{.MYI},
+and @file{.frm} files to which the table corresponds.
+@end itemize
+
+@item
+In SQL statements, you can access tables from different databases
+with the @code{db_name.tbl_name} syntax. Some SQL servers provide
+the same functionality but call this @code{User space}.
+MySQL doesn't support tablespaces as in:
+@code{create table ralph.my_table...IN my_tablespace}.
+
+@item
+@code{LIKE} is allowed on numeric columns.
+
+@item
+Use of @code{INTO OUTFILE} and @code{STRAIGHT_JOIN} in a @code{SELECT}
+statement. @xref{SELECT, , @code{SELECT}}.
+
+@item
+The @code{SQL_SMALL_RESULT} option in a @code{SELECT} statement.
+
+@item
+@code{EXPLAIN SELECT} to get a description on how tables are joined.
+
+@item
+Use of index names, indexes on a prefix of a field, and use of
+@code{INDEX} or @code{KEY} in a @code{CREATE TABLE}
+statement. @xref{CREATE TABLE, , @code{CREATE TABLE}}.
+
+@item
+Use of @code{TEMPORARY} or @code{IF NOT EXISTS} with @code{CREATE TABLE}.
+
+@item
+Use of @code{COUNT(DISTINCT list)} where 'list' is more than one element.
+
+@item
+Use of @code{CHANGE col_name}, @code{DROP col_name}, or @code{DROP
+INDEX}, @code{IGNORE} or @code{RENAME} in an @code{ALTER TABLE}
+statement. @xref{ALTER TABLE, , @code{ALTER TABLE}}.
+
+@item
+Use of @code{RENAME TABLE}. @xref{RENAME TABLE, , @code{RENAME TABLE}}.
+
+@item
+Use of multiple @code{ADD}, @code{ALTER}, @code{DROP}, or @code{CHANGE}
+clauses in an @code{ALTER TABLE} statement.
+
+@item
+Use of @code{DROP TABLE} with the keywords @code{IF EXISTS}.
+
+@item
+You can drop multiple tables with a single @code{DROP TABLE} statement.
+
+@item
+The @code{LIMIT} clause of the @code{DELETE} statement.
+
+@item
+The @code{DELAYED} clause of the @code{INSERT} and @code{REPLACE}
+statements.
+
+@item
+The @code{LOW_PRIORITY} clause of the @code{INSERT}, @code{REPLACE},
+@code{DELETE}, and @code{UPDATE} statements.
+
+@cindex Oracle compatibility
+@cindex compatibility, with Oracle
+@item
+Use of @code{LOAD DATA INFILE}. In many cases, this syntax is compatible with
+Oracle's @code{LOAD DATA INFILE}. @xref{LOAD DATA, , @code{LOAD DATA}}.
+
+@item
+The @code{ANALYZE TABLE}, @code{CHECK TABLE}, @code{OPTIMIZE TABLE}, and
+@code{REPAIR TABLE} statements.
+
+@item
+The @code{SHOW} statement.
+@xref{SHOW, , @code{SHOW}}.
+
+@item
+Strings may be enclosed by either @samp{"} or @samp{'}, not just by @samp{'}.
+
+@item
+Use of the escape @samp{\} character.
+
+@item
+The @code{SET OPTION} statement. @xref{SET OPTION, , @code{SET OPTION}}.
+
+@item
+You don't need to name all selected columns in the @code{GROUP BY} part.
+This gives better performance for some very specific, but quite normal
+queries.
+@xref{Group by functions}.
+
+@item
+One can specify @code{ASC} and @code{DESC} with @code{GROUP BY}.
+
+@item
+To make it easier for users who come from other SQL environments,
+MySQL supports aliases for many functions. For example, all
+string functions support both ANSI SQL syntax and ODBC syntax.
+
+@item
+MySQL understands the @code{||} and @code{&&} operators to mean
+logical OR and AND, as in the C programming language. In MySQL,
+@code{||} and @code{OR} are synonyms, as are @code{&&} and @code{AND}.
+Because of this nice syntax, MySQL doesn't support
+the ANSI SQL @code{||} operator for string concatenation; use
+@code{CONCAT()} instead. Because @code{CONCAT()} takes any number
+of arguments, it's easy to convert use of the @code{||} operator to
+MySQL.
+
+@item
+@code{CREATE DATABASE} or @code{DROP DATABASE}.
+@xref{CREATE DATABASE, , @code{CREATE DATABASE}}.
+
+@cindex PostgreSQL compatibility
+@cindex compatibility, with PostgreSQL
+@item
+The @code{%} operator is a synonym for @code{MOD()}. That is,
+@code{N % M} is equivalent to @code{MOD(N,M)}. @code{%} is supported
+for C programmers and for compatibility with PostgreSQL.
+
+@item
+The @code{=}, @code{<>}, @code{<=} ,@code{<}, @code{>=},@code{>},
+@code{<<}, @code{>>}, @code{<=>}, @code{AND}, @code{OR}, or @code{LIKE}
+operators may be used in column comparisons to the left of the
+@code{FROM} in @code{SELECT} statements. For example:
+
+@example
+mysql> SELECT col1=1 AND col2=2 FROM tbl_name;
+@end example
+
+@item
+The @code{LAST_INSERT_ID()} function.
+@xref{mysql_insert_id, , @code{mysql_insert_id()}}.
+
+@item
+The @code{REGEXP} and @code{NOT REGEXP} extended regular expression
+operators.
+
+@item
+@code{CONCAT()} or @code{CHAR()} with one argument or more than two
+arguments. (In MySQL, these functions can take any number of
+arguments.)
+
+@item The @code{BIT_COUNT()}, @code{CASE}, @code{ELT()},
+@code{FROM_DAYS()}, @code{FORMAT()}, @code{IF()}, @code{PASSWORD()},
+@code{ENCRYPT()}, @code{md5()}, @code{ENCODE()}, @code{DECODE()},
+@code{PERIOD_ADD()}, @code{PERIOD_DIFF()}, @code{TO_DAYS()}, or
+@code{WEEKDAY()} functions.
+
+@item
+Use of @code{TRIM()} to trim substrings. ANSI SQL only supports removal
+of single characters.
+
+@item
+The @code{GROUP BY} functions @code{STD()}, @code{BIT_OR()}, and
+@code{BIT_AND()}.
+
+@item
+Use of @code{REPLACE} instead of @code{DELETE} + @code{INSERT}.
+@xref{REPLACE, , @code{REPLACE}}.
+
+@item
+The @code{FLUSH flush_option} statement.
+
+@item
+The possibility to set variables in a statement with @code{:=}:
+@example
+SELECT @@a:=SUM(total),@@b=COUNT(*),@@a/@@b AS avg FROM test_table;
+SELECT @@t1:=(@@t2:=1)+@@t3:=4,@@t1,@@t2,@@t3;
+@end example
+
+@end itemize
+
+
+@node Differences from ANSI, ANSI mode, Extensions to ANSI, Compatibility
+@subsection MySQL Differences Compared to ANSI SQL92
+
+We try to make MySQL follow the ANSI SQL standard and the
+ODBC SQL standard, but in some cases MySQL does some things
+differently:
+
+@itemize @bullet
+@item
+@code{--} is only a comment if followed by a white space. @xref{Missing
+comments}.
+
+@item
+For @code{VARCHAR} columns, trailing spaces are removed when the value is
+stored. @xref{Bugs}.
+
+@item
+In some cases, @code{CHAR} columns are silently changed to @code{VARCHAR}
+columns. @xref{Silent column changes}.
+
+@item
+Privileges for a table are not automatically revoked when you delete a
+table. You must explicitly issue a @code{REVOKE} to revoke privileges for
+a table. @xref{GRANT, , @code{GRANT}}.
+
+@item
+@code{NULL AND FALSE} will evaluate to @code{NULL} and not to @code{FALSE}.
+This is because we don't think it's good to have to evaluate a lot of
+extra conditions in this case.
+@end itemize
+
+
+@node ANSI mode, Missing functions, Differences from ANSI, Compatibility
+@subsection Running MySQL in ANSI Mode
+
+@cindex running, ANSI mode
+@cindex ANSI mode, running
+
+If you start @code{mysqld} with the @code{--ansi} option, the following
+behavior of MySQL changes:
+
+@itemize @bullet
+@item
+@code{||} is string concatenation instead of @code{OR}.
+
+@item
+You can have any number of spaces between a function name and the @samp{(}.
+This forces all function names to be treated as reserved words.
+
+@item
+@samp{"} will be an identifier quote character (like the MySQL
+@samp{`} quote character) and not a string quote character.
+
+@item
+@code{REAL} will be a synonym for @code{FLOAT} instead of a synonym of
+@code{DOUBLE}.
+
+@item
+The default transaction isolation level is @code{SERIALIZABLE}.
+@xref{SET TRANSACTION}.
+@end itemize
+
+This is the same as using @code{--sql-mode=REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,SERIALIZE,ONLY_FULL_GROUP_BY}.
+
+@node Missing functions, Standards, ANSI mode, Compatibility
+@subsection Functionality Missing from MySQL
+
+@cindex missing functionality
+@cindex functionality, missing
+
+The following functionality is missing in the current version of
+MySQL. For a prioritized list indicating when new extensions
+may be added to MySQL, you should consult
+@uref{http://www.mysql.com/documentation/manual.php?section=TODO, the
+online MySQL TODO list}. That is the latest version of the TODO
+list in this manual. @xref{TODO}.
+
+@menu
+* Missing Sub-selects:: Sub-selects
+* Missing SELECT INTO TABLE:: @code{SELECT INTO TABLE}
+* Missing Transactions:: Transactions
+* Missing Triggers:: Triggers
+* Missing Foreign Keys:: Foreign Keys
+* Broken Foreign KEY:: Reasons NOT to Use Foreign Keys constraints
+* Missing Views:: Views
+* Missing comments:: @samp{--} as the start of a comment
+@end menu
+
+
+@node Missing Sub-selects, Missing SELECT INTO TABLE, Missing functions, Missing functions
+@subsubsection Sub-selects
+
+@cindex sub-selects
+
+MySQL currently only supports sub selects of the form @code{INSERT
+... SELECT ...} and @code{REPLACE ... SELECT ...}. You can however use
+the function @code{IN()} in other contexts.
+
+In many cases you can rewrite the query without a sub-select:
+
+@example
+SELECT * FROM table1 WHERE id IN (SELECT id FROM table2);
+@end example
+
+This can be re-written as:
+
+@example
+SELECT table1.* FROM table1,table2 WHERE table1.id=table2.id;
+@end example
+
+The queries:
+@example
+SELECT * FROM table1 WHERE id NOT IN (SELECT id FROM table2);
+SELECT * FROM table1 WHERE NOT EXISTS (SELECT id FROM table2 where table1.id=table2.id);
+@end example
+
+Can be rewritten as:
+
+@example
+SELECT table1.* FROM table1 LEFT JOIN table2 ON table1.id=table2.id where table2.id IS NULL
+@end example
+
+For more complicated subqueries you can often create temporary tables
+to hold the subquery. In some cases, however this option will not
+work. The most frequently encountered of these cases arises with
+@code{DELETE} statements, for which standard SQL does not support joins
+(except in sub-selects). For this situation there are two options
+available until subqueries are supported by MySQL.
+
+The first option is to use a procedural programming language (such as
+Perl or PHP) to submit a @code{SELECT} query to obtain the primary keys
+for the records to be deleted, and then use these values to construct
+the @code{DELETE} statement (@code{DELETE FROM ... WHERE ... IN (key1,
+key2, ...)}).
+
+The second option is to use interactive SQL to contruct a set of
+@code{DELETE} statements automatically, using the MySQL
+extension @code{CONCAT()} (in lieu of the standard @code{||} operator).
+For example:
+
+@example
+SELECT CONCAT('DELETE FROM tab1 WHERE pkid = ', tab1.pkid, ';')
+ FROM tab1, tab2
+ WHERE tab1.col1 = tab2.col2;
+@end example
+
+You can place this query in a script file and redirect input from it to
+the @code{mysql} command-line interpreter, piping its output back to a
+second instance of the interpreter:
+
+@example
+prompt> mysql --skip-column-names mydb < myscript.sql | mysql mydb
+@end example
+
+MySQL 4.0 supports multi-table deletes that can be used to efficiently
+delete rows based on information from one table or even from many tables
+at the same time.
+
+@node Missing SELECT INTO TABLE, Missing Transactions, Missing Sub-selects, Missing functions
+@subsubsection @code{SELECT INTO TABLE}
+
+@findex SELECT INTO TABLE
+
+MySQL doesn't yet support the Oracle SQL extension:
+@code{SELECT ... INTO TABLE ...}. MySQL supports instead the
+ANSI SQL syntax @code{INSERT INTO ... SELECT ...}, which is basically
+the same thing. @xref{INSERT SELECT}.
+
+@example
+INSERT INTO tblTemp2 (fldID) SELECT tblTemp1.fldOrder_ID FROM tblTemp1 WHERE
+tblTemp1.fldOrder_ID > 100;
+@end example
+
+Alternatively, you can use @code{SELECT INTO OUTFILE...} or @code{CREATE
+TABLE ... SELECT} to solve your problem.
+
+
+@node Missing Transactions, Missing Triggers, Missing SELECT INTO TABLE, Missing functions
+@subsubsection Transactions
+
+@cindex transactions, support
+
+As MySQL does nowadays support transactions, the following
+discussion is only valid if you are only using the non-transaction-safe
+table types. @xref{COMMIT}.
+
+The question is often asked, by the curious and the critical, ``Why is
+MySQL not a transactional database?'' or ``Why does MySQL
+not support transactions?''
+
+MySQL has made a conscious decision to support another paradigm
+for data integrity, ``atomic operations.'' It is our thinking and
+experience that atomic operations offer equal or even better integrity
+with much better performance. We, nonetheless, appreciate and understand
+the transactional database paradigm and plan, within the next few releases,
+to introduce transaction-safe tables on a per table basis. We will be
+giving our users the possibility to decide if they need the speed of
+atomic operations or if they need to use transactional features in their
+applications.
+
+How does one use the features of MySQL to maintain rigorous integrity
+and how do these features compare with the transactional paradigm?
+
+First, in the transactional paradigm, if your applications are written
+in a way that is dependent on the calling of ``rollback'' instead of
+``commit'' in critical situations, then transactions are more
+convenient. Moreover, transactions ensure that unfinished updates or
+corrupting activities are not committed to the database; the server is
+given the opportunity to do an automatic rollback and your database is
+saved.
+
+MySQL, in almost all cases, allows you to solve for potential
+problems by including simple checks before updates and by running simple
+scripts that check the databases for inconsistencies and automatically
+repair or warn if such occurs. Note that just by using the
+MySQL log or even adding one extra log, one can normally fix
+tables perfectly with no data integrity loss.
+
+Moreover, fatal transactional updates can be rewritten to be
+atomic. In fact,we will go so far as to say that all integrity problems
+that transactions solve can be done with @code{LOCK TABLES} or atomic updates,
+ensuring that you never will get an automatic abort from the database,
+which is a common problem with transactional databases.
+
+Not even transactions can prevent all loss if the server goes down. In
+such cases even a transactional system can lose data. The difference
+between different systems lies in just how small the time-lap is where
+they could lose data. No system is 100% secure, only ``secure
+enough.'' Even Oracle, reputed to be the safest of transactional
+databases, is reported to sometimes lose data in such situations.
+
+To be safe with MySQL, you only need to have backups and have
+the update logging turned on. With this you can recover from any
+situation that you could with any transactional database. It is, of
+course, always good to have backups, independent of which database you
+use.
+
+The transactional paradigm has its benefits and its drawbacks. Many
+users and application developers depend on the ease with which they can
+code around problems where an abort appears to be, or is necessary, and they
+may have to do a little more work with MySQL to either think
+differently or write more. If you are new to the atomic operations
+paradigm, or more familiar or more comfortable with transactions, do not
+jump to the conclusion that MySQL has not addressed these
+issues. Reliability and integrity are foremost in our minds. Recent
+estimates indicate that there are more than 1,000,000 @code{mysqld} servers
+currently running, many of which are in production environments. We
+hear very, very seldom from our users that they have lost any data, and
+in almost all of those cases user error is involved. This is, in our
+opinion, the best proof of MySQL's stability and reliability.
+
+Lastly, in situations where integrity is of highest importance,
+MySQL's current features allow for transaction-level or better
+reliability and integrity. If you lock tables with @code{LOCK TABLES}, all
+updates will stall until any integrity checks are made. If you only obtain
+a read lock (as opposed to a write lock), then reads and inserts are
+still allowed to happen. The new inserted records will not be seen by
+any of the clients that have a @code{READ} lock until they release their read
+locks. With @code{INSERT DELAYED} you can queue inserts into a local queue,
+until the locks are released, without having the client wait for the insert
+to complete. @xref{INSERT DELAYED}.
+
+``Atomic,'' in the sense that we mean it, is nothing magical. It only means
+that you can be sure that while each specific update is running, no other
+user can interfere with it, and there will never be an automatic
+rollback (which can happen on transaction based systems if you are not
+very careful). MySQL also guarantees that there will not be
+any dirty reads. You can find some example of how to write atomic updates
+in the commit-rollback section. @xref{Commit-rollback}.
+
+We have thought quite a bit about integrity and performance, and we
+believe that our atomic operations paradigm allows for both high
+reliability and extremely high performance, on the order of three to
+five times the speed of the fastest and most optimally tuned of
+transactional databases. We didn't leave out transactions because they
+are hard to do. The main reason we went with atomic operations as
+opposed to transactions is that by doing this we could apply many speed
+optimizations that would not otherwise have been possible.
+
+Many of our users who have speed foremost in their minds are not at all
+concerned about transactions. For them transactions are not an
+issue. For those of our users who are concerned with or have wondered
+about transactions vis-a-vis MySQL, there is a ``MySQL
+way'' as we have outlined above. For those where safety is more
+important than speed, we recommend them to use the @code{BDB},
+or @code{InnoDB} tables for all their critical data. @xref{Table types}.
+
+One final note: We are currently working on a safe replication schema
+that we believe to be better than any commercial replication system we
+know of. This system will work most reliably under the atomic
+operations, non-transactional, paradigm. Stay tuned.
+
+
+@node Missing Triggers, Missing Foreign Keys, Missing Transactions, Missing functions
+@subsubsection Stored Procedures and Triggers
+
+@cindex stored procedures and triggers, defined
+@cindex procedures, stored
+@cindex triggers, stored
+
+A stored procedure is a set of SQL commands that can be compiled and stored
+in the server. Once this has been done, clients don't need to keep reissuing
+the entire query but can refer to the stored procedure. This provides better
+performance because the query has to be parsed only once, and less information
+needs to be sent between the server and the client. You can also raise the
+conceptual level by having libraries of functions in the server.
+
+A trigger is a stored procedure that is invoked when a particular event
+occurs. For example, you can install a stored procedure that is triggered
+each time a record is deleted from a transaction table and that automatically
+deletes the corresponding customer from a customer table when all his
+transactions are deleted.
+
+The planned update language will be able to
+handle stored procedures, but without triggers. Triggers usually slow
+down everything, even queries for which they are not needed.
+
+To see when MySQL might get stored procedures, see @ref{TODO}.
+
+
+@node Missing Foreign Keys, Broken Foreign KEY, Missing Triggers, Missing functions
+@subsubsection Foreign Keys
+
+@cindex foreign keys
+@cindex keys, foreign
+
+Note that foreign keys in SQL are not used to join tables, but are used
+mostly for checking referential integrity (foreign key constraints). If
+you want to get results from multiple tables from a @code{SELECT}
+statement, you do this by joining tables:
+
+@example
+SELECT * from table1,table2 where table1.id = table2.id;
+@end example
+
+@xref{JOIN, , @code{JOIN}}. @xref{example-Foreign keys}.
+
+The @code{FOREIGN KEY} syntax in MySQL exists only for compatibility
+with other SQL vendors' @code{CREATE TABLE} commands; it doesn't do
+anything. The @code{FOREIGN KEY} syntax without @code{ON DELETE ...} is
+mostly used for documentation purposes. Some ODBC applications may use this
+to produce automatic @code{WHERE} clauses, but this is usually easy to
+override. @code{FOREIGN KEY} is sometimes used as a constraint check, but
+this check is unnecessary in practice if rows are inserted into the tables in
+the right order. MySQL only supports these clauses because some
+applications require them to exist (regardless of whether or not they
+work).
+
+In MySQL, you can work around the problem of @code{ON DELETE
+...} not being implemented by adding the appropriate @code{DELETE} statement to
+an application when you delete records from a table that has a foreign key.
+In practice this is as quick (in some cases quicker) and much more portable
+than using foreign keys.
+
+In the near future we will extend the @code{FOREIGN KEY} implementation so
+that at least the information will be saved in the table specification file
+and may be retrieved by @code{mysqldump} and ODBC. At a later stage we will
+implement the foreign key constraints for application that can't easily be
+coded to avoid them.
+
+@menu
+* Broken Foreign KEY:: Reasons NOT to use foreign keys constraints
+@end menu
+
+
+@node Broken Foreign KEY, Missing Views, Missing Foreign Keys, Missing functions
+@subsubsection Reasons NOT to Use Foreign Keys constraints
+
+@cindex foreign keys, reasons not to use
+
+There are so many problems with foreign key constraints that we don't
+know where to start:
+
+@itemize @bullet
+@item
+Foreign key constraints make life very complicated, because the foreign
+key definitions must be stored in a database and implementing them would
+destroy the whole ``nice approach'' of using files that can be moved,
+copied, and removed.
+
+@item
+The speed impact is terrible for @code{INSERT} and @code{UPDATE}
+statements, and in this case almost all @code{FOREIGN KEY} constraint
+checks are useless because you usually insert records in the right
+tables in the right order, anyway.
+
+@item
+There is also a need to hold locks on many more tables when updating one
+table, because the side effects can cascade through the entire database. It's
+MUCH faster to delete records from one table first and subsequently delete
+them from the other tables.
+
+@item
+You can no longer restore a table by doing a full delete from the table
+and then restoring all records (from a new source or from a backup).
+
+@item
+If you use foreign key constraints you can't dump and restore tables
+unless you do so in a very specific order.
+
+@item
+It's very easy to do ``allowed'' circular definitions that make the
+tables impossible to re-create each table with a single create statement,
+even if the definition works and is usable.
+
+@item
+It's very easy to overlook @code{FOREIGN KEY ... ON DELETE} rules when
+one codes an application. It's not unusual that one loses a lot of
+important information just because a wrong or misused @code{ON DELETE} rule.
+@end itemize
+
+The only nice aspect of @code{FOREIGN KEY} is that it gives ODBC and some
+other client programs the ability to see how a table is connected and to use
+this to show connection diagrams and to help in building applications.
+
+MySQL will soon store @code{FOREIGN KEY} definitions so that a
+client can ask for and receive an answer about how the original
+connection was made. The current @file{.frm} file format does not have
+any place for it. At a later stage we will implement the foreign key
+constraints for application that can't easily be coded to avoid them.
+
+
+@node Missing Views, Missing comments, Broken Foreign KEY, Missing functions
+@subsubsection Views
+
+@cindex views
+
+MySQL doesn't yet support views, but we plan to implement these
+to about 4.1.
+
+Views are mostly useful for letting users access a set of relations as one
+table (in read-only mode). Many SQL databases don't allow one to update
+any rows in a view, but you have to do the updates in the separate tables.
+
+As MySQL is mostly used in applications and on web system where
+the application writer has full control on the database usage, most of
+our users haven't regarded views to be very important. (At least no one
+has been interested enough in this to be prepared to finance the
+implementation of views).
+
+One doesn't need views in MySQL to restrict access to columns
+as MySQL has a very sophisticated privilege
+system. @xref{Privilege system}.
+
+
+@node Missing comments, , Missing Views, Missing functions
+@subsubsection @samp{--} as the Start of a Comment
+
+@cindex comments, starting
+@cindex starting, comments
+
+Some other SQL databases use @samp{--} to start comments. MySQL
+has @samp{#} as the start comment character, even if the @code{mysql}
+command-line tool removes all lines that start with @samp{--}.
+You can also use the C comment style @code{/* this is a comment */} with
+MySQL.
+@xref{Comments}.
+
+MySQL Version 3.23.3 and above supports the @samp{--} comment style
+only if the comment is followed by a space. This is because this
+degenerate comment style has caused many problems with automatically
+generated SQL queries that have used something like the following code,
+where we automatically insert the value of the payment for
+@code{!payment!}:
+
+@example
+UPDATE tbl_name SET credit=credit-!payment!
+@end example
+
+What do you think will happen when the value of @code{payment} is negative?
+
+Because @code{1--1} is legal in SQL, we think it is terrible that
+@samp{--} means start comment.
+
+In MySQL Version 3.23 you can, however, use:
+@code{1-- This is a comment}
+
+The following discussion only concerns you if you are running a MySQL
+version earlier than Version 3.23:
+
+If you have a SQL program in a text file that contains @samp{--} comments
+you should use:
+
+@example
+shell> replace " --" " #" < text-file-with-funny-comments.sql \
+ | mysql database
+@end example
+
+instead of the usual:
+
+@example
+shell> mysql database < text-file-with-funny-comments.sql
+@end example
+
+You can also edit the command file ``in place'' to change the @samp{--}
+comments to @samp{#} comments:
+
+@example
+shell> replace " --" " #" -- text-file-with-funny-comments.sql
+@end example
+
+Change them back with this command:
+
+@example
+shell> replace " #" " --" -- text-file-with-funny-comments.sql
+@end example
+
+
+@node Standards, Commit-rollback, Missing functions, Compatibility
+@subsection What Standards Does MySQL Follow?
+
+Entry level SQL92. ODBC levels 0-2.
+
+
+@node Commit-rollback, Bugs, Standards, Compatibility
+@subsection How to Cope Without @code{COMMIT}/@code{ROLLBACK}
+
+@findex COMMIT
+@findex ROLLBACK
+@cindex transaction-safe tables
+@cindex tables, updating
+@cindex updating, tables
+@cindex @code{BDB} tables
+@cindex @code{InnoDB} tables
+
+The following mostly applies only for @code{ISAM}, @code{MyISAM}, and
+@code{HEAP} tables. If you only use transaction-safe tables (@code{BDB},
+or @code{InnoDB} tables) in an an update, you can do
+@code{COMMIT} and @code{ROLLBACK} also with MySQL.
+@xref{COMMIT}.
+
+The problem with handling @code{COMMIT}-@code{ROLLBACK} efficiently with
+the above table types would require a completely different table layout
+than MySQL uses today. The table type would also need extra
+threads that do automatic cleanups on the tables, and the disk usage
+would be much higher. This would make these table types about 2-4 times
+slower than they are today.
+
+For the moment, we prefer implementing the SQL server language (something
+like stored procedures). With this you would very seldom really need
+@code{COMMIT}-@code{ROLLBACK.} This would also give much better performance.
+
+Loops that need transactions normally can be coded with the help of
+@code{LOCK TABLES}, and you don't need cursors when you can update records
+on the fly.
+
+We at TcX had a greater need for a real fast database than a 100%
+general database. Whenever we find a way to implement these features without
+any speed loss, we will probably do it. For the moment, there are many more
+important things to do. Check the TODO for how we prioritize things at
+the moment. (Customers with higher levels of support can alter this, so
+things may be reprioritized.)
+
+The current problem is actually @code{ROLLBACK}. Without
+@code{ROLLBACK}, you can do any kind of @code{COMMIT} action with
+@code{LOCK TABLES}. To support @code{ROLLBACK} with the above table
+types, MySQL would have to be changed to store all old records
+that were updated and revert everything back to the starting point if
+@code{ROLLBACK} was issued. For simple cases, this isn't that hard to do
+(the current @code{isamlog} could be used for this purpose), but it
+would be much more difficult to implement @code{ROLLBACK} for
+@code{ALTER/DROP/CREATE TABLE}.
+
+To avoid using @code{ROLLBACK}, you can use the following strategy:
+
+@enumerate
+@item
+Use @code{LOCK TABLES ...} to lock all the tables you want to access.
+@item
+Test conditions.
+@item
+Update if everything is okay.
+@item
+Use @code{UNLOCK TABLES} to release your locks.
+@end enumerate
+
+This is usually a much faster method than using transactions with possible
+@code{ROLLBACK}s, although not always. The only situation this solution
+doesn't handle is when someone kills the threads in the middle of an
+update. In this case, all locks will be released but some of the updates may
+not have been executed.
+
+You can also use functions to update records in a single operation.
+You can get a very efficient application by using the following techniques:
+
+@itemize @bullet
+@item Modify fields relative to their current value.
+@item Update only those fields that actually have changed.
+@end itemize
+
+For example, when we are doing updates to some customer information, we
+update only the customer data that has changed and test only that none of
+the changed data, or data that depend on the changed data, has changed
+compared to the original row. The test for changed data is done with the
+@code{WHERE} clause in the @code{UPDATE} statement. If the record wasn't
+updated, we give the client a message: "Some of the data you have changed
+have been changed by another user". Then we show the old row versus the new
+row in a window, so the user can decide which version of the customer record
+he should use.
+
+This gives us something that is similar to column locking but is actually
+even better, because we only update some of the columns, using values that
+are relative to their current values. This means that typical @code{UPDATE}
+statements look something like these:
+
+@example
+UPDATE tablename SET pay_back=pay_back+'relative change';
+
+UPDATE customer
+ SET
+ customer_date='current_date',
+ address='new address',
+ phone='new phone',
+ money_he_owes_us=money_he_owes_us+'new_money'
+ WHERE
+ customer_id=id AND address='old address' AND phone='old phone';
+@end example
+
+As you can see, this is very efficient and works even if another client has
+changed the values in the @code{pay_back} or @code{money_he_owes_us} columns.
+
+@findex mysql_insert_id()
+@findex LAST_INSERT_ID()
+In many cases, users have wanted @code{ROLLBACK} and/or @code{LOCK
+TABLES} for the purpose of managing unique identifiers for some tables. This
+can be handled much more efficiently by using an @code{AUTO_INCREMENT} column
+and either the SQL function @code{LAST_INSERT_ID()} or the C API function
+@code{mysql_insert_id()}. @xref{mysql_insert_id, , @code{mysql_insert_id()}}.
+
+@cindex rows, locking
+At MySQL AB, we have never had any need for row-level locking
+because we have always been able to code around it. Some cases really need
+row locking, but they are very few. If you want row-level locking, you
+can use a flag column in the table and do something like this:
+
+@example
+UPDATE tbl_name SET row_flag=1 WHERE id=ID;
+@end example
+
+MySQL returns 1 for the number of affected rows if the row was
+found and @code{row_flag} wasn't already 1 in the original row.
+
+You can think of it as MySQL changed the above query to:
+
+@example
+UPDATE tbl_name SET row_flag=1 WHERE id=ID and row_flag <> 1;
+@end example
+
+
+@node Bugs, , Commit-rollback, Compatibility
+@subsection Known errors and design deficiencies in MySQL
+
+@cindex bugs, known
+@cindex errors, known
+@cindex design, issues
+@cindex known errors
+
+The following problems are known and have a very high priority to get
+fixed:
+
+@itemize @bullet
+@item
+@code{ANALYZE TABLE} on a BDB table may in some case make the table
+unusable until one has restarted @code{mysqld}. When this happens you will
+see errors like the following in the MySQL error file:
+
+@example
+001207 22:07:56 bdb: log_flush: LSN past current end-of-log
+@end example
+
+@item
+Don't execute @code{ALTER TABLE} on a @code{BDB} table on which you are
+running not completed multi-statement transactions. (The transaction
+will probably be ignored).
+
+@item
+@code{ANALYZE TABLE}, @code{OPTIMIZE TABLE} and @code{REPAIR TABLE} may
+cause problems on tables for which you are using @code{INSERT DELAYED}.
+
+@item
+Doing a @code{LOCK TABLE ..} and @code{FLUSH TABLES ..} doesn't
+guarantee that there isn't a half-finished transaction in progress on the
+table.
+
+@item
+BDB tables are a bit slow to open. If you have many BDB tables in a
+database, it will take a long time to use the @code{mysql} client on the
+database if you are not using the @code{-A} option or if you are using
+@code{rehash}. This is especially notable when you have a big table
+cache.
+
+@item
+Th current replication protocol cannot deal with @code{LOAD DATA INFILE}
+and line terminator characters of more than 1 character.
+@end itemize
+
+The following problems are known and will be fixed in due time:
+
+@itemize @bullet
+@item
+For the moment @code{MATCH} only works with @code{SELECT} statements.
+
+@item
+When using @code{SET CHARACTER SET}, one can't use translated
+characters in database, table and column names.
+
+@item
+@code{DELETE FROM merge_table} used without a @code{WHERE}
+will only clear the mapping for the table, not delete everything in the
+mapped tables
+
+@item
+You cannot build in another directory when using
+MIT-pthreads. Because this requires changes to MIT-pthreads, we are not
+likely to fix this.
+
+@item
+@code{BLOB} values can't ``reliably'' be used in @code{GROUP BY} or
+@code{ORDER BY} or @code{DISTINCT}. Only the first @code{max_sort_length}
+bytes (default 1024) are used when comparing @code{BLOB}bs in these cases.
+This can be changed with the @code{-O max_sort_length} option to
+@code{mysqld}. A workaround for most cases is to use a substring:
+@code{SELECT DISTINCT LEFT(blob,2048) FROM tbl_name}.
+
+@item
+Calculation is done with @code{BIGINT} or @code{DOUBLE} (both are
+normally 64 bits long). It depends on the function which precision one
+gets. The general rule is that bit functions are done with @code{BIGINT}
+precision, @code{IF}, and @code{ELT()} with @code{BIGINT} or @code{DOUBLE}
+precision and the rest with @code{DOUBLE} precision. One should try to
+avoid using bigger unsigned long long values than 63 bits
+(9223372036854775807) for anything else than bit fields!
+
+@item
+All string columns, except @code{BLOB} and @code{TEXT} columns, automatically
+have all trailing spaces removed when retrieved. For @code{CHAR} types this
+is okay, and may be regarded as a feature according to ANSI SQL92. The bug is
+that in MySQL, @code{VARCHAR} columns are treated the same way.
+
+@item
+You can only have up to 255 @code{ENUM} and @code{SET} columns in one table.
+
+@item
+@code{safe_mysqld} re-directs all messages from @code{mysqld} to the
+@code{mysqld} log. One problem with this is that if you execute
+@code{mysqladmin refresh} to close and reopen the log,
+@code{stdout} and @code{stderr} are still redirected to the old log.
+If you use @code{--log} extensively, you should edit @code{safe_mysqld} to
+log to @file{'hostname'.err} instead of @file{'hostname'.log} so you can
+easily reclaim the space for the old log by deleting the old one and
+executing @code{mysqladmin refresh}.
+
+@item
+In the @code{UPDATE} statement, columns are updated from left to right. If
+you refer to an updated column, you will get the updated value instead of the
+original value. For example:
+
+@example
+mysql> UPDATE tbl_name SET KEY=KEY+1,KEY=KEY+1;
+@end example
+
+This will update @code{KEY} with @code{2} instead of with @code{1}.
+
+@item
+You can't use temporary tables more than once in the same query.
+For example, the following doesn't work.
+
+@example
+select * from temporary_table, temporary_table as t2;
+@end example
+
+@item
+@code{RENAME} doesn't work with @code{TEMPORARY} tables.
+
+@item
+The optimizer may handle @code{DISTINCT} differently if you are using
+'hidden' columns in a join or not. In a join, hidden columns are
+counted as part of the result (even if they are not shown) while in
+normal queries hidden columns doesn't participate in the @code{DISTINCT}
+comparison. We will probably change this in the future to never compare
+the hidden columns when executing @code{DISTINCT}
+
+An example of this is:
+
+@example
+SELECT DISTINCT mp3id FROM band_downloads WHERE userid = 9 ORDER BY id
+DESC;
+@end example
+
+and
+
+@example
+SELECT DISTINCT band_downloads.mp3id, FROM band_downloads,band_mp3
+WHERE band_downloads.userid = 9 AND band_mp3.id = band_downloads.mp3id
+ORDER BY band_downloads.id DESC;
+@end example
+
+In the second case you may in MySQL 3.23.x get two identical rows
+in the result set (because the hidden 'id' column may differ).
+
+Note that the this only happens for queries where you don't have the
+ORDER BY columns in the result, something that is you are not allowed
+to do in ANSI SQL.
+
+@item
+Because MySQL allows you to work with table types that doesn't
+support transactions (and thus can't @code{rollback} data) some things
+behaves a little different in MySQL than in other SQL servers:
+(This is just to ensure that MySQL never need to do a rollback
+for a SQL command). This may be a little awkward at times as column
+Because MySQL allows you to work with table types that don't
+support transactions, and thus can't @code{rollback} data, some things
+behave a little differently in MySQL than in other SQL servers.
+This is just to ensure that MySQL never need to do a rollback
+for a SQL command. This may be a little awkward at times as column
+values must be checked in the application, but this will actually give
+you a nice speed increase as it allows MySQL to do some
+optimizations that otherwise would be very hard to do.
+
+If you set a column to an incorrect value, MySQL will, instead of
+doing a rollback, store the @code{best possible value} in the column:
+
+@itemize @minus
+@item
+If you try to store a value outside the range in a numerical column,
+MySQL will instead store the smallest or biggest possible value in
+the column.
+
+@item
+If you try to store a string that doesn't start with a number into a
+numerical column, MySQL will store 0 into it.
+
+@item
+If you try to store @code{NULL} into a column that doesn't take
+@code{NULL} values, MySQL will store 0 or @code{''} (empty
+string) in it instead. (This behavior can, however, be changed with the
+-DDONT_USE_DEFAULT_FIELDS compile option).
+
+@item
+MySQL allows you to store some wrong date values into
+@code{DATE} and @code{DATETIME} columns. (Like 2000-02-31 or 2000-02-00).
+If the date is totally wrong, MySQL will store the special
+0000-00-00 date value in the column.
+
+@item
+If you set an @code{enum} to an unsupported value, it will be set to
+the error value 'empty string', with numeric value 0.
+@end itemize
+
+@item
+If you execute a @code{PROCEDURE} on a query that returns an empty set,
+in some cases the @code{PROCEDURE} will not transform the columns.
+
+@item
+Creation of a table of type @code{MERGE} doesn't check if the underlying
+tables are of compatible types.
+
+@item
+MySQL can't yet handle @code{NaN}, @code{-Inf} and @code{Inf}
+values in double. Using these will cause problems when trying to export
+and import data. We should as an intermediate solution change @code{NaN} to
+@code{NULL} (if possible) and @code{-Inf} and @code{Inf} to the
+Minimum respective maximum possible @code{double} value.
+
+@item
+@code{LIMIT} on negative numbers are treated as big positive numbers.
+@item
+If you use @code{ALTER TABLE} to first add an @code{UNIQUE} index to a
+table used in a @code{MERGE} table and then use @code{ALTER TABLE} to
+add a normal index on the @code{MERGE} table, the key order will be
+different for the tables if there was an old not-unique key in the
+table. This is because @code{ALTER TABLE} puts @code{UNIQUE} keys before
+normal keys to be able to detect duplicate keys as early as possible.
+@end itemize
+
+The following are known bugs in earlier versions of MySQL:
+
+@itemize @bullet
+@item
+You can get a hung thread if you do a @code{DROP TABLE} on a table that is
+one among many tables that is locked with @code{LOCK TABLES}.
+
+@item
+In the following case you can get a core dump:
+
+@itemize @minus
+@item
+Delayed insert handler has pending inserts to a table.
+
+@item
+@code{LOCK table} with @code{WRITE}
+
+@item
+@code{FLUSH TABLES}
+@end itemize
+
+@item
+Before MySQL Version 3.23.2 an @code{UPDATE} that updated a key with
+a @code{WHERE} on the same key may have failed because the key was used to
+search for records and the same row may have been found multiple times:
+
+@example
+UPDATE tbl_name SET KEY=KEY+1 WHERE KEY > 100;
+@end example
+
+A workaround is to use:
+
+@example
+mysql> UPDATE tbl_name SET KEY=KEY+1 WHERE KEY+0 > 100;
+@end example
+
+This will work because MySQL will not use index on expressions in
+the @code{WHERE} clause.
+
+@item
+Before MySQL Version 3.23, all numeric types where treated as fixed-point
+fields. That means you had to specify how many decimals a floating-point
+field shall have. All results were returned with the correct number of
+decimals.
+@end itemize
+
+For platform-specific bugs, see the sections about compiling and porting.
+
+
+@node Comparisons, TODO, Compatibility, Introduction
+@section How MySQL Compares to Other Databases
+
+@cindex databases, MySQL vs. others
+@cindex comparisons, MySQL vs. others
+
+@menu
+* Compare mSQL:: How MySQL compares to @code{mSQL}
+* Compare PostgreSQL:: How MySQL compares with PostgreSQL
+@end menu
+
+This section compares MySQL to other popular databases.
+
+This section has been written by the MySQL developers, so it
+should be read with that in mind. There are no factual errors contained
+in this section that we know of. If you find something which you believe
+to be an error, please contact us about it at @email{docs@@mysql.com}.
+
+For a list of all supported limits, functions, and types, see the
+@code{crash-me} Web page at
+@uref{http://www.mysql.com/information/crash-me.php}.
+
+
+@node Compare mSQL, Compare PostgreSQL, Comparisons, Comparisons
+@subsection How MySQL Compares to @code{mSQL}
+
+@table @strong
+@item Performance
+
+For a true comparison of speed, consult the growing MySQL benchmark
+suite. @xref{MySQL Benchmarks}.
+
+Because there is no thread creation overhead, a small parser, few features, and
+simple security, @code{mSQL} should be quicker at:
+
+@itemize @bullet
+@item
+Tests that perform repeated connects and disconnects, running a very simple
+query during each connection.
+
+@item
+@code{INSERT} operations into very simple tables with few columns and keys.
+
+@item
+@code{CREATE TABLE} and @code{DROP TABLE}.
+
+@item
+@code{SELECT} on something that isn't an index. (A table scan is very
+easy.)
+@end itemize
+
+Because these operations are so simple, it is hard to be better at them when
+you have a higher startup overhead. After the connection is established,
+MySQL should perform much better.
+
+On the other hand, MySQL is much faster than @code{mSQL} (and
+most other SQL implementations) on the following:
+
+@itemize @bullet
+@item
+Complex @code{SELECT} operations.
+
+@item
+Retrieving large results (MySQL has a better, faster, and safer
+protocol).
+
+@item
+Tables with variable-length strings, because MySQL has more efficient
+handling and can have indexes on @code{VARCHAR} columns.
+
+@item
+Handling tables with many columns.
+
+@item
+Handling tables with large record lengths.
+
+@item
+@code{SELECT} with many expressions.
+
+@item
+@code{SELECT} on large tables.
+
+@item
+Handling many connections at the same time. MySQL is fully
+multi-threaded. Each connection has its own thread, which means that
+no thread has to wait for another (unless a thread is modifying
+a table another thread wants to access). In @code{mSQL}, once one connection
+is established, all others must wait until the first has finished, regardless
+of whether the connection is running a query that is short or long. When the
+first connection terminates, the next can be served, while all the others wait
+again, etc.
+
+@item
+Joins.
+@code{mSQL} can become pathologically slow if you change the order of tables
+in a @code{SELECT}. In the benchmark suite, a time more than 15000 times
+slower than MySQL was seen. This is due to @code{mSQL}'s lack of a
+join optimizer to order tables in the optimal order. However, if you put the
+tables in exactly the right order in @code{mSQL}2 and the @code{WHERE} is
+simple and uses index columns, the join will be relatively fast!
+@xref{MySQL Benchmarks}.
+
+@item
+@code{ORDER BY} and @code{GROUP BY}.
+
+@item
+@code{DISTINCT}.
+
+@item
+Using @code{TEXT} or @code{BLOB} columns.
+@end itemize
+
+@item SQL Features
+
+@itemize @bullet
+@item @code{GROUP BY} and @code{HAVING}.
+@code{mSQL} does not support @code{GROUP BY} at all.
+MySQL supports a full @code{GROUP BY} with both @code{HAVING} and
+the following functions: @code{COUNT()}, @code{AVG()}, @code{MIN()},
+@code{MAX()}, @code{SUM()}, and @code{STD()}. @code{COUNT(*)} is optimized to
+return very quickly if the @code{SELECT} retrieves from one table, no other
+columns are retrieved, and there is no @code{WHERE} clause. @code{MIN()} and
+@code{MAX()} may take string arguments.
+
+@item @code{INSERT} and @code{UPDATE} with calculations.
+MySQL can do calculations in an @code{INSERT} or @code{UPDATE}.
+For example:
+
+@example
+mysql> UPDATE SET x=x*10+y WHERE x<20;
+@end example
+
+@item Aliasing.
+MySQL has column aliasing.
+
+@item Qualifying column names.
+In MySQL, if a column name is unique among the tables used in a
+query, you do not have to use the full qualifier.
+
+@item @code{SELECT} with functions.
+MySQL has many functions (too many to list here; see @ref{Functions}).
+
+@end itemize
+
+@item Disk Space Efficiency
+That is, how small can you make your tables?
+
+MySQL has very precise types, so you can create tables that take
+very little space. An example of a useful MySQL datatype is the
+@code{MEDIUMINT} that is 3 bytes long. If you have 100,000,000 records,
+saving even one byte per record is very important.
+
+@code{mSQL2} has a more limited set of column types, so it is
+more difficult to get small tables.
+
+@item Stability
+This is harder to judge objectively. For a discussion of MySQL
+stability, see @ref{Stability}.
+
+We have no experience with @code{mSQL} stability, so we cannot say
+anything about that.
+
+@item Price
+Another important issue is the license. MySQL has a
+more flexible license than @code{mSQL}, and is also less expensive than
+@code{mSQL}. Whichever product you choose to use, remember to at least
+consider paying for a license or e-mail support. (You are required to get
+a license if you include MySQL with a product that you sell,
+of course.)
+
+@item Perl Interfaces
+MySQL has basically the same interfaces to Perl as @code{mSQL} with
+some added features.
+
+@item JDBC (Java)
+MySQL currently has a lot of different JDBC drivers:
+
+@itemize @bullet
+@item
+The mm driver: A type 4 JDBC driver by Mark Matthews
+@email{mmatthew@@ecn.purdue.edu}. This is released under the LGPL.
+
+@item
+The Resin driver. This is a commercial JDBC driver released under open
+source. @uref{http://www.caucho.com/projects/jdbc-mysql/index.xtp}
+
+@item
+The gwe driver: A Java interface by GWE technologies (not supported anymore).
+
+@item
+The jms driver: An improved gwe driver by Xiaokun Kelvin ZHU
+@email{X.Zhu@@brad.ac.uk} (not supported anymore).
+
+@item
+The twz driver: A type 4 JDBC driver by Terrence W. Zellers
+@email{zellert@@voicenet.com}. This is commercial but is free for private
+and educational use (not supported anymore).
+@end itemize
+
+The recommended driver is the mm driver. The Resin driver may also be
+good (at least the benchmarks looks good), but we haven't received that much
+information about this yet.
+
+We know that @code{mSQL} has a JDBC driver, but we have too little experience
+with it to compare.
+
+@item Rate of Development
+MySQL has a very small team of developers, but we are quite
+used to coding C and C++ very rapidly. Because threads, functions,
+@code{GROUP BY}, and so on are still not implemented in @code{mSQL}, it
+has a lot of catching up to do. To get some perspective on this, you
+can view the @code{mSQL} @file{HISTORY} file for the last year and
+compare it with the News section of the MySQL Reference Manual
+(@pxref{News}). It should be pretty obvious which one has developed
+most rapidly.
+
+@item Utility Programs
+Both @code{mSQL} and MySQL have many interesting third-party
+tools. Because it is very easy to port upward (from @code{mSQL} to
+MySQL), almost all the interesting applications that are available for
+@code{mSQL} are also available for MySQL.
+
+MySQL comes with a simple @code{msql2mysql} program that fixes
+differences in spelling between @code{mSQL} and MySQL for the
+most-used C API functions.
+For example, it changes instances of @code{msqlConnect()} to
+@code{mysql_connect()}. Converting a client program from @code{mSQL} to
+MySQL usually takes a couple of minutes.
+@end table
+
+@menu
+* Using mSQL tools:: How to convert @code{mSQL} tools for MySQL
+* Protocol differences:: How @code{mSQL} and MySQL Client/Server Communications Protocols Differ
+* Syntax differences:: How @code{mSQL} 2.0 SQL Syntax Differs from MySQL
+@end menu
+
+
+@node Using mSQL tools, Protocol differences, Compare mSQL, Compare mSQL
+@subsubsection How to Convert @code{mSQL} Tools for MySQL
+
+@cindex MySQL tools, conversion
+@cindex converting, tools
+@cindex tools, converting
+
+According to our experience, it would just take a few hours to convert tools
+such as @code{msql-tcl} and @code{msqljava} that use the
+@code{mSQL} C API so that they work with the MySQL C API.
+
+The conversion procedure is:
+
+@enumerate
+@item
+Run the shell script @code{msql2mysql} on the source. This requires the
+@code{replace} program, which is distributed with MySQL.
+
+@item
+Compile.
+
+@item
+Fix all compiler errors.
+@end enumerate
+
+Differences between the @code{mSQL} C API and the MySQL C API are:
+
+@itemize @bullet
+@item
+MySQL uses a @code{MYSQL} structure as a connection type (@code{mSQL}
+uses an @code{int}).
+
+@item
+@code{mysql_connect()} takes a pointer to a @code{MYSQL} structure as a
+parameter. It is easy to define one globally or to use @code{malloc()} to get
+one. @code{mysql_connect()} also takes two parameters for specifying the
+user and password. You may set these to @code{NULL, NULL} for default use.
+
+@item
+@code{mysql_error()} takes the @code{MYSQL} structure as a parameter. Just add
+the parameter to your old @code{msql_error()} code if you are porting old code.
+
+@item
+MySQL returns an error number and a text error message for all
+errors. @code{mSQL} returns only a text error message.
+
+@item
+Some incompatibilities exist as a result of MySQL supporting
+multiple connections to the server from the same process.
+@end itemize
+
+
+@node Protocol differences, Syntax differences, Using mSQL tools, Compare mSQL
+@subsubsection How @code{mSQL} and MySQL Client/Server Communications Protocols Differ
+
+@cindex communications protocols
+@cindex mSQL vs. MySQL
+
+There are enough differences that it is impossible (or at least not easy)
+to support both.
+
+The most significant ways in which the MySQL protocol differs
+from the @code{mSQL} protocol are listed below:
+
+@itemize @bullet
+@item
+A message buffer may contain many result rows.
+
+@item
+The message buffers are dynamically enlarged if the query or the
+result is bigger than the current buffer, up to a configurable server and
+client limit.
+
+@item
+All packets are numbered to catch duplicated or missing packets.
+
+@item
+All column values are sent in ASCII. The lengths of columns and rows are sent
+in packed binary coding (1, 2, or 3 bytes).
+
+@item
+MySQL can read in the result unbuffered (without having to store the
+full set in the client).
+
+@item
+If a single read/write takes more than 30 seconds, the server closes
+the connection.
+
+@item
+If a connection is idle for 8 hours, the server closes the connection.
+@end itemize
+
+@menu
+* Syntax differences:: How @code{mSQL} 2.0 SQL Syntax Differs from MySQL
+@end menu
+
+
+@node Syntax differences, , Protocol differences, Compare mSQL
+@subsubsection How @code{mSQL} 2.0 SQL Syntax Differs from MySQL
+
+@noindent
+@strong{Column types}
+
+@table @code
+@item MySQL
+Has the following additional types (among others;
+@pxref{CREATE TABLE, , @code{CREATE TABLE}}):
+@itemize @bullet
+@item
+@code{ENUM} type for one of a set of strings.
+@item
+@code{SET} type for many of a set of strings.
+@item
+@code{BIGINT} type for 64-bit integers.
+@end itemize
+@item
+MySQL also supports
+the following additional type attributes:
+@itemize @bullet
+@item
+@code{UNSIGNED} option for integer columns.
+@item
+@code{ZEROFILL} option for integer columns.
+@item
+@code{AUTO_INCREMENT} option for integer columns that are a
+@code{PRIMARY KEY}.
+@xref{mysql_insert_id, , @code{mysql_insert_id()}}.
+@item
+@code{DEFAULT} value for all columns.
+@end itemize
+@item mSQL2
+@code{mSQL} column types correspond to the MySQL types shown below:
+@multitable @columnfractions .15 .85
+@item @code{mSQL} @strong{type} @tab @strong{Corresponding MySQL type}
+@item @code{CHAR(len)} @tab @code{CHAR(len)}
+@item @code{TEXT(len)} @tab @code{TEXT(len)}. @code{len} is the maximal length.
+And @code{LIKE} works.
+@item @code{INT} @tab @code{INT}. With many more options!
+@item @code{REAL} @tab @code{REAL}. Or @code{FLOAT}. Both 4- and 8-byte versions are available.
+@item @code{UINT} @tab @code{INT UNSIGNED}
+@item @code{DATE} @tab @code{DATE}. Uses ANSI SQL format rather than @code{mSQL}'s own format.
+@item @code{TIME} @tab @code{TIME}
+@item @code{MONEY} @tab @code{DECIMAL(12,2)}. A fixed-point value with two decimals.
+@end multitable
+@end table
+
+@noindent
+@strong{Index Creation}
+
+@table @code
+@item MySQL
+Indexes may be specified at table creation time with the @code{CREATE TABLE}
+statement.
+@item mSQL
+Indexes must be created after the table has been created, with separate
+@code{CREATE INDEX} statements.
+@end table
+
+@noindent
+@strong{To Insert a Unique Identifier into a Table}
+
+@table @code
+@item MySQL
+Use @code{AUTO_INCREMENT} as a column type
+specifier.
+@xref{mysql_insert_id, , @code{mysql_insert_id()}}.
+@item mSQL
+Create a @code{SEQUENCE} on a table and select the @code{_seq} column.
+@end table
+
+@noindent
+@strong{To Obtain a Unique Identifier for a Row}
+
+@table @code
+@item MySQL
+Add a @code{PRIMARY KEY} or @code{UNIQUE} key to the table and use this.
+New in Version 3.23.11: If the @code{PRIMARY} or @code{UNIQUE} key consists of only one
+column and this is of type integer, one can also refer to it as
+@code{_rowid}.
+@item mSQL
+Use the @code{_rowid} column. Observe that @code{_rowid} may change over time
+depending on many factors.
+@end table
+
+@noindent
+@strong{To Get the Time a Column Was Last Modified}
+
+@table @code
+@item MySQL
+Add a @code{TIMESTAMP} column to the table. This column is automatically set
+to the current date and time for @code{INSERT} or @code{UPDATE} statements if
+you don't give the column a value or if you give it a @code{NULL} value.
+
+@item mSQL
+Use the @code{_timestamp} column.
+@end table
+
+@noindent
+@strong{@code{NULL} Value Comparisons}
+
+@table @code
+@item MySQL
+MySQL follows
+ANSI SQL, and a comparison with @code{NULL} is always @code{NULL}.
+@item mSQL
+In @code{mSQL}, @code{NULL = NULL} is TRUE. You
+must change @code{=NULL} to @code{IS NULL} and @code{<>NULL} to
+@code{IS NOT NULL} when porting old code from @code{mSQL} to MySQL.
+@end table
+
+@noindent
+@strong{String Comparisons}
+
+@table @code
+@item MySQL
+Normally, string comparisons are performed in case-independent fashion with
+the sort order determined by the current character set (ISO-8859-1 Latin1 by
+default). If you don't like this, declare your columns with the
+@code{BINARY} attribute, which causes comparisons to be done according to the
+ASCII order used on the MySQL server host.
+@item mSQL
+All string comparisons are performed in case-sensitive fashion with
+sorting in ASCII order.
+@end table
+
+@noindent
+@strong{Case-insensitive Searching}
+
+@table @code
+@item MySQL
+@code{LIKE} is a case-insensitive or case-sensitive operator, depending on
+the columns involved. If possible, MySQL uses indexes if the
+@code{LIKE} argument doesn't start with a wild-card character.
+@item mSQL
+Use @code{CLIKE}.
+@end table
+
+@noindent
+@strong{Handling of Trailing Spaces}
+
+@table @code
+@item MySQL
+Strips all spaces at the end of @code{CHAR} and @code{VARCHAR}
+columns. Use a @code{TEXT} column if this behavior is not desired.
+@item mSQL
+Retains trailing space.
+@end table
+
+@noindent
+@strong{@code{WHERE} Clauses}
+
+@table @code
+@item MySQL
+MySQL correctly prioritizes everything (@code{AND} is evaluated
+before @code{OR}). To get @code{mSQL} behavior in MySQL, use
+parentheses (as shown in an example below).
+@item mSQL
+Evaluates everything from left to right. This means that some logical
+calculations with more than three arguments cannot be expressed in any
+way. It also means you must change some queries when you upgrade to
+MySQL. You do this easily by adding parentheses. Suppose you
+have the following @code{mSQL} query:
+@example
+mysql> SELECT * FROM table WHERE a=1 AND b=2 OR a=3 AND b=4;
+@end example
+To make MySQL evaluate this the way that @code{mSQL} would,
+you must add parentheses:
+@example
+mysql> SELECT * FROM table WHERE (a=1 AND (b=2 OR (a=3 AND (b=4))));
+@end example
+@end table
+
+@noindent
+@strong{Access Control}
+
+@table @code
+@item MySQL
+Has tables to store grant (permission) options per user, host, and
+database. @xref{Privileges}.
+@item mSQL
+Has a file @file{mSQL.acl} in which you can grant read/write privileges for
+users.
+@item
+@end table
+
+
+@node Compare PostgreSQL, , Compare mSQL, Comparisons
+@subsection How MySQL Compares to PostgreSQL
+
+@cindex PostgreSQL vs. MySQL, overview
+
+When reading the following, please note that both products are continually
+evolving. We at MySQL AB and the PostgreSQL developers are both working
+on making our respective database as good as possible, so we are both a
+serious choice to any commercial database.
+
+The following comparison is made by us at MySQL AB. We have tried to be
+as accurate and fair as possible, but because we don't have a full
+knowledge of all PostgreSQL features while we know MySQL througly, we
+may have got some things wrong. We will however correct these when they
+come to our attention.
+
+We would first like to note that PostgreSQL and MySQL are both widely used
+products, but with different design goals, even if we are both striving to
+be ANSI SQL compatible. This means that for some applications MySQL is
+more suited, while for others PostgreSQL is more suited. When choosing
+which database to use, you should first check if the database's feature set
+satisfies your application. If you need raw speed, MySQL is probably your
+best choice. If you need some of the extra features that only PostgreSQL
+can offer, you should use @code{PostgreSQL}.
+
+@cindex PostgreSQL/MySQL, strategies
+@menu
+* MySQL-PostgreSQL goals:: MySQL and PostgreSQL development strategies
+* MySQL-PostgreSQL features:: Featurewise Comparison of MySQL and PostgreSQL
+* MySQL-PostgreSQL benchmarks:: Benchmarking MySQL and PostgreSQL
+@end menu
+
+
+@node MySQL-PostgreSQL goals, MySQL-PostgreSQL features, Compare PostgreSQL, Compare PostgreSQL
+@subsubsection MySQL and PostgreSQL development strategies
+
+When adding things to MySQL we take pride to do an optimal, definite
+solution. The code should be so good that we shouldn't have any need to
+change it in the foreseeable future. We also do not like to sacrifice
+speed for features but instead will do our utmost to find a solution
+that will give maximal throughput. This means that development will take
+a little longer, but the end result will be well worth this. This kind
+of development is only possible because all server code are checked by
+one of a few (currently two) persons before it's included in the
+MySQL server.
+
+We at MySQL AB believe in frequent releases to be able to push out new
+features quickly to our users. Because of this we do a new small release
+about every three weeks, and a major branch every year. All releases are
+throughly tested with our testing tools on a lot of different platforms.
+
+PostgreSQL is based on a kernel with lots of contributors. In this setup
+it makes sense to prioritize adding a lot of new features, instead of
+implementing them optimally, because one can always optimize things
+later if there arises a need for this.
+
+Another big difference between MySQL and PostgreSQL is that
+nearly all of the code in the MySQL server are coded by developers that
+are employed by MySQL AB and are still working on the server code. The
+exceptions are the transaction engines, and the regexp library.
+
+This is in sharp contrast to the PostgreSQL code where the majority of
+the code is coded by a big group of people with different backgrounds.
+It was only recently that the PostgreSQL developers announced that their
+current developer group had finally had time to take a look at all
+the code in the current PostgreSQL release.
+
+Both of the above development methods has it's own merits and drawbacks.
+We here at MySQL AB think of course that our model is better because our
+model gives better code consistency, more optimal and reusable code, and
+in our opinion, fewer bugs. Because we are the authors of the MySQL server
+code, we are better able to coordinate new features and releases.
+
+
+@node MySQL-PostgreSQL features, MySQL-PostgreSQL benchmarks, MySQL-PostgreSQL goals, Compare PostgreSQL
+@subsubsection Featurewise Comparison of MySQL and PostgreSQL
+
+@cindex PostgreSQL/MySQL, features
+
+On the @uref{http://www.mysql.com/information/crash-me.php, crash-me}
+page you can find a list of those database constructs and limits that
+one can detect automatically with a program. Note however that a lot of
+the numerical limits may be changed with startup options for respective
+database. The above web page is however extremely useful when you want to
+ensure that your applications works with many different databases or
+when you want to convert your application from one datbase to another.
+
+MySQL offers the following advantages over PostgreSQL:
+
+@itemize @bullet
+@item
+@code{MySQL} is generally much faster than PostgreSQL.
+@xref{MySQL-PostgreSQL benchmarks}.
+
+@item
+MySQL has a much larger user base than PostgreSQL, therefor the
+code is more tested and has historically been more stable than
+PostgreSQL. MySQL is the much more used in production
+environments than PostgreSQL, mostly thanks to that MySQL AB,
+formerly TCX DataKonsult AB, has provided top quality commercial support
+for MySQL from the day it was released, whereas until recently
+PostgreSQL was unsupported.
+
+@item
+MySQL works on more platforms than PostgreSQL. @xref{Which OS}.
+
+@item
+MySQL works better on Windows than PostgreSQL does. MySQL runs as a
+native Windows application (a service on NT/Win2000/WinXP), while
+PostgreSQL is run under the cygwin emulation. We have heard that
+PostgreSQL is not yet that stable on Windows but we haven't been able to
+verify this ourselves.
+
+@item
+MySQL has more APIs to other languages and is supported by more
+existing programs than PostgreSQL. @xref{Contrib}.
+
+@item
+MySQL works on 24/7 heavy duty systems. In most circumstances
+you never have to run any cleanups on MySQL. PostgreSQL doesn't
+yet support 24/7 systems because you have to run @code{VACUUM()}
+once in a while to reclaim space from @code{UPDATE} and @code{DELETE}
+commands and to perform statistics analyzes that are critical to get
+good performance with PostgreSQL. @code{VACUUM()} is also needed after
+adding a lot of new rows to a table. On a busy system with lots of changes,
+@code{VACUUM()} must be run very frequently, in the worst cases even
+many times a day. During the @code{VACUUM()} run, which may take hours
+if the database is big, the database is from a production standpoint,
+practically dead. The PostgreSQL team has fixing this on their TODO,
+but we assume that this is not an easy thing to fix permanently.
+
+@item
+A working, tested replication feature used by sites like:
+@itemize @minus
+@item Yahoo Finance (@uref{http://finance.yahoo.com})
+@item Mobile.de (@uref{http://www.mobile.de/})
+@item Slashdot (@uref{http://www.slashdot.org})
+@end itemize
+
+@item
+Included in the MySQL distribution are two different testing suites,
+@file{mysql-test-run} and
+@uref{http://www.mysql.com/information/crash-me.php,crash-me}, as well
+as a benchmark suite. The test system is actively updated with code to
+test each new feature and almost all repeatable bugs that have come to
+our attention. We test MySQL with these on a lot of platforms before
+every release. These tests are more sophisticated than anything we have
+seen from PostgreSQL, and they ensures that the MySQL is kept to a high
+standard.
+
+@item
+There are far more books in print about MySQL than about PostgreSQL.
+O'Reilly, Sams, Que, and New Riders are all major publishers with books
+about MySQL. All MySQL features are also documented in the MySQL on-line
+manual, because when a new feature is implemented, the MySQL developers
+are required to document it before it's included in the source.
+
+@item
+MySQL supports more of the standard ODBC functions than @code{PostgreSQL}.
+
+@item
+MySQL has a much more sophisticated @code{ALTER TABLE}.
+
+@item
+MySQL has support for tables without transactions for applications that
+need all speed they can get. The tables may be memory based, @code{HEAP}
+tables or disk based @code{MyISAM}. @xref{Table types}.
+
+@item
+MySQL has support for two different table handlers that support
+transactions, @code{BerkeleyDB} and @code{InnoDB}. Because every
+transaction engine performs differently under different conditions, this
+gives the application writer more options to find an optimal solution for
+his or her setup. @xref{Table types}.
+
+@item
+@code{MERGE} tables gives you a unique way to instantly make a view over
+a set of identical tables and use these as one. This is perfect for
+systems where you have log files that you order for example by month.
+@xref{MERGE}.
+
+@item
+The option to compress read-only tables, but still have direct access to
+the rows in the table, gives you better performance by minimizing disk
+reads. This is very useful when you are archiving things.
+@xref{myisampack}.
+
+@item
+MySQL has internal support for fulltext search. @xref{Fulltext Search}.
+
+@item
+You can access many databases from the same connection (depending of course
+on your privileges).
+
+@item
+MySQL is coded from the start to be multi-threaded while PostgreSQL uses
+processes. Context switching and access to common storage areas is much
+faster between threads than between separate processes, this gives MySQL
+a big speed advantage in multi-user applications and also makes it easier
+for MySQL to take full advantage of symmetric multiprocessor (SMP) systems.
+
+@item
+MySQL has a much more sophisticated privilege system than PostgreSQL.
+While PostgreSQL only supports @code{INSERT}, @code{SELECT}, and
+@code{UPDATE/DELETE} grants per user on a database or a table, MySQL allows
+you to define a full set of different privileges on database, table and
+column level. MySQL also allows you to specify the privilege on host and
+user combinations. @xref{GRANT}.
+
+@item
+MySQL supports a compressed client/server protocol which improves
+performance over slow links.
+
+@item
+MySQL employs a ``table handler'' concept, and is the only relational
+database we know of built around this concept. This allows different
+low-level table types to be swapped into the SQL engine, and each table
+type can be optimized for different performance characteristics.
+
+@item
+All MySQL table types (except @strong{InnoDB}) are implemented as files
+(one table per file), which makes it really easy to backup, move, delete
+and even symlink databases and tables, even when the server is down.
+
+@item
+Tools to repair and optimize @strong{MyISAM} tables (the most common
+MySQL table type). A repair tool is only needed when a physical corruption
+of a data file happens, usually from a hardware failure. It allows a
+majority of the data to be recovered.
+
+@item
+Upgrading MySQL is painless. When you are upgrading MySQL, you don't need
+to dump/restore your data, as you have to do with most PostgreSQL upgrades.
+@end itemize
+
+Drawbacks with MySQL compared to PostgreSQL:
+
+@itemize @bullet
+@item
+The transaction support in MySQL is not yet as well tested as PostgreSQL's
+system.
+
+@item
+Because MySQL uses threads, which are not yet flawless on many OSes, one
+must either use binaries from @uref{http://www.mysql.com/downloads}, or
+carefully follow our instructions on
+@uref{http://www.mysql.com/doc/I/n/Installing_source.html} to get an
+optimal binary that works in all cases.
+
+@item
+Table locking, as used by the non-transactional @code{MyISAM} tables, is
+in many cases faster than page locks, row locks or versioning. The
+drawback however is that if one doesn't take into account how table
+locks work, a single long-running query can block a table for updates
+for a long time. This can usable be avoided when designing the
+application. If not, one can always switch the trouble table to use one
+of the transactional table types. @xref{Table locking}.
+
+@item
+With UDF (user defined functions) one can extend MySQL with both normal
+SQL functions and aggregates, but this is not yet as easy or as flexible
+as in PostgreSQL. @xref{Adding functions}.
+
+@item
+Updates and deletes that run over multiple tables is harder to do in
+MySQL. This will, hoever, be fixed in MySQL 4.0 with multi-table
+@code{DELETE} and multi-table @code{UPDATE} and in MySQL 4.1
+with subselects.
+@end itemize
+
+PostgreSQL currently offers the following advantages over MySQL:
+
+Note that because we know the MySQL road map, we have included in the
+following table the version when MySQL should support this feature.
+Unfortunately we couldn't do this for previous comparison, because we
+don't know the PostgreSQL roadmap.
+
+@multitable @columnfractions .70 .30
+@item @strong{Feature} @tab @strong{MySQL version}
+@item Subselects @tab 4.1
+@item Foreign keys @tab 4.0 and 4.1
+@item Views @tab 4.2
+@item Stored procedures @tab 4.1
+@item Extensible type system @tab Not planned
+@item Unions @tab 4.0
+@item Full join @tab 4.0 or 4.1
+@item Triggers @tab 4.1
+@item Constrainst @tab 4.1
+@item Cursors @tab 4.1 or 4.2
+@item Extensible index types like R-trees @tab R-trees are planned for 4.2
+@item Inherited tables @tab Not planned
+@end multitable
+
+Other reasons to use PostgreSQL:
+
+@itemize @bullet
+@item
+Standard usage in PostgreSQL is closer to ANSI SQL in some cases.
+
+@item
+One can speed up PostgreSQL by coding things as stored procedures.
+
+@item
+PostgreSQL has a bigger team of developers that contribute to the server.
+@end itemize
+
+Drawbacks with PostgreSQL compared to MySQL:
+
+@itemize @bullet
+@item
+@code{VACUUM()} makes PostgreSQL hard to use in a 24/7 environment.
+
+@item
+Only transactional tables.
+
+@item
+Much slower @code{INSERT}, @code{DELETE}, and @code{UPDATE}.
+@end itemize
+
+For a complete list of drawbacks, you should also examine the first table
+in this section.
+
+@menu
+* MySQL-PostgreSQL benchmarks:: Benchmarking MySQL and PostgreSQL
+@end menu
+
+
+@node MySQL-PostgreSQL benchmarks, , MySQL-PostgreSQL features, Compare PostgreSQL
+@subsubsection Benchmarking MySQL and PostgreSQL
+
+@cindex PostgreSQL vs. MySQL, benchmarks
+
+The only open source benchmark that we know of that can be used to
+benchmark MySQL and PostgreSQL (and other databases) is our own. It can
+be found at @uref{http://www.mysql.com/information/benchmarks.html}.
+
+We have many times asked the PostgreSQL developers and some PostgreSQL
+users to help us extend this benchmark to make it the definitive benchmark
+for databases, but unfortunately we haven't gotten any feedback for this.
+
+We the MySQL developers have, because of this, spent a lot of hours to get
+maximum performance from PostgreSQL for the benchmarks, but because we
+don't know PostgreSQL intimately, we are sure that there are things that
+we have missed. We have on the benchmark page documented exactly how we
+did run the benchmark so that it should be easy for anyone to repeat and
+verify our results.
+
+The benchmarks are usually run with and without the @code{--fast} option.
+When run with @code{--fast} we are trying to use every trick the server can
+do to get the code to execute as fast as possible. The idea is that the
+normal run should show how the server would work in a default setup and
+the @code{--fast} run shows how the server would do if the application
+developer would use extensions in the server to make his application run
+faster.
+
+When running with PostgreSQL and @code{--fast} we do a @code{VACUUM()}
+after every major table @code{UPDATE} and @code{DROP TABLE} to make the
+database in perfect shape for the following @code{SELECT}s. The time for
+@code{VACUUM()} is measured separately.
+
+When running with PostgreSQL 7.1.1 we could, however, not run with
+@code{--fast} because during the @code{INSERT} test, the postmaster (the
+PostgreSQL deamon) died and the database was so corrupted that it was
+impossible to restart postmaster. After this happened twice, we decided
+to postpone the @code{--fast} test until next PostgreSQL release. The
+details about the machine we run the benchmark can be found on the
+benchmark page.
+
+Before going to the other benchmarks we know of, we would like to give
+some background on benchmarks:
+
+It's very easy to write a test that shows ANY database to be best
+database in the world, by just restricting the test to something the
+database is very good at and not test anything that the database is not
+good at. If one after this publishes the result with a single figure,
+things are even easier.
+
+This would be like us measuring the speed of MySQL compared to PostgreSQL
+by looking at the summary time of the MySQL benchmarks on our web page.
+Based on this MySQL would be more than 40 times faster than PostgreSQL,
+something that is of course not true. We could make things even worse
+by just taking the test where PostgreSQL performs worst and claim that
+MySQL is more than 2000 times faster than PostgreSQL.
+
+The case is that MySQL does a lot of optimizations that PostgreSQL doesn't
+do and the other way around. An SQL optimizer is a very complex thing, and
+a company could spend years on just making the optimizer faster and faster.
+
+When looking at the benchmark results you should look for things that
+you do in your application and just use these results to decide which
+database would be best suited for your application. The benchmark
+results also shows things a particular database is not good at and should
+give you a notion about things to avoid and what you may have to do in
+other ways.
+
+We know of two benchmark tests that claims that PostgreSQL performs better
+than MySQL. These both where multi-user tests, a test that we here at
+MySQL AB haven't had time to write and include in the benchmark suite,
+mainly because it's a big task to do this in a manner that is fair against
+all databases.
+
+One is the benchmark paid for by Great Bridge, which you can read about at:
+@uref{http://www.greatbridge.com/about/press.php?content_id=4}.
+
+This is the probably worst benchmark we have ever seen anyone conduct. This
+was not only tuned to only test what PostgreSQL is absolutely best at, it
+was also totally unfair against every other database involved in the test.
+
+@strong{NOTE}: We know that not even some of the main PostgreSQL
+developers did like the way Great Bridge conducted the benchmark, so we
+don't blame them for the way the benchmark was made.
+
+This benchmark has been condemned in a lot of postings and newsgroups so
+we will here just shortly repeat some things that where wrong with it.
+
+@itemize @bullet
+@item
+The tests were run with an expensive commercial tool, that makes it
+impossible for an open source company like us to verify the benchmarks,
+or even check how the benchmarks were really done. The tool is not even
+a true benchmark tool, but an application/setup testing tool. To refer
+this as a ``standard'' benchmark tool is to stretch the truth a long way.
+
+@item
+Great Bridge admitted that they had optimized the PostgreSQL database
+(with @code{VACUUM()} before the test) and tuned the startup for the tests,
+something they hadn't done for any of the other databases involved. To
+say ``This process optimizes indexes and frees up disk space a bit. The
+optimized indexes boost performance by some margin.'' Our benchmarks
+clearly indicate that the difference in running a lot of selects on a
+database with and without @code{VACUUM()} can easily differ by a factor
+of ten.
+
+@item
+The test results were also strange. The AS3AP test documentation
+mentions that the test does ``selections, simple joins, projections,
+aggregates, one-tuple updates, and bulk updates''.
+
+PostgreSQL is good at doing @code{SELECT}s and @code{JOIN}s (especially
+after a @code{VACUUM()}), but doesn't perform as well on @code{INSERT}s or
+@code{UPDATE}s. The benchmarks seem to indicate that only @code{SELECT}s
+were done (or very few updates). This could easily explain they good results
+for PostgreSQL in this test. The bad results for MySQL will be obvious a
+bit down in this document.
+
+@item
+They did run the so-called benchmark from a Windows machine against a
+Linux machine over ODBC, a setup that no normal database user would ever
+do when running a heavy multi-user application. This tested more the
+ODBC driver and the Windows protocol used between the clients than the
+database itself.
+
+@item
+When running the database against Oracle and MS-SQL (Great Bridge has
+indirectly indicated that the databases they used in the test), they
+didn't use the native protocol but instead ODBC. Anyone that has ever
+used Oracle knows that all real application uses the native interface
+instead of ODBC. Doing a test through ODBC and claiming that the results
+had anything to do with using the database in a real-world situation can't
+be regarded as fair. They should have done two tests with and without ODBC
+to provide the right facts (after having got experts to tune all involved
+databases of course).
+
+@item
+They refer to the TPC-C tests, but they don't mention anywhere that the
+test they did was not a true TPC-C test and they were not even allowed to
+call it a TPC-C test. A TPC-C test can only be conducted by the rules
+approved by the TPC Council (@uref{http://www.tpc.org}). Great Bridge
+didn't do that. By doing this they have both violated the TPC trademark
+and miscredited their own benchmarks. The rules set by the TPC Council
+are very strict to ensure that no one can produce false results or make
+unprovable statements. Apparently Great Bridge wasn't interested in
+doing this.
+
+@item
+After the first test, we contacted Great Bridge and mentioned to them
+some of the obvious mistakes they had done with MySQL:
+
+@itemize @minus
+@item
+Running with a debug version of our ODBC driver
+
+@item
+Running on a Linux system that wasn't optimized for threads
+
+@item
+Using an old MySQL version when there was a recommended newer one available
+
+@item
+Not starting MySQL with the right options for heavy multi-user use (the
+default installation of MySQL is tuned for minimal resource use).
+@end itemize
+
+Great Bridge did run a new test, with our optimized ODBC driver and with
+better startup options for MySQL, but refused to either use our updated
+glibc library or our standard binary (used by 80% of our users), which was
+statically linked with a fixed glibc library.
+
+According to what we know, Great Bridge did nothing to ensure that the
+other databases were set up correctly to run well in their test
+environment. We are sure however that they didn't contact Oracle or
+Microsoft to ask for their advice in this matter ;)
+
+@item
+The benchmark was paid for by Great Bridge, and they decided to publish
+only partial, chosen results (instead of publishing it all).
+@end itemize
+
+Tim Perdue, a long time PostgreSQL fan and a reluctant MySQL user
+published a comparison on
+@uref{http://www.phpbuilder.com/columns/tim20001112.php3,phpbuider}.
+
+When we became aware of the comparison, we phoned Tim Perdue about this
+because there were a lot of strange things in his results. For example,
+he claimed that MySQL had a problem with five users in his tests, when we
+know that there are users with similar machines as his that are using
+MySQL with 2000 simultaneous connections doing 400 queries per second.
+(In this case the limit was the web bandwidth, not the database.)
+
+It sounded like he was using a Linux kernel that either had some
+problems with many threads, such as kernels before 2.4, which had a problem
+with this but we have documented how to fix this and Tim should be aware of
+this problem. The other possible problem could have been an old glibc
+library and that Tim didn't use a MySQL binary from our site, which is
+linked with a corrected glibc library, but had compiled a version of his
+own with. In any of the above cases, the symptom would have been exactly
+what Tim had measured.
+
+We asked Tim if we could get access to his data so that we could repeat
+the benchmark and if he could check the MySQL version on the machine to
+find out what was wrong and he promised to come back to us about this.
+He has not done that yet.
+
+Because of this we can't put any trust in this benchmark either :(
+
+Conclusion:
+
+The only benchmarks that exist today that anyone can download and run
+against MySQL and PostgreSQL is the MySQL benchmarks. We here at MySQL
+believe that open source databases should be tested with open source tools!
+This is the only way to ensure that no one does tests that nobody can
+reproduce and use this to claim that a database is better than another.
+Without knowing all the facts it's impossible to answer the claims of the
+tester.
+
+The thing we find strange is that every test we have seen about
+PostgreSQL, that is impossible to reproduce, claims that PostgreSQL is
+better in most cases while our tests, which anyone can reproduce,
+clearly shows otherwise. With this we don't want to say that PostgreSQL
+isn't good at many things (it is!). We would just like to see a fair test
+where they are very good so that we could get some friendly competition
+going!
+
+For more information about our benchmarks suite @xref{MySQL Benchmarks}.
+
+We are working on an even better benchmark suite, including much better
+documentation of what the individual tests really do, and how to add more
+tests to the suite.
+
+
+@node TODO, , Comparisons, Introduction
+@section MySQL and the future (The TODO)
+
+@cindex ToDo list for MySQL
+
+@menu
+* TODO MySQL 4.0:: Things that should be in Version 4.0
+* TODO future:: Things that must be done in the near future
+* TODO sometime:: Things that have to be done sometime
+* TODO unplanned:: Some things we don't have any plans to do
+@end menu
+
+This appendix lists the features that we plan to implement in MySQL.
+
+Everything in this list is approximately in the order it will be done. If you
+want to affect the priority order, please register a license or support us and
+tell us what you want to have done more quickly. @xref{Licensing and Support}.
+
+The plan is that we in the future will support the full ANSI SQL99
+standard, but with a lot of useful extensions. The challenge is to do
+this without sacrifying the speed or compromise the code.
+
+
+@node TODO MySQL 4.0, TODO future, TODO, TODO
+@subsection Things that should be in 4.0
+
+We plan to make MySQL Version 4.0 a ``quick'' release where we only
+add some new stuff to enable others to help us with developing new features
+into Version 4.1. The MySQL 4.0 version should only take us about
+a month to make after which we want to stabilize it and start working on
+Version 4.1. Version 4.0 should have the following new features:
+
+The news section for 4.0 includes a list of the features we have already
+implemented in the 4.0 tree. @xref{News-4.0.x}.
+
+@itemize @bullet
+@item
+New table definition file format (@code{.frm} files) This will enable us
+to not run out of bits when adding more table options. One will still
+be able to use the old @code{.frm} file format with 4.0. All newly created
+tables will, however, use the new format.
+
+The new file format will enable us to add new column types, more options
+for keys and @code{FOREIGN KEY} support.
+@item
+@code{mysqld} as a library. This will have the same interface as the
+standard MySQL client (with an extra function to just set up
+startup parameters) but will be faster (no TCP/IP or socket overhead),
+smaller and much easier to use for embedded products.
+
+One will be able to define at link time if one wants to use the
+client/server model or a stand-alone application just by defining which
+library to link with.
+
+The @code{mysqld} will support all standard MySQL features and
+one can use it in a threaded client to run different queries in each
+thread.
+@item
+Replication should work with @code{RAND()} and user variables @code{@@var}.
+@item
+Online backup with very low performance penalty. The online backup will
+make it easy to add a new replication slave without taking down the
+master.
+@item
+@code{DELETE FROM table_name} will return the number of deleted rows. For
+fast execution one should use @code{TRUNCATE table_name}.
+@item
+Allow @code{DELETE} on @code{MyISAM} tables to use the record cache.
+To do this, we need to update the threads record cache when we update
+the @code{.MYD} file.
+@item
+Better replication.
+@item
+More functions for full-text search.
+@xref{Fulltext Features to Appear in MySQL 4.0}.
+@item
+Character set casts and syntax for handling multiple character sets.
+@item
+Allow users to change startup options without taking down the server.
+@item
+Help for all commands from the client.
+@item
+Secure connections (with SSL).
+@item
+Extend the optimizer to be able to optimize some @code{ORDER BY key_name DESC}
+queries.
+@item
+@code{SHOW COLUMNS FROM table_name} (used by @code{mysql} client to allow
+expansions of column names) should not open the table, but only the
+definition file. This will require less memory and be much faster.
+@item
+New key cache
+@item
+When using @code{SET CHARACTER SET} we should translate the whole query
+at once and not only strings. This will enable users to use the translated
+characters in database, table and column names.
+@item
+Add a portable interface over @code{gethostbyaddr_r()} so that we can change
+@code{ip_to_hostname()} to not block other threads while doing DNS lookups.
+@item
+Add @code{record_in_range()} method to @code{MERGE} tables to be
+able to choose the right index when there is many to choose from. We should
+also extend the info interface to get the key distribution for each index,
+of @code{analyze} is run on all sub tables.
+@item
+@code{SET SQL_DEFAULT_TABLE_TYPE=[MyISAM | INNODB | BDB | HEAP]}.
+@end itemize
+
+
+@node TODO future, TODO sometime, TODO MySQL 4.0, TODO
+@subsection Things that must be done in the real near future
+
+@itemize @bullet
+@item
+Fail safe replication.
+@item
+Subqueries.
+@code{select id from t where grp in (select grp from g where u > 100)}
+@item
+Derived tables.
+@example
+select a.col1, b.col2 from (select max(col1) as col1 from root_table ) a,
+other_table b where a.col1=b.col1
+@end example
+
+This could be done by automatically creating temporary tables for the
+derived tables for the duration of the query.
+@item
+Add @code{PREPARE} of statements and sending of parameters to @code{mysqld}.
+@item
+Extend the server/client protocol to support warnings.
+@item
+Add options to the server/protocol protocol to get progress notes
+for long running commands.
+@item
+Add database and real table name (in case of alias) to the MYSQL_FIELD
+structure.
+@item
+Don't allow more than a defined number of threads to run MyISAM recover
+at the same time.
+@item
+Change @code{INSERT ... SELECT} to optionally use concurrent inserts.
+@item
+Implement @code{RENAME DATABASE}. To make this safe for all table handlers,
+it should work as follows:
+@itemize @bullet
+@item
+Create the new database.
+@item
+For every table do a rename of the table to another database, as
+we do with the @code{RENAME} command.
+@item
+Drop the old database.
+@end itemize
+@item
+Return the original field types() when doing @code{SELECT MIN(column)
+... GROUP BY}.
+@item
+Multiple result sets.
+@item
+Change the protocol to allow binary transfer of values. To do this
+efficiently, we need to add an API to allow binding of variables.
+@item
+Make it possible to specify @code{long_query_time} with a granularity
+in microseconds.
+@item
+Add a configurable prompt to the @code{mysql} command line client, with
+options like database in use, time and date...
+@item
+Add range checking to @code{MERGE} tables.
+@item
+Link the @code{myisampack} code into the server.
+@item
+Port of MySQL to BeOS.
+@item
+Port of the MySQL clients to LynxOS.
+@item
+Add a temporary key buffer cache during @code{INSERT/DELETE/UPDATE} so that we
+can gracefully recover if the index file gets full.
+@item
+If you perform an @code{ALTER TABLE} on a table that is symlinked to another
+disk, create temporary tables on this disk.
+@item
+Implement a @code{DATE/DATETIME} type that handles time zone information
+properly, so that dealing with dates in different time zones is easier.
+@item
+FreeBSD and MIT-pthreads; Do sleeping threads take CPU?
+@item
+Check if locked threads take any CPU.
+@item
+Fix configure so that one can compile all libraries (like @code{MyISAM})
+without threads.
+@item
+Add an option to periodically flush key pages for tables with delayed keys
+if they haven't been used in a while.
+@item
+Allow join on key parts (optimization issue).
+@item
+@code{INSERT SQL_CONCURRENT} and @code{mysqld --concurrent-insert} to do
+a concurrent insert at the end of the file if the file is read-locked.
+@item
+Remember @code{FOREIGN} key definitions in the @file{.frm} file.
+@item
+Cascading @code{DELETE}
+@item
+Server side cursors.
+@item
+Check if @code{lockd} works with modern Linux kernels; If not, we have
+to fix @code{lockd}! To test this, start @code{mysqld} with
+@code{--enable-locking} and run the different fork* test suits. They shouldn't
+give any errors if @code{lockd} works.
+@item
+Allow SQL variables in @code{LIMIT}, like in @code{LIMIT @@a,@@b}.
+@item
+Allow update of variables in @code{UPDATE} statements. For example:
+@code{UPDATE TABLE foo SET @@a=a+b,a=@@a, b=@@a+c}
+@item
+Change when user variables are updated so that one can use them with
+@code{GROUP BY}, as in the following example:
+@code{SELECT id, @@a:=count(*), sum(sum_col)/@@a FROM table_name GROUP BY id}.
+@item
+Don't add automatic @code{DEFAULT} values to columns. Give an error when using
+an @code{INSERT} that doesn't contain a column that doesn't have a
+@code{DEFAULT}.
+@item
+Caching of queries and results. This should be done as a separated
+module that examines each query and if this is query is in the cache
+the cached result should be returned. When one updates a table one
+should remove as few queries as possible from the cache.
+This should give a big speed bost on machines with much RAM where
+queries are often repeated (like WWW applications).
+One idea would be to only cache queries of type:
+@code{SELECT CACHED ...}
+@item
+Fix @file{libmysql.c} to allow two @code{mysql_query()} commands in a row
+without reading results or give a nice error message when one does this.
+@item
+Optimize @code{BIT} type to take 1 bit (now @code{BIT} takes 1 char).
+@item
+Check why MIT-pthreads @code{ctime()} doesn't work on some FreeBSD systems.
+@item
+Add an @code{IMAGE} option to @code{LOAD DATA INFILE} to not update
+@code{TIMESTAMP} and @code{AUTO_INCREMENT} fields.
+@item
+Added @code{LOAD DATE INFILE.. UPDATE} syntax.
+@itemize @bullet
+@item
+For tables with primary keys, if the data contains the primary key,
+entries matching that primary key are updated from the remainder of the
+columns. However, columns MISSING from the incoming data feed are not
+touched.
+@item
+For tables tables with primary keys that are missing some part of the key
+in the incoming data stream, or that have no primary key, the feed is
+treated as a @code{LOAD DATA INFILE ... REPLACE INTO} is now.
+@end itemize
+@item
+Make @code{LOAD DATA INFILE} understand syntax like:
+@example
+LOAD DATA INFILE 'file_name.txt' INTO TABLE tbl_name
+TEXT_FIELDS (text_field1, text_field2, text_field3)
+SET table_field1=concatenate(text_field1, text_field2), table_field3=23
+IGNORE text_field3
+
+This can be used to skip over extra columns in the text file, or update columns
+based on expressions of the read data...
+@end example
+@item
+@code{LOAD DATA INFILE 'file_name' INTO TABLE 'table_name' ERRORS TO err_table_name}
+This would cause any errors and warnings to be logged into the err_table_name
+table. That table would have a structure like:
+
+@example
+line_number - line number in data file
+error_message - the error/warning message
+and maybe
+data_line - the line from the data file
+@end example
+@item
+Add true @code{VARCHAR} support (There is already support for this in MyISAM).
+@item
+Automatic output from @code{mysql} to netscape.
+@item
+@code{LOCK DATABASES}. (with various options)
+@item
+Change sort to allocate memory in ``hunks'' to get better memory utilization.
+@item
+@code{DECIMAL} and @code{NUMERIC} types can't read exponential numbers;
+@code{Field_decimal::store(const char *from,uint len)} must be recoded
+to fix this.
+@item
+Fix @code{mysql.cc} to do fewer @code{malloc()} calls when hashing field
+names.
+@item
+Functions:
+ADD_TO_SET(value,set) and REMOVE_FROM_SET(value,set)
+@item
+Add use of @code{t1 JOIN t2 ON ...} and @code{t1 JOIN t2 USING ...}
+Currently, you can only use this syntax with @code{LEFT JOIN}.
+@item
+Add full support for @code{unsigned long long} type.
+@item
+Many more variables for @code{show status}. Counts for:
+@code{INSERT}/@code{DELETE}/@code{UPDATE} statements. Records reads and
+updated. Selects on 1 table and selects with joins. Mean number of
+tables in select. Number of @code{ORDER BY} and @code{GROUP BY} queries.
+@item
+If you abort @code{mysql} in the middle of a query, you should open
+another connection and kill the old running query.
+Alternatively, an attempt should be made to detect this in the server.
+@item
+Add a handler interface for table information so you can use it as a system
+table. This would be a bit slow if you requested information about all tables,
+but very flexible. @code{SHOW INFO FROM tbl_name} for basic table information
+should be implemented.
+@item
+Add support for UNICODE.
+@item
+@code{NATURAL JOIN} and @code{UNION JOIN}
+@item
+Allow @code{select a from crash_me left join crash_me2 using (a)}; In this
+case a is assumed to come from the crash_me table.
+@item
+Fix that @code{ON} and @code{USING} works with the @code{JOIN} and
+@code{INNER JOIN} join types.
+@item
+Oracle like @code{CONNECT BY PRIOR ...} to search hierarchy structures.
+@item
+@code{RENAME DATABASE}
+@item
+@code{mysqladmin copy database new-database}. -- Requires COPY command to be
+added to @code{mysqld}
+@item
+Processlist should show number of queries/thread.
+@item
+@code{SHOW HOSTS} for printing information about the hostname cache.
+@item
+@code{DELETE} and @code{REPLACE} options to the @code{UPDATE} statement
+(this will delete rows when one gets a duplicate key error while updating).
+@item
+Change the format of @code{DATETIME} to store fractions of seconds.
+@item
+Add all missing ANSI92 and ODBC 3.0 types.
+@item
+Change table names from empty strings to @code{NULL} for calculated columns.
+@item
+Don't use 'Item_copy_string' on numerical values to avoid
+number->string->number conversion in case of:
+@code{SELECT COUNT(*)*(id+0) FROM table_name GROUP BY id}
+@item
+Make it possible to use the new GNU regexp library instead of the current
+one (The GNU library should be much faster than the old one).
+@item
+Change that @code{ALTER TABLE} doesn't abort clients that executes
+@code{INSERT DELAYED}.
+@item
+Fix that when columns referenced in an @code{UPDATE} clause contains the old
+values before the update started.
+@item
+@code{myisamchk}, @code{REPAIR} and @code{OPTIMIZE TABLE} should be able
+to handle cases where the data and/or index files are symbolic links.
+@item
+Add simulation of @code{pread()}/@code{pwrite()} on Windows to enable
+concurrent inserts.
+@item
+A logfile analyzer that could parsed out information about which tables
+are hit most often, how often multi-table joins are executed, etc. It
+should help users identify areas or table design that could be optimized
+to execute much more efficient queries.
+@item
+Add @code{SUM(DISTINCT)}
+@item
+Add @code{ANY()},@code{EVERY()} and @code{SOME()} group functions. In
+ANSI SQL these only works on boolean columns, but we can extend these to
+work on any columns/expressions by applying: value == 0 -> FALSE and
+value <> 0 -> TRUE.
+@item
+Fix that the type for @code{MAX(column)} is the same as the column type.
+@example
+create table t1 (a DATE);
+insert into t1 values (now());
+create table t2 select max(a) from t1;
+show columns from t2;
+@end example
+@item
+Come up with a nice syntax for a statement that will @code{UPDATE} the row
+if it exists and @code{INSERT} a new row if the row didn't exist.
+(Like @code{REPLACE} works with @code{INSERT} / @code{DELETE})
+@end itemize
+
+
+@node TODO sometime, TODO unplanned, TODO future, TODO
+@subsection Things that have to be done sometime
+
+@itemize @bullet
+@item
+Implement function: @code{get_changed_tables(timeout,table1,table2,...)}
+@item
+Atomic multi-table updates, eg @code{update items,month set
+items.price=month.price where items.id=month.id;};
+@item
+Change reading through tables to use memmap when possible. Now only
+compressed tables use memmap.
+@item
+Add a new privilege @strong{'Show_priv'} for @code{SHOW} commands.
+@item
+Make the automatic timestamp code nicer. Add timestamps to the update
+log with @code{SET TIMESTAMP=#;}
+@item
+Use read/write mutex in some places to get more speed.
+@item
+Full foreign key support. One probably wants to implement a procedural
+language first.
+@item
+Simple views (first on one table, later on any expression).
+@item
+Automatically close some tables if a table, temporary table or temporary files
+gets error 23 (not enough open files).
+@item
+When one finds a field=#, change all occurrences of field to #. Now this
+is only done for some simple cases.
+@item
+Change all const expressions with calculated expressions if possible.
+@item
+Optimize key = expression. At the moment only key = field or key =
+constant are optimized.
+@item
+Join some of the copy functions for nicer code.
+@item
+Change @file{sql_yacc.yy} to an inline parser to reduce its size and get
+better error messages (5 days).
+@item
+Change the parser to use only one rule per different number of arguments
+in function.
+@item
+Use of full calculation names in the order part. (For ACCESS97)
+@item
+@code{UNION}, @code{MINUS}, @code{INTERSECT} and @code{FULL OUTER JOIN}.
+(Currently only @code{LEFT OUTER JOIN} is supported)
+@item
+Allow @code{UNIQUE} on fields that can be @code{NULL}.
+@item
+@code{SQL_OPTION MAX_SELECT_TIME=#} to put a time limit on a query.
+@item
+Make the update log to a database.
+@item
+Negative @code{LIMIT} to retrieve data from the end.
+@item
+Alarm around client connect/read/write functions.
+@item
+Please note the changes to @code{safe_mysqld}: according to FSSTND (which
+Debian tries to follow) PID files should go into @file{/var/run/<progname>.pid}
+and log files into @file{/var/log}. It would be nice if you could put the
+"DATADIR" in the first declaration of "pidfile" and "log", so the
+placement of these files can be changed with a single statement.
+@item
+Allow a client to request logging.
+@item
+Add use of @code{zlib()} for @code{gzip}-ed files to @code{LOAD DATA INFILE}.
+@item
+Fix sorting and grouping of @code{BLOB} columns (partly solved now).
+@item
+Stored procedures. This is currently not regarded to be very
+important as stored procedures are not very standardized yet.
+Another problem is that true stored procedures make it much harder for
+the optimizer and in many cases the result is slower than before
+We will, on the other hand, add a simple (atomic) update language that
+can be used to write loops and such in the MySQL server.
+@item
+Change to use semaphores when counting threads. One should first implement
+a semaphore library to MIT-pthreads.
+@item
+Don't assign a new @code{AUTO_INCREMENT} value when one sets a column to 0.
+Use @code{NULL} instead.
+@item
+Add full support for @code{JOIN} with parentheses.
+@item
+As an alternative for one thread / connection manage a pool of threads
+to handle the queries.
+@item
+Allow one to get more than one lock with @code{GET_LOCK}. When doing this,
+one must also handle the possible deadlocks this change will introduce.
+@end itemize
+
+Time is given according to amount of work, not real time.
+
+
+@node TODO unplanned, , TODO sometime, TODO
+@subsection Some things we don't have any plans to do
+
+@itemize @bullet
+@item
+Nothing; In the long run we plan to be fully ANSI 92 / ANSI 99 compliant.
+@end itemize
+
+
+
+
+@node Installing, Tutorial, Introduction, Top
+@chapter MySQL Installation
+
@cindex installing, overview
@menu
-* Getting MySQL:: How to get @strong{MySQL}
-* Which OS:: Operating systems supported by @strong{MySQL}
-* Which version:: Which @strong{MySQL} version to use
-* Many versions:: How and when updates are released
-* Installation layouts:: Installation layouts
-* Installing binary:: Installing a @strong{MySQL} binary distribution
-* Installing source:: Installing a @strong{MySQL} source distribution
-* Installing source tree:: Installing @strong{MySQL} from development source tree
-* Compilation problems:: Problems compiling?
-* MIT-pthreads:: MIT-pthreads notes
-* Perl support:: Perl installation comments
-* Source install system issues:: System-specific issues
-* Windows:: Windows notes
-* OS/2:: OS/2 notes
-* MySQL binaries:: MySQL binaries
-* Post-installation:: Post-installation setup and testing
-* Installing many servers:: Installing many servers on the same machine
-* Upgrade:: Upgrading/Downgrading MySQL
+* Quick Standard Installation:: Quick Standard Installation of MySQL
+* General Installation Issues:: General Installation Issues
+* Installing source:: Installing a MySQL source distribution
+* Post-installation:: Post-installation setup and testing
+* Upgrade:: Upgrading/Downgrading MySQL
+* Operating System Specific Notes:: Operating System Specific Notes
@end menu
-This chapter describes how to obtain and install @strong{MySQL}:
+This chapter describes how to obtain and install MySQL:
@itemize @bullet
@item
-For a list of sites from which you can obtain @strong{MySQL}, see
-@ref{Getting MySQL, , Getting @strong{MySQL}}.
+For a list of sites from which you can obtain MySQL, see
+@ref{Getting MySQL, , Getting MySQL}.
@item
To see which platforms are supported, see @ref{Which OS}. Please note that
-not all supported system are equally good for running @strong{MySQL} on them.
+not all supported system are equally good for running MySQL on them.
On some it is much more robust and efficient than others - see @ref{Which OS}
for details.
@item
-Several versions of @strong{MySQL} are available in both binary and
+Several versions of MySQL are available in both binary and
source distributions. We also provide public access to our current
source tree for those who want to see our most recent developments and
help us test new code. To determine which version and type of
@@ -4289,27 +6184,205 @@ into.
@item
For post-installation procedures, see @ref{Post-installation}. These
-procedures apply whether you install @strong{MySQL} using a binary or
+procedures apply whether you install MySQL using a binary or
source distribution.
@end itemize
+
+@node Quick Standard Installation, General Installation Issues, Installing, Installing
+@section Quick Standard Installation of MySQL
+
+@c This node name is special
+@menu
+* Linux-RPM:: Installing MySQL on Linux
+* Windows installation:: Installing MySQL on Windows
+@end menu
+
+
+@node Linux-RPM, Windows installation, Quick Standard Installation, Quick Standard Installation
+@subsection Installing MySQL on Linux
+
+@cindex RPM file
+@cindex RedHat Package Manager
+
+The recommended way to install MySQL on Linux is by using an RPM
+file. The MySQL RPMs are currently being built on a RedHat Version
+6.2 system but should work on other versions of Linux that support @code{rpm}
+and use @code{glibc}.
+
+If you have problems with an RPM file, for example, if you receive the error
+``@code{Sorry, the host 'xxxx' could not be looked up}'', see
+@ref{Binary notes-Linux}.
+
+The RPM files you may want to use are:
+
+@itemize @bullet
+@item @code{MySQL-VERSION.i386.rpm}
+
+The MySQL server. You will need this unless you only want to
+connect to a MySQL server running on another machine.
+
+@item @code{MySQL-client-VERSION.i386.rpm}
+
+The standard MySQL client programs. You probably always want to
+install this package.
+
+@item @code{MySQL-bench-VERSION.i386.rpm}
+
+Tests and benchmarks. Requires Perl and msql-mysql-modules RPMs.
+
+@item @code{MySQL-devel-VERSION.i386.rpm}
+
+Libraries and include files needed if you want to compile other
+MySQL clients, such as the Perl modules.
+
+@item @code{MySQL-VERSION.src.rpm}
+
+This contains the source code for all of the above packages. It can also
+be used to try to build RPMs for other architectures (for example, Alpha
+or SPARC).
+@end itemize
+
+To see all files in an RPM package, run:
+@example
+shell> rpm -qpl MySQL-VERSION.i386.rpm
+@end example
+
+To perform a standard minimal installation, run:
+
+@example
+shell> rpm -i MySQL-VERSION.i386.rpm MySQL-client-VERSION.i386.rpm
+@end example
+
+To install just the client package, run:
+
+@example
+shell> rpm -i MySQL-client-VERSION.i386.rpm
+@end example
+
+The RPM places data in @file{/var/lib/mysql}. The RPM also creates the
+appropriate entries in @file{/etc/rc.d/} to start the server automatically
+at boot time. (This means that if you have performed a previous
+installation, you may want to make a copy of your previously installed
+MySQL startup file if you made any changes to it, so you don't lose
+your changes.)
+
+After installing the RPM file(s), the @code{mysqld} daemon should be running
+and you should now be able to start using MySQL.
+@xref{Post-installation}.
+
+If something goes wrong, you can find more information in the binary
+installation chapter. @xref{Installing binary}.
+
+
+@node Windows installation, , Linux-RPM, Quick Standard Installation
+@subsection Installing MySQL on Windows
+
+The following instructions apply to precompiled binary distributions.
+If you download a source distribution, you will have to compile and install
+it yourself.
+
+If you don't have a copy of the MySQL distribution, you should
+first download one from @uref{http://www.mysql.com/downloads/mysql-3.23.html}.
+
+If you plan to connect to MySQL from some other program, you will
+probably also need the @strong{MyODBC} driver. You can find this at the
+@strong{MyODBC} download page
+(@uref{http://www.mysql.com/downloads/api-myodbc.html}).
+
+To install either distribution, unzip it in some empty directory and run the
+@code{Setup.exe} program.
+
+By default, MySQL-Windows is configured to be installed in
+@file{C:\mysql}. If you want to install MySQL elsewhere,
+install it in @file{C:\mysql} first, then move the installation to
+where you want it. If you do move MySQL, you must indicate
+where everything is located by supplying a @code{--basedir} option when
+you start the server. For example, if you have moved the MySQL
+distribution to @file{D:\programs\mysql}, you must start @code{mysqld}
+like this:
+
+@example
+C:\> D:\programs\mysql\bin\mysqld --basedir D:\programs\mysql
+@end example
+
+Use @code{mysqld --help} to display all the options that @code{mysqld}
+understands!
+
+With all newer MySQL versions, you can also create a
+@file{C:\my.cnf} file that holds any default options for the
+MySQL server. Copy the file @file{\mysql\my-xxxxx.cnf} to
+@file{C:\my.cnf} and edit it to suit your setup. Note that you should
+specify all paths with @samp{/} instead of @samp{\}. If you use
+@samp{\}, you need to specify it twice, because @samp{\} is the escape
+character in MySQL. @xref{Option files}.
+
+Starting with MySQL 3.23.38, the Windows distribution includes
+both the normal and the @strong{MySQL-Max} binaries. The main benefit
+of using the normal @code{mysqld.exe} binary is that it's a little
+faster and uses less resources.
+
+Here is a list of the different MySQL servers you can use:
+
+@multitable @columnfractions .25 .75
+@item @code{mysqld} @tab
+Compiled with full debugging and automatic memory allocation checking,
+symbolic links, BDB and InnoDB tables.
+@item @code{mysqld-opt} @tab
+Optimized binary with no support for transactional tables.
+@item @code{mysqld-nt} @tab
+Optimized binary for NT with support for named pipes. You can run this
+version on Win98, but in this case no named pipes are created and you must
+have TCP/IP installed.
+@item @code{mysqld-max} @tab
+Optimized binary with support for symbolic links, BDB and InnoDB tables.
+@item @code{mysqld-max-nt} @tab
+Like @code{mysqld-max}, but compiled with support for named pipes.
+@end multitable
+
+All of the above binaries are optimized for the Pentium Pro processor but
+should work on any Intel processor >= i386.
+
+NOTE: If you want to use InnoDB tables, there are certain startup
+options that must be specified in your @file{my.ini} file! @xref{InnoDB start}.
+
+
+@node General Installation Issues, Installing source, Quick Standard Installation, Installing
+@section General Installation Issues
+
+@c @node Methods of Installation, , ,
+@c @subsection Methods of Installation
+
+@c FIX: this needs to be written?
+
+@menu
+* Getting MySQL:: How to Get MySQL
+* Which OS:: Operating Systems Supported by MySQL
+* Which version:: Which MySQL Version to Use
+* Installation layouts:: Installation Layouts
+* Many versions:: How and When Updates Are Released
+* MySQL binaries:: MySQL Binaries Compiled by MySQL AB
+@end menu
+
+
+@node Getting MySQL, Which OS, General Installation Issues, General Installation Issues
+@subsection How to Get MySQL
+
@cindex downloading
@cindex MySQL version
@cindex version, latest
@cindex getting MySQL
@cindex mirror sites
@cindex URLS for downloading MySQL
-@node Getting MySQL, Which OS, Installing, Installing
-@section How to Get MySQL
-Check the @uref{http://www.mysql.com/, @strong{MySQL} home page} for
+Check the @uref{http://www.mysql.com/, MySQL home page} for
information about the current version and for downloading instructions.
Our main download mirror is located at:
@uref{http://download.sourceforge.net/mirrors/mysql/}
-If you are interested in becoming a @strong{MySQL} mirror site, you may
+If you are interested in becoming a MySQL mirror site, you may
anonymously rsync with: @code{rsync://download.sourceforge.net/mysql/}. Please
send e-mail to @email{webmaster@@mysql.com} notifying us of your mirror to be
added to the list below.
@@ -4382,8 +6455,8 @@ Please report bad or out-of-date mirrors to @email{webmaster@@mysql.com}.
@item
@c EMAIL: mkp@socsci.auc.dk (Martin Kasper Petersen)
@image{Flags/denmark} Denmark [SunSITE] @
-@uref{http://SunSITE.auc.dk/mysql/, WWW}
-@uref{ftp://SunSITE.auc.dk/pub/databases/mysql/, FTP}
+@uref{http://mirrors.sunsite.dk/mysql/, WWW}
+@uref{ftp://sunsite.dk/mirrors/mysql/, FTP}
@c @item
@c Tõnu does not work there anymore :-) 990720
@@ -4480,6 +6553,11 @@ Please report bad or out-of-date mirrors to @email{webmaster@@mysql.com}.
@uref{ftp://mysql.tiszanet.hu/pub/mirrors/mysql/, FTP}
@item
+@c EMAIL: i.habencius@telnet.hu (Habencius Istvan)
+@image{Flags/hungary} Hungary [stop.hu] @
+@uref{http://mysql.mirror.stop.hu/, WWW}
+
+@item
@c EMAIL: mirrors@gm.is (Tomas Edwardsson)
@image{Flags/iceland} Iceland [GM] @
@uref{http://mysql.gm.is/, WWW}
@@ -4634,13 +6712,12 @@ Please report bad or out-of-date mirrors to @email{webmaster@@mysql.com}.
@c @image{Flags/spain} Spain [MasterD]
@c @uref{http://mysql.masterd.es, WWW}
-@c @item
-@c Not ok 20000919; Old site (Matt)
+@item
@c EMAIL: Patrik.Karen@sdi.slu.se (Patrik Karen)
@c ftp -> remove old files
-@c @image{Flags/sweden} Sweden [Sunet] @
-@c @uref{http://ftp.sunet.se/pub/unix/databases/relational/mysql/, WWW}
-@c @uref{ftp://ftp.sunet.se/pub/unix/databases/relational/mysql/, FTP}
+@image{Flags/sweden} Sweden [Sunet] @
+@uref{http://ftp.sunet.se/pub/unix/databases/relational/mysql/, WWW}
+@uref{ftp://ftp.sunet.se/pub/unix/databases/relational/mysql/, FTP}
@item
@c EMAIL: archive@sunsite.cnlab-switch.ch (Thomas Lenggenhager)
@@ -4655,21 +6732,16 @@ Please report bad or out-of-date mirrors to @email{webmaster@@mysql.com}.
@c @uref{ftp://ftp.oyster.co.uk/pub/mysql, FTP}
@item
-@c EMAIL: gareth@omnipotent.net (Gareth Watts)
-@image{Flags/great-britain} UK [Omnipotent/UK] @
-@uref{http://mysql.omnipotent.net/, WWW}
-@uref{ftp://mysql.omnipotent.net/, FTP}
-
-@item
@c EMAIL: keet@mordor.plig.net (Christiaan Keet)
@image{Flags/great-britain} UK [PLiG/UK] @
@uref{http://ftp.plig.org/pub/mysql/, WWW}
@uref{ftp://ftp.plig.org/pub/mysql/, FTP}
-@item
+@c @item
+@c Not ok 20010808; Non-existent (Matt)
@c EMAIL: sean@telekon.co.uk (Sean Gibson)
-@image{Flags/great-britain} UK [Telekon Internet/UK] @
-@uref{ftp://ftp.telekon.co.uk/pub/mysql/, FTP}
+@c @image{Flags/great-britain} UK [Telekon Internet/UK] @
+@c @uref{ftp://ftp.telekon.co.uk/pub/mysql/, FTP}
@c @item
@c lance@uklinux.net (Lance)
@@ -4690,16 +6762,22 @@ Please report bad or out-of-date mirrors to @email{webmaster@@mysql.com}.
@c @uref{ftp://sunsite.org.uk/packages/mysql/, FTP}
@item
-@c sander@paco.net (Alexander Ivanov)
+@c EMAIL: sander@paco.net (Alexander Ivanov)
@image{Flags/ukraine} Ukraine [PACO] @
@uref{http://mysql.paco.net.ua, WWW}
@uref{ftp://mysql.paco.net.ua/, FTP}
@item
-@c mizi@alkar.net (Alexander Ryumshin)
+@c EMAIL: mizi@alkar.net (Alexander Ryumshin)
@image{Flags/ukraine} Ukraine [ISP Alkar Teleport/Dnepropetrovsk] @
@uref{http://mysql.dp.ua/, WWW}
+@item
+@c EMAIL: bole@bolex.bolex.co.yu (Bosko Radivojevic)
+@image{Flags/yugoslavia} Yugoslavia [bolex.co.yu] @
+@uref{http://mysql.boa.org.yu/, WWW}
+@uref{ftp://ftp.linux.org.yu/pub/MySQL/, FTP}
+
@end itemize
@strong{North America:}
@@ -4823,6 +6901,17 @@ Please report bad or out-of-date mirrors to @email{webmaster@@mysql.com}.
@image{Flags/usa} USA [adgrafix.com/Boston, MA] @
@uref{http://mysql.adgrafix.com/, WWW}
+@item
+@c EMAIL: Pjacob@netnumina.com (Philip Jacob)
+@image{Flags/usa} USA [netNumina/Cambridge, MA] @
+@uref{http://mysql.mirrors.netnumina.com/, WWW}
+
+@item
+@c EMAIL: hagler@ahaza.com (Mark Hagler)
+@image{Flags/usa} USA [Ahaza Systems/Seattle, WA] @
+@uref{http://mysql.mirrortree.com/, WWW}
+@uref{ftp://mysql.mirrortree.com/pub/mysql/, FTP}
+
@end itemize
@strong{South America:}
@@ -4869,10 +6958,11 @@ Please report bad or out-of-date mirrors to @email{webmaster@@mysql.com}.
@strong{Asia:}
@itemize @bullet
-@item
+@c @item
+@c Host cannot be resolved for last week at least 20010809 Tonu
@c EMAIL: mirnshi@263.net (Meng Lingbo)
-@image{Flags/china} China [Freecode] @
-@uref{http://www.freecode.net.cn/mirror/mysql/, WWW}
+@c @image{Flags/china} China [Freecode] @
+@c @uref{http://www.freecode.net.cn/mirror/mysql/, WWW}
@item
@c EMAIL: yusun@atwell.co.jp (yu sun)
@@ -4880,14 +6970,27 @@ Please report bad or out-of-date mirrors to @email{webmaster@@mysql.com}.
@uref{http://www2.linuxforum.net/mirror/mysql/, WWW}
@item
-@c EMAIL: Vincent_Fong@innovator.com.hk (Vincent Fong)
-@image{Flags/china} China [ISL/Hong Kong] @
-@uref{http://mysql.islnet.net, WWW}
+@c EMAIL: vfong@hklpg.org (Vincent Fong)
+@image{Flags/china} China [HKLPG/Hong Kong] @
+@uref{http://mysql.hklpg.org, WWW}
@item
+@c EMAIL: jason-wong@gremlins.com.hk (Gremlins Jason Wong)
+@image{Flags/china} China [Gremlins/Hong Kong] @
+@uref{http://mysql.gremlins.com.hk/, WWW}
+@uref{ftp://ftp.mirrors.gremlins.com.hk/mysql/, FTP}
+
+@item
+@c EMAIL: shell@linux.org.hk (Shell Hung)
+@image{Flags/china} China [shellhung.org/Hong Kong] @
+@uref{http://mysql.shellhung.org/, WWW}
+@uref{ftp://ftp.shellhung.org/pub/Mirror/mysql/, FTP}
+
+@c @item
+@c Not ok 20010308; Other content! (Tonu)
@c EMAIL: xcyber@yahoo.com (xcyber)
-@image{Flags/china} China [xcyber.org/Hong Kong] @
-@uref{http://mysql.xcyber.org/, WWW}
+@c @image{Flags/china} China [xcyber.org/Hong Kong] @
+@c @uref{http://mysql.xcyber.org/, WWW}
@c @item
@c Not ok 20010330; Non-existent! (Matt)
@@ -4901,27 +7004,16 @@ Please report bad or out-of-date mirrors to @email{webmaster@@mysql.com}.
@c @image{Flags/china} China [Netfirm] @
@c @uref{http://mysql.netfirm.net, WWW}
-@c @item
-@c Not ok 20000919; Old site (Matt)
-@c EMAIL: ahmlhs@nmsvr.chosun.com (Ho-sun Lee)
-@c @image{Flags/south-korea} South Korea [KREONet] @
-@c @uref{http://linux.kreonet.re.kr/mysql/, WWW}
-
@item
-@c EMAIL: jasper@webiiz.com (Kang, Tae-jin)
-@image{Flags/south-korea} South Korea [Webiiz] @
-@uref{http://mysql.webiiz.com/, WWW}
+@c EMAIL: dnata@incaf.net (Denie Nataprawira)
+@image{Flags/indonesia} Indonesia [incaf.net] @
+@uref{http://mysql.incaf.net/, WWW}
@item
-@c EMAIL: hollywar@holywar.net (Oh Junseon)
-@image{Flags/south-korea} South Korea [PanworldNet] @
-@uref{http://mysql.holywar.net/, WWW}
-
-@c @item
-@c ftp -> remove old files
-@c EX: ahmlhs@nmsvr.chosun.com (Ho-sun Lee)
-@c @image{Flags/south-korea} South Korea [KREONet] @
-@c @uref{ftp://linux.kreonet.re.kr/pub/tools/db/mysql/, FTP}
+@c EMAIL: andika@piksi.itb.ac.id (Andika Triwidada)
+@image{Flags/indonesia} Indonesia [web.id] @
+@uref{http://mysql.itb.web.id/, WWW}
+@uref{ftp://mysql.itb.web.id/pub/MySQL/, FTP}
@item
@c Ok 980805
@@ -4950,6 +7042,28 @@ Please report bad or out-of-date mirrors to @email{webmaster@@mysql.com}.
@c @uref{ftp://mirror.nucba.ac.jp/mirror/mysql, FTP}
@c @item
+@c Not ok 20000919; Old site (Matt)
+@c EMAIL: ahmlhs@nmsvr.chosun.com (Ho-sun Lee)
+@c @image{Flags/south-korea} South Korea [KREONet] @
+@c @uref{http://linux.kreonet.re.kr/mysql/, WWW}
+
+@item
+@c EMAIL: jasper@webiiz.com (Kang, Tae-jin)
+@image{Flags/south-korea} South Korea [Webiiz] @
+@uref{http://mysql.webiiz.com/, WWW}
+
+@item
+@c EMAIL: hollywar@holywar.net (Oh Junseon)
+@image{Flags/south-korea} South Korea [PanworldNet] @
+@uref{http://mysql.holywar.net/, WWW}
+
+@c @item
+@c ftp -> remove old files
+@c EX: ahmlhs@nmsvr.chosun.com (Ho-sun Lee)
+@c @image{Flags/south-korea} South Korea [KREONet] @
+@c @uref{ftp://linux.kreonet.re.kr/pub/tools/db/mysql/, FTP}
+
+@c @item
@c Removed 990308
@c EMAIL: terence@com5.net (Terence Chan)
@c @image{Flags/singapore} Singapore [Com5 Productions] @
@@ -5009,15 +7123,15 @@ Please report bad or out-of-date mirrors to @email{webmaster@@mysql.com}.
@end itemize
-@strong{Australia:}
+@c @strong{Australia:}
-@itemize @bullet
-@item
+@c @itemize @bullet
+@c @item
@c Added 980610
@c EMAIL: jason@dstc.edu.au (Jason Andrade)
-@image{Flags/australia} Australia [AARNet/Queensland] @
-@uref{http://mysql.mirror.aarnet.edu.au/, WWW}
-@uref{ftp://mysql.mirror.aarnet.edu.au/, FTP}
+@c @image{Flags/australia} Australia [AARNet/Queensland] @
+@c @uref{http://mysql.mirror.aarnet.edu.au/, WWW}
+@c @uref{ftp://mysql.mirror.aarnet.edu.au/, FTP}
@c @item
@c Added 980805. Removed 000102 'no such directory'
@@ -5046,7 +7160,7 @@ Please report bad or out-of-date mirrors to @email{webmaster@@mysql.com}.
@c EMAIL: lucifer@maths.uq.edu.au (David Conran)
@c @image{Flags/australia} Australia FTP @
@c @uref{ftp://ftp.sage-au.org.au/pub/database/mysql, [Sage]}
-@end itemize
+@c @end itemize
@strong{Africa:}
@@ -5068,22 +7182,23 @@ Please report bad or out-of-date mirrors to @email{webmaster@@mysql.com}.
@c END_OF_MIRROR_LISTING
+@node Which OS, Which version, Getting MySQL, General Installation Issues
+@subsection Operating Systems Supported by MySQL
+
@cindex operating systems, supported
@cindex native thread support
@cindex thread support
@cindex process support
@cindex support, for operating systems
-@node Which OS, Which version, Getting MySQL, Installing
-@section Operating Systems Supported by MySQL
-We use GNU Autoconf, so it is possible to port @strong{MySQL} to all modern
+We use GNU Autoconf, so it is possible to port MySQL to all modern
systems with working Posix threads and a C++ compiler. (To compile only the
client code, a C++ compiler is required but not threads.) We use and develop
the software ourselves primarily on Sun Solaris (Versions 2.5 - 2.7) and
SuSE Linux Version 7.x.
Note that for many operating systems, the native thread support works only
-in the latest versions. @strong{MySQL} has been reported to compile
+in the latest versions. MySQL has been reported to compile
successfully on the following operating system/thread package combinations:
@itemize @bullet
@@ -5133,92 +7248,98 @@ Win95, Win98, NT, and Win2000. @xref{Windows}.
@end itemize
Note that not all platforms are suited equally well for running
-@strong{MySQL}. How well a certain platform is suited for a high-load
-mission critical @strong{MySQL} server is determined by the following
+MySQL. How well a certain platform is suited for a high-load
+mission critical MySQL server is determined by the following
factors:
-@itemize
+@itemize @bullet
@item
General stability of the thread library. A platform may have excellent
reputation otherwise, but if the thread library is unstable in the code
-that is called by @strong{MySQL}, even if
-everything else is perfect, @strong{MySQL} will be only as stable as the
-thread library.
+that is called by MySQL, even if everything else is perfect, MySQL will
+be only as stable as the thread library.
+
@item
The ability of the kernel and/or thread library to take advantage of
-@strong{SMP} on
-multi-processor systems. In other words, when a process creates a thread, it
-should be possible for that thread to run on a different CPU than the original
-process.
+@strong{SMP} on multi-processor systems. In other words, when a process
+creates a thread, it should be possible for that thread to run on a different
+CPU than the original process.
+
@item
The ability of the kernel and/or the thread library to run many threads which
acquire/release a mutex over a short critical region frequently without
excessive context switches. In other words, if the implementation of
@code{pthread_mutex_lock()} is too anxious to yield CPU, this will hurt
-@strong{MySQL} tremendously. If this issue
-is not taken care of, adding extra CPUs will actually make @strong{MySQL}
-slower.
+MySQL tremendously. If this issue is not taken care of, adding extra CPUs
+will actually make MySQL slower.
+
@item
General file system stability/performance.
+
@item
Ability of the file system to deal with large files at all and deal with them
efficiently, if your tables are big.
+
@item
-Our level of expertise here at @strong{MySQL AB} with the platform. If we know
+Our level of expertise here at MySQL AB with the platform. If we know
a platform well, we introduce platform-specific optimizations/fixes enabled at
compile time. We can also provide advice on configuring your system optimally
-for @strong{MySQL}.
+for MySQL.
+
@item
The amount of testing of similar configurations we have done internally.
+
@item
-The number of users that have successfully run @strong{MySQL} on that
+The number of users that have successfully run MySQL on that
platform in similar configurations. If this number is high, the chances of
hitting some platform-specific surprise are much smaller.
@end itemize
Based on the above criteria, the best platforms for running
-@strong{MySQL} at this point are x86 with SuSE Linux 7.1, 2.4 kernel and
+MySQL at this point are x86 with SuSE Linux 7.1, 2.4 kernel and
ReiserFS (or any similar Linux distribution) and Sparc with Solaris 2.7
or 2.8. FreeBSD comes third, but we really hope it will join the top
club once the thread library is improved. We also hope that at some
point we will be able to include all other platforms on which
-@strong{MySQL} compiles, runs ok, but not quite with the same level of
+MySQL compiles, runs ok, but not quite with the same level of
stability and performance, into the top category. This will require some
effort on our part in cooperation with the developers of the OS/library
-components @strong{MySQL} depends upon. If you are interested in making
+components MySQL depends upon. If you are interested in making
one of those components better, are in a position to influence their
-development, and need more detailed instructions on what @strong{MySQL}
+development, and need more detailed instructions on what MySQL
needs to run better, send an e-mail to
@email{internals@@lists.mysql.com}.
Please note that the comparison above is not to say that one OS is better or
worse than the other in general. We are talking about choosing a particular OS
-for a dedicated purpose - running @strong{MySQL}, and compare platforms in that
+for a dedicated purpose - running MySQL, and compare platforms in that
regard only. With this in mind, the result of this comparison
would be different if we included more issues into it. And in some cases,
the reason one OS is better than the other could simply be that we have put
forth more effort into testing on and optimizing for that particular platform.
We are just stating our observations to help you make a
-decision on which platform to use @strong{MySQL} on in your setup.
+decision on which platform to use MySQL on in your setup.
+
+
+@node Which version, Installation layouts, Which OS, General Installation Issues
+@subsection Which MySQL Version to Use
@cindex MySQL binary distribution
@cindex MySQL source distribution
@cindex release numbers
@cindex version, choosing
@cindex choosing, a MySQL version
-@node Which version, Many versions, Which OS, Installing
-@section Which MySQL Version to Use
The first decision to make is whether you want to use the latest development
release or the last stable release:
@itemize @bullet
@item
-Normally, if you are beginning to use @strong{MySQL} for the first time
+Normally, if you are beginning to use MySQL for the first time
or trying to port it to some system for which there is no binary
distribution, we recommend going with the stable release (currently
-Version @value{mysql_version}. Note that all @strong{MySQL} releases are
-checked with the @strong{MySQL} benchmarks and an extensive test suite
+Version @value{mysql_version}. Note that all MySQL releases are
+checked with the MySQL benchmarks and an extensive test suite
before each release.
@item
@@ -5239,7 +7360,7 @@ installation:
@itemize @bullet
@item
-If you want to install @strong{MySQL} at some explicit location. (The standard
+If you want to install MySQL at some explicit location. (The standard
binary distributions are ``ready to run'' at any place, but you may want
to get even more flexibility).
@@ -5249,9 +7370,9 @@ different binary versions; One compiled with the non-transactional table
handlers, (a small, fast binary), and one configured with the most
important extended options like transaction-safe tables. Both versions
are compiled from the same source distribution. All native @code{MySQL}
-clients can connect to both @strong{MySQL} versions.
+clients can connect to both MySQL versions.
-The extended @strong{MySQL} binary distribution is marked with the
+The extended MySQL binary distribution is marked with the
@code{-max} suffix and is configured with the same options as
@code{mysqld-max}. @xref{mysqld-max, , @code{mysqld-max}}.
@@ -5259,17 +7380,17 @@ If you want to use the @code{MySQL-Max} RPM, you must first
install the standard @code{MySQL} RPM.
@item
-If you want to configure @code{mysqld} with some extra feature that are NOT in
-the standard binary distributions. Here is a list of the most common
-extra options that you may want to use:
+If you want to configure @code{mysqld} with some extra features that are
+NOT in the standard binary distributions. Here is a list of the most
+common extra options that you may want to use:
@itemize @bullet
-@item --with-berkeley-db
-@item --with-innodb
-@item --with-raid
-@item --with-libwrap
-@item --with-named-z-lib (This is done for some of the binaries)
-@item --with-debug[=full]
+@item @code{--with-berkeley-db}
+@item @code{--with-innodb}
+@item @code{--with-raid}
+@item @code{--with-libwrap}
+@item @code{--with-named-z-lib (This is done for some of the binaries)}
+@item @code{--with-debug[=full]}
@end itemize
@item
@@ -5277,19 +7398,19 @@ The default binary distribution is normally compiled with support
for all characters sets and should work on a variety of processors from
the same processor family.
-If you want a faster @strong{MySQL} server you may want to recompile it
+If you want a faster MySQL server you may want to recompile it
with support for only the character sets you need, use a better compiler
(like @code{pgcc}) or use compiler options that are better optimized for your
processor.
@item
-If you have found a bug and reported it to the @strong{MySQL}
+If you have found a bug and reported it to the MySQL
development team you will probably receive a patch that you need to apply to
the source distribution to get the bug fixed.
@item
If you want to read (and/or modify) the C and C++ code that makes up
-@strong{MySQL}, you should get a source distribution. The source code is
+MySQL, you should get a source distribution. The source code is
always the ultimate manual. Source distributions also contain more
tests and examples than binary distributions.
@end itemize
@@ -5297,7 +7418,7 @@ tests and examples than binary distributions.
@cindex naming, releases of MySQL
@cindex releases, naming scheme
-The @strong{MySQL} naming scheme uses release numbers that consist of three
+The MySQL naming scheme uses release numbers that consist of three
numbers and a suffix. For example, a release name like
@code{mysql-3.21.17-beta} is interpreted like this:
@@ -5330,7 +7451,7 @@ should be documented in the News section. @xref{News}. There are also new
commands and extensions in most alpha releases. Active development that
may involve major code changes can occur on an alpha release, but everything
will be tested before doing a release. There should be no known bugs in any
-@strong{MySQL} release.
+MySQL release.
@item
@code{beta} means that all new code has been tested. No major new
@@ -5352,7 +7473,7 @@ release. This is what we call a stable release.
@end itemize
@end itemize
-All versions of @strong{MySQL} are run through our standard tests and
+All versions of MySQL are run through our standard tests and
benchmarks to ensure that they are relatively safe to use. Because the
standard tests are extended over time to check for all previously found bugs,
the test suite keeps getting better.
@@ -5367,82 +7488,23 @@ Note that all releases have been tested at least with:
This is part of a production system for a customer. It has many tables with
hundreds of megabytes of data.
-@item The @strong{MySQL} benchmark suite
+@item The MySQL benchmark suite
This runs a range of common queries. It is also a test to see whether the
latest batch of optimizations actually made the code faster.
-@xref{Benchmarks}.
+@xref{MySQL Benchmarks}.
@item The @code{crash-me} test
This tries to determine what features the database supports and what its
-capabilities and limitations are. @xref{Benchmarks}.
+capabilities and limitations are. @xref{MySQL Benchmarks}.
@end table
-Another test is that we use the newest @strong{MySQL} version in our internal
+Another test is that we use the newest MySQL version in our internal
production environment, on at least one machine. We have more than 100
gigabytes of data to work with.
-@cindex releases, updating
-@cindex updating, releases of MySQL
-@node Many versions, Installation layouts, Which version, Installing
-@section How and When Updates Are Released
-
-@strong{MySQL} is evolving quite rapidly here at @strong{MySQL AB} and we
-want to share this with other @strong{MySQL} users. We try to make a release
-when we have very useful features that others seem to have a need for.
-
-We also try to help out users who request features that are easy to
-implement. We take note of what our licensed users want to have, and
-we especially take note of what our extended e-mail supported customers
-want and try to help them out.
-
-No one has to download a new release. The News section will tell you if
-the new release has something you really want. @xref{News}.
-
-We use the following policy when updating @strong{MySQL}:
-
-@itemize @bullet
-@item
-For each minor update, the last number in the version string is incremented.
-When there are major new features or minor incompatibilities with previous
-versions, the second number in the version string is incremented. When the
-file format changes, the first number is increased.
-
-@item
-Stable tested releases are meant to appear about 1-2 times a year, but
-if small bugs are found, a release with only bug fixes will be released.
-
-@item
-Working releases are meant to appear about every 1-8 weeks.
-
-@item
-Binary distributions for some platforms will be made by us for major releases.
-Other people may make binary distributions for other systems but probably
-less frequently.
-
-@item
-We usually make patches available as soon as we have located and fixed
-small bugs.
-
-@item
-For non-critical but annoying bugs, we will make patches available if they
-are sent to us. Otherwise we will combine many of them into a larger
-patch.
-@item
-If there is, by any chance, a fatal bug in a release we will make a new
-release as soon as possible. We would like other companies to do this,
-too.
-@end itemize
-
-The current stable release is Version 3.23; We have already moved active
-development to Version 4.0. Bugs will still be fixed in the stable version.
-We don't believe in a complete freeze, as this also leaves out bug fixes
-and things that ``must be done.'' ``Somewhat frozen'' means that we may
-add small things that ``almost surely will not affect anything that's
-already working.''
-
-@node Installation layouts, Installing binary, Many versions, Installing
-@section Installation Layouts
+@node Installation layouts, Many versions, Which version, General Installation Issues
+@subsection Installation Layouts
@cindex installation layouts
@cindex layout of installation
@@ -5506,492 +7568,142 @@ The header file and library directories are @file{include/mysql} and
You can create your own binary installation from a compiled source
distribution by executing the script @file{scripts/make_binary_distribution}.
-@cindex installing, binary distribution
-@cindex binary distributions, installing
-@node Installing binary, Installing source, Installation layouts, Installing
-@section Installing a MySQL Binary Distribution
-
-@menu
-* Linux-RPM:: Linux RPM files
-* Building clients:: Building client programs
-* Binary install system issues:: System-specific issues
-@end menu
-You need the following tools to install a @strong{MySQL} binary distribution:
+@node Many versions, MySQL binaries, Installation layouts, General Installation Issues
+@subsection How and When Updates Are Released
-@itemize @bullet
-@item
-GNU @code{gunzip} to uncompress the distribution.
-
-@item
-A reasonable @code{tar} to unpack the distribution. GNU @code{tar} is
-known to work. Sun @code{tar} is known to have problems.
-@end itemize
-
-@cindex RPM, defined
-@cindex RedHat Package Manager
-An alternative installation method under Linux is to use RPM (RedHat Package
-Manager) distributions. @xref{Linux-RPM}.
-
-@c texi2html fails to split chapters if I use strong for all of this.
-If you run into problems, @strong{PLEASE ALWAYS USE} @code{mysqlbug} when
-posting questions to @email{mysql@@lists.mysql.com}. Even if the problem
-isn't a bug, @code{mysqlbug} gathers system information that will help others
-solve your problem. By not using @code{mysqlbug}, you lessen the likelihood
-of getting a solution to your problem! You will find @code{mysqlbug} in the
-@file{bin} directory after you unpack the distribution. @xref{Bug reports}.
-
-@cindex commands, for binary distribution
-The basic commands you must execute to install and use a @strong{MySQL}
-binary distribution are:
-
-@example
-shell> groupadd mysql
-shell> useradd -g mysql mysql
-shell> cd /usr/local
-shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
-shell> ln -s mysql-VERSION-OS mysql
-shell> cd mysql
-shell> scripts/mysql_install_db
-shell> chown -R root /usr/local/mysql
-shell> chown -R mysql /usr/local/mysql/data
-shell> chgrp -R mysql /usr/local/mysql
-shell> chown -R root /usr/local/mysql/bin
-shell> bin/safe_mysqld --user=mysql &
-@end example
-
-@cindex adding, new users
-@cindex new users, adding
-@cindex users, adding
-
-You can add new users using the @code{bin/mysql_setpermission} script if
-you install the @code{DBI} and @code{Msql-Mysql-modules} Perl modules.
-
-A more detailed description follows.
-
-To install a binary distribution, follow the steps below, then proceed
-to @ref{Post-installation}, for post-installation setup and testing:
-
-@enumerate
-@item
-Pick the directory under which you want to unpack the distribution, and move
-into it. In the example below, we unpack the distribution under
-@file{/usr/local} and create a directory @file{/usr/local/mysql} into which
-@strong{MySQL} is installed. (The following instructions therefore assume
-you have permission to create files in @file{/usr/local}. If that directory
-is protected, you will need to perform the installation as @code{root}.)
-
-@item
-Obtain a distribution file from one of the sites listed in
-@ref{Getting MySQL, , Getting @strong{MySQL}}.
-
-@strong{MySQL} binary distributions are provided as compressed @code{tar}
-archives and have names like @file{mysql-VERSION-OS.tar.gz}, where
-@code{VERSION} is a number (for example, @code{3.21.15}), and @code{OS}
-indicates the type of operating system for which the distribution is intended
-(for example, @code{pc-linux-gnu-i586}).
-
-@item
-If you see a binary distribution marked with the @code{-max} prefix, this
-means that the binary has support for transaction-safe tables and other
-features. @xref{mysqld-max, , @code{mysqld-max}}. Note that all binaries
-are built from the same @strong{MySQL} source distribution.
-
-@item
-Add a user and group for @code{mysqld} to run as:
-
-@example
-shell> groupadd mysql
-shell> useradd -g mysql mysql
-@end example
-
-These commands add the @code{mysql} group and the @code{mysql} user. The
-syntax for @code{useradd} and @code{groupadd} may differ slightly on different
-versions of Unix. They may also be called @code{adduser} and @code{addgroup}.
-You may wish to call the user and group something else instead of @code{mysql}.
-
-@item
-Change into the intended installation directory:
+@cindex releases, updating
+@cindex updating, releases of MySQL
-@example
-shell> cd /usr/local
-@end example
+MySQL is evolving quite rapidly here at MySQL AB and we
+want to share this with other MySQL users. We try to make a release
+when we have very useful features that others seem to have a need for.
-@item
-Unpack the distribution and create the installation directory:
+We also try to help out users who request features that are easy to
+implement. We take note of what our licensed users want to have, and
+we especially take note of what our extended e-mail supported customers
+want and try to help them out.
-@example
-shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
-shell> ln -s mysql-VERSION-OS mysql
-@end example
+No one has to download a new release. The News section will tell you if
+the new release has something you really want. @xref{News}.
-The first command creates a directory named @file{mysql-VERSION-OS}. The
-second command makes a symbolic link to that directory. This lets you refer
-more easily to the installation directory as @file{/usr/local/mysql}.
+We use the following policy when updating MySQL:
+@itemize @bullet
@item
-Change into the installation directory:
-
-@example
-shell> cd mysql
-@end example
-
-You will find several files and subdirectories in the @code{mysql} directory.
-The most important for installation purposes are the @file{bin} and
-@file{scripts} subdirectories.
-
-@table @file
-@item bin
-@tindex PATH environment variable
-@tindex environment variable, PATH
-This directory contains client programs and the server
-You should add the full pathname of this directory to your
-@code{PATH} environment variable so that your shell finds the @strong{MySQL}
-programs properly. @xref{Environment variables}.
-
-@item scripts
-This directory contains the @code{mysql_install_db} script used to initialize
-the @code{mysql} database containing the grant tables that store the server
-access permissions.
-@end table
+For each minor update, the last number in the version string is incremented.
+When there are major new features or minor incompatibilities with previous
+versions, the second number in the version string is incremented. When the
+file format changes, the first number is increased.
@item
-If you would like to use @code{mysqlaccess} and have the @strong{MySQL}
-distribution in some non-standard place, you must change the location where
-@code{mysqlaccess} expects to find the @code{mysql} client. Edit the
-@file{bin/mysqlaccess} script at approximately line 18. Search for a line
-that looks like this:
-
-@example
-$MYSQL = '/usr/local/bin/mysql'; # path to mysql executable
-@end example
-
-Change the path to reflect the location where @code{mysql} actually is
-stored on your system. If you do not do this, you will get a @code{Broken
-pipe} error when you run @code{mysqlaccess}.
+Stable tested releases are meant to appear about 1-2 times a year, but
+if small bugs are found, a release with only bug fixes will be released.
@item
-Create the @strong{MySQL} grant tables (necessary only if you haven't
-installed @strong{MySQL} before):
-@example
-shell> scripts/mysql_install_db
-@end example
-
-Note that @strong{MySQL} versions older than Version 3.22.10 started the
-@strong{MySQL} server when you run @code{mysql_install_db}. This is no
-longer true!
+Working releases are meant to appear about every 1-8 weeks.
@item
-Change ownership of binaries to @code{root} and ownership of the data
-directory to the user that you will run @code{mysqld} as:
-
-@example
-shell> chown -R root /usr/local/mysql
-shell> chown -R mysql /usr/local/mysql/data
-shell> chgrp -R mysql /usr/local/mysql
-@end example
-
-The first command changes the @code{owner} attribute of the files to the
-@code{root} user, the second one changes the @code{owner} attribute of the
-data directory to the @code{mysql} user, and the third one changes the
-@code{group} attribute to the @code{mysql} group.
+Binary distributions for some platforms will be made by us for major releases.
+Other people may make binary distributions for other systems but probably
+less frequently.
@item
-If you want to install support for the Perl @code{DBI}/@code{DBD} interface,
-see @ref{Perl support}.
+We usually make patches available as soon as we have located and fixed
+small bugs.
@item
-If you would like @strong{MySQL} to start automatically when you boot your
-machine, you can copy @code{support-files/mysql.server} to the location where
-your system has its startup files. More information can be found in the
-@code{support-files/mysql.server} script itself and in
-@ref{Automatic start}.
-
-@end enumerate
-
-After everything has been unpacked and installed, you should initialize
-and test your distribution.
-
-You can start the @strong{MySQL} server with the following command:
-
-@example
-shell> bin/safe_mysqld --user=mysql &
-@end example
-
-@xref{safe_mysqld, , @code{safe_mysqld}}.
-
-@xref{Post-installation}.
-
-@cindex RPM file
-@cindex RedHat Package Manager
-@c This node name is special
-@node Linux-RPM, Building clients, Installing binary, Installing binary
-@subsection Linux RPM Notes
-
-The recommended way to install @strong{MySQL} on Linux is by using an RPM
-file. The @strong{MySQL} RPMs are currently being built on a RedHat Version
-6.2 system but should work on other versions of Linux that support @code{rpm}
-and use @code{glibc}.
-
-If you have problems with an RPM file, for example, if you receive the error
-``@code{Sorry, the host 'xxxx' could not be looked up}'', see
-@ref{Binary notes-Linux}.
-
-The RPM files you may want to use are:
-
-@itemize @bullet
-@item @code{MySQL-VERSION.i386.rpm}
-
-The @strong{MySQL} server. You will need this unless you only want to
-connect to a @strong{MySQL} server running on another machine.
-
-@item @code{MySQL-client-VERSION.i386.rpm}
-
-The standard @strong{MySQL} client programs. You probably always want to
-install this package.
-
-@item @code{MySQL-bench-VERSION.i386.rpm}
-
-Tests and benchmarks. Requires Perl and msql-mysql-modules RPMs.
-
-@item @code{MySQL-devel-VERSION.i386.rpm}
-
-Libraries and include files needed if you want to compile other
-@strong{MySQL} clients, such as the Perl modules.
-
-@item @code{MySQL-VERSION.src.rpm}
-
-This contains the source code for all of the above packages. It can also
-be used to try to build RPMs for other architectures (for example, Alpha
-or SPARC).
-@end itemize
-
-To see all files in an RPM package, run:
-@example
-shell> rpm -qpl MySQL-VERSION.i386.rpm
-@end example
-
-To perform a standard minimal installation, run:
-
-@example
-shell> rpm -i MySQL-VERSION.i386.rpm MySQL-client-VERSION.i386.rpm
-@end example
-
-To install just the client package, run:
-
-@example
-shell> rpm -i MySQL-client-VERSION.i386.rpm
-@end example
-
-The RPM places data in @file{/var/lib/mysql}. The RPM also creates the
-appropriate entries in @file{/etc/rc.d/} to start the server automatically
-at boot time. (This means that if you have performed a previous
-installation, you may want to make a copy of your previously installed
-@strong{MySQL} startup file if you made any changes to it, so you don't lose
-your changes.)
-
-After installing the RPM file(s), the @code{mysqld} daemon should be running
-and you should now be able to start using @strong{MySQL}.
-@xref{Post-installation}.
-
-If something goes wrong, you can find more information in the binary
-installation chapter. @xref{Installing binary}.
-
-@cindex client programs, building
-@cindex linking
-@cindex building, client programs
-@cindex programs, client
-@node Building clients, Binary install system issues, Linux-RPM, Installing binary
-@subsection Building Client Programs
-
-If you compile @strong{MySQL} clients that you've written yourself or that
-you obtain from a third party, they must be linked using the
-@code{-lmysqlclient -lz} option on the link command. You may also need to
-specify a @code{-L} option to tell the linker where to find the library. For
-example, if the library is installed in @file{/usr/local/mysql/lib}, use
-@code{-L/usr/local/mysql/lib -lmysqlclient -lz} on the link command.
-
-For clients that use @strong{MySQL} header files, you may need to specify a
-@code{-I} option when you compile them (for example,
-@code{-I/usr/local/mysql/include}), so the compiler can find the header
-files.
-
-@node Binary install system issues, , Building clients, Installing binary
-@subsection System-specific Issues
-
-@menu
-* Binary notes-Linux:: Linux notes for binary distribution
-* Binary notes-HP-UX:: HP-UX notes for binary distribution
-@end menu
-
-The following sections indicate some of the issues that have been observed
-on particular systems when installing @strong{MySQL} from a binary
-distribution or from RPM files.
-
-@cindex binary distributions, on Linux
-@cindex Linux, binary distribution
-@node Binary notes-Linux, Binary notes-HP-UX, Binary install system issues, Binary install system issues
-@subsubsection Linux Notes for Binary Distributions
-
-@strong{MySQL} needs at least Linux Version 2.0.
-
-The binary release is linked with @code{-static}, which means you do not
-normally need to worry about which version of the system libraries you
-have. You need not install LinuxThreads, either. A program linked with
-@code{-static} is slightly bigger than a dynamically linked program but
-also slightly faster (3-5%). One problem, however, is that you can't use
-user-definable functions (UDFs) with a statically linked program. If
-you are going to write or use UDF functions (this is something only for
-C or C++ programmers), you must compile @strong{MySQL} yourself, using
-dynamic linking.
-
-If you are using a @code{libc}-based system (instead of a @code{glibc2}
-system), you will probably get some problems with hostname resolving and
-@code{getpwnam()} with the binary release. (This is because @code{glibc}
-unfortunately depends on some external libraries to resolve hostnames
-and @code{getpwent()}, even when compiled with @code{-static}). In this
-case you probably get the following error message when you run
-@code{mysql_install_db}:
-
-@example
-Sorry, the host 'xxxx' could not be looked up
-@end example
-
-or the following error when you try to run @code{mysqld} with the @code{--user}
-option:
-
-@example
-getpwnam: No such file or directory
-@end example
-
-You can solve this problem in one of the following ways:
+For non-critical but annoying bugs, we will make patches available if they
+are sent to us. Otherwise we will combine many of them into a larger
+patch.
-@itemize @bullet
-@item
-Get a @strong{MySQL} source distribution (an RPM or the @code{tar.gz}
-distribution) and install this instead.
@item
-Execute @code{mysql_install_db --force}; This will not execute the
-@code{resolveip} test in @code{mysql_install_db}. The downside is that
-you can't use host names in the grant tables; you must use IP numbers
-instead (except for @code{localhost}). If you are using an old @strong{MySQL}
-release that doesn't support @code{--force}, you have to remove the
-@code{resolveip} test in @code{mysql_install} with an editor.
-@item
-Start @code{mysqld} with @code{su} instead of using @code{--user}.
+If there is, by any chance, a fatal bug in a release we will make a new
+release as soon as possible. We would like other companies to do this,
+too.
@end itemize
-The Linux-Intel binary and RPM releases of @strong{MySQL} are configured
-for the highest possible speed. We are always trying to use the fastest
-stable compiler available.
-
-@strong{MySQL} Perl support requires Version Perl 5.004_03 or newer.
-
-On some Linux 2.2 versions, you may get the error @code{Resource
-temporarily unavailable} when you do a lot of new connections to a
-@code{mysqld} server over TCP/IP.
+The current stable release is Version 3.23; We have already moved active
+development to Version 4.0. Bugs will still be fixed in the stable version.
+We don't believe in a complete freeze, as this also leaves out bug fixes
+and things that ``must be done.'' ``Somewhat frozen'' means that we may
+add small things that ``almost surely will not affect anything that's
+already working.''
-The problem is that Linux has a delay between when you close a TCP/IP
-socket and until this is actually freed by the system. As there is only
-room for a finite number of TCP/IP slots, you will get the above error if
-you try to do too many new TCP/IP connections during a small time, like
-when you run the @strong{MySQL} @file{test-connect} benchmark over
-TCP/IP.
-We have mailed about this problem a couple of times to different Linux
-mailing lists but have never been able to resolve this properly.
+@node MySQL binaries, , Many versions, General Installation Issues
+@subsection MySQL Binaries Compiled by MySQL AB
-The only known 'fix' to this problem is to use persistent connections in
-your clients or use sockets, if you are running the database server
-and clients on the same machine. We hope that the @code{Linux 2.4}
-kernel will fix this problem in the future.
+@cindex binary distributions
-@cindex HP-UX, binary distribution
-@cindex binary distributions, on HP-UX
-@node Binary notes-HP-UX, , Binary notes-Linux, Binary install system issues
-@subsubsection HP-UX Notes for Binary Distributions
+As a service, we at MySQL AB provide a set of binary distributions
+of MySQL that are compiled at our site or at sites where customers
+kindly have given us access to their machines.
-Some of the binary distributions of @strong{MySQL} for HP-UX is
-distributed as an HP depot file and as a tar file. To use the depot
-file you must be running at least HP-UX 10.x to have access to HP's
-software depot tools.
+These distributions are generated with @code{scripts/make_binary_distribution}
+and are configured with the following compilers and options:
-The HP version of @strong{MySQL} was compiled on an HP 9000/8xx server
-under HP-UX 10.20, and uses MIT-pthreads. It is known to work well under
-this configuration. @strong{MySQL} Version 3.22.26 and newer can also be
-built with HP's native thread package.
+@table @asis
+@item SunOS 4.1.4 2 sun4c with @code{gcc} 2.7.2.1
+@code{CC=gcc CXX=gcc CXXFLAGS="-O3 -felide-constructors" ./configure --prefix=/usr/local/mysql --disable-shared --with-extra-charsets=complex --enable-assembler}
-Other configurations that may work:
+@item SunOS 5.5.1 (and above) sun4u with @code{egcs} 1.0.3a or 2.90.27 or gcc 2.95.2 and newer
+@code{CC=gcc CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --with-low-memory --with-extra-charsets=complex --enable-assembler}
-@itemize @bullet
-@item
-HP 9000/7xx running HP-UX 10.20+
-@item
-HP 9000/8xx running HP-UX 10.30
-@end itemize
+@item SunOS 5.6 i86pc with @code{gcc} 2.8.1
+@code{CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql --with-low-memory --with-extra-charsets=complex}
-The following configurations almost definitely won't work:
+@item Linux 2.0.33 i386 with @code{pgcc} 2.90.29 (@code{egcs} 1.0.3a)
+@code{CFLAGS="-O3 -mpentium -mstack-align-double" CXX=gcc CXXFLAGS="-O3 -mpentium -mstack-align-double -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --enable-assembler --with-mysqld-ldflags=-all-static --with-extra-charsets=complex}
-@itemize @bullet
-@item
-HP 9000/7xx or 8xx running HP-UX 10.x where x < 2
-@item
-HP 9000/7xx or 8xx running HP-UX 9.x
-@end itemize
+@item Linux 2.2.x with x686 with @code{gcc} 2.95.2
+@code{CFLAGS="-O3 -mpentiumpro" CXX=gcc CXXFLAGS="-O3 -mpentiumpro -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --enable-assembler --with-mysqld-ldflags=-all-static --disable-shared --with-extra-charset=complex}
-To install the distribution, use one of the commands below, where
-@code{/path/to/depot} is the full pathname of the depot file:
+@item SCO 3.2v5.0.4 i386 with @code{gcc} 2.7-95q4
+@code{CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql --with-extra-charsets=complex}
-@itemize @bullet
-@item
-To install everything, including the server, client and development tools:
+@item AIX 2 4 with @code{gcc} 2.7.2.2
+@code{CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql --with-extra-charsets=complex}
-@example
-shell> /usr/sbin/swinstall -s /path/to/depot mysql.full
-@end example
+@item OSF1 V4.0 564 alpha with @code{gcc} 2.8.1
+@code{CC=gcc CFLAGS=-O CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql --with-low-memory --with-extra-charsets=complex}
-@item
-To install only the server:
+@item Irix 6.3 IP32 with @code{gcc} 2.8.0
+@code{CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql --with-extra-charsets=complex}
-@example
-shell> /usr/sbin/swinstall -s /path/to/depot mysql.server
-@end example
+@item BSDI BSD/OS 3.1 i386 with @code{gcc} 2.7.2.1
+@code{CC=gcc CXX=gcc CXXFLAGS=-O ./configure --prefix=/usr/local/mysql --with-extra-charsets=complex}
-@item
-To install only the client package:
+@item BSDI BSD/OS 2.1 i386 with @code{gcc} 2.7.2
+@code{CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql --with-extra-charsets=complex}
+@end table
-@example
-shell> /usr/sbin/swinstall -s /path/to/depot mysql.client
-@end example
+Anyone who has more optimal options for any of the configurations listed
+above can always mail them to the developer's mailing list at
+@email{internals@@lists.mysql.com}.
-@item
-To install only the development tools:
+RPM distributions prior to MySQL Version 3.22 are user-contributed.
+Beginning with Version 3.22, the RPMs are generated by us at
+MySQL AB.
-@example
-shell> /usr/sbin/swinstall -s /path/to/depot mysql.developer
-@end example
-@end itemize
+If you want to compile a debug version of MySQL, you should add
+@code{--with-debug} or @code{--with-debug=full} to the above configure lines
+and remove any @code{-fomit-frame-pointer} options.
-The depot places binaries and libraries in @file{/opt/mysql} and data in
-@file{/var/opt/mysql}. The depot also creates the appropriate entries in
-@file{/etc/init.d} and @file{/etc/rc2.d} to start the server automatically
-at boot time. Obviously, this entails being @code{root} to install.
-To install the HP-UX tar.gz distribution, you must have a copy of GNU
-@code{tar}.
+@node Installing source, Post-installation, General Installation Issues, Installing
+@section Installing a MySQL Source Distribution
@cindex installing, source distribution
@cindex source distribution, installing
@cindex installation overview
-@node Installing source, Installing source tree, Installing binary, Installing
-@section Installing a MySQL Source Distribution
Before you proceed with the source installation, check first to see if our
binary is available for your platform and if it will work for you. We
put in a lot of effort into making sure that our binaries are built with the
best possible options.
-You need the following tools to build and install @strong{MySQL} from source:
+You need the following tools to build and install MySQL from source:
@itemize @bullet
@item
@@ -6008,11 +7720,11 @@ compilers that are known to work. @code{libg++} is not needed when
using @code{gcc}. @code{gcc} 2.7.x has a bug that makes it impossible
to compile some perfectly legal C++ files, such as
@file{sql/sql_base.cc}. If you only have @code{gcc} 2.7.x, you must
-upgrade your @code{gcc} to be able to compile @strong{MySQL}. @code{gcc}
+upgrade your @code{gcc} to be able to compile MySQL. @code{gcc}
2.8.1 is also known to have problems on some platforms so it should be
avoided if there exists a new compiler for the platform..
-@code{gcc} >= 2.95.2 is recommended when compiling @strong{MySQL}
+@code{gcc} >= 2.95.2 is recommended when compiling MySQL
Version 3.23.x.
@item
@@ -6048,12 +7760,16 @@ of getting a solution to your problem! You will find @code{mysqlbug} in the
* Quick install:: Quick installation overview
* Applying patches:: Applying patches
* configure options:: Typical @code{configure} options
+* Installing source tree:: Installing from the Development Source Tree
+* Compilation problems:: Problems Compiling?
+* MIT-pthreads:: MIT-pthreads Notes
@end menu
+
@node Quick install, Applying patches, Installing source, Installing source
@subsection Quick Installation Overview
-The basic commands you must execute to install a @strong{MySQL} source
+The basic commands you must execute to install a MySQL source
distribution are:
@example
@@ -6100,7 +7816,7 @@ into it.
@item
Obtain a distribution file from one of the sites listed in
-@ref{Getting MySQL, , Getting @strong{MySQL}}.
+@ref{Getting MySQL, , Getting MySQL}.
@item
If you are interested in using Berkeley DB tables with MySQL, you
@@ -6108,7 +7824,7 @@ will need to obtain a patched version of the Berkeley DB source
code. Please read the chapter on Berkeley DB tables before
proceeding. @xref{BDB}.
-@strong{MySQL} source distributions are provided as compressed @code{tar}
+MySQL source distributions are provided as compressed @code{tar}
archives and have names like @file{mysql-VERSION.tar.gz}, where
@code{VERSION} is a number like @value{mysql_version}.
@@ -6140,7 +7856,7 @@ Change into the top-level directory of the unpacked distribution:
shell> cd mysql-VERSION
@end example
-Note that currently you must configure and build @strong{MySQL} from
+Note that currently you must configure and build MySQL from
this top-level directory. You can not build it in a different
directory.
@@ -6177,15 +7893,15 @@ shell> make install
You might need to run this command as @code{root}.
@item
-Create the @strong{MySQL} grant tables (necessary only if you haven't
-installed @strong{MySQL} before):
+Create the MySQL grant tables (necessary only if you haven't
+installed MySQL before):
@example
shell> scripts/mysql_install_db
@end example
-Note that @strong{MySQL} versions older than Version 3.22.10 started the
-@strong{MySQL} server when you run @code{mysql_install_db}. This is no
+Note that MySQL versions older than Version 3.22.10 started the
+MySQL server when you run @code{mysql_install_db}. This is no
longer true!
@item
@@ -6208,7 +7924,7 @@ If you want to install support for the Perl @code{DBI}/@code{DBD} interface,
see @ref{Perl support}.
@item
-If you would like @strong{MySQL} to start automatically when you boot your
+If you would like MySQL to start automatically when you boot your
machine, you can copy @code{support-files/mysql.server} to the location where
your system has its startup files. More information can be found in the
@code{support-files/mysql.server} script itself and in
@@ -6229,17 +7945,19 @@ running. @xref{Multiple servers}.
@xref{Post-installation}.
-@cindex patches, applying
-@cindex applying, patches
+
@node Applying patches, configure options, Quick install, Installing source
@subsection Applying Patches
+@cindex patches, applying
+@cindex applying, patches
+
Sometimes patches appear on the mailing list or are placed in the
@uref{http://www.mysql.com/Downloads/Patches, patches area} of the
-@strong{MySQL} Web site.
+MySQL Web site.
To apply a patch from the mailing list, save the message in which the patch
-appears in a file, change into the top-level directory of your @strong{MySQL}
+appears in a file, change into the top-level directory of your MySQL
source tree, and run these commands:
@example
@@ -6251,7 +7969,7 @@ shell> make clean
Patches from the FTP site are distributed as plain text files or as files
compressed with @code{gzip}. Apply a plain patch as shown above for
mailing list patches. To apply a compressed patch, change into the
-top-level directory of your @strong{MySQL} source tree and run these
+top-level directory of your MySQL source tree and run these
commands:
@example
@@ -6262,24 +7980,26 @@ shell> make clean
After applying a patch, follow the instructions for a normal source install,
beginning with the @code{./configure} step. After running the @code{make
-install} step, restart your @strong{MySQL} server.
+install} step, restart your MySQL server.
You may need to bring down any currently running server before you run
@code{make install}. (Use @code{mysqladmin shutdown} to do this.) Some
systems do not allow you to install a new version of a program if it replaces
the version that is currently executing.
+
+@node configure options, Installing source tree, Applying patches, Installing source
+@subsection Typical @code{configure} Options
+
+@findex without-server option
@cindex @code{configure} script
@cindex options, configure
@cindex configuration options
-@findex without-server option
@cindex log files
@cindex files, log
-@node configure options, , Applying patches, Installing source
-@subsection Typical @code{configure} Options
The @code{configure} script gives you a great deal of control over how
-you configure your @strong{MySQL} distribution. Typically you do this
+you configure your MySQL distribution. Typically you do this
using options on the @code{configure} command line. You can also affect
@code{configure} using certain environment variables. @xref{Environment
variables}. For a list of options supported by @code{configure}, run
@@ -6293,7 +8013,7 @@ Some of the more commonly-used @code{configure} options are described below:
@itemize @bullet
@item
-To compile just the @strong{MySQL} client libraries and client programs and
+To compile just the MySQL client libraries and client programs and
not the server, use the @code{--without-server} option:
@example
@@ -6332,7 +8052,7 @@ prefix, but overrides the default location for database directories
@cindex socket location, changing
@cindex mysql.sock, changing location of
@item
-If you are using Unix and you want the @strong{MySQL} socket located somewhere
+If you are using Unix and you want the MySQL socket located somewhere
other than the default location (normally in the directory @file{/tmp} or
@file{/var/run}) use a @code{configure} command like this:
@@ -6342,7 +8062,7 @@ shell> ./configure --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
Note that the given file must be an absolute pathname!
-@cindex compiling statically
+@cindex compiling, statically
@cindex statically, compiling
@item
If you want to compile statically linked programs (for example, to make a
@@ -6354,13 +8074,13 @@ shell> ./configure --with-client-ldflags=-all-static \
--with-mysqld-ldflags=-all-static
@end example
-@tindex CC environment variable
-@tindex environment variable, CC
-@tindex CXX environment variable
-@tindex environment variable, CXX
-@cindex gcc
-@cindex C++ complier, gcc
-@cindex compiler, C++ gcc
+@tindex @code{CC} environment variable
+@tindex environment variable, @code{CC}
+@tindex @code{CXX} environment variable
+@tindex environment variable, @code{CXX}
+@cindex @code{gcc}
+@cindex C++ compiler, @code{gcc}
+@cindex compiler, C++ @code{gcc}
@item
If you are using @code{gcc} and don't have @code{libg++} or @code{libstdc++}
installed, you can tell @code{configure} to use @code{gcc} as your C++
@@ -6389,7 +8109,7 @@ CFLAGS="-O3 -mpentiumpro" CXX=gcc CXXFLAGS="-O3 -mpentiumpro -felide-constructor
CFLAGS="-O3 -mpentiumpro -mstack-align-double" CXX=gcc CXXFLAGS="-O3 -mpentiumpro -mstack-align-double -felide-constructors -fno-exceptions -fno-rtti"
@end multitable
-In most cases you can get a reasonably optimal @strong{MySQL} binary by
+In most cases you can get a reasonably optimal MySQL binary by
using the options from the above and adding the following options to the
configure line:
@@ -6404,7 +8124,7 @@ following for all recent gcc versions:
CFLAGS="-O3 -mpentiumpro" CXX=gcc CXXFLAGS="-O3 -mpentiumpro -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --enable-assembler --with-mysqld-ldflags=-all-static
@end example
-The binaries we provide on the @strong{MySQL} Web site at
+The binaries we provide on the MySQL Web site at
@uref{http://www.mysql.com} are all compiled with full optimization and
should be perfect for most users. @xref{MySQL binaries}. There are some
things you can tweak to make an even faster binary, but this is only for
@@ -6419,7 +8139,7 @@ is a version number), you can work around this problem by giving the
@cindex default values, suppression
@cindex suppression, default values
@item
-You can configure @strong{MySQL} not to use @code{DEFAULT} column values for
+You can configure MySQL not to use @code{DEFAULT} column values for
non-@code{NULL} columns (that is, columns that are not allowed to be
@code{NULL}). This causes @code{INSERT} statements to generate an error
unless you explicitly specify values for all columns that require a
@@ -6436,7 +8156,7 @@ shell> CXXFLAGS=-DDONT_USE_DEFAULT_FIELDS ./configure
@findex configure option, --with-charset
@findex configure option, --with-extra-charset
@item
-By default, @strong{MySQL} uses the ISO-8859-1 (Latin1) character set. To
+By default, MySQL uses the ISO-8859-1 (Latin1) character set. To
change the default set, use the @code{--with-charset} option:
@example
shell> ./configure --with-charset=CHARSET
@@ -6457,18 +8177,18 @@ you should take a look at the @code{SET OPTION CHARACTER SET} command.
@strong{Warning:} If you change character sets after having created any
tables, you will have to run @code{myisamchk -r -q} on every table. Your
indexes may be sorted incorrectly otherwise. (This can happen if you
-install @strong{MySQL}, create some tables, then reconfigure
-@strong{MySQL} to use a different character set and reinstall it.)
+install MySQL, create some tables, then reconfigure
+MySQL to use a different character set and reinstall it.)
With the option @code{--with-extra-charset=LIST} you can define
which additional character sets should be incompiled in the server.
Here @code{LIST} is either a list of character set separated with space,
-@code{complex} to include all characters that can't be dynamicly loaded
+@code{complex} to include all characters that can't be dynamically loaded
or @code{all} to include all character sets into the binaries.
@item
-To configure @strong{MySQL} with debugging code, use the @code{--with-debug}
+To configure MySQL with debugging code, use the @code{--with-debug}
option:
@example
shell> ./configure --with-debug
@@ -6479,26 +8199,27 @@ and that provides output about what is happening.
@item
If your client programs are using threads, you need to also compile a
-thread-safe version of the @strong{MySQL} client library with the
+thread-safe version of the MySQL client library with the
@code{--with-thread-safe-client} configure options. This will create a
@code{libmysqlclient_r} library with which you should link your threaded
applications. @xref{Thread-safe clients}.
@item
Options that pertain to particular systems can be found in the
-system-specific sections later in this chapter. @xref{Source install
-system issues}.
+system-specific section of this manual.
+@xref{Operating System Specific Notes}.
@end itemize
-@node Installing source tree, Compilation problems, Installing source, Installing
-@section Installing from the Development Source Tree
+
+@node Installing source tree, Compilation problems, configure options, Installing source
+@subsection Installing from the Development Source Tree
@cindex development source tree
@cindex BitKeeper tree
@cindex cvs tree
@strong{CAUTION:} You should read this section only if you are interested
-in helping us test our new code. If you just want to get @strong{MySQL} up
+in helping us test our new code. If you just want to get MySQL up
and running on your system, you should use a standard release distribution
(either a source or binary distribution will do).
@@ -6515,7 +8236,7 @@ Follow the instructions to install it.
@item
After @strong{BitKeeper} is installed, use this command if you want to clone
-the @strong{MySQL} 3.23 branch:
+the MySQL 3.23 branch:
@example
shell> bk clone bk://work.mysql.com:7000 mysql
@@ -6552,7 +8273,7 @@ modify the script removing flags that are Pentium-specific.
@item
When the build is done, run @code{make install}. Be careful with this
on a production machine; the command may overwrite your live release
-installation. If you have another installation of @strong{MySQL}, we
+installation. If you have another installation of MySQL, we
recommand that you run @code{./configure} with different values for the
@code{prefix}, @code{tcp-port}, and @code{unix-socket-path} options than
those used for your production server.
@@ -6591,15 +8312,17 @@ a description.
@end enumerate
+
+@node Compilation problems, MIT-pthreads, Installing source tree, Installing source
+@subsection Problems Compiling?
+
@cindex compiling, problems
@cindex problems, compiling
@cindex reconfiguring
@cindex @code{config.cache} file
@cindex files, @code{config.cache}
-@node Compilation problems, MIT-pthreads, Installing source tree, Installing
-@section Problems Compiling?
-All @strong{MySQL} programs compile cleanly for us with no warnings on
+All MySQL programs compile cleanly for us with no warnings on
Solaris using @code{gcc}. On other systems, warnings may occur due to
differences in system include files. See @ref{MIT-pthreads} for warnings
that may occur when using MIT-pthreads. For other problems, check the list
@@ -6637,7 +8360,7 @@ shell> make clean
Alternatively, you can run @code{make distclean}.
-The list below describes some of the problems compiling @strong{MySQL}
+The list below describes some of the problems compiling MySQL
that have been found to occur most often:
@itemize @bullet
@@ -6794,7 +8517,7 @@ operating system. (Note that you will have to do this each time you run
@item
The @file{sql_yacc.cc} file is generated from @file{sql_yacc.yy}. Normally
the build process doesn't need to create @file{sql_yacc.cc}, because
-@strong{MySQL} comes with an already-generated copy. However, if you do need
+MySQL comes with an already-generated copy. However, if you do need
to re-create it, you might encounter this error:
@example
@@ -6806,15 +8529,17 @@ You probably need to install @code{bison} (the GNU version of @code{yacc})
and use that instead.
@item
-If you need to debug @code{mysqld} or a @strong{MySQL} client, run
+If you need to debug @code{mysqld} or a MySQL client, run
@code{configure} with the @code{--with-debug} option, then recompile and
link your clients with the new client library. @xref{Debugging client}.
@end itemize
+
+@node MIT-pthreads, , Compilation problems, Installing source
+@subsection MIT-pthreads Notes
+
@cindex MIT-pthreads
@cindex thread support, non-native
-@node MIT-pthreads, Perl support, Compilation problems, Installing
-@section MIT-pthreads Notes
This section describes some of the issues involved in using MIT-pthreads.
@@ -6822,7 +8547,7 @@ Note that on Linux you should NOT use MIT-pthreads but install LinuxThreads!
@xref{Linux}.
If your system does not provide native thread support, you will need to
-build @strong{MySQL} using the MIT-pthreads package. This includes
+build MySQL using the MIT-pthreads package. This includes
older FreeBSD systems, SunOS 4.x, Solaris 2.4 and earlier, and some others.
@xref{Which OS}.
@@ -6848,7 +8573,7 @@ Because Unix sockets do not work under MIT-pthreads, this means you will need
to use @code{-h} or @code{--host} when you run client programs.
@item
-When @strong{MySQL} is compiled using MIT-pthreads, system locking is
+When MySQL is compiled using MIT-pthreads, system locking is
disabled by default for performance reasons. You can tell the server to use
system locking with the @code{--use-locking} option.
@@ -6901,628 +8626,1034 @@ We haven't gotten @code{readline} to work with MIT-pthreads. (This isn't
needed, but may be interesting for someone.)
@end itemize
-@cindex Perl, installing
-@cindex installing, Perl
-@node Perl support, Source install system issues, MIT-pthreads, Installing
-@section Perl Installation Comments
-
-@menu
-* Perl installation:: Installing Perl on Unix
-* ActiveState Perl:: Installing ActiveState Perl on Windows
-* Windows Perl:: Installing the @strong{MySQL} Perl distribution on Windows
-* Perl support problems:: Problems using the Perl @code{DBI}/@code{DBD} interface
-@end menu
-@node Perl installation, ActiveState Perl, Perl support, Perl support
-@subsection Installing Perl on Unix
+@node Post-installation, Upgrade, Installing source, Installing
+@section Post-installation Setup and Testing
-Perl support for @strong{MySQL} is provided by means of the
-@code{DBI}/@code{DBD} client interface. @xref{Perl}. The Perl
-@code{DBD}/@code{DBI} client code requires Perl Version 5.004 or later. The
-interface @strong{will not work} if you have an older version of Perl.
+@cindex post-installation, setup and testing
+@cindex testing, post-installation
+@cindex setup, post-installation
-@strong{MySQL} Perl support also requires that you've installed
-@strong{MySQL} client programming support. If you installed @strong{MySQL}
-from RPM files, client programs are in the client RPM, but client programming
-support is in the developer RPM. Make sure you've installed the latter RPM.
+@menu
+* mysql_install_db:: Problems running @code{mysql_install_db}
+* Starting server:: Problems starting the MySQL server
+* Automatic start:: Starting and stopping MySQL automatically
+@end menu
-As of Version 3.22.8, Perl support is distributed separately from the main
-@strong{MySQL} distribution. If you want to install Perl support, the files
-you will need can be obtained from
-@uref{http://www.mysql.com/Downloads/Contrib/}.
+Once you've installed MySQL (from either a binary or source
+distribution), you need to initialize the grant tables, start the server,
+and make sure that the server works okay. You may also wish to arrange
+for the server to be started and stopped automatically when your system
+starts up and shuts down.
-The Perl distributions are provided as compressed @code{tar} archives and
-have names like @file{MODULE-VERSION.tar.gz}, where @code{MODULE} is the
-module name and @code{VERSION} is the version number. You should get the
-@code{Data-Dumper}, @code{DBI}, and @code{Msql-Mysql-modules} distributions
-and install them in that order. The installation procedure is shown below.
-The example shown is for the @code{Data-Dumper} module, but the procedure is
-the same for all three distributions:
+Normally you install the grant tables and start the server like this
+for installation from a source distribution:
+@cindex starting, the server
+@cindex server, starting
-@enumerate
-@item
-Unpack the distribution into the current directory:
@example
-shell> gunzip < Data-Dumper-VERSION.tar.gz | tar xvf -
+shell> ./scripts/mysql_install_db
+shell> cd mysql_installation_directory
+shell> ./bin/safe_mysqld --user=mysql &
@end example
-This command creates a directory named @file{Data-Dumper-VERSION}.
-@item
-Change into the top-level directory of the unpacked distribution:
+For a binary distribution (not RPM or pkg packages), do this:
+
@example
-shell> cd Data-Dumper-VERSION
+shell> cd mysql_installation_directory
+shell> ./bin/mysql_install_db
+shell> ./bin/safe_mysqld --user=mysql &
@end example
+This creates the @code{mysql} database which will hold all database
+privileges, the @code{test} database which you can use to test
+MySQL and also privilege entries for the user that run
+@code{mysql_install_db} and a @code{root} user (without any passwords).
+This also starts the @code{mysqld} server.
+
+@code{mysql_install_db} will not overwrite any old privilege tables, so
+it should be safe to run in any circumstances. If you don't want to
+have the @code{test} database you can remove it with @code{mysqladmin -u
+root drop test}.
+
+Testing is most easily done from the top-level directory of the MySQL
+distribution. For a binary distribution, this is your installation directory
+(typically something like @file{/usr/local/mysql}). For a source
+distribution, this is the main directory of your MySQL source tree.
+@cindex testing, the server
+
+In the commands shown below in this section and in the following
+subsections, @code{BINDIR} is the path to the location in which programs
+like @code{mysqladmin} and @code{safe_mysqld} are installed. For a
+binary distribution, this is the @file{bin} directory within the
+distribution. For a source distribution, @code{BINDIR} is probably
+@file{/usr/local/bin}, unless you specified an installation directory
+other than @file{/usr/local} when you ran @code{configure}.
+@code{EXECDIR} is the location in which the @code{mysqld} server is
+installed. For a binary distribution, this is the same as
+@code{BINDIR}. For a source distribution, @code{EXECDIR} is probably
+@file{/usr/local/libexec}.
+
+Testing is described in detail below:
+@cindex testing, installation
+
+@enumerate
@item
-Build the distribution and compile everything:
+If necessary, start the @code{mysqld} server and set up the initial
+MySQL grant tables containing the privileges that determine how
+users are allowed to connect to the server. This is normally done with the
+@code{mysql_install_db} script:
+
@example
-shell> perl Makefile.PL
-shell> make
-shell> make test
-shell> make install
+shell> scripts/mysql_install_db
@end example
-@end enumerate
-The @code{make test} command is important because it verifies that the
-module is working. Note that when you run that command during the
-@code{Msql-Mysql-modules} installation to exercise the interface code, the
-@strong{MySQL} server must be running or the test will fail.
+Typically, @code{mysql_install_db} needs to be run only the first time you
+install MySQL. Therefore, if you are upgrading an existing
+installation, you can skip this step. (However, @code{mysql_install_db} is
+quite safe to use and will not update any tables that already exist, so if
+you are unsure of what to do, you can always run @code{mysql_install_db}.)
-It is a good idea to rebuild and reinstall the @code{Msql-Mysql-modules}
-distribution whenever you install a new release of @strong{MySQL},
-particularly if you notice symptoms such as all your @code{DBI} scripts
-dumping core after you upgrade @strong{MySQL}.
+@code{mysql_install_db} creates six tables (@code{user}, @code{db},
+@code{host}, @code{tables_priv}, @code{columns_priv}, and @code{func}) in the
+@code{mysql} database. A description of the initial privileges is given in
+@ref{Default privileges}. Briefly, these privileges allow the MySQL
+@code{root} user to do anything, and allow anybody to create or use databases
+with a name of @code{'test'} or starting with @code{'test_'}.
-If you don't have the right to install Perl modules in the system directory
-or if you to install local Perl modules, the following reference may help
-you:
+If you don't set up the grant tables, the following error will appear in the
+log file when you start the server:
+@tindex host.frm, problems finding
@example
-@uref{http://www.iserver.com/support/contrib/perl5/modules.html}
+mysqld: Can't find file: 'host.frm'
@end example
-Look under the heading
-@code{Installing New Modules that Require Locally Installed Modules}.
+The above may also happen with a binary MySQL distribution if you
+don't start MySQL by executing exactly @code{./bin/safe_mysqld}!
+@xref{safe_mysqld, , @code{safe_mysqld}}.
-@node ActiveState Perl, Windows Perl, Perl installation, Perl support
-@subsection Installing ActiveState Perl on Windows
-@cindex installing, Perl on Windows
-@cindex Perl, installing on Windows
-@cindex ActiveState Perl
+You might need to run @code{mysql_install_db} as @code{root}. However,
+if you prefer, you can run the MySQL server as an unprivileged
+(non-@code{root}) user, provided that user can read and write files in
+the database directory. Instructions for running MySQL as an
+unprivileged user are given in @ref{Changing MySQL user, , Changing
+MySQL user}.
-To install the @strong{MySQL} @code{DBD} module with ActiveState Perl on
-Windows, you should do the following:
+If you have problems with @code{mysql_install_db}, see
+@ref{mysql_install_db, , @code{mysql_install_db}}.
+
+There are some alternatives to running the @code{mysql_install_db}
+script as it is provided in the MySQL distribution:
@itemize @bullet
-@item
-Get ActiveState Perl from
-@uref{http://www.activestate.com/Products/ActivePerl/index.html}
-and install it.
+@item
+You may want to edit @code{mysql_install_db} before running it, to change
+the initial privileges that are installed into the grant tables. This is
+useful if you want to install MySQL on a lot of machines with the
+same privileges. In this case you probably should need only to add a few
+extra @code{INSERT} statements to the @code{mysql.user} and @code{mysql.db}
+tables!
@item
-Open a DOS shell.
+If you want to change things in the grant tables after installing them, you
+can run @code{mysql_install_db}, then use @code{mysql -u root mysql} to
+connect to the grant tables as the MySQL @code{root} user and issue
+SQL statements to modify the grant tables directly.
-@item
-If required, set the HTTP_proxy variable. For example, you might try:
+@item
+It is possible to re-create the grant tables completely after they have
+already been created. You might want to do this if you've already installed
+the tables but then want to re-create them after editing
+@code{mysql_install_db}.
+@end itemize
+
+For more information about these alternatives, see @ref{Default privileges}.
+
+@item
+Start the MySQL server like this:
@example
-set HTTP_proxy=my.proxy.com:3128
+shell> cd mysql_installation_directory
+shell> bin/safe_mysqld &
@end example
+If you have problems starting the server, see @ref{Starting server}.
+
@item
-Start the PPM program:
+Use @code{mysqladmin} to verify that the server is running. The following
+commands provide a simple test to check that the server is up and responding
+to connections:
@example
-C:\> c:\perl\bin\ppm.pl
+shell> BINDIR/mysqladmin version
+shell> BINDIR/mysqladmin variables
@end example
-@item
-If you have not already done so, install @code{DBI}:
+The output from @code{mysqladmin version} varies slightly depending on your
+platform and version of MySQL, but should be similar to that shown
+below:
@example
-ppm> install DBI
+shell> BINDIR/mysqladmin version
+mysqladmin Ver 8.14 Distrib 3.23.32, for linux on i586
+Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+This software comes with ABSOLUTELY NO WARRANTY. This is free software,
+and you are welcome to modify and redistribute it under the GPL license
+
+Server version 3.23.32-debug
+Protocol version 10
+Connection Localhost via Unix socket
+TCP port 3306
+UNIX socket /tmp/mysql.sock
+Uptime: 16 sec
+
+Threads: 1 Questions: 9 Slow queries: 0 Opens: 7 Flush tables: 2 Open tables: 0 Queries per second avg: 0.000 Memory in use: 132K Max memory used: 16773K
@end example
+To get a feeling for what else you can do with @code{BINDIR/mysqladmin},
+invoke it with the @code{--help} option.
+
@item
-If this succeeds, run the following command:
+Verify that you can shut down the server:
+@cindex server, shutdown
+@cindex shutting down, the server
@example
-install ftp://ftp.de.uu.net/pub/CPAN/authors/id/JWIED/DBD-mysql-1.2212.x86.ppd
+shell> BINDIR/mysqladmin -u root shutdown
@end example
-@end itemize
-The above should work at least with ActiveState Perl Version 5.6.
+@item
+Verify that you can restart the server. Do this using @code{safe_mysqld} or
+by invoking @code{mysqld} directly. For example:
-If you can't get the above to work, you should instead install the
-@strong{MyODBC} driver and connect to @strong{MySQL} server through
-ODBC:
+@cindex server, restart
+@cindex restarting, the server
@example
-use DBI;
-$dbh= DBI->connect("DBI:ODBC:$dsn","$user","$password") ||
- die "Got error $DBI::errstr when connecting to $dsn\n";
+shell> BINDIR/safe_mysqld --log &
@end example
-@node Windows Perl, Perl support problems, ActiveState Perl, Perl support
-@subsection Installing the MySQL Perl Distribution on Windows
+If @code{safe_mysqld} fails, try running it from the MySQL
+installation directory (if you are not already there). If that doesn't work,
+see @ref{Starting server}.
-The @strong{MySQL} Perl distribution contains @code{DBI},
-@code{DBD:MySQL} and @code{DBD:ODBC}.
+@item
+Run some simple tests to verify that the server is working.
+The output should be similar to what is shown below:
-@itemize @bullet
-@item
-Get the Perl distribution for Windows from
-@uref{http://www.mysql.com/download.html}.
+@example
+shell> BINDIR/mysqlshow
++-----------+
+| Databases |
++-----------+
+| mysql |
++-----------+
-@item
-Unzip the distribution in @code{C:} so that you get a @file{C:\PERL} directory.
+shell> BINDIR/mysqlshow mysql
+Database: mysql
++--------------+
+| Tables |
++--------------+
+| columns_priv |
+| db |
+| func |
+| host |
+| tables_priv |
+| user |
++--------------+
-@item
-Add the directory @file{C:\PERL\BIN} to your path.
+shell> BINDIR/mysql -e "select host,db,user from db" mysql
++------+--------+------+
+| host | db | user |
++------+--------+------+
+| % | test | |
+| % | test_% | |
++------+--------+------+
+@end example
-@item
-Add the directory @file{C:\PERL\BIN\MSWIN32-x86-thread} or
-@file{C:\PERL\BIN\MSWIN32-x86} to your path.
+There is also a benchmark suite in the @file{sql-bench} directory (under the
+MySQL installation directory) that you can use to compare how
+MySQL performs on different platforms. The @file{sql-bench/Results}
+directory contains the results from many runs against different databases and
+platforms. To run all tests, execute these commands:
-@item
-Test that @code{perl} works by executing @code{perl -v} in a DOS shell.
-@end itemize
+@example
+shell> cd sql-bench
+shell> run-all-tests
+@end example
-@cindex problems, installing Perl
-@cindex Perl DBI/DBD, installation problems
-@node Perl support problems, , Windows Perl, Perl support
-@subsection Problems Using the Perl @code{DBI}/@code{DBD} Interface
+If you don't have the @file{sql-bench} directory, you are probably using an
+RPM for a binary distribution. (Source distribution RPMs include the
+benchmark directory.) In this case, you must first install the benchmark
+suite before you can use it. Beginning with MySQL Version 3.22,
+there are benchmark RPM files named @file{mysql-bench-VERSION-i386.rpm} that
+contain benchmark code and data.
-If Perl reports that it can't find the @file{../mysql/mysql.so} module,
-then the problem is probably that Perl can't locate the shared library
-@file{libmysqlclient.so}.
+If you have a source distribution, you can also run the tests in the
+@file{tests} subdirectory. For example, to run @file{auto_increment.tst}, do
+this:
-You can fix this by any of the following methods:
+@example
+shell> BINDIR/mysql -vvf test < ./tests/auto_increment.tst
+@end example
-@itemize @bullet
-@item
-Compile the @code{Msql-Mysql-modules} distribution with @code{perl
-Makefile.PL -static -config} rather than @code{perl Makefile.PL}.
+The expected results are shown in the @file{./tests/auto_increment.res} file.
+@end enumerate
-@item
-Copy @code{libmysqlclient.so} to the directory where your other shared
-libraries are located (probably @file{/usr/lib} or @file{/lib}).
-@item
-On Linux you can add the pathname of the directory where
-@file{libmysqlclient.so} is located to the @file{/etc/ld.so.conf} file.
+@node mysql_install_db, Starting server, Post-installation, Post-installation
+@subsection Problems Running @code{mysql_install_db}
+@cindex @code{mysql_install_db} script
+@cindex scripts, @code{mysql_install_db}
-@tindex LD_RUN_PATH environment variable
-@tindex Environment variable, LD_RUN_PATH
-@item
-Add the pathname of the directory where @file{libmysqlclient.so} is located
-to the @code{LD_RUN_PATH} environment variable.
-@end itemize
+The purpose of the @code{mysql_install_db} script is to generate new
+MySQL privilege tables. It will not affect any other data!
+It will also not do anything if you already have MySQL privilege
+tables installed!
-If you get the following errors from @code{DBD-mysql},
-you are probably using @code{gcc} (or using an old binary compiled with
-@code{gcc}):
+If you want to re-create your privilege tables, you should take down
+the @code{mysqld} server, if it's running, and then do something like:
@example
-/usr/bin/perl: can't resolve symbol '__moddi3'
-/usr/bin/perl: can't resolve symbol '__divdi3'
+mv mysql-data-directory/mysql mysql-data-directory/mysql-old
+mysql_install_db
@end example
-Add @code{-L/usr/lib/gcc-lib/... -lgcc} to the link command when the
-@file{mysql.so} library gets built (check the output from @code{make} for
-@file{mysql.so} when you compile the Perl client). The @code{-L} option
-should specify the pathname of the directory where @file{libgcc.a} is located
-on your system.
+This section lists problems you might encounter when you run
+@code{mysql_install_db}:
-Another cause of this problem may be that Perl and @strong{MySQL} aren't both
-compiled with @code{gcc}. In this case, you can solve the mismatch by
-compiling both with @code{gcc}.
+@table @strong
+@item @code{mysql_install_db} doesn't install the grant tables
-If you get the following error from @code{Msql-Mysql-modules}
-when you run the tests:
+You may find that @code{mysql_install_db} fails to install the grant
+tables and terminates after displaying the following messages:
@example
-t/00base............install_driver(mysql) failed: Can't load '../blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql: ../blib/arch/auto/DBD/mysql/mysql.so: undefined symbol: uncompress at /usr/lib/perl5/5.00503/i586-linux/DynaLoader.pm line 169.
+starting mysqld daemon with databases from XXXXXX
+mysql daemon ended
@end example
-it means that you need to include the compression library, -lz, to the
-link line. This can be doing the following change in the file
-@file{lib/DBD/mysql/Install.pm}:
+In this case, you should examine the log file very carefully! The log
+should be located in the directory @file{XXXXXX} named by the error message,
+and should indicate why @code{mysqld} didn't start. If you don't understand
+what happened, include the log when you post a bug report using
+@code{mysqlbug}!
+@xref{Bug reports}.
-@example
-$sysliblist .= " -lm";
+@item There is already a @code{mysqld} daemon running
-to
+In this case, you probably don't have to run @code{mysql_install_db} at
+all. You have to run @code{mysql_install_db} only once, when you install
+MySQL the first time.
-$sysliblist .= " -lm -lz";
-@end example
+@item Installing a second @code{mysqld} daemon doesn't work when one daemon is running
-After this, you MUST run 'make realclean' and then proceed with the
-installation from the beginning.
+This can happen when you already have an existing MySQL
+installation, but want to put a new installation in a different place (for
+example, for testing, or perhaps you simply want to run two installations at
+the same time). Generally the problem that occurs when you try to run the
+second server is that it tries to use the same socket and port as the old one.
+In this case you will get the error message: @code{Can't start server: Bind on
+TCP/IP port: Address already in use} or @code{Can't start server : Bind on
+unix socket...}. @xref{Installing many servers}.
-If you want to use the Perl module on a system that doesn't support dynamic
-linking (like SCO) you can generate a static version of Perl that includes
-@code{DBI} and @code{DBD-mysql}. The way this works is that you generate a
-version of Perl with the @code{DBI} code linked in and install it on top of
-your current Perl. Then you use that to build a version of Perl that
-additionally has the @code{DBD} code linked in, and install that.
+@item You don't have write access to @file{/tmp}
+@cindex write access, tmp
+@cindex temporary file, write access
+@cindex files, @code{tmp}
-On SCO, you must have the following environment variables set:
+If you don't have write access to create a socket file at the default place
+(in @file{/tmp}) or permission to create temporary files in @file{/tmp,}
+you will get an error when running @code{mysql_install_db} or when
+starting or using @code{mysqld}.
+You can specify a different socket and temporary directory as follows:
+
+@tindex TMPDIR environment variable
+@tindex MYSQL_UNIX_PORT environment variable
+@tindex Environment variable, TMPDIR
+@tindex Environment variable, MYSQL_UNIX_PORT
@example
-shell> LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib:/usr/progressive/lib
-or
-shell> LD_LIBRARY_PATH=/usr/lib:/lib:/usr/local/lib:/usr/ccs/lib:/usr/progressive/lib:/usr/skunk/lib
-shell> LIBPATH=/usr/lib:/lib:/usr/local/lib:/usr/ccs/lib:/usr/progressive/lib:/usr/skunk/lib
-shell> MANPATH=scohelp:/usr/man:/usr/local1/man:/usr/local/man:/usr/skunk/man:
+shell> TMPDIR=/some_tmp_dir/
+shell> MYSQL_UNIX_PORT=/some_tmp_dir/mysqld.sock
+shell> export TMPDIR MYSQL_UNIX_PORT
@end example
-First, create a Perl that includes a statically linked @code{DBI} by running
-these commands in the directory where your @code{DBI} distribution is
-located:
+@file{some_tmp_dir} should be the path to some directory for which you
+have write permission. @xref{Environment variables}.
+
+After this you should be able to run @code{mysql_install_db} and start
+the server with these commands:
@example
-shell> perl Makefile.PL -static -config
-shell> make
-shell> make install
-shell> make perl
+shell> scripts/mysql_install_db
+shell> BINDIR/safe_mysqld &
@end example
-Then you must install the new Perl. The output of @code{make perl} will
-indicate the exact @code{make} command you will need to execute to perform
-the installation. On SCO, this is @code{make -f Makefile.aperl inst_perl
-MAP_TARGET=perl}.
+@item @code{mysqld} crashes immediately
-Next, use the just-created Perl to create another Perl that also includes a
-statically-linked @code{DBD::mysql} by running these commands in the
-directory where your @code{Msql-Mysql-modules} distribution is located:
+If you are running RedHat Version 5.0 with a version of @code{glibc} older than
+2.0.7-5, you should make sure you have installed all @code{glibc} patches!
+There is a lot of information about this in the MySQL mail
+archives. Links to the mail archives are available online at
+@uref{http://www.mysql.com/documentation/}.
+Also, see @ref{Linux}.
+
+You can also start @code{mysqld} manually using the @code{--skip-grant-tables}
+option and add the privilege information yourself using @code{mysql}:
@example
-shell> perl Makefile.PL -static -config
-shell> make
-shell> make install
-shell> make perl
+shell> BINDIR/safe_mysqld --skip-grant-tables &
+shell> BINDIR/mysql -u root mysql
@end example
-Finally, you should install this new Perl. Again, the output of @code{make
-perl} indicates the command to use.
+From @code{mysql}, manually execute the SQL commands in
+@code{mysql_install_db}. Make sure you run @code{mysqladmin
+flush-privileges} or @code{mysqladmin reload} afterward to tell the server to
+reload the grant tables.
+@end table
-@node Source install system issues, Windows, Perl support, Installing
-@section System-specific Issues
-The following sections indicate some of the issues that have been observed to
-occur on particular systems when installing @strong{MySQL} from a source
-distribution.
+@node Starting server, Automatic start, mysql_install_db, Post-installation
+@subsection Problems Starting the MySQL Server
+@cindex server, starting problems
+@cindex problems, starting the server
-@menu
-* Solaris:: Solaris notes
-* Solaris 2.7:: Solaris 2.7 / 2.8 notes
-* Solaris x86:: Solaris x86 notes
-* SunOS:: SunOS 4 notes
-* Linux:: Linux notes (all Linux versions)
-* Alpha-DEC-UNIX:: Alpha-DEC-UNIX notes
-* Alpha-DEC-OSF1:: Alpha-DEC-OSF1 notes
-* SGI-Irix:: SGI-Irix notes
-* FreeBSD:: FreeBSD notes
-* NetBSD:: NetBSD notes
-* OpenBSD:: OpenBSD 2.5 notes
-* BSDI:: BSD/OS notes
-* SCO:: SCO notes
-* SCO Unixware:: SCO Unixware 7.0 notes
-* IBM-AIX:: IBM-AIX notes
-* HP-UX 10.20:: HP-UX 10.20 notes
-* HP-UX 11.x:: HP-UX 11.x notes
-* Mac OS X:: Mac OS X notes
-* BEOS:: BeOS Notes
-@end menu
+If you are going to use tables that support transactions (BDB, InnoDB),
+you should first create a my.cnf file and set startup options
+for the table types you plan to use. @xref{Table types}.
+Generally, you start the @code{mysqld} server in one of three ways:
-@cindex Solaris installation problems
-@cindex problems, installing on Solaris
-@cindex tar, problems on Solaris
-@cindex errors, directory checksum
-@cindex checksum errors
-@node Solaris, Solaris 2.7, Source install system issues, Source install system issues
-@subsection Solaris Notes
+@itemize @bullet
+@item
+By invoking @code{mysql.server}. This script is used primarily at
+system startup and shutdown, and is described more fully in
+@ref{Automatic start}.
-On Solaris, you may run into trouble even before you get the @strong{MySQL}
-distribution unpacked! Solaris @code{tar} can't handle long file names, so
-you may see an error like this when you unpack @strong{MySQL}:
+@item
+By invoking @code{safe_mysqld}, which tries to determine the proper options
+for @code{mysqld} and then runs it with those options. @xref{safe_mysqld, ,
+@code{safe_mysqld}}.
+@item
+On NT you should install @code{mysqld} as a service as follows:
@example
-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
-tar: directory checksum error
+bin\mysqld-nt --install # Install MySQL as a service
@end example
-In this case, you must use GNU @code{tar} (@code{gtar}) to unpack the
-distribution. You can find a precompiled copy for Solaris at
-@uref{http://www.mysql.com/Downloads/}.
-
-Sun native threads work only on Solaris 2.5 and higher. For Version 2.4 and
-earlier, @strong{MySQL} will automatically use MIT-pthreads.
-@xref{MIT-pthreads}.
+You can now start/stop @code{mysqld} as follows:
+@example
+NET START mysql
+NET STOP mysql
+@end example
-If you get the following error from configure:
+Note that in this case you can't use any other options for @code{mysqld}!
+You can remove the service as follows:
@example
-checking for restartable system calls... configure: error can not run test
-programs while cross compiling
+bin\mysqld-nt --remove # remove MySQL as a service
@end example
-This means that you have something wrong with your compiler installation!
-In this case you should upgrade your compiler to a newer version. You may
-also be able to solve this problem by inserting the following row into the
-@file{config.cache} file:
+@item
+By invoking @code{mysqld} directly.
+@end itemize
+
+When the @code{mysqld} daemon starts up, it changes directory to the
+data directory. This is where it expects to write log files and the pid
+(process ID) file, and where it expects to find databases.
+
+The data directory location is hardwired in when the distribution is
+compiled. However, if @code{mysqld} expects to find the data directory
+somewhere other than where it really is on your system, it will not work
+properly. If you have problems with incorrect paths, you can find out
+what options @code{mysqld} allows and what the default path settings are by
+invoking @code{mysqld} with the @code{--help} option. You can override the
+defaults by specifying the correct pathnames as command-line arguments to
+@code{mysqld}. (These options can be used with @code{safe_mysqld} as well.)
+
+Normally you should need to tell @code{mysqld} only the base directory under
+which MySQL is installed. You can do this with the @code{--basedir}
+option. You can also use @code{--help} to check the effect of changing path
+options (note that @code{--help} @emph{must} be the final option of the
+@code{mysqld} command). For example:
@example
-ac_cv_sys_restartable_syscalls=$@{ac_cv_sys_restartable_syscalls='no'@}
+shell> EXECDIR/mysqld --basedir=/usr/local --help
@end example
-If you are using Solaris on a SPARC, the recommended compiler is
-@code{gcc} 2.95.2. You can find this at @uref{http://gcc.gnu.org/}.
-Note that @code{egcs} 1.1.1 and @code{gcc} 2.8.1 don't work reliably on
-SPARC!
+Once you determine the path settings you want, start the server without
+the @code{--help} option.
-The recommended @code{configure} line when using @code{gcc} 2.95.2 is:
+Whichever method you use to start the server, if it fails to start up
+correctly, check the log file to see if you can find out why. Log files
+are located in the data directory (typically
+@file{/usr/local/mysql/data} for a binary distribution,
+@file{/usr/local/var} for a source distribution,
+@file{\mysql\data\mysql.err} on Windows.) Look in the data directory for
+files with names of the form @file{host_name.err} and
+@file{host_name.log} where @code{host_name} is the name of your server
+host. Then check the last few lines of these files:
@example
-CC=gcc CFLAGS="-O3" \
-CXX=gcc CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti" \
-./configure --prefix=/usr/local/mysql --with-low-memory --enable-assembler
+shell> tail host_name.err
+shell> tail host_name.log
@end example
-If you have a ultra sparc, you can get 4 % more performance by adding
-"-mcpu=v8 -Wa,-xarch=v8plusa" to CFLAGS and CXXFLAGS.
+If you find something like the following in the log file:
+@example
+000729 14:50:10 bdb: Recovery function for LSN 1 27595 failed
+000729 14:50:10 bdb: warning: ./test/t1.db: No such file or directory
+000729 14:50:10 Can't init databases
+@end example
-If you have the Sun Workshop (SunPro) 4.2 (or newer) compiler, you can
-run @code{configure} like this:
+This means that you didn't start @code{mysqld} with @code{--bdb-no-recover}
+and Berkeley DB found something wrong with its log files when it
+tried to recover your databases. To be able to continue, you should
+move away the old Berkeley DB log file from the database directory to
+some other place, where you can later examine these. The log files are
+named @file{log.0000000001}, where the number will increase over time.
+
+If you are running @code{mysqld} with BDB table support and @code{mysqld} core
+dumps at start this could be because of some problems with the BDB
+recover log. In this case you can try starting @code{mysqld} with
+@code{--bdb-no-recover}. If this helps, then you should remove all
+@file{log.*} files from the data directory and try starting @code{mysqld}
+again.
+
+If you get the following error, it means that some other program (or another
+@code{mysqld} server) is already using the TCP/IP port or socket
+@code{mysqld} is trying to use:
@example
-CC=cc CFLAGS="-Xa -fast -xO4 -native -xstrconst -mt" \
-CXX=CC CXXFLAGS="-noex -xO4 -mt" \
-./configure --prefix=/usr/local/mysql --enable-assembler
+Can't start server: Bind on TCP/IP port: Address already in use
+ or
+Can't start server : Bind on unix socket...
@end example
-You may also have to edit the @code{configure} script to change this line:
+Use @code{ps} to make sure that you don't have another @code{mysqld} server
+running. If you can't find another server running, you can try to execute
+the command @code{telnet your-host-name tcp-ip-port-number} and press
+@code{RETURN} a couple of times. If you don't get an error message like
+@code{telnet: Unable to connect to remote host: Connection refused},
+something is using the TCP/IP port @code{mysqld} is trying to use.
+See @ref{mysql_install_db} and @ref{Multiple servers}.
+
+If @code{mysqld} is currently running, you can find out what path settings
+it is using by executing this command:
@example
-#if !defined(__STDC__) || __STDC__ != 1
+shell> mysqladmin variables
@end example
-to this:
+or
@example
-#if !defined(__STDC__)
+shell> mysqladmin -h 'your-host-name' variables
@end example
-If you turn on @code{__STDC__} with the @code{-Xc} option, the Sun compiler
-can't compile with the Solaris @file{pthread.h} header file. This is a Sun
-bug (broken compiler or broken include file).
-
-If @code{mysqld} issues the error message shown below when you run it, you have
-tried to compile @strong{MySQL} with the Sun compiler without enabling the
-multi-thread option (@code{-mt}):
+If @code{safe_mysqld} starts the server but you can't connect to it,
+you should make sure you have an entry in @file{/etc/hosts} that looks like
+this:
@example
-libc internal error: _rmutex_unlock: rmutex not held
+127.0.0.1 localhost
@end example
-Add @code{-mt} to @code{CFLAGS} and @code{CXXFLAGS} and try again.
+This problem occurs only on systems that don't have a working thread
+library and for which MySQL must be configured to use MIT-pthreads.
-If you get the following error when compiling @strong{MySQL} with @code{gcc},
-it means that your @code{gcc} is not configured for your version of Solaris:
+If you can't get @code{mysqld} to start you can try to make a trace file
+to find the problem. @xref{Making trace files}.
+
+If you are using InnoDB tables, refer to the InnoDB-specific startup
+options. @xref{InnoDB start}.
+
+If you are using BDB (Berkeley DB) tables, you should familiarize
+yourself with the different BDB specific startup options. @xref{BDB start}.
+
+
+@node Automatic start, , Starting server, Post-installation
+@subsection Starting and Stopping MySQL Automatically
+
+@cindex starting, the server automatically
+@cindex stopping, the server
+@cindex server, starting and stopping
+
+The @code{mysql.server} and @code{safe_mysqld} scripts can be used to start
+the server automatically at system startup time. @code{mysql.server} can also
+be used to stop the server.
+
+The @code{mysql.server} script can be used to start or stop the server
+by invoking it with @code{start} or @code{stop} arguments:
@example
-shell> gcc -O3 -g -O2 -DDBUG_OFF -o thr_alarm ...
-./thr_alarm.c: In function `signal_hand':
-./thr_alarm.c:556: too many arguments to function `sigwait'
+shell> mysql.server start
+shell> mysql.server stop
@end example
-The proper thing to do in this case is to get the newest version of
-@code{gcc} and compile it with your current @code{gcc} compiler! At
-least for Solaris 2.5, almost all binary versions of @code{gcc} have
-old, unusable include files that will break all programs that use
-threads (and possibly other programs)!
+@code{mysql.server} can be found in the @file{share/mysql} directory
+under the MySQL installation directory or in the @file{support-files}
+directory of the MySQL source tree.
-Solaris doesn't provide static versions of all system libraries
-(@code{libpthreads} and @code{libdl}), so you can't compile @strong{MySQL}
-with @code{--static}. If you try to do so, you will get the error:
+Before @code{mysql.server} starts the server, it changes directory to
+the MySQL installation directory, then invokes @code{safe_mysqld}.
+You might need to edit @code{mysql.server} if you have a binary distribution
+that you've installed in a non-standard location. Modify it to @code{cd}
+into the proper directory before it runs @code{safe_mysqld}. If you want the
+server to run as some specific user, add an appropriate @code{user} line
+to the @file{/etc/my.cnf} file, as shown later in this section.
-@example
-ld: fatal: library -ldl: not found
+@code{mysql.server stop} brings down the server by sending a signal to it.
+You can take down the server manually by executing @code{mysqladmin shutdown}.
-or
+You might want to add these start and stop commands to the appropriate places
+in your @file{/etc/rc*} files when you start using MySQL for
+production applications. Note that if you modify @code{mysql.server}, then
+upgrade MySQL sometime, your modified version will be overwritten,
+so you should make a copy of your edited version that you can reinstall.
-undefined reference to `dlopen'
+If your system uses @file{/etc/rc.local} to start external scripts, you
+should append the following to it:
+@example
+/bin/sh -c 'cd /usr/local/mysql ; ./bin/safe_mysqld --user=mysql &'
@end example
-If too many processes try to connect very rapidly to @code{mysqld}, you will
-see this error in the @strong{MySQL} log:
+You can also add options for @code{mysql.server} in a global
+@file{/etc/my.cnf} file. A typical @file{/etc/my.cnf} file might look like
+this:
@example
-Error in accept: Protocol error
+[mysqld]
+datadir=/usr/local/mysql/var
+socket=/tmp/mysqld.sock
+port=3306
+user=mysql
+
+[mysql.server]
+basedir=/usr/local/mysql
@end example
-You might try starting the server with the @code{--set-variable back_log=50}
-option as a workaround for this. @xref{Command-line options}.
+The @code{mysql.server} script understands the following options:
+@code{datadir}, @code{basedir}, and @code{pid-file}.
-If you are linking your own @strong{MySQL} client, you might get the
-following error when you try to execute it:
+The following table shows which option groups each of the startup scripts
+read from option files:
-@example
-ld.so.1: ./my: fatal: libmysqlclient.so.#: open failed: No such file or directory
-@end example
+@multitable @columnfractions .20 .80
+@item @strong{Script} @tab @strong{Option groups}
+@item @code{mysqld} @tab @code{mysqld} and @code{server}
+@item @code{mysql.server} @tab @code{mysql.server}, @code{mysqld}, and @code{server}
+@item @code{safe_mysqld} @tab @code{mysql.server}, @code{mysqld}, and @code{server}
+@end multitable
-The problem can be avoided by one of the following methods:
+@xref{Option files}.
+
+
+@node Upgrade, Operating System Specific Notes, Post-installation, Installing
+@section Upgrading/Downgrading MySQL
+
+@cindex upgrading
+@cindex downgrading
+
+You can always move the MySQL form and data files between
+different versions on the same architecture as long as you have the same
+base version of MySQL. The current base version is
+3. If you change the character set when running MySQL (which may
+also change the sort order), you must run @code{myisamchk -r -q} on all
+tables. Otherwise your indexes may not be ordered correctly.
+
+If you are afraid of new versions, you can always rename your old
+@code{mysqld} to something like @code{mysqld}-'old-version-number'. If
+your new @code{mysqld} then does something unexpected, you can simply shut it
+down and restart with your old @code{mysqld}!
+
+When you do an upgrade you should also back up your old databases, of course.
+
+If after an upgrade, you experience problems with recompiled client programs,
+like @code{Commands out of sync} or unexpected core dumps, you probably have
+used an old header or library file when compiling your programs. In this
+case you should check the date for your @file{mysql.h} file and
+@file{libmysqlclient.a} library to verify that they are from the new
+MySQL distribution. If not, please recompile your programs!
+
+If you get some problems that the new @code{mysqld} server doesn't want to
+start or that you can't connect without a password, check that you don't
+have some old @file{my.cnf} file from your old installation! You can
+check this with: @code{program-name --print-defaults}. If this outputs
+anything other than the program name, you have an active @code{my.cnf}
+file that will affect things!
+
+It is a good idea to rebuild and reinstall the @code{Msql-Mysql-modules}
+distribution whenever you install a new release of MySQL,
+particularly if you notice symptoms such as all your @code{DBI} scripts
+dumping core after you upgrade MySQL.
+
+@menu
+* Upgrading-from-3.22:: Upgrading from a 3.22 version to 3.23
+* Upgrading-from-3.21:: Upgrading from a 3.21 version to 3.22
+* Upgrading-from-3.20:: Upgrading from a 3.20 version to 3.21
+* Upgrading-to-arch:: Upgrading to another architecture
+@end menu
+
+
+@node Upgrading-from-3.22, Upgrading-from-3.21, Upgrade, Upgrade
+@subsection Upgrading From Version 3.22 to Version 3.23
+
+@cindex compatibility, between MySQL versions
+@cindex upgrading, 3.22 to 3.23
+
+MySQL Version 3.23 supports tables of the new @code{MyISAM} type and
+the old @code{ISAM} type. You don't have to convert your old tables to
+use these with Version 3.23. By default, all new tables will be created with
+type @code{MyISAM} (unless you start @code{mysqld} with the
+@code{--default-table-type=isam} option). You can change an @code{ISAM}
+table to a @code{MyISAM} table with @code{ALTER TABLE table_name TYPE=MyISAM}
+or the Perl script @code{mysql_convert_table_format}.
+
+Version 3.22 and 3.21 clients will work without any problems with a Version
+3.23 server.
+
+The following lists tell what you have to watch out for when upgrading to
+Version 3.23:
@itemize @bullet
@item
-Link the client with the following flag (instead of @code{-Lpath}):
-@code{-Wl,r/full-path-to-libmysqlclient.so}.
+All tables that uses the @code{tis620} character set must be fixed
+with @code{myisamchk -r} or @code{REPAIR TABLE}.
@item
-Copy @file{libmysqclient.so} to @file{/usr/lib}.
+If you do a @code{DROP DATABASE} on a symbolic linked database, both the
+link and the original database is deleted. (This didn't happen in 3.22
+because configure didn't detect the @code{readlink} system call).
-@tindex LD_RUN_PATH environment variable
-@tindex Environment variable, LD_RUN_PATH
@item
-Add the pathname of the directory where @file{libmysqlclient.so} is located
-to the @code{LD_RUN_PATH} environment variable before running your client.
-@end itemize
+@code{OPTIMIZE TABLE} now only works for @strong{MyISAM} tables.
+For other table types, you can use @code{ALTER TABLE} to optimize the table.
+During @code{OPTIMIZE TABLE} the table is now locked from other threads.
-When using the @code{--with-libwrap} configure option, you must also
-include the libraries that @file{libwrap.a} needs:
+@item
+The MySQL client @code{mysql} is now by default started with the
+option @code{--no-named-commands (-g)}. This option can be disabled with
+@code{--enable-named-commands (-G)}. This may cause incompatibility problems in
+some cases, for example in SQL scripts that use named commands without a
+semicolon! Long format commands still work from the first line.
-@example
---with-libwrap="/opt/NUtcpwrapper-7.6/lib/libwrap.a -lnsl -lsocket
-@end example
+@item
+If you are using the @code{german} character sort order, you must repair
+all your tables with @code{isamchk -r}, as we have made some changes in
+the sort order!
-If you have problems with configure trying to link with @code{-lz} and
-you don't have @code{zlib} installed, you have two options:
+@item
+The default return type of @code{IF} will now depend on both arguments
+and not only the first argument.
+
+@item
+@code{AUTO_INCREMENT} will not work with negative numbers. The reason
+for this is that negative numbers caused problems when wrapping from -1 to 0.
+@code{AUTO_INCREMENT} is now for MyISAM tables handled at a lower level and
+is much faster than before. For MyISAM tables old numbers are also not reused
+anymore, even if you delete some rows from the table.
+
+@item
+@code{CASE}, @code{DELAYED}, @code{ELSE}, @code{END}, @code{FULLTEXT},
+@code{INNER}, @code{RIGHT}, @code{THEN} and @code{WHEN} are now reserved words.
+
+@item
+@code{FLOAT(X)} is now a true floating-point type and not a value with a
+fixed number of decimals.
+
+@item
+When declaring @code{DECIMAL(length,dec)} the length argument no longer
+includes a place for the sign or the decimal point.
+
+@item
+A @code{TIME} string must now be of one of the following formats:
+@code{[[[DAYS] [H]H:]MM:]SS[.fraction]} or
+@code{[[[[[H]H]H]H]MM]SS[.fraction]}
+
+@item
+@code{LIKE} now compares strings using the same character comparison rules
+as @code{'='}. If you require the old behavior, you can compile
+MySQL with the @code{CXXFLAGS=-DLIKE_CMP_TOUPPER} flag.
+
+@item
+@code{REGEXP} is now case insensitive for normal (not binary) strings.
+
+@item
+When you check/repair tables you should use @code{CHECK TABLE}
+or @code{myisamchk} for @code{MyISAM} tables (@code{.MYI}) and
+@code{isamchk} for ISAM (@code{.ISM}) tables.
+
+@item
+If you want your @code{mysqldump} files to be compatible between
+MySQL Version 3.22 and Version 3.23, you should not use the
+@code{--opt} or @code{--full} option to @code{mysqldump}.
+
+@item
+Check all your calls to @code{DATE_FORMAT()} to make sure there is a
+@samp{%} before each format character. (Later MySQL Version 3.22
+did allow this syntax.)
-@itemize @bullet
@item
-If you want to be able to use the compressed communication protocol,
-you need to get and install zlib from ftp.gnu.org.
+@code{mysql_fetch_fields_direct} is now a function (it was a macro) and
+it returns a pointer to a @code{MYSQL_FIELD} instead of a
+@code{MYSQL_FIELD}.
@item
-Configure with @code{--with-named-z-libs=no}.
+@code{mysql_num_fields()} can no longer be used on a @code{MYSQL*} object (it's
+now a function that takes @code{MYSQL_RES*} as an argument. You should now
+use @code{mysql_field_count()} instead.
+
+@item
+In MySQL Version 3.22, the output of @code{SELECT DISTINCT ...} was
+almost always sorted. In Version 3.23, you must use @code{GROUP BY} or
+@code{ORDER BY} to obtain sorted output.
+
+@item
+@code{SUM()} now returns @code{NULL}, instead of 0, if there is no matching
+rows. This is according to ANSI SQL.
+
+@item
+An @code{AND} or @code{OR} with @code{NULL} values will now return
+@code{NULL} instead of 0. This mostly affects queries that use @code{NOT}
+on an @code{AND/OR} expression as @code{NOT NULL} = @code{NULL}.
+@code{LPAD()} and @code{RPAD()} will shorten the result string if it's longer
+than the length argument.
@end itemize
-If you are using gcc and have problems with loading @code{UDF} functions
-into @strong{MySQL}, try adding @code{-lgcc} to the link line for the
-@code{UDF} function.
-If you would like @strong{MySQL} to start automatically, you can copy
-@file{support-files/mysql.server} to @file{/etc/init.d} and create a
-symbolic link to it named @file{/etc/rc3.d/S99mysql.server}.
+@node Upgrading-from-3.21, Upgrading-from-3.20, Upgrading-from-3.22, Upgrade
+@subsection Upgrading from Version 3.21 to Version 3.22
-@node Solaris 2.7, Solaris x86, Solaris, Source install system issues
-@subsection Solaris 2.7/2.8 Notes
+@cindex compatibility, between MySQL versions
+@cindex upgrading, 3.21 to 3.22
-You can normally use a Solaris 2.6 binary on Solaris 2.7 and 2.8. Most
-of the Solaris 2.6 issues also apply for Solaris 2.7 and 2.8.
+Nothing that affects compatibility has changed between Version 3.21 and 3.22.
+The only pitfall is that new tables that are created with @code{DATE} type
+columns will use the new way to store the date. You can't access these new
+fields from an old version of @code{mysqld}.
-Note that @strong{MySQL} Version 3.23.4 and above should be able to autodetect
-new versions of Solaris and enable workarounds for the following problems!
+After installing MySQL Version 3.22, you should start the new server
+and then run the @code{mysql_fix_privilege_tables} script. This will add the
+new privileges that you need to use the @code{GRANT} command. If you forget
+this, you will get @code{Access denied} when you try to use @code{ALTER
+TABLE}, @code{CREATE INDEX}, or @code{DROP INDEX}. If your MySQL root
+user requires a password, you should give this as an argument to
+@code{mysql_fix_privilege_tables}.
-Solaris 2.7 / 2.8 has some bugs in the include files. You may see the
-following error when you use @code{gcc}:
+The C API interface to @code{mysql_real_connect()} has changed. If you have
+an old client program that calls this function, you must place a @code{0} for
+the new @code{db} argument (or recode the client to send the @code{db}
+element for faster connections). You must also call @code{mysql_init()}
+before calling @code{mysql_real_connect()}! This change was done to allow
+the new @code{mysql_options()} function to save options in the @code{MYSQL}
+handler structure.
-@example
-/usr/include/widec.h:42: warning: `getwc' redefined
-/usr/include/wchar.h:326: warning: this is the location of the previous
-definition
-@end example
+The @code{mysqld} variable @code{key_buffer} has changed names to
+@code{key_buffer_size}, but you can still use the old name in your
+startup files.
-If this occurs, you can do the following to fix the problem:
-Copy @code{/usr/include/widec.h} to
-@code{.../lib/gcc-lib/os/gcc-version/include} and change line 41 from:
+@node Upgrading-from-3.20, Upgrading-to-arch, Upgrading-from-3.21, Upgrade
+@subsection Upgrading from Version 3.20 to Version 3.21
-@example
-#if !defined(lint) && !defined(__lint)
+@cindex upgrading, 3.20 to 3.21
-to
+If you are running a version older than Version 3.20.28 and want to
+switch to Version 3.21, you need to do the following:
-#if !defined(lint) && !defined(__lint) && !defined(getwc)
-@end example
+You can start the @code{mysqld} Version 3.21 server with @code{safe_mysqld
+--old-protocol} to use it with clients from a Version 3.20 distribution.
+In this case, the new client function @code{mysql_errno()} will not
+return any server error, only @code{CR_UNKNOWN_ERROR} (but it
+works for client errors), and the server uses the old @code{password()}
+checking rather than the new one.
-Alternatively, you can edit @file{/usr/include/widec.h} directly. Either
-way, after you make the fix, you should remove @file{config.cache} and run
-@code{configure} again!
+If you are @strong{NOT} using the @code{--old-protocol} option to
+@code{mysqld}, you will need to make the following changes:
-If you get errors like this when you run @code{make}, it's because
-@code{configure} didn't detect the @file{curses.h} file (probably
-because of the error in @file{/usr/include/widec.h}):
+@itemize @bullet
+@item
+All client code must be recompiled. If you are using ODBC, you must get
+the new @strong{MyODBC} 2.x driver.
+@item
+The script @code{scripts/add_long_password} must be run to convert the
+@code{Password} field in the @code{mysql.user} table to @code{CHAR(16)}.
+@item
+All passwords must be reassigned in the @code{mysql.user} table (to get 62-bit
+rather than 31-bit passwords).
+@item
+The table format hasn't changed, so you don't have to convert any tables.
+@end itemize
+
+MySQL Version 3.20.28 and above can handle the new @code{user} table
+format without affecting clients. If you have a MySQL version earlier
+than Version 3.20.28, passwords will no longer work with it if you convert the
+@code{user} table. So to be safe, you should first upgrade to at least Version
+3.20.28 and then upgrade to Version 3.21.
+
+@cindex Protocol mismatch
+The new client code works with a 3.20.x @code{mysqld} server, so
+if you experience problems with 3.21.x, you can use the old 3.20.x server
+without having to recompile the clients again.
+
+If you are not using the @code{--old-protocol} option to @code{mysqld},
+old clients will issue the error message:
@example
-In file included from mysql.cc:50:
-/usr/include/term.h:1060: syntax error before `,'
-/usr/include/term.h:1081: syntax error before `;'
+ERROR: Protocol mismatch. Server Version = 10 Client Version = 9
@end example
-The solution to this is to do one of the following:
+The new Perl @code{DBI}/@code{DBD} interface also supports the old
+@code{mysqlperl} interface. The only change you have to make if you use
+@code{mysqlperl} is to change the arguments to the @code{connect()} function.
+The new arguments are: @code{host}, @code{database}, @code{user},
+@code{password} (the @code{user} and @code{password} arguments have changed
+places).
+@xref{Perl DBI Class, , Perl @code{DBI} Class}.
+
+The following changes may affect queries in old applications:
@itemize @bullet
@item
-Configure with @code{CFLAGS=-DHAVE_CURSES_H CXXFLAGS=-DHAVE_CURSES_H ./configure}.
-
+@code{HAVING} must now be specified before any @code{ORDER BY} clause.
@item
-Edit @file{/usr/include/widec.h} as indicted above and rerun configure.
-
+The parameters to @code{LOCATE()} have been swapped.
@item
-Remove the @code{#define HAVE_TERM} line from @file{config.h} file and
-run @code{make} again.
+There are some new reserved words. The most notable are @code{DATE},
+@code{TIME}, and @code{TIMESTAMP}.
@end itemize
-If you get a problem that your linker can't find @code{-lz} when linking
-your client program, the problem is probably that your @file{libz.so} file is
-installed in @file{/usr/local/lib}. You can fix this by one of the
-following methods:
-@itemize @bullet
-@item
-Add @file{/usr/local/lib} to @code{LD_LIBRARY_PATH}.
+@node Upgrading-to-arch, , Upgrading-from-3.20, Upgrade
+@subsection Upgrading to Another Architecture
-@item
-Add a link to @file{libz.so} from @file{/lib}.
+@cindex upgrading, different architecture
-@item
-If you are using Solaris 8, you can install the optional zlib from your
-Solaris 8 CD distribution.
+If you are using MySQL Version 3.23, you can copy the @code{.frm},
+@code{.MYI}, and @code{.MYD} files between different architectures that
+support the same floating-point format. (MySQL takes care of any
+byte swapping issues.)
-@item
-Configure @strong{MySQL} with the @code{--with-named-z-libs=no} option.
-@end itemize
+The MySQL @code{ISAM} data and index files (@file{.ISD} and
+@file{*.ISM}, respectively) are architecture-dependent and in some cases
+OS-dependent. If you want to move your applications to another machine
+that has a different architecture or OS than your current machine, you
+should not try to move a database by simply copying the files to the
+other machine. Use @code{mysqldump} instead.
-@node Solaris x86, SunOS, Solaris 2.7, Source install system issues
-@subsection Solaris x86 Notes
+By default, @code{mysqldump} will create a file full of SQL statements.
+You can then transfer the file to the other machine and feed it as input
+to the @code{mysql} client.
-On Solaris 2.8 on x86, @strong{mysqld} will core dump if you run
-'strip' in.
+Try @code{mysqldump --help} to see what options are available.
+If you are moving the data to a newer version of MySQL, you should use
+@code{mysqldump --opt} with the newer version to get a fast, compact dump.
-If you are using @code{gcc} or @code{egcs} on Solaris x86 and you
-experience problems with core dumps under load, you should use the
-following @code{configure} command:
+The easiest (although not the fastest) way to move a database between two
+machines is to run the following commands on the machine on which the
+database is located:
@example
-CC=gcc CFLAGS="-O3 -fomit-frame-pointer -DHAVE_CURSES_H" \
-CXX=gcc \
-CXXFLAGS="-O3 -fomit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti -DHAVE_CURSES_H" \
-./configure --prefix=/usr/local/mysql
+shell> mysqladmin -h 'other hostname' create db_name
+shell> mysqldump --opt db_name \
+ | mysql -h 'other hostname' db_name
@end example
-This will avoid problems with the @code{libstdc++} library and with C++
-exceptions.
+If you want to copy a database from a remote machine over a slow network,
+you can use:
-If this doesn't help, you should compile a debug version and run
-it with a trace file or under @code{gdb}. @xref{Using gdb on mysqld}.
+@example
+shell> mysqladmin create db_name
+shell> mysqldump -h 'other hostname' --opt --compress db_name \
+ | mysql db_name
+@end example
-@node SunOS, Linux, Solaris x86, Source install system issues
-@subsection SunOS 4 Notes
+You can also store the result in a file, then transfer the file to the
+target machine and load the file into the database there. For example,
+you can dump a database to a file on the source machine like this:
-On SunOS 4, MIT-pthreads is needed to compile @strong{MySQL}, which in turn
-means you will need GNU @code{make}.
+@example
+shell> mysqldump --quick db_name | gzip > db_name.contents.gz
+@end example
-Some SunOS 4 systems have problems with dynamic libraries and @code{libtool}.
-You can use the following @code{configure} line to avoid this problem:
+(The file created in this example is compressed.) Transfer the file
+containing the database contents to the target machine and run these commands
+there:
@example
-shell> ./configure --disable-shared --with-mysqld-ldflags=-all-static
+shell> mysqladmin create db_name
+shell> gunzip < db_name.contents.gz | mysql db_name
@end example
-When compiling @code{readline}, you may get warnings about duplicate defines.
-These may be ignored.
+@cindex @code{mysqldump}
+@cindex @code{mysqlimport}
+You can also use @code{mysqldump} and @code{mysqlimport} to accomplish
+the database transfer.
+For big tables, this is much faster than simply using @code{mysqldump}.
+In the commands shown below, @code{DUMPDIR} represents the full pathname
+of the directory you use to store the output from @code{mysqldump}.
-When compiling @code{mysqld}, there will be some @code{implicit declaration
-of function} warnings. These may be ignored.
+First, create the directory for the output files and dump the database:
+
+@example
+shell> mkdir DUMPDIR
+shell> mysqldump --tab=DUMPDIR db_name
+@end example
-@node Linux, Alpha-DEC-UNIX, SunOS, Source install system issues
+Then transfer the files in the @code{DUMPDIR} directory to some corresponding
+directory on the target machine and load the files into MySQL
+there:
+
+@example
+shell> mysqladmin create db_name # create database
+shell> cat DUMPDIR/*.sql | mysql db_name # create tables in database
+shell> mysqlimport db_name DUMPDIR/*.txt # load data into tables
+@end example
+
+Also, don't forget to copy the @code{mysql} database, because that's where the
+grant tables (@code{user}, @code{db}, @code{host}) are stored. You may have
+to run commands as the MySQL @code{root} user on the new machine
+until you have the @code{mysql} database in place.
+
+After you import the @code{mysql} database on the new machine, execute
+@code{mysqladmin flush-privileges} so that the server reloads the grant table
+information.
+
+
+@node Operating System Specific Notes, , Upgrade, Installing
+@section Operating System Specific Notes
+
+@menu
+* Linux:: Linux Notes (All Linux Versions)
+* Windows:: Windows Notes
+* Solaris:: Solaris Notes
+* BSD Notes:: BSD Notes
+* Mac OS X:: Mac OS X Notes
+* Other Unix Notes:: Other Unix Notes
+* OS/2:: OS/2 Notes
+* BeOS:: BeOS Notes
+* Novell Netware:: Novell Netware Notes
+@end menu
+
+
+@node Linux, Windows, Operating System Specific Notes, Operating System Specific Notes
@subsection Linux Notes (All Linux Versions)
+@menu
+* Binary notes-Linux:: Linux Notes for Binary Distributions
+* Linux-x86:: Linux x86 Notes
+* Linux-SPARC:: Linux SPARC Notes
+* Linux-Alpha:: Linux Alpha Notes
+* Linux-PowerPC:: Linux PowerPC Notes
+* Linux-MIPS:: Linux MIPS Notes
+* Linux-IA64:: Linux IA64 Notes
+@end menu
+
The notes below regarding @strong{glibc} apply only to the situation
-when you build @strong{MySQL}
+when you build MySQL
yourself. If you are running Linux on an x86 machine, in most cases it is
much better for you to just use our binary. We link our binaries against
the best patched version of @strong{glibc} we can come up with and with the
@@ -7535,13 +9666,13 @@ can build a better binary next time. For a typical user, even for setups with
a lot of concurrent connections and/or tables exceeding 2GB limit, our
binary in most cases is the best choice.
-@strong{MySQL} uses LinuxThreads on Linux. If you are using an old
+MySQL uses LinuxThreads on Linux. If you are using an old
Linux version that doesn't have @code{glibc2}, you must install
-LinuxThreads before trying to compile @strong{MySQL}. You can get
+LinuxThreads before trying to compile MySQL. You can get
LinuxThreads at @uref{http://www.mysql.com/Downloads/Linux}.
@strong{NOTE:} We have seen some strange problems with Linux 2.2.14 and
-@strong{MySQL} on SMP systems; If you have a SMP system, we recommend
+MySQL on SMP systems; If you have a SMP system, we recommend
you to upgrade to Linux 2.4 ASAP! Your system will be faster and more
stable by doing this!
@@ -7551,15 +9682,15 @@ when you do @code{INSERT DELAYED}. We recommend you to not use
@code{INSERT DELAYED} before upgrading glibc.
If you plan to have 1000+ concurrent connections, you will need to make
-some changes to LinuxThreads, recompile it, and relink @strong{MySQL} against
+some changes to LinuxThreads, recompile it, and relink MySQL against
the new @file{libpthread.a}. Increase @code{PTHREAD_THREADS_MAX} in
@file{sysdeps/unix/sysv/linux/bits/local_lim.h} to 4096 and decrease
@code{STACK_SIZE} in @file{linuxthreads/internals.h} to 256 KB. The paths are
-relative to the root of @code{glibc} Note that @strong{MySQL} will not be
+relative to the root of @code{glibc} Note that MySQL will not be
stable with around 600-1000 connections if @code{STACK_SIZE} is the default
of 2 MB.
-If you have a problem with that @strong{MySQL} can't open enough files,
+If you have a problem with that MySQL can't open enough files,
or connections, it may be that you haven't configured Linux to handle
enough files.
@@ -7588,10 +9719,10 @@ You should also add /etc/my.cnf:
@example
[safe_mysqld]
-open_files_limit=8192
+open-files-limit=8192
@end example
-The above should allow @strong{MySQL} to create up to 8192 connections/files.
+The above should allow MySQL to create up to 8192 connections + files.
The @code{STACK_SIZE} constant in LinuxThreads controls the spacing of thread
stacks in the address space. It needs to be large enough so that there will
@@ -7608,10 +9739,10 @@ thread stacks to stay away from the global heap. With @code{mysqld}, you
should enforce this "gentleman" behavior by setting a reasonable value for
the @code{max_connections} variable.
-If you build @strong{MySQL} yourself and do not what to mess with patching
+If you build MySQL yourself and do not want to mess with patching
LinuxThreads, you should set @code{max_connections} to a value no higher
than 500. It should be even less if you have a large key buffer, large
-heap tables, or some other things that make @strong{mysqld} allocate a lot
+heap tables, or some other things that make @code{mysqld} allocate a lot
of memory or if you are running a 2.2 kernel with a 2GB patch. If you are
using our binary or RPM version 3.23.25 or later, you can safely set
@code{max_connections} at 1500, assuming no large key buffer or heap tables
@@ -7621,10 +9752,10 @@ the more threads you can safely create. We recommend the values between
If you use a lot of concurrent connections, you may suffer from a "feature"
in the 2.2 kernel that penalizes a process for forking or cloning a child
-in an attempt to prevent a fork bomb attack. This will cause @strong{MySQL}
+in an attempt to prevent a fork bomb attack. This will cause MySQL
not to scale well as you increase the number of concurrent clients. On
single CPU systems, we have seen this manifested in a very slow thread
-creation, which means it may take a long time to connect to @strong{MySQL}
+creation, which means it may take a long time to connect to MySQL
(as long as 1 minute), and it may take just as long to shut it down. On
multiple CPU systems, we have observed a gradual drop in query speed as
the number of clients increases. In the process of trying to find a
@@ -7641,10 +9772,10 @@ the current performance of your system, rather than patching your 2.2 kernel,
it might be easier to just upgrade to 2.4, which will also give you a nice
SMP boost in addition to fixing this fairness bug.
-We have tested @strong{MySQL} on the 2.4 kernel on a 2 CPU machine and
-found @strong{MySQL} scales MUCH better - there was virtually no slowdown
+We have tested MySQL on the 2.4 kernel on a 2 CPU machine and
+found MySQL scales MUCH better - there was virtually no slowdown
on query throughput all the way up
-to 1000 clients, and @strong{MySQL} scaling factor ( computed as the ratio of
+to 1000 clients, and MySQL scaling factor ( computed as the ratio of
maximum throughput to the throughput with one client) was 180%.
We have observed similar results on a 4-CPU system - virtually no
slowdown as the number of
@@ -7663,22 +9794,22 @@ systems. If you have access such a system and have done some benchmarks,
please send a mail to @email{docs@@mysql.com} with the results - we will
include them in the manual.
-There is another issue that greatly hurts @strong{MySQL} performance,
+There is another issue that greatly hurts MySQL performance,
especially on SMP systems. The implementation of mutex in
LinuxThreads in @strong{glibc-2.1} is very bad for programs with many
threads that only
hold the mutex for a short time. On an SMP system, ironic as it is, if
-you link @strong{MySQL} against unmodified @strong{LinuxThreads},
-removing processors from the machine improves @strong{MySQL} performance
+you link MySQL against unmodified @strong{LinuxThreads},
+removing processors from the machine improves MySQL performance
in many cases. We have made a patch available for @strong{glibc 2.1.3},
@uref{http://www.mysql.com/Downloads/Linux/linuxthreads-2.1-patch,linuxthreads-2.1-patch}
to correct this behavior.
With @strong{glibc-2.2.2}
-@strong{MySQL} version 3.23.36 will use the adaptive mutex, which is much
+MySQL version 3.23.36 will use the adaptive mutex, which is much
better than even the patched one in @strong{glibc-2.1.3}. Be warned, however,
that under some conditions, the current mutex code in @strong{glibc-2.2.2}
-overspins, which hurts @strong{MySQL} performance. The chance of this
+overspins, which hurts MySQL performance. The chance of this
condition can be reduced by renicing @code{mysqld} process to the highest
priority. We have also been able to correct the overspin behavior with
a patch, available @uref{http://www.mysql.com/Downloads/Linux/linuxthreads-2.2.2.patch,here}. It combines the correction of overspin, maximum number of
@@ -7690,7 +9821,7 @@ some form in to the future releases of @code{glibc-2.2}. In any case, if
you link against @code{glibc-2.2.2} you still need to correct
@code{STACK_SIZE} and @code{PTHREAD_THREADS_MAX}. We hope that the defaults
will be corrected to some more acceptable values for high-load
-@strong{MySQL} setup in the future, so that your own build can be reduced
+MySQL setup in the future, so that your own build can be reduced
to @code{./configure; make; make install}.
We recommend that you use the above patches to build a special static
@@ -7703,7 +9834,7 @@ install it on your system, you are doing it at your own risk with regard
to other applications that depend on @code{LinuxThreads}.
If you experience any strange problems during the installation of
-@strong{MySQL}, or with some common utilties hanging, it is very likely that
+MySQL, or with some common utilties hanging, it is very likely that
they are either library or compiler related. If this is the case, using our
binary will resolve them.
@@ -7719,12 +9850,12 @@ to handle alarms and signals.
Note that the Linux kernel and the LinuxThread library can by default
only have 1024 threads. This means that you can only have up to 1021
-connections to @strong{MySQL} on an unpatched system. The page
+connections to MySQL on an unpatched system. The page
@uref{http://www.volano.com/linuxnotes.html} contains information how to
go around this limit.
If you see a dead @code{mysqld} daemon process with @code{ps}, this usually
-means that you have found a bug in @strong{MySQL} or you have a corrupted
+means that you have found a bug in MySQL or you have a corrupted
table. @xref{Crashing}.
To get a core dump on Linux if @code{mysqld} dies with a SIGSEGV
@@ -7739,7 +9870,7 @@ need to raise the @code{core file size} by adding @code{ulimit -c 1000000} to
@code{safe_mysqld} or starting @code{safe_mysqld} with
@code{--core-file-sizes=1000000}. @xref{safe_mysqld, , @code{safe_mysqld}}.
-If you are linking your own @strong{MySQL} client and get the error:
+If you are linking your own MySQL client and get the error:
@example
ld.so.1: ./my: fatal: libmysqlclient.so.4: open failed: No such file or directory
@@ -7764,7 +9895,7 @@ to the @code{LD_RUN_PATH} environment variable before running your client.
@end itemize
If you are using the Fujitsu compiler @code{(fcc / FCC)} you will have
-some problems compiling @strong{MySQL} because the Linux header files are very
+some problems compiling MySQL because the Linux header files are very
@code{gcc} oriented.
The following @code{configure} line should work with @code{fcc/FCC}:
@@ -7773,21 +9904,91 @@ The following @code{configure} line should work with @code{fcc/FCC}:
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
@end example
-@menu
-* Linux-x86:: Linux-x86 notes
-* Linux-RedHat50:: RedHat 5.0 notes
-* Linux-RedHat51:: RedHat 5.1 notes
-* Linux-SPARC:: Linux-SPARC notes
-* Linux-Alpha:: Linux-Alpha notes
-* MKLinux:: MkLinux notes
-* Qube2:: Qube2 Linux notes
-* Linux-Ia64:: Linux-Ia64 notes
-@end menu
-@node Linux-x86, Linux-RedHat50, Linux, Linux
-@subsubsection Linux-x86 Notes
+@node Binary notes-Linux, Linux-x86, Linux, Linux
+@subsubsection Linux Notes for Binary Distributions
+
+@cindex binary distributions, on Linux
+@cindex Linux, binary distribution
+
+MySQL needs at least Linux Version 2.0.
+
+The binary release is linked with @code{-static}, which means you do not
+normally need to worry about which version of the system libraries you
+have. You need not install LinuxThreads, either. A program linked with
+@code{-static} is slightly bigger than a dynamically linked program but
+also slightly faster (3-5%). One problem, however, is that you can't use
+user-definable functions (UDFs) with a statically linked program. If
+you are going to write or use UDF functions (this is something only for
+C or C++ programmers), you must compile MySQL yourself, using
+dynamic linking.
+
+If you are using a @code{libc}-based system (instead of a @code{glibc2}
+system), you will probably get some problems with hostname resolving and
+@code{getpwnam()} with the binary release. (This is because @code{glibc}
+unfortunately depends on some external libraries to resolve hostnames
+and @code{getpwent()}, even when compiled with @code{-static}). In this
+case you probably get the following error message when you run
+@code{mysql_install_db}:
+
+@example
+Sorry, the host 'xxxx' could not be looked up
+@end example
+
+or the following error when you try to run @code{mysqld} with the @code{--user}
+option:
+
+@example
+getpwnam: No such file or directory
+@end example
+
+You can solve this problem in one of the following ways:
+
+@itemize @bullet
+@item
+Get a MySQL source distribution (an RPM or the @code{tar.gz}
+distribution) and install this instead.
+@item
+Execute @code{mysql_install_db --force}; This will not execute the
+@code{resolveip} test in @code{mysql_install_db}. The downside is that
+you can't use host names in the grant tables; you must use IP numbers
+instead (except for @code{localhost}). If you are using an old MySQL
+release that doesn't support @code{--force}, you have to remove the
+@code{resolveip} test in @code{mysql_install} with an editor.
+@item
+Start @code{mysqld} with @code{su} instead of using @code{--user}.
+@end itemize
+
+The Linux-Intel binary and RPM releases of MySQL are configured
+for the highest possible speed. We are always trying to use the fastest
+stable compiler available.
+
+MySQL Perl support requires Version Perl 5.004_03 or newer.
+
+On some Linux 2.2 versions, you may get the error @code{Resource
+temporarily unavailable} when you do a lot of new connections to a
+@code{mysqld} server over TCP/IP.
+
+The problem is that Linux has a delay between when you close a TCP/IP
+socket and until this is actually freed by the system. As there is only
+room for a finite number of TCP/IP slots, you will get the above error if
+you try to do too many new TCP/IP connections during a small time, like
+when you run the MySQL @file{test-connect} benchmark over
+TCP/IP.
+
+We have mailed about this problem a couple of times to different Linux
+mailing lists but have never been able to resolve this properly.
+
+The only known 'fix' to this problem is to use persistent connections in
+your clients or use sockets, if you are running the database server
+and clients on the same machine. We hope that the @code{Linux 2.4}
+kernel will fix this problem in the future.
+
-@strong{MySQL} requires @code{libc} Version 5.4.12 or newer. It's known to
+@node Linux-x86, Linux-SPARC, Binary notes-Linux, Linux
+@subsubsection Linux x86 Notes
+
+MySQL requires @code{libc} Version 5.4.12 or newer. It's known to
work with @code{libc} 5.4.46. @code{glibc} Version 2.0.6 and later should
also work. There have been some problems with the @code{glibc} RPMs from
RedHat, so if you have problems, check whether or not there are any updates!
@@ -7814,7 +10015,7 @@ mysqld.cc: In function `void * signal_hand(void *)':
mysqld.cc:346: warning: assignment of negative value `-1' to `long unsigned int'
@end example
-In Debian GNU/Linux, if you want @strong{MySQL} to start automatically when
+In Debian GNU/Linux, if you want MySQL to start automatically when
the system boots, do the following:
@example
@@ -7823,15 +10024,13 @@ shell> /usr/sbin/update-rc.d mysql.server defaults 99
@end example
@code{mysql.server} can be found in the @file{share/mysql} directory
-under the @strong{MySQL} installation directory or in the
-@file{support-files} directory of the @strong{MySQL} source tree.
+under the MySQL installation directory or in the
+@file{support-files} directory of the MySQL source tree.
If @code{mysqld} always core dumps when it starts up, the problem may be that
you have an old @file{/lib/libc.a}. Try renaming it, then remove
@file{sql/mysqld} and do a new @code{make install} and try again. This
-problem has been reported on some Slackware installations. RedHat Version 5.0
-also has a similar problem with some new @code{glibc} versions.
-@xref{Linux-RedHat50}.
+problem has been reported on some Slackware installations.
If you get the following error when linking @code{mysqld},
it means that your @file{libg++.a} is not installed correctly:
@@ -7847,84 +10046,9 @@ You can avoid using @file{libg++.a} by running @code{configure} like this:
shell> CXX=gcc ./configure
@end example
-@node Linux-RedHat50, Linux-RedHat51, Linux-x86, Linux
-@subsubsection RedHat Version 5.0 Notes
-
-If you have any problems with @strong{MySQL} on RedHat, you should start by
-upgrading @code{glibc} to the newest possible version!
-
-If you install all the official RedHat patches (including
-@code{glibc-2.0.7-19} and @code{glibc-devel-2.0.7-19}), both the
-binary and source distributions of @strong{MySQL} should work without
-any trouble!
-
-The updates are needed because there is a bug in @code{glibc} 2.0.5 in how
-@code{pthread_key_create} variables are freed. With @code{glibc} 2.0.5, you
-must use a statically linked @strong{MySQL} binary distribution. If you
-want to compile from source, you must install the corrected version of
-LinuxThreads from @uref{http://www.mysql.com/Downloads/Linux} or upgrade your
-@code{glibc}.
-
-If you have an incorrect version of @code{glibc} or LinuxThreads, the symptom
-is that @code{mysqld} crashes after each connection. For example,
-@code{mysqladmin version} will crash @code{mysqld} when it finishes!
-
-Another symptom of incorrect libraries is that @code{mysqld} crashes at
-once when it starts. On some Linux systems, this can be fixed by configuring
-like this:
-
-@example
-shell> ./configure --with-mysqld-ldflags=-all-static
-@end example
-
-On Redhat Version 5.0, the easy way out is to install the @code{glibc}
-2.0.7-19 RPM and run @code{configure} @strong{without} the
-@code{--with-mysqld-ldflags=-all-static} option.
-
-For the source distribution of @code{glibc} 2.0.7, a patch that is easy to
-apply and is tested with @strong{MySQL} may be found at:
-
-@example
-@uref{http://www.mysql.com/Downloads/Linux/glibc-2.0.7-total-patch.tar.gz}
-@end example
-
-If you experience crashes like these when you build @strong{MySQL}, you can
-always download the newest binary version of @strong{MySQL}. This is
-statically-linked to avoid library conflicts and should work on all Linux
-systems!
-
-@strong{MySQL} comes with an internal debugger that can generate
-trace files with a lot of information that can be used to find and solve a
-wide range of different problems.
-@xref{Debugging server}.
-
-@node Linux-RedHat51, Linux-SPARC, Linux-RedHat50, Linux
-@subsubsection RedHat Version 5.1 notes
-
-The @code{glibc} of RedHat Version 5.1 (@code{glibc} 2.0.7-13) has a memory
-leak, so to get a stable @strong{MySQL} version, you must upgrade @code{glibc},
-to 2.0.7-19, downgrade @code{glibc} or use a binary version of @code{mysqld}.
-If you don't do this, you will encounter memory problems (out of memory, etc.).
-The most common error in this case is:
-
-@example
-Can't create a new thread (errno 11). If you are not out of available
-memory, you can consult the manual for any possible OS dependent bug
-@end example
-
-After you have upgraded to @code{glibc} 2.0.7-19, you can configure
-@strong{MySQL} with dynamic linking (the default), but you @strong{cannot}
-run @code{configure} with the @code{--with-mysqld-ldflags=-all-static} option
-until you have installed @code{glibc} 2.0.7-19 from source!
-
-You can check which version of @code{glibc} you have with @code{rpm -q glibc}.
-Another reason for the above error is if you try to use more threads
-than your Linux kernel is configured for. In this case you should raise
-the limits in @file{include/linux/tasks.h} and recompile your kernel!
-
-@node Linux-SPARC, Linux-Alpha, Linux-RedHat51, Linux
-@subsubsection Linux-SPARC Notes
+@node Linux-SPARC, Linux-Alpha, Linux-x86, Linux
+@subsubsection Linux SPARC Notes
In some implementations, @code{readdir_r()} is broken. The symptom is that
@code{SHOW DATABASES} always returns an empty set. This can be fixed by
@@ -7939,24 +10063,25 @@ that is available at @code{vger.rutgers.edu} (a version of Linux that was
never merged with the official 2.0.30). You must also install LinuxThreads
Version 0.6 or newer.
-@node Linux-Alpha, MKLinux, Linux-SPARC, Linux
-@subsubsection Linux-Alpha Notes
-@strong{MySQL} Version 3.23.12 is the first @strong{MySQL} version that is
-tested on Linux-Alpha. If you plan to use @strong{MySQL} on Linux-Alpha,
+@node Linux-Alpha, Linux-PowerPC, Linux-SPARC, Linux
+@subsubsection Linux Alpha Notes
+
+MySQL Version 3.23.12 is the first MySQL version that is
+tested on Linux-Alpha. If you plan to use MySQL on Linux-Alpha,
you should ensure that you have this version or newer.
-We have tested @strong{MySQL} on Alpha with our benchmarks and test suite,
+We have tested MySQL on Alpha with our benchmarks and test suite,
and it appears to work nicely. The main thing we haven't yet had time to
test is how things works with many concurrent users.
-When we compiled the standard @strong{MySQL} binary we are using SuSE 6.4,
+When we compiled the standard MySQL binary we are using SuSE 6.4,
kernel 2.2.13-SMP, Compaq C compiler (V6.2-504) and Compaq C++ compiler
(V6.3-005) on a Comaq DS20 machine with an Alpha EV6 processor.
You can find the above compilers at
@uref{http://www.support.compaq.com/alpha-tools}). By using these compilers,
-instead of gcc, we get about 9-14 % better performance with @strong{MySQL}.
+instead of gcc, we get about 9-14 % better performance with MySQL.
Note that the configure line optimized the binary for the current CPU; This
means you can only use our binary if you have an Alpha EV6 processor. We also
@@ -7972,11 +10097,11 @@ If you want to use egcs the following configure line worked for us:
CFLAGS="-O3 -fomit-frame-pointer" CXX=gcc CXXFLAGS="-O3 -fomit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --disable-shared
@end example
-Some known problems when running @strong{MySQL} on Linux-Alpha:
+Some known problems when running MySQL on Linux-Alpha:
@itemize @bullet
@item
-Debugging threaded applications like @strong{MySQL} will not work with
+Debugging threaded applications like MySQL will not work with
@code{gdb 4.18}. You should download and use gdb 5.0 instead!
@item
@@ -7985,24 +10110,27 @@ resulting image will core dump at start. In other words, @strong{DON'T}
use @code{--with-mysqld-ldflags=-all-static} with @code{gcc}.
@end itemize
-@node MKLinux, Qube2, Linux-Alpha, Linux
-@subsubsection MkLinux Notes
-@strong{MySQL} should work on MkLinux with the newest @code{glibc} package
+@node Linux-PowerPC, Linux-MIPS, Linux-Alpha, Linux
+@subsubsection Linux PowerPC Notes
+
+MySQL should work on MkLinux with the newest @code{glibc} package
(tested with @code{glibc} 2.0.7).
-@node Qube2, Linux-Ia64, MKLinux, Linux
-@subsubsection Qube2 Linux Notes
-To get @strong{MySQL} to work on Qube2, (Linux Mips), you need the
+@node Linux-MIPS, Linux-IA64, Linux-PowerPC, Linux
+@subsubsection Linux MIPS Notes
+
+To get MySQL to work on Qube2, (Linux Mips), you need the
newest @code{glibc} libraries (@code{glibc-2.0.7-29C2} is known to
work). You must also use the @code{egcs} C++ compiler
(@code{egcs-1.0.2-9}, @code{gcc 2.95.2} or newer).
-@node Linux-Ia64, , Qube2, Linux
+
+@node Linux-IA64, , Linux-MIPS, Linux
@subsubsection Linux IA64 Notes
-To get @strong{MySQL} to compile on Linux Ia64, we had to do the following
+To get MySQL to compile on Linux Ia64, we had to do the following
(we assume that this will be easier when next gcc version for ia64 is
released).
@@ -8025,255 +10153,887 @@ make
make_install
@end example
-and @strong{mysqld} should be ready to run.
+and @code{mysqld} should be ready to run.
-@node Alpha-DEC-UNIX, Alpha-DEC-OSF1, Linux, Source install system issues
-@subsection Alpha-DEC-UNIX Notes (Tru64)
+On Ia64 the MySQL client binaries are using shared libraries. This means
+that if you install our binary distribution in some other place than
+@file{/usr/local/mysql} you need to either modify @file{/etc/ld.so.conf}
+or add the path to the directory where you have @file{libmysqlclient.so}
+to the @code{LD_LIBRARY_PATH} environment variable.
-If you are using egcs 1.1.2 on Digital Unix, you should upgrade to gcc
-2.95.2, as egcs on DEC has some serious bugs!
+@xref{Link errors}.
-When compiling threaded programs under Digital Unix, the documentation
-recommends using the @code{-pthread} option for @code{cc} and @code{cxx} and
-the libraries @code{-lmach -lexc} (in addition to @code{-lpthread}). You
-should run @code{configure} something like this:
+@node Windows, Solaris, Linux, Operating System Specific Notes
+@subsection Windows Notes
+
+This section describes installation and use of MySQL on Windows.
+This information is also provided in the @file{README} file that comes
+with the MySQL Windows distribution.
+
+@menu
+* Win95 start:: Starting MySQL on Win95 / Win98
+* NT start:: Starting MySQL on NT / Win2000
+* Windows running:: Running MySQL on Windows
+* Windows and SSH:: Connecting to a remote MySQL from Windows with SSH
+* Windows symbolic links:: Splitting data across different disks under Win32
+* Windows compiling:: Compiling MySQL clients on Windows.
+* Windows vs Unix:: MySQL-Windows compared to Unix MySQL
+@end menu
+
+
+@node Win95 start, NT start, Windows, Windows
+@subsubsection Starting MySQL on Windows 95 or Windows 98
+
+MySQL uses TCP/IP to connect a client to a server. (This will
+allow any machine on your network to connect to your MySQL
+server.) Because of this, you must install TCP/IP on your machine before
+starting MySQL. You can find TCP/IP on your Windows CD-ROM.
+
+Note that if you are using an old Win95 release (for example OSR2), it's
+likely that you have an old Winsock package! MySQL requires
+Winsock 2! You can get the newest Winsock from
+@uref{http://www.microsoft.com/}. Win98 has the new Winsock 2 library, so
+the above doesn't apply for Win98.
+
+To start the @code{mysqld} server, you should start an MS-DOS window and type:
@example
-CC="cc -pthread" CXX="cxx -pthread -O" \
-./configure --with-named-thread-libs="-lpthread -lmach -lexc -lc"
+C:\> C:\mysql\bin\mysqld
@end example
-When compiling @code{mysqld}, you may see a couple of warnings like this:
+This will start @code{mysqld} in the background without a window.
+
+You can kill the MySQL server by executing:
@example
-mysqld.cc: In function void handle_connections()':
-mysqld.cc:626: passing long unsigned int *' as argument 3 of
-accept(int,sockadddr *, int *)'
+C:\> C:\mysql\bin\mysqladmin -u root shutdown
@end example
-You can safely ignore these warnings. They occur because @code{configure}
-can detect only errors, not warnings.
+Note that Win95 and Win98 don't support creation of named pipes.
+On Win95 and Win98, you can only use named pipes to connect to a
+remote MySQL server running on a Windows NT server host.
+(The MySQL server must also support named pipes, of
+course. For example, using @code{mysqld-opt} under NT will not allow
+named pipe connections. You should use either @code{mysqld-nt} or
+@code{mysqld-max-nt}.)
-If you start the server directly from the command line, you may have problems
-with it dying when you log out. (When you log out, your outstanding processes
-receive a @code{SIGHUP} signal.) If so, try starting the server like this:
+If @code{mysqld} doesn't start, please check the
+@file{\mysql\data\mysql.err} file to see if the server wrote any message
+there to indicate the cause of the problem. You can also try to start
+the server with @code{mysqld --standalone}; In this case, you may get
+some useful information on the screen that may help solve the problem.
+
+The last option is to start @code{mysqld} with @code{--standalone
+--debug}. In this case @code{mysqld} will write a log file
+@file{C:\mysqld.trace} that should contain the reason why @code{mysqld}
+doesn't start. @xref{Making trace files}.
+
+
+@node NT start, Windows running, Win95 start, Windows
+@subsubsection Starting MySQL on Windows NT or Windows 2000
+
+The Win95/Win98 section also applies to MySQL on NT/Win2000, with
+the following differences:
+
+To get MySQL to work with TCP/IP on NT, you must install
+service pack 3 (or newer)!
+
+Note that everything in the following that applies for NT also applies
+for Win2000!
+
+For NT/Win2000, the server name is @code{mysqld-nt}. Normally you
+should install MySQL as a service on NT/Win2000:
@example
-shell> nohup mysqld [options] &
+C:\> C:\mysql\bin\mysqld-nt --install
@end example
-@code{nohup} causes the command following it to ignore any @code{SIGHUP}
-signal sent from the terminal. Alternatively, start the server by running
-@code{safe_mysqld}, which invokes @code{mysqld} using @code{nohup} for you.
-@xref{safe_mysqld, , @code{safe_mysqld}}.
+or
-If you get a problem when compiling mysys/get_opt.c, just remove the
-line #define _NO_PROTO from the start of that file!
+@example
+C:\> C:\mysql\bin\mysqld-max-nt --install
+@end example
-If you are using Compac's CC compiler, the following configure line should
-work:
+(Under Windows NT, you can actually install any of the server binaries
+as a service, but only those having names that end with @code{-nt.exe}
+provide support for named pipes.)
+
+You can start and stop the MySQL service with these commands:
@example
-CC="cc -pthread"
-CFLAGS="-O4 -ansi_alias -ansi_args -fast -inline speed -speculate all -arch host"
-CXX="cxx -pthread"
-CXXFLAGS="-O4 -ansi_alias -ansi_args -fast -inline speed -speculate all -arch host"
-export CC CFLAGS CXX CXXFLAGS
-./configure \
---prefix=/usr/local/mysql \
---with-low-memory \
---enable-large-files \
---enable-shared=yes \
---with-named-thread-libs="-lpthread -lmach -lexc -lc"
-gnumake
+C:\> NET START mysql
+C:\> NET STOP mysql
@end example
-If you get a problem with libtool, when compiling with shared libraries
-as above, when linking @code{mysql}, you should be able to get around
-this by issuing:
+Note that in this case you can't use any other options for @code{mysqld-nt}!
+
+You can also run @code{mysqld-nt} as a stand-alone program on NT if you need
+to start @code{mysqld-nt} with any options! If you start @code{mysqld-nt}
+without options on NT, @code{mysqld-nt} tries to start itself as a service
+with the default service options. If you have stopped @code{mysqld-nt}, you
+have to start it with @code{NET START mysql}.
+
+The service is installed with the name @code{MySQL}. Once installed, it must
+be started using the Services Control Manager (SCM) Utility found in the
+Control Panel, or by using the @code{NET START MySQL} command. If any options
+are desired, they must be specified as ``Startup parameters'' in the SCM utility
+before you start the MySQL service. Once running, @code{mysqld-nt}
+can be stopped using @code{mysqladmin}, or from the SCM utility or by using
+the command @code{NET STOP MySQL}. If you use SCM to stop @code{mysqld-nt},
+there is a strange message from SCM about @code{mysqld shutdown normally}.
+When run as a service, @code{mysqld-nt} has no access to a console and so no
+messages can be seen.
+
+On NT you can get the following service error messages:
+
+@multitable @columnfractions .3 .7
+@item Permission Denied @tab Means that it cannot find @code{mysqld-nt.exe}.
+@item Cannot Register @tab Means that the path is incorrect.
+@item Failed to install service. @tab Means that the service is already installed or that the Service Control Manager is in bad state.
+@end multitable
+
+If you have problems installing @code{mysqld-nt} as a service, try starting
+it with the full path:
@example
-cd mysql
-/bin/sh ../libtool --mode=link cxx -pthread -O3 -DDBUG_OFF \
--O4 -ansi_alias -ansi_args -fast -inline speed \
--speculate all \ -arch host -DUNDEF_HAVE_GETHOSTBYNAME_R \
--o mysql mysql.o readline.o sql_string.o completion_hash.o \
-../readline/libreadline.a -lcurses \
-../libmysql/.libs/libmysqlclient.so -lm
-cd ..
-gnumake
-gnumake install
-scripts/mysql_install_db
+C:\> C:\mysql\bin\mysqld-nt --install
@end example
-@node Alpha-DEC-OSF1, SGI-Irix, Alpha-DEC-UNIX, Source install system issues
-@subsection Alpha-DEC-OSF1 Notes
+If this doesn't work, you can get @code{mysqld-nt} to start properly by fixing
+the path in the registry!
+
+If you don't want to start @code{mysqld-nt} as a service, you can start it as
+follows:
-If you have problems compiling and have DEC @code{CC} and @code{gcc}
-installed, try running @code{configure} like this:
+@example
+C:\> C:\mysql\bin\mysqld-nt --standalone
+@end example
+
+or
@example
-CC=cc CFLAGS=-O CXX=gcc CXXFLAGS=-O3 \
-./configure --prefix=/usr/local/mysql
+C:\> C:\mysql\bin\mysqld --standalone --debug
@end example
-If you get problems with the @file{c_asm.h} file, you can create and use
-a 'dummy' @file{c_asm.h} file with:
+The last version gives you a debug trace in @file{C:\mysqld.trace}.
+@xref{Making trace files}.
+
+
+@node Windows running, Windows and SSH, NT start, Windows
+@subsubsection Running MySQL on Windows
+
+@cindex TCP/IP
+@cindex named pipes
+
+MySQL supports TCP/IP on all Windows platforms and named pipes on NT.
+The default is to use named pipes for local connections on NT and TCP/IP for
+all other cases if the client has TCP/IP installed. The host name specifies
+which protocol is used:
+
+@multitable @columnfractions .3 .7
+@strong{Host name} @tab @strong{Protocol}
+@item NULL (none) @tab On NT, try named pipes first; if that doesn't work, use TCP/IP. On Win95/Win98, TCP/IP is used.
+@item . @tab Named pipes
+@item localhost @tab TCP/IP to current host
+@item hostname @tab TCP/IP
+@end multitable
+
+You can force a MySQL client to use named pipes by specifying the
+@code{--pipe} option or by specifying @code{.} as the host name. Use the
+@code{--socket} option to specify the name of the pipe.
+
+You can test whether or not MySQL is working by executing the
+following commands:
@example
-touch include/c_asm.h
-CC=gcc CFLAGS=-I./include \
-CXX=gcc CXXFLAGS=-O3 \
-./configure --prefix=/usr/local/mysql
+C:\> C:\mysql\bin\mysqlshow
+C:\> C:\mysql\bin\mysqlshow -u root mysql
+C:\> C:\mysql\bin\mysqladmin version status proc
+C:\> C:\mysql\bin\mysql test
@end example
-Note that the following problems with the @code{ld} program can be fixed
-by downloading the latest DEC (Compaq) patch kit from:
-@uref{http://ftp.support.compaq.com/public/unix/}.
+If @code{mysqld} is slow to answer to connections on Win95/Win98, there is
+probably a problem with your DNS. In this case, start @code{mysqld} with
+@code{--skip-name-resolve} and use only @code{localhost} and IP numbers in
+the MySQL grant tables. You can also avoid DNS when connecting to a
+@code{mysqld-nt} MySQL server running on NT by using the
+@code{--pipe} argument to specify use of named pipes. This works for most
+MySQL clients.
-On OSF1 V4.0D and compiler "DEC C V5.6-071 on Digital Unix V4.0 (Rev. 878)"
-the compiler had some strange behavior (undefined @code{asm} symbols).
-@code{/bin/ld} also appears to be broken (problems with @code{_exit
-undefined} errors occuring while linking @code{mysqld}). On this system, we
-have managed to compile @strong{MySQL} with the following @code{configure}
-line, after replacing @code{/bin/ld} with the version from OSF 4.0C:
+There are two versions of the MySQL command-line tool:
+@multitable @columnfractions .25 .75
+@item @code{mysql} @tab Compiled on native Windows, which offers very limited text editing capabilities.
+@item @code{mysqlc} @tab Compiled with the Cygnus GNU compiler and libraries, which offers @code{readline} editing.
+@end multitable
+
+If you want to use @code{mysqlc.exe}, you must copy
+@file{C:\mysql\lib\cygwinb19.dll} to your Windows system directory
+(@file{\windows\system} or similar place).
+
+The default privileges on Windows give all local users full privileges
+to all databases without specifying a password. To make MySQL
+more secure, you should set a password for all users and remove the row in
+the @code{mysql.user} table that has @code{Host='localhost'} and
+@code{User=''}.
+
+You should also add a password for the @code{root} user. The following
+example starts by removing the anonymous user that can be used by anyone
+to access the @code{test} database, then sets a @code{root} user password:
@example
-CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql
+C:\> C:\mysql\bin\mysql mysql
+mysql> DELETE FROM user WHERE Host='localhost' AND User='';
+mysql> QUIT
+C:\> C:\mysql\bin\mysqladmin reload
+C:\> C:\mysql\bin\mysqladmin -u root password your_password
@end example
-With the Digital compiler "C++ V6.1-029", the following should work:
+After you've set the password, if you want to take down the @code{mysqld}
+server, you can do so using this command:
@example
-CC=cc -pthread
-CFLAGS=-O4 -ansi_alias -ansi_args -fast -inline speed -speculate all -arch host
-CXX=cxx -pthread
-CXXFLAGS=-O4 -ansi_alias -ansi_args -fast -inline speed -speculate all -arch host -noexceptions -nortti
-export CC CFLAGS CXX CXXFLAGS
-./configure --prefix=/usr/mysql/mysql --with-mysqld-ldflags=-all-static --disable-shared --with-named-thread-libs="-lmach -lexc -lc"
+C:\> mysqladmin --user=root --password=your_password shutdown
@end example
-In some versions of OSF1, the @code{alloca()} function is broken. Fix
-this by removing the line in @file{config.h} that defines @code{'HAVE_ALLOCA'}.
+If you are using the old shareware version of MySQL Version
+3.21 under Windows, the above command will fail with an error:
+@code{parse error near 'SET OPTION password'}. The fix is in to upgrade
+to the current MySQL version, which is freely available.
-The @code{alloca()} function also may have an incorrect prototype in
-@code{/usr/include/alloca.h}. This warning resulting from this can be ignored.
+With the current MySQL versions you can easily add new users
+and change privileges with @code{GRANT} and @code{REVOKE} commands.
+@xref{GRANT}.
-@code{configure} will use the following thread libraries automatically:
-@code{--with-named-thread-libs="-lpthread -lmach -lexc -lc"}.
-When using @code{gcc}, you can also try running @code{configure} like this:
+@node Windows and SSH, Windows symbolic links, Windows running, Windows
+@subsubsection Connecting to a Remote MySQL from Windows with SSH
+
+@c FIX this is ugly, real ugly.
+
+@cindex SSH
+@cindex connecting, remotely with SSH
+
+Here is a note about how to connect to get a secure connection to remote
+MySQL server with SSH (by David Carlson @email{dcarlson@@mplcomm.com}):
+
+@itemize @bullet
+@item
+Install an SSH client on your Windows machine. As a user, the best non-free
+one I've found is from @code{SecureCRT} from @uref{http://www.vandyke.com/}.
+Another option is @code{f-secure} from @uref{http://www.f-secure.com/}. You
+can also find some free ones on @strong{Google} at
+@uref{http://directory.google.com/Top/Computers/Security/Products_and_Tools/Cryptography/SSH/Clients/Windows/}.
+
+@item
+Start your Windows SSH client.
+Set @code{Host_Name = yourmysqlserver_URL_or_IP}.
+Set @code{userid=your_userid} to log in to your server (probably not the same
+as your MySQL login/password.
+
+@item
+Set up port forwarding. Either do a remote forward (Set @code{local_port: 3306}, @code{remote_host: yourmysqlservername_or_ip}, @code{remote_port: 3306} )
+or a local forward (Set @code{port: 3306}, @code{host: localhost}, @code{remote port: 3306}).
+
+@item
+Save everything, otherwise you'll have to redo it the next time.
+
+@item
+Log in to your server with SSH session you just created.
+
+@item
+On your Windows machine, start some ODBC application (such as Access).
+
+@item
+Create a new file in Windows and link to MySQL using the ODBC
+driver the same way you normally do, EXCEPT type in @code{localhost}
+for the MySQL host server --- not @code{yourmysqlservername}.
+@end itemize
+
+You should now have an ODBC connection to MySQL, encrypted using SSH.
+
+
+@node Windows symbolic links, Windows compiling, Windows and SSH, Windows
+@subsubsection Splitting Data Across Different Disks on Windows
+
+@cindex symbolic links
+@cindex using multiple disks to start data
+@cindex disks, splitting data across
+
+Beginning with MySQL Version 3.23.16, the @code{mysqld-max}
+and @code{mysql-max-nt} servers in the MySQL distribution are
+compiled with the @code{-DUSE_SYMDIR} option. This allows you to put a
+database on different disk by adding a symbolic link to it
+(in a manner similar to the way that symbolic links work on Unix).
+
+On Windows, you make a symbolic link to a database by creating a file
+that contains the path to the destination directory and saving this in
+the @file{mysql_data} directory under the filename @file{database.sym}.
+Note that the symbolic link will be used only if the directory
+@file{mysql_data_dir\database} doesn't exist.
+
+For example, if the MySQL data directory is @file{C:\mysql\data}
+and you want to have database @code{foo} located at @file{D:\data\foo}, you
+should create the file @file{C:\mysql\data\foo.sym} that contains the
+text @code{D:\data\foo\}. After that, all tables created in the database
+@code{foo} will be created in @file{D:\data\foo}.
+
+Note that because of the speed penalty you get when opening every table,
+we have not enabled this by default even if you have compiled
+MySQL with support for this. To enable symlinks you should put
+in your @code{my.cnf} or @code{my.ini} file the following entry:
@example
-shell> CFLAGS=-D_PTHREAD_USE_D4 CXX=gcc CXXFLAGS=-O3 ./configure ....
+[mysqld]
+use-symbolic-links
@end example
-If you have problems with signals (@strong{MySQL} dies unexpectedly
-under high load), you may have found an OS bug with threads and
-signals. In this case you can tell @strong{MySQL} not to use signals by
-configuring with:
+In MySQL 4.0 we will enable symlinks by default. Then you
+should instead use the @code{skip-symlink} option if you want to
+disable this.
+
+
+@node Windows compiling, Windows vs Unix, Windows symbolic links, Windows
+@subsubsection Compiling MySQL Clients on Windows
+
+@cindex compiling, on Windows
+@cindex Windows, compiling on
+
+In your source files, you should include @file{windows.h} before you include
+@file{mysql.h}:
@example
-shell> CFLAGS=-DDONT_USE_THR_ALARM \
- CXXFLAGS=-DDONT_USE_THR_ALARM \
- ./configure ...
+#if defined(_WIN32) || defined(_WIN64)
+#include <windows.h>
+#endif
+#include <mysql.h>
@end example
-This doesn't affect the performance of @strong{MySQL}, but has the side
-effect that you can't kill clients that are ``sleeping'' on a connection with
-@code{mysqladmin kill} or @code{mysqladmin shutdown}. Instead, the client
-will die when it issues its next command.
+You can either link your code with the dynamic @file{libmysql.lib} library,
+which is just a wrapper to load in @file{libmysql.dll} on demand, or link
+with the static @file{mysqlclient.lib} library.
-With @code{gcc} 2.95.2, you will probably run into the following compile error:
+Note that as the mysqlclient libraries are compiled as threaded libraries,
+you should also compile your code to be multi-threaded!
+
+
+@node Windows vs Unix, , Windows compiling, Windows
+@subsubsection MySQL-Windows Compared to Unix MySQL
+
+@cindex Windows, versus Unix
+@cindex operating systems, Windows versus Unix
+
+MySQL-Windows has by now proven itself to be very stable. This version
+of MySQL has the same features as the corresponding Unix version
+with the following exceptions:
+
+@table @strong
+@item Win95 and threads
+Win95 leaks about 200 bytes of main memory for each thread creation.
+Each connection in MySQL creates a new thread, so you shouldn't
+run @code{mysqld} for an extended time on Win95 if your server handles
+many connections! WinNT and Win98 don't suffer from this bug.
+
+@item Concurrent reads
+MySQL depends on the @code{pread()} and @code{pwrite()} calls to be
+able to mix @code{INSERT} and @code{SELECT}. Currently we use mutexes
+to emulate @code{pread()}/@code{pwrite()}. We will, in the long run,
+replace the file level interface with a virtual interface so that we can
+use the @code{readfile()}/@code{writefile()} interface on NT to get more speed.
+The current implementation limits the number of open files MySQL
+can use to 1024, which means that you will not be able to run as many
+concurrent threads on NT as on Unix.
+
+@item Blocking read
+MySQL uses a blocking read for each connection.
+This means that:
+
+@itemize @bullet
+@item
+A connection will not be disconnected automatically after 8 hours, as happens
+with the Unix version of MySQL.
+
+@item
+If a connection hangs, it's impossible to break it without killing
+MySQL.
+
+@item
+@code{mysqladmin kill} will not work on a sleeping connection.
+
+@item
+@code{mysqladmin shutdown} can't abort as long as there are sleeping
+connections.
+@end itemize
+
+We plan to fix this problem when our Windows developers have figured out a
+nice workaround.
+
+@item UDF functions
+For the moment, MySQL-Windows does not support user-definable
+functions.
+
+@item @code{DROP DATABASE}
+You can't drop a database that is in use by some thread.
+
+@item Killing MySQL from the task manager
+You can't kill MySQL from the task manager or with the shutdown
+utility in Win95. You must take it down with @code{mysqladmin shutdown}.
+
+@item Case-insensitive names
+Filenames are case insensitive on Windows, so database and table names
+are also case insensitive in MySQL for Windows. The only
+restriction is that database and table names must be specified using the same
+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
+also the escape character in MySQL. If you are using @code{LOAD
+DATA INFILE} or @code{SELECT ... INTO OUTFILE}, you must double the @samp{\}
+character:
@example
-sql_acl.cc:1456: Internal compiler error in `scan_region', at except.c:2566
-Please submit a full bug report.
+mysql> LOAD DATA INFILE "C:\\tmp\\skr.txt" INTO TABLE skr;
+mysql> SELECT * INTO OUTFILE 'C:\\tmp\\skr.txt' FROM skr;
@end example
-To fix this you should change to the @code{sql} directory and do a ``cut
-and paste'' of the last @code{gcc} line, but change @code{-O3} to
-@code{-O0} (or add @code{-O0} immediately after @code{gcc} if you don't
-have any @code{-O} option on your compile line.) After this is done you
-can just change back to the top-level directly and run @code{make}
-again.
+Alternatively, use Unix style filenames with @samp{/} characters:
-@node SGI-Irix, FreeBSD, Alpha-DEC-OSF1, Source install system issues
-@subsection SGI-Irix Notes
+@example
+mysql> LOAD DATA INFILE "C:/tmp/skr.txt" INTO TABLE skr;
+mysql> SELECT * INTO OUTFILE 'C:/tmp/skr.txt' FROM skr;
+@end example
-If you are using Irix Version 6.5.3 or newer @code{mysqld} will only be able to
-create threads if you run it as a user with @code{CAP_SCHED_MGT}
-privileges (like @code{root}) or give the @code{mysqld} server this privilege
-with the following shell command:
+@item @code{Can't open named pipe} error
+If you use a MySQL 3.22 version on NT with the newest mysql-clients
+you will get the following error:
@example
-shell> chcap "CAP_SCHED_MGT+epi" /opt/mysql/libexec/mysqld
+error 2017: can't open named pipe to host: . pipe...
@end example
-You may have to undefine some things in @file{config.h} after running
-@code{configure} and before compiling.
+@tindex .my.cnf file
+This is because the release version of MySQL uses named pipes on NT
+by default. You can avoid this error by using the @code{--host=localhost}
+option to the new MySQL clients or create an option file
+@file{C:\my.cnf} that contains the following information:
-In some Irix implementations, the @code{alloca()} function is broken. If the
-@code{mysqld} server dies on some @code{SELECT} statements, remove the lines
-from @file{config.h} that define @code{HAVE_ALLOC} and @code{HAVE_ALLOCA_H}.
-If @code{mysqladmin create} doesn't work, remove the line from @file{config.h}
-that defines @code{HAVE_READDIR_R}. You may have to remove the
-@code{HAVE_TERM_H} line as well.
+@example
+[client]
+host = localhost
+@end example
-SGI recommends that you install all of the patches on this page as a set:
-http://support.sgi.com/surfzone/patches/patchset/6.2_indigo.rps.html
+@item @code{Access denied for user} error
+If you get the error @code{Access denied for user: 'some-user@@unknown'
+to database 'mysql'} when accessing a MySQL server on the same
+machine, this means that MySQL can't resolve your host name
+properly.
-At the very minimum, you should install the latest kernel rollup, the
-latest @code{rld} rollup, and the latest @code{libc} rollup.
+To fix this, you should create a file @file{\windows\hosts} with the
+following information:
-You definitely need all the POSIX patches on this page, for pthreads support:
+@example
+127.0.0.1 localhost
+@end example
-@uref{http://support.sgi.com/surfzone/patches/patchset/6.2_posix.rps.html}
+@item @code{ALTER TABLE}
+While you are executing an @code{ALTER TABLE} statement, the table is locked
+from usage by other threads. This has to do with the fact that on Windows,
+you can't delete a file that is in use by another threads. (In the future,
+we may find some way to work around this problem.)
-If you get the something like the following error when compiling
-@file{mysql.cc}:
+@item @code{DROP TABLE} on a table that is in use by a @code{MERGE} table will not work
+The @code{MERGE} handler does its table mapping hidden from MySQL.
+Because Windows doesn't allow you to drop files that are open, you first
+must flush all @code{MERGE} tables (with @code{FLUSH TABLES}) or drop the
+@code{MERGE} table before dropping the table. We will fix this at the same
+time we introduce @code{VIEW}s.
+@end table
+
+Here are some open issues for anyone who might want to help us with the Windows
+release:
+
+@cindex Windows, open issues
+
+@itemize @bullet
+@item
+Make a single-user @code{MYSQL.DLL} server. This should include everything in
+a standard MySQL server, except thread creation. This will make
+MySQL much easier to use in applications that don't need a true
+client/server and don't need to access the server from other hosts.
+
+@item
+Add some nice start and shutdown icons to the MySQL installation.
+
+@item
+Create a tool to manage registry entries for the MySQL startup
+options. The registry entry reading is already coded into @file{mysqld.cc},
+but it should be recoded to be more parameter oriented. The tool should
+also be able to update the @file{C:\my.cnf} option file if the user prefers
+to use that instead of the registry.
+
+@item
+When registering @code{mysqld} as a service with @code{--install} (on NT)
+it would be nice if you could also add default options on the command line.
+For the moment, the workaround is to list the parameters in the
+@file{C:\my.cnf} file instead.
+
+@item
+It would be real nice to be able to kill @code{mysqld} from the task manager.
+For the moment, you must use @code{mysqladmin shutdown}.
+
+@item
+Port @code{readline} to Windows for use in the @code{mysql} command line tool.
+
+@item
+GUI versions of the standard MySQL clients (@code{mysql},
+@code{mysqlshow}, @code{mysqladmin}, and @code{mysqldump}) would be nice.
+
+@item
+It would be nice if the socket read and write functions in @file{net.c} were
+interruptible. This would make it possible to kill open threads with
+@code{mysqladmin kill} on Windows.
+
+@item
+@code{mysqld} always starts in the "C" locale and not in the default locale.
+We would like to have @code{mysqld} use the current locale for the sort order.
+
+@item
+Implement UDF functions with @code{.DLL}s.
+
+@item
+Add macros to use the faster thread-safe increment/decrement methods
+provided by Windows.
+
+@end itemize
+
+Other Windows-specific issues are described in the @file{README} file that
+comes with the MySQL-Windows distribution.
+
+
+@node Solaris, BSD Notes, Windows, Operating System Specific Notes
+@subsection Solaris Notes
+
+@cindex Solaris installation problems
+@cindex problems, installing on Solaris
+@cindex tar, problems on Solaris
+@cindex errors, directory checksum
+@cindex checksum errors
+
+On Solaris, you may run into trouble even before you get the MySQL
+distribution unpacked! Solaris @code{tar} can't handle long file names, so
+you may see an error like this when you unpack MySQL:
@example
-"/usr/include/curses.h", line 82: error(1084): invalid combination of type
+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
+tar: directory checksum error
@end example
-Type the following in the top-level directory of your @strong{MySQL} source
-tree:
+In this case, you must use GNU @code{tar} (@code{gtar}) to unpack the
+distribution. You can find a precompiled copy for Solaris at
+@uref{http://www.mysql.com/Downloads/}.
+
+Sun native threads work only on Solaris 2.5 and higher. For Version 2.4 and
+earlier, MySQL will automatically use MIT-pthreads.
+@xref{MIT-pthreads}.
+
+If you get the following error from configure:
@example
-shell> extra/replace bool curses_bool < /usr/include/curses.h > include/curses.h
-shell> make
+checking for restartable system calls... configure: error can not run test
+programs while cross compiling
@end example
-There have also been reports of scheduling problems. If only one thread is
-running, things go slow. Avoid this by starting another client. This may
-lead to a 2-to-10-fold increase in execution speed thereafter for the other
-thread. This is a poorly understood problem with Irix threads; you may have
-to improvise to find solutions until this can be fixed.
+This means that you have something wrong with your compiler installation!
+In this case you should upgrade your compiler to a newer version. You may
+also be able to solve this problem by inserting the following row into the
+@file{config.cache} file:
-If you are compiling with @code{gcc}, you can use the following
-@code{configure} command:
+@example
+ac_cv_sys_restartable_syscalls=$@{ac_cv_sys_restartable_syscalls='no'@}
+@end example
+
+If you are using Solaris on a SPARC, the recommended compiler is
+@code{gcc} 2.95.2. You can find this at @uref{http://gcc.gnu.org/}.
+Note that @code{egcs} 1.1.1 and @code{gcc} 2.8.1 don't work reliably on
+SPARC!
+
+The recommended @code{configure} line when using @code{gcc} 2.95.2 is:
@example
-CC=gcc CXX=gcc CXXFLAGS=-O3 \
-./configure --prefix=/usr/local/mysql --with-thread-safe-client --with-named-thread-libs=-lpthread
+CC=gcc CFLAGS="-O3" \
+CXX=gcc CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti" \
+./configure --prefix=/usr/local/mysql --with-low-memory --enable-assembler
@end example
-On Irix 6.5.11 with native Irix C and C++ compilers ver. 7.3.1.2, the
-following is reported to work
+If you have a ultra sparc, you can get 4 % more performance by adding
+"-mcpu=v8 -Wa,-xarch=v8plusa" to CFLAGS and CXXFLAGS.
+
+If you have Sun Workshop (Fortre) 5.3 (or newer) compiler, you can
+run @code{configure} like this:
@example
-CC=cc CXX=CC CFLAGS='-O3 -n32 -TARG:platform=IP22 -I/usr/local/include \
--L/usr/local/lib' CXXFLAGS='-O3 -n32 -TARG:platform=IP22 \
--I/usr/local/include -L/usr/local/lib' ./configure --prefix=/usr/local/mysql \
---with-berkeley-db --with-innodb \
---with-libwrap=/usr/local --with-named-curses-libs=/usr/local/lib/libncurses.a
+CC=cc CFLAGS="-Xa -fast -xO4 -native -xstrconst -mt" \
+CXX=CC CXXFLAGS="-noex -xO4 -mt" \
+./configure --prefix=/usr/local/mysql --enable-assembler
+@end example
+
+In the MySQL benchmarks, we got a 6 % speedup on an Ultrasparc when
+using Sun Workshop 5.3 compared to using gcc with -mcpu flags.
+
+If you get a problem with @code{fdatasync} or @code{sched_yield},
+you can fix this by adding @code{LIBS=-lrt} to the configure line
+
+The following paragraph is only relevant for older compilers than
+WorkShop 5.3:
+
+You may also have to edit the @code{configure} script to change this line:
+
+@example
+#if !defined(__STDC__) || __STDC__ != 1
+@end example
+
+to this:
+
+@example
+#if !defined(__STDC__)
+@end example
+
+If you turn on @code{__STDC__} with the @code{-Xc} option, the Sun compiler
+can't compile with the Solaris @file{pthread.h} header file. This is a Sun
+bug (broken compiler or broken include file).
+
+If @code{mysqld} issues the error message shown below when you run it, you have
+tried to compile MySQL with the Sun compiler without enabling the
+multi-thread option (@code{-mt}):
+
+@example
+libc internal error: _rmutex_unlock: rmutex not held
+@end example
+
+Add @code{-mt} to @code{CFLAGS} and @code{CXXFLAGS} and try again.
+
+If you get the following error when compiling MySQL with @code{gcc},
+it means that your @code{gcc} is not configured for your version of Solaris:
+
+@example
+shell> gcc -O3 -g -O2 -DDBUG_OFF -o thr_alarm ...
+./thr_alarm.c: In function `signal_hand':
+./thr_alarm.c:556: too many arguments to function `sigwait'
@end example
-@node FreeBSD, NetBSD, SGI-Irix, Source install system issues
-@subsection FreeBSD Notes
+The proper thing to do in this case is to get the newest version of
+@code{gcc} and compile it with your current @code{gcc} compiler! At
+least for Solaris 2.5, almost all binary versions of @code{gcc} have
+old, unusable include files that will break all programs that use
+threads (and possibly other programs)!
+
+Solaris doesn't provide static versions of all system libraries
+(@code{libpthreads} and @code{libdl}), so you can't compile MySQL
+with @code{--static}. If you try to do so, you will get the error:
+
+@example
+ld: fatal: library -ldl: not found
-FreeBSD 3.x is recommended for running @strong{MySQL} since the thread package
+or
+
+undefined reference to `dlopen'
+
+or
+
+cannot find -lrt
+@end example
+
+If too many processes try to connect very rapidly to @code{mysqld}, you will
+see this error in the MySQL log:
+
+@example
+Error in accept: Protocol error
+@end example
+
+You might try starting the server with the @code{--set-variable back_log=50}
+option as a workaround for this. @xref{Command-line options}.
+
+If you are linking your own MySQL client, you might get the
+following error when you try to execute it:
+
+@example
+ld.so.1: ./my: fatal: libmysqlclient.so.#: open failed: No such file or directory
+@end example
+
+The problem can be avoided by one of the following methods:
+
+@itemize @bullet
+@item
+Link the client with the following flag (instead of @code{-Lpath}):
+@code{-Wl,r/full-path-to-libmysqlclient.so}.
+
+@item
+Copy @file{libmysqclient.so} to @file{/usr/lib}.
+
+@tindex LD_RUN_PATH environment variable
+@tindex Environment variable, LD_RUN_PATH
+@item
+Add the pathname of the directory where @file{libmysqlclient.so} is located
+to the @code{LD_RUN_PATH} environment variable before running your client.
+@end itemize
+
+When using the @code{--with-libwrap} configure option, you must also
+include the libraries that @file{libwrap.a} needs:
+
+@example
+--with-libwrap="/opt/NUtcpwrapper-7.6/lib/libwrap.a -lnsl -lsocket
+@end example
+
+If you have problems with configure trying to link with @code{-lz} and
+you don't have @code{zlib} installed, you have two options:
+
+@itemize @bullet
+@item
+If you want to be able to use the compressed communication protocol,
+you need to get and install zlib from ftp.gnu.org.
+
+@item
+Configure with @code{--with-named-z-libs=no}.
+@end itemize
+
+If you are using gcc and have problems with loading @code{UDF} functions
+into MySQL, try adding @code{-lgcc} to the link line for the
+@code{UDF} function.
+
+If you would like MySQL to start automatically, you can copy
+@file{support-files/mysql.server} to @file{/etc/init.d} and create a
+symbolic link to it named @file{/etc/rc3.d/S99mysql.server}.
+
+
+@menu
+* Solaris 2.7:: Solaris 2.7/2.8 Notes
+* Solaris x86:: Solaris x86 Notes
+@end menu
+
+
+@node Solaris 2.7, Solaris x86, Solaris, Solaris
+@subsubsection Solaris 2.7/2.8 Notes
+
+You can normally use a Solaris 2.6 binary on Solaris 2.7 and 2.8. Most
+of the Solaris 2.6 issues also apply for Solaris 2.7 and 2.8.
+
+Note that MySQL Version 3.23.4 and above should be able to autodetect
+new versions of Solaris and enable workarounds for the following problems!
+
+Solaris 2.7 / 2.8 has some bugs in the include files. You may see the
+following error when you use @code{gcc}:
+
+@example
+/usr/include/widec.h:42: warning: `getwc' redefined
+/usr/include/wchar.h:326: warning: this is the location of the previous
+definition
+@end example
+
+If this occurs, you can do the following to fix the problem:
+
+Copy @code{/usr/include/widec.h} to
+@code{.../lib/gcc-lib/os/gcc-version/include} and change line 41 from:
+
+@example
+#if !defined(lint) && !defined(__lint)
+
+to
+
+#if !defined(lint) && !defined(__lint) && !defined(getwc)
+@end example
+
+Alternatively, you can edit @file{/usr/include/widec.h} directly. Either
+way, after you make the fix, you should remove @file{config.cache} and run
+@code{configure} again!
+
+If you get errors like this when you run @code{make}, it's because
+@code{configure} didn't detect the @file{curses.h} file (probably
+because of the error in @file{/usr/include/widec.h}):
+
+@example
+In file included from mysql.cc:50:
+/usr/include/term.h:1060: syntax error before `,'
+/usr/include/term.h:1081: syntax error before `;'
+@end example
+
+The solution to this is to do one of the following:
+
+@itemize @bullet
+@item
+Configure with @code{CFLAGS=-DHAVE_CURSES_H CXXFLAGS=-DHAVE_CURSES_H ./configure}.
+
+@item
+Edit @file{/usr/include/widec.h} as indicted above and rerun configure.
+
+@item
+Remove the @code{#define HAVE_TERM} line from @file{config.h} file and
+run @code{make} again.
+@end itemize
+
+If you get a problem that your linker can't find @code{-lz} when linking
+your client program, the problem is probably that your @file{libz.so} file is
+installed in @file{/usr/local/lib}. You can fix this by one of the
+following methods:
+
+@itemize @bullet
+@item
+Add @file{/usr/local/lib} to @code{LD_LIBRARY_PATH}.
+
+@item
+Add a link to @file{libz.so} from @file{/lib}.
+
+@item
+If you are using Solaris 8, you can install the optional zlib from your
+Solaris 8 CD distribution.
+
+@item
+Configure MySQL with the @code{--with-named-z-libs=no} option.
+@end itemize
+
+
+@node Solaris x86, , Solaris 2.7, Solaris
+@subsubsection Solaris x86 Notes
+
+On Solaris 2.8 on x86, @code{mysqld} will core dump if you run
+'strip' in.
+
+If you are using @code{gcc} or @code{egcs} on Solaris x86 and you
+experience problems with core dumps under load, you should use the
+following @code{configure} command:
+
+@example
+CC=gcc CFLAGS="-O3 -fomit-frame-pointer -DHAVE_CURSES_H" \
+CXX=gcc \
+CXXFLAGS="-O3 -fomit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti -DHAVE_CURSES_H" \
+./configure --prefix=/usr/local/mysql
+@end example
+
+This will avoid problems with the @code{libstdc++} library and with C++
+exceptions.
+
+If this doesn't help, you should compile a debug version and run
+it with a trace file or under @code{gdb}. @xref{Using gdb on mysqld}.
+
+
+@node BSD Notes, Mac OS X, Solaris, Operating System Specific Notes
+@subsection BSD Notes
+
+@menu
+* FreeBSD:: FreeBSD Notes
+* NetBSD:: NetBSD notes
+* OpenBSD:: OpenBSD Notes
+* OpenBSD 2.5:: OpenBSD 2.5 Notes
+* OpenBSD 2.8:: OpenBSD 2.8 Notes
+* BSDI:: BSD/OS Notes
+* BSDI2:: BSD/OS Version 2.x Notes
+* BSDI3:: BSD/OS Version 3.x Notes
+* BSDI4:: BSD/OS Version 4.x Notes
+@end menu
+
+
+@node FreeBSD, NetBSD, BSD Notes, BSD Notes
+@subsubsection FreeBSD Notes
+
+FreeBSD 3.x is recommended for running MySQL since the thread package
is much more integrated.
The easiest and therefor the preferred way to install is to use the
@@ -8282,7 +11042,7 @@ mysql-server and mysql-client ports available on @uref{http://www.freebsd.org}.
Using these gives you:
@itemize @bullet
@item
-A working @strong{MySQL} with all optimizations known to work on your version
+A working MySQL with all optimizations known to work on your version
of FreeBSD enabled.
@item
@@ -8293,7 +11053,7 @@ Startup scripts installed in /usr/local/etc/rc.d.
@item
Ability to see which files that are installed with pkg_info -L. And to
-remove them all with pkg_delete if you no longer want @strong{MySQL} on that
+remove them all with pkg_delete if you no longer want MySQL on that
machine.
@end itemize
@@ -8301,9 +11061,8 @@ It is recommended you use MIT-pthreads on FreeBSD 2.x and native threads on
Versions 3 and up. It is possible to run with native threads on some late
2.2.x versions but you may encounter problems shutting down @code{mysqld}.
-The @strong{MYSQL} Makefiles require GNU make (@code{gmake}) to work.
-If you want to compile @strong{MYSQL} you need to install GNU make
-first.
+The MySQL @file{Makefile}s require GNU make (@code{gmake}) to work. If
+you want to compile MySQL you need to install GNU @code{make} first.
Be sure to have your name resolver setup correct. Otherwise you may
experience resolver delays or failures when connecting to @code{mysqld}.
@@ -8336,47 +11095,52 @@ appropriate class for this user in the password file if you are not
using the default (use: chpass mysqld-user-name). @xref{safe_mysqld, ,
@code{safe_mysqld}}.
-If you get problems with the current date in @strong{MySQL}, setting the
+If you get problems with the current date in MySQL, setting the
@code{TZ} variable will probably help. @xref{Environment variables}.
To get a secure and stable system you should only use FreeBSD kernels
that are marked @code{-STABLE}.
-@node NetBSD, OpenBSD, FreeBSD, Source install system issues
-@subsection NetBSD notes
+
+@node NetBSD, OpenBSD, FreeBSD, BSD Notes
+@subsubsection NetBSD notes
To compile on NetBSD you need GNU @code{make}. Otherwise the compile will
crash when @code{make} tries to run @code{lint} on C++ files.
-@node OpenBSD, BSDI, NetBSD, Source install system issues
-@subsection OpenBSD Notes
+
+@node OpenBSD, OpenBSD 2.5, NetBSD, BSD Notes
+@subsubsection OpenBSD Notes
@menu
* OpenBSD 2.5:: OpenBSD 2.5 Notes
* OpenBSD 2.8:: OpenBSD 2.8 Notes
@end menu
-@node OpenBSD 2.5, OpenBSD 2.8, OpenBSD, OpenBSD
+
+@node OpenBSD 2.5, OpenBSD 2.8, OpenBSD, BSD Notes
@subsubsection OpenBSD 2.5 Notes
-On OpenBSD Version 2.5, you can compile @strong{MySQL} with native threads
+On OpenBSD Version 2.5, you can compile MySQL with native threads
with the following options:
@example
CFLAGS=-pthread CXXFLAGS=-pthread ./configure --with-mit-threads=no
@end example
-@node OpenBSD 2.8, , OpenBSD 2.5, OpenBSD
+
+@node OpenBSD 2.8, BSDI, OpenBSD 2.5, BSD Notes
@subsubsection OpenBSD 2.8 Notes
Our users have reported that OpenBSD 2.8 has a threading bug which causes
-problems with @strong{MySQL}. The OpenBSD Developers have fixed the problem,
+problems with MySQL. The OpenBSD Developers have fixed the problem,
but as of January 25th, 2001, it's only available in the ``-current'' branch.
The symptoms of this threading bug are: slow response, high load, high CPU
usage, and crashes.
-@node BSDI, SCO, OpenBSD, Source install system issues
-@subsection BSD/OS Notes
+
+@node BSDI, BSDI2, OpenBSD 2.8, BSD Notes
+@subsubsection BSD/OS Notes
@menu
* BSDI2:: BSD/OS 2.x notes
@@ -8384,10 +11148,11 @@ usage, and crashes.
* BSDI4:: BSD/OS 4.x notes
@end menu
-@node BSDI2, BSDI3, BSDI, BSDI
+
+@node BSDI2, BSDI3, BSDI, BSD Notes
@subsubsection BSD/OS Version 2.x Notes
-If you get the following error when compiling @strong{MySQL}, your
+If you get the following error when compiling MySQL, your
@code{ulimit} value for virtual memory is too low:
@example
@@ -8405,16 +11170,17 @@ If you are using @code{gcc}, you may also use have to use the
@code{--with-low-memory} flag for @code{configure} to be able to compile
@file{sql_yacc.cc}.
-If you get problems with the current date in @strong{MySQL}, setting the
+If you get problems with the current date in MySQL, setting the
@code{TZ} variable will probably help. @xref{Environment variables}.
-@node BSDI3, BSDI4, BSDI2, BSDI
+
+@node BSDI3, BSDI4, BSDI2, BSD Notes
@subsubsection BSD/OS Version 3.x Notes
Upgrade to BSD/OS Version 3.1. If that is not possible, install
BSDIpatch M300-038.
-Use the following command when configuring @strong{MySQL}:
+Use the following command when configuring MySQL:
@example
shell> env CXX=shlicc++ CC=shlicc2 \
@@ -8448,11 +11214,12 @@ If this doesn't work and you are using @code{bash}, try switching to
@code{csh} or @code{sh}; some BSDI users have reported problems with
@code{bash} and @code{ulimit}.
-@node BSDI4, , BSDI3, BSDI
+
+@node BSDI4, , BSDI3, BSD Notes
@subsubsection BSD/OS Version 4.x Notes
BSDI Version 4.x has some thread-related bugs. If you want to use
-@strong{MySQL} on this, you should install all thread-related patches. At
+MySQL on this, you should install all thread-related patches. At
least M400-023 should be installed.
On some BSDI Version 4.x systems, you may get problems with shared libraries.
@@ -8473,15 +11240,668 @@ Note that the above means that you can't symbolic link a database directories
to another database directory or symbolic link a table to another database
on BSDI! (Making a symbolic link to another disk is ok).
-@node SCO, SCO Unixware, BSDI, Source install system issues
-@subsection SCO Notes
+
+@node Mac OS X, Other Unix Notes, BSD Notes, Operating System Specific Notes
+@subsection Mac OS X Notes
+
+@menu
+* Mac OS X Public Beta:: Mac OS X Public Beta
+* Mac OS X Server:: Mac OS X Server
+@end menu
+
+
+@node Mac OS X Public Beta, Mac OS X Server, Mac OS X, Mac OS X
+@subsubsection Mac OS X Public Beta
+
+MySQL should work without any problems on Mac OS X Public Beta
+(Darwin). You don't need the pthread patches for this OS!
+
+
+@node Mac OS X Server, , Mac OS X Public Beta, Mac OS X
+@subsubsection Mac OS X Server
+
+Before trying to configure MySQL on Mac OS X server you must
+first install the pthread package from
+@uref{http://www.prnet.de/RegEx/mysql.html}.
+
+Our binary for Mac OS X is compiled on Rhapsody 5.5 with the following
+configure line:
+
+@example
+CC=gcc CFLAGS="-O2 -fomit-frame-pointer" CXX=gcc CXXFLAGS="-O2 -fomit-frame-pointer" ./configure --prefix=/usr/local/mysql "--with-comment=Official MySQL binary" --with-extra-charsets=complex --disable-shared
+@end example
+
+You might want to also add aliases to your shell's resource file to
+access @code{mysql} and @code{mysqladmin} from the command line:
+
+@example
+alias mysql '/usr/local/mysql/bin/mysql'
+alias mysqladmin '/usr/local/mysql/bin/mysqladmin'
+@end example
+
+
+@node Other Unix Notes, OS/2, Mac OS X, Operating System Specific Notes
+@subsection Other Unix Notes
+
+@menu
+* Binary notes-HP-UX:: HP-UX Notes for Binary Distributions
+* HP-UX 10.20:: HP-UX Version 10.20 Notes
+* HP-UX 11.x:: HP-UX Version 11.x Notes
+* IBM-AIX:: IBM-AIX notes
+* SunOS:: SunOS 4 Notes
+* Alpha-DEC-UNIX:: Alpha-DEC-UNIX Notes (Tru64)
+* Alpha-DEC-OSF1:: Alpha-DEC-OSF1 Notes
+* SGI-Irix:: SGI Irix Notes
+* SCO:: SCO Notes
+* SCO Unixware:: SCO Unixware Version 7.0 Notes
+@end menu
+
+
+@node Binary notes-HP-UX, HP-UX 10.20, Other Unix Notes, Other Unix Notes
+@subsubsection HP-UX Notes for Binary Distributions
+
+@cindex HP-UX, binary distribution
+@cindex binary distributions, on HP-UX
+
+Some of the binary distributions of MySQL for HP-UX is
+distributed as an HP depot file and as a tar file. To use the depot
+file you must be running at least HP-UX 10.x to have access to HP's
+software depot tools.
+
+The HP version of MySQL was compiled on an HP 9000/8xx server
+under HP-UX 10.20, and uses MIT-pthreads. It is known to work well under
+this configuration. MySQL Version 3.22.26 and newer can also be
+built with HP's native thread package.
+
+Other configurations that may work:
+
+@itemize @bullet
+@item
+HP 9000/7xx running HP-UX 10.20+
+@item
+HP 9000/8xx running HP-UX 10.30
+@end itemize
+
+The following configurations almost definitely won't work:
+
+@itemize @bullet
+@item
+HP 9000/7xx or 8xx running HP-UX 10.x where x < 2
+@item
+HP 9000/7xx or 8xx running HP-UX 9.x
+@end itemize
+
+To install the distribution, use one of the commands below, where
+@code{/path/to/depot} is the full pathname of the depot file:
+
+@itemize @bullet
+@item
+To install everything, including the server, client and development tools:
+
+@example
+shell> /usr/sbin/swinstall -s /path/to/depot mysql.full
+@end example
+
+@item
+To install only the server:
+
+@example
+shell> /usr/sbin/swinstall -s /path/to/depot mysql.server
+@end example
+
+@item
+To install only the client package:
+
+@example
+shell> /usr/sbin/swinstall -s /path/to/depot mysql.client
+@end example
+
+@item
+To install only the development tools:
+
+@example
+shell> /usr/sbin/swinstall -s /path/to/depot mysql.developer
+@end example
+@end itemize
+
+The depot places binaries and libraries in @file{/opt/mysql} and data in
+@file{/var/opt/mysql}. The depot also creates the appropriate entries in
+@file{/etc/init.d} and @file{/etc/rc2.d} to start the server automatically
+at boot time. Obviously, this entails being @code{root} to install.
+
+To install the HP-UX tar.gz distribution, you must have a copy of GNU
+@code{tar}.
+
+
+@node HP-UX 10.20, HP-UX 11.x, Binary notes-HP-UX, Other Unix Notes
+@subsubsection HP-UX Version 10.20 Notes
+
+There are a couple of small problems when compiling MySQL on
+HP-UX. We recommend that you use @code{gcc} instead of the HP-UX native
+compiler, because @code{gcc} produces better code!
+
+We recommend using gcc 2.95 on HP-UX. Don't use high optimization
+flags (like -O6) as this may not be safe on HP-UX.
+
+Note that MIT-pthreads can't be compiled with the HP-UX compiler
+because it can't compile @code{.S} (assembler) files.
+
+The following configure line should work:
+
+@example
+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
+@end example
+
+If you are compiling @code{gcc} 2.95 yourself, you should NOT link it with
+the DCE libraries (@code{libdce.a} or @code{libcma.a}) if you want to compile
+MySQL with MIT-pthreads. If you mix the DCE and MIT-pthreads
+packages you will get a @code{mysqld} to which you cannot connect. Remove
+the DCE libraries while you compile @code{gcc} 2.95!
+
+
+@node HP-UX 11.x, IBM-AIX, HP-UX 10.20, Other Unix Notes
+@subsubsection HP-UX Version 11.x Notes
+
+For HP-UX Version 11.x we recommend MySQL Version 3.23.15 or later.
+
+Because of some critical bugs in the standard HP-UX libraries, you should
+install the following patches before trying to run MySQL on HP-UX 11.0:
+
+@example
+PHKL_22840 Streams cumulative
+PHNE_22397 ARPA cumulative
+@end example
+
+This will solve a problem that one gets @code{EWOULDBLOCK} from @code{recv()}
+and @code{EBADF} from @code{accept()} in threaded applications.
+
+If you are using @code{gcc} 2.95.1 on an unpatched HP-UX 11.x system,
+you will get the error:
+
+@example
+In file included from /usr/include/unistd.h:11,
+ from ../include/global.h:125,
+ from mysql_priv.h:15,
+ from item.cc:19:
+/usr/include/sys/unistd.h:184: declaration of C function ...
+/usr/include/sys/pthread.h:440: previous declaration ...
+In file included from item.h:306,
+ from mysql_priv.h:158,
+ from item.cc:19:
+@end example
+
+The problem is that HP-UX doesn't define @code{pthreads_atfork()} consistently.
+It has conflicting prototypes in
+@file{/usr/include/sys/unistd.h}:184 and
+@file{/usr/include/sys/pthread.h}:440 (details below).
+
+One solution is to copy @file{/usr/include/sys/unistd.h} into
+@file{mysql/include} and edit @file{unistd.h} and change it to match
+the definition in @file{pthread.h}. Here's the diff:
+
+@example
+183,184c183,184
+< extern int pthread_atfork(void (*prepare)(), void (*parent)(),
+< void (*child)());
+---
+> extern int pthread_atfork(void (*prepare)(void), void (*parent)(void),
+> void (*child)(void));
+@end example
+
+After this, the following configure line should work:
+
+@example
+CFLAGS="-fomit-frame-pointer -O3 -fpic" CXX=gcc CXXFLAGS="-felide-constructors -fno-exceptions -fno-rtti -O3" ./configure --prefix=/usr/local/mysql --disable-shared
+@end example
+
+Here is some information that a HP-UX Version 11.x user sent us about compiling
+MySQL with HP-UX:x compiler:
+
+@example
+ Environment:
+ proper compilers.
+ setenv CC cc
+ setenv CXX aCC
+ flags
+ setenv CFLAGS -D_REENTRANT
+ setenv CXXFLAGS -D_REENTRANT
+ setenv CPPFLAGS -D_REENTRANT
+ % aCC -V
+ aCC: HP ANSI C++ B3910B X.03.14.06
+ % cc -V /tmp/empty.c
+ cpp.ansi: HP92453-01 A.11.02.00 HP C Preprocessor (ANSI)
+ ccom: HP92453-01 A.11.01.00 HP C Compiler
+ cc: "/tmp/empty.c", line 1: warning 501: Empty source file.
+
+ configuration:
+ ./configure --with-pthread \
+ --prefix=/source-control/mysql \
+ --with-named-thread-libs=-lpthread \
+ --with-low-memory
+
+ added '#define _CTYPE_INCLUDED' to include/m_ctype.h. This
+ symbol is the one defined in HP's /usr/include/ctype.h:
+
+ /* Don't include std ctype.h when this is included */
+ #define _CTYPE_H
+ #define __CTYPE_INCLUDED
+ #define _CTYPE_INCLUDED
+ #define _CTYPE_USING /* Don't put names in global namespace. */
+@end example
+
+@itemize @bullet
+@item
+I had to use the compile-time flag @code{-D_REENTRANT} to get the compiler
+to recognize the prototype for @code{localtime_r}. Alternatively I could have
+supplied the prototype for @code{localtime_r}. But I wanted to catch other
+bugs without needing to run into them. I wasn't sure where I needed it, so I
+added it to all flags.
+@item
+The optimization flags used by MySQL (-O3) are not recognized by HP's
+compilers. I did not change the flags.
+@end itemize
+
+If you get the following error from @code{configure}
+
+@example
+checking for cc option to accept ANSI C... no
+configure: error: MySQL requires a ANSI C compiler (and a C++ compiler). Try gcc. See the Installation chapter in the Reference Manual.
+@end example
+
+Check that you don't have the path to the K&R compiler before the path
+to the HP-UX C and C++ compiler.
+
+
+@node IBM-AIX, SunOS, HP-UX 11.x, Other Unix Notes
+@subsubsection IBM-AIX notes
+
+@cindex problems, installing on IBM-AIX
+
+Automatic detection of @code{xlC} is missing from Autoconf, so a
+@code{configure} command something like this is needed when compiling
+MySQL (This example uses the IBM compiler):
+
+@example
+export CC="xlc_r -ma -O3 -qstrict -qoptimize=3 -qmaxmem=8192 "
+export CXX="xlC_r -ma -O3 -qstrict -qoptimize=3 -qmaxmem=8192"
+export CFLAGS="-I /usr/local/include"
+export LDLFAGS="-L /usr/local/lib"
+export CPPFLAGS=$CFLAGS
+export CXXFLAGS=$CFLAGS
+
+./configure --prefix=/usr/local \
+ --localstatedir=/var/mysql \
+ --sysconfdir=/etc/mysql \
+ --sbindir='/usr/local/bin' \
+ --libexecdir='/usr/local/bin' \
+ --enable-thread-safe-client \
+ --enable-large-files
+@end example
+
+Above are the options used to compile the MySQL distribution that
+can be found at @uref{http://www-frec.bull.com/}.
+
+If you change the @code{-O3} to @code{-O2} in the above configure line,
+you must also remove the @code{-qstrict} option (this is a limitation in
+the IBM C compiler).
+
+If you are using @code{gcc} or @code{egcs} to compile MySQL, you
+@strong{MUST} use the @code{-fno-exceptions} flag, as the exception
+handling in @code{gcc}/@code{egcs} is not thread safe! (This is tested with
+@code{egcs} 1.1.). There are also some known problems with IBM's assembler,
+which may cause it to generate bad code when used with gcc.
+
+We recommend the following @code{configure} line with @code{egcs} and
+@code{gcc 2.95} on AIX:
+
+@example
+CC="gcc -pipe -mcpu=power -Wa,-many" \
+CXX="gcc -pipe -mcpu=power -Wa,-many" \
+CXXFLAGS="-felide-constructors -fno-exceptions -fno-rtti" \
+./configure --prefix=/usr/local/mysql --with-low-memory
+@end example
+
+The @code{-Wa,-many} is necessary for the compile to be successful. IBM is
+aware of this problem but is in to hurry to fix it because of the workaround
+available. We don't know if the @code{-fno-exceptions} is required with
+@code{gcc 2.95}, but as MySQL doesn't use exceptions and the above
+option generates faster code, we recommend that you should always use this
+option with @code{egcs / gcc}.
+
+If you get a problem with assembler code try changing the -mcpu=xxx to
+match your cpu. Typically power2, power, or powerpc may need to be used,
+alternatively you might need to use 604 or 604e. I'm not positive but I
+would think using "power" would likely be safe most of the time, even on
+a power2 machine.
+
+If you don't know what your cpu is then do a "uname -m", this will give
+you back a string that looks like "000514676700", with a format of
+xxyyyyyymmss where xx and ss are always 0's, yyyyyy is a unique system
+id and mm is the id of the CPU Planar. A chart of these values can be
+found at
+@uref{http://www.rs6000.ibm.com/doc_link/en_US/a_doc_lib/cmds/aixcmds5/uname.htm}.
+This will give you a machine type and a machine model you can use to
+determine what type of cpu you have.
+
+If you have problems with signals (MySQL dies unexpectedly
+under high load) you may have found an OS bug with threads and
+signals. In this case you can tell MySQL not to use signals by
+configuring with:
+
+@example
+shell> CFLAGS=-DDONT_USE_THR_ALARM CXX=gcc \
+ CXXFLAGS="-felide-constructors -fno-exceptions -fno-rtti -DDONT_USE_THR_ALARM" \
+ ./configure --prefix=/usr/local/mysql --with-debug --with-low-memory
+@end example
+
+This doesn't affect the performance of MySQL, but has the side
+effect that you can't kill clients that are ``sleeping'' on a connection with
+@code{mysqladmin kill} or @code{mysqladmin shutdown}. Instead, the client
+will die when it issues its next command.
+
+On some versions of AIX, linking with @code{libbind.a} makes
+@code{getservbyname} core dump. This is an AIX bug and should be reported
+to IBM.
+
+For AIX 4.2.1 and gcc you have to do the following changes.
+
+After configuring, edit @file{config.h} and @file{include/my_config.h}
+and change the line that says
+
+@example
+#define HAVE_SNPRINTF 1
+@end example
+
+to
+
+@example
+#undef HAVE_SNPRINTF
+@end example
+
+And finally, in @file{mysqld.cc} you need to add a prototype for initgoups.
+
+@example
+#ifdef _AIX41
+extern "C" int initgroups(const char *,int);
+#endif
+@end example
+
+
+@node SunOS, Alpha-DEC-UNIX, IBM-AIX, Other Unix Notes
+@subsubsection SunOS 4 Notes
+
+On SunOS 4, MIT-pthreads is needed to compile MySQL, which in turn
+means you will need GNU @code{make}.
+
+Some SunOS 4 systems have problems with dynamic libraries and @code{libtool}.
+You can use the following @code{configure} line to avoid this problem:
+
+@example
+shell> ./configure --disable-shared --with-mysqld-ldflags=-all-static
+@end example
+
+When compiling @code{readline}, you may get warnings about duplicate defines.
+These may be ignored.
+
+When compiling @code{mysqld}, there will be some @code{implicit declaration
+of function} warnings. These may be ignored.
+
+
+@node Alpha-DEC-UNIX, Alpha-DEC-OSF1, SunOS, Other Unix Notes
+@subsubsection Alpha-DEC-UNIX Notes (Tru64)
+
+If you are using egcs 1.1.2 on Digital Unix, you should upgrade to gcc
+2.95.2, as egcs on DEC has some serious bugs!
+
+When compiling threaded programs under Digital Unix, the documentation
+recommends using the @code{-pthread} option for @code{cc} and @code{cxx} and
+the libraries @code{-lmach -lexc} (in addition to @code{-lpthread}). You
+should run @code{configure} something like this:
+
+@example
+CC="cc -pthread" CXX="cxx -pthread -O" \
+./configure --with-named-thread-libs="-lpthread -lmach -lexc -lc"
+@end example
+
+When compiling @code{mysqld}, you may see a couple of warnings like this:
+
+@example
+mysqld.cc: In function void handle_connections()':
+mysqld.cc:626: passing long unsigned int *' as argument 3 of
+accept(int,sockadddr *, int *)'
+@end example
+
+You can safely ignore these warnings. They occur because @code{configure}
+can detect only errors, not warnings.
+
+If you start the server directly from the command line, you may have problems
+with it dying when you log out. (When you log out, your outstanding processes
+receive a @code{SIGHUP} signal.) If so, try starting the server like this:
+
+@example
+shell> nohup mysqld [options] &
+@end example
+
+@code{nohup} causes the command following it to ignore any @code{SIGHUP}
+signal sent from the terminal. Alternatively, start the server by running
+@code{safe_mysqld}, which invokes @code{mysqld} using @code{nohup} for you.
+@xref{safe_mysqld, , @code{safe_mysqld}}.
+
+If you get a problem when compiling mysys/get_opt.c, just remove the
+line #define _NO_PROTO from the start of that file!
+
+If you are using Compac's CC compiler, the following configure line should
+work:
+
+@example
+CC="cc -pthread"
+CFLAGS="-O4 -ansi_alias -ansi_args -fast -inline speed all -arch host"
+CXX="cxx -pthread"
+CXXFLAGS="-O4 -ansi_alias -ansi_args -fast -inline speed all -arch host"
+export CC CFLAGS CXX CXXFLAGS
+./configure \
+--prefix=/usr/local/mysql \
+--with-low-memory \
+--enable-large-files \
+--enable-shared=yes \
+--with-named-thread-libs="-lpthread -lmach -lexc -lc"
+gnumake
+@end example
+
+If you get a problem with libtool, when compiling with shared libraries
+as above, when linking @code{mysql}, you should be able to get around
+this by issuing:
+
+@example
+cd mysql
+/bin/sh ../libtool --mode=link cxx -pthread -O3 -DDBUG_OFF \
+-O4 -ansi_alias -ansi_args -fast -inline speed \
+-speculate all \ -arch host -DUNDEF_HAVE_GETHOSTBYNAME_R \
+-o mysql mysql.o readline.o sql_string.o completion_hash.o \
+../readline/libreadline.a -lcurses \
+../libmysql/.libs/libmysqlclient.so -lm
+cd ..
+gnumake
+gnumake install
+scripts/mysql_install_db
+@end example
+
+
+@node Alpha-DEC-OSF1, SGI-Irix, Alpha-DEC-UNIX, Other Unix Notes
+@subsubsection Alpha-DEC-OSF1 Notes
+
+If you have problems compiling and have DEC @code{CC} and @code{gcc}
+installed, try running @code{configure} like this:
+
+@example
+CC=cc CFLAGS=-O CXX=gcc CXXFLAGS=-O3 \
+./configure --prefix=/usr/local/mysql
+@end example
+
+If you get problems with the @file{c_asm.h} file, you can create and use
+a 'dummy' @file{c_asm.h} file with:
+
+@example
+touch include/c_asm.h
+CC=gcc CFLAGS=-I./include \
+CXX=gcc CXXFLAGS=-O3 \
+./configure --prefix=/usr/local/mysql
+@end example
+
+Note that the following problems with the @code{ld} program can be fixed
+by downloading the latest DEC (Compaq) patch kit from:
+@uref{http://ftp.support.compaq.com/public/unix/}.
+
+On OSF1 V4.0D and compiler "DEC C V5.6-071 on Digital Unix V4.0 (Rev. 878)"
+the compiler had some strange behavior (undefined @code{asm} symbols).
+@code{/bin/ld} also appears to be broken (problems with @code{_exit
+undefined} errors occuring while linking @code{mysqld}). On this system, we
+have managed to compile MySQL with the following @code{configure}
+line, after replacing @code{/bin/ld} with the version from OSF 4.0C:
+
+@example
+CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql
+@end example
+
+With the Digital compiler "C++ V6.1-029", the following should work:
+
+@example
+CC=cc -pthread
+CFLAGS=-O4 -ansi_alias -ansi_args -fast -inline speed -speculate all -arch host
+CXX=cxx -pthread
+CXXFLAGS=-O4 -ansi_alias -ansi_args -fast -inline speed -speculate all -arch host -noexceptions -nortti
+export CC CFLAGS CXX CXXFLAGS
+./configure --prefix=/usr/mysql/mysql --with-mysqld-ldflags=-all-static --disable-shared --with-named-thread-libs="-lmach -lexc -lc"
+@end example
+
+In some versions of OSF1, the @code{alloca()} function is broken. Fix
+this by removing the line in @file{config.h} that defines @code{'HAVE_ALLOCA'}.
+
+The @code{alloca()} function also may have an incorrect prototype in
+@code{/usr/include/alloca.h}. This warning resulting from this can be ignored.
+
+@code{configure} will use the following thread libraries automatically:
+@code{--with-named-thread-libs="-lpthread -lmach -lexc -lc"}.
+
+When using @code{gcc}, you can also try running @code{configure} like this:
+
+@example
+shell> CFLAGS=-D_PTHREAD_USE_D4 CXX=gcc CXXFLAGS=-O3 ./configure ....
+@end example
+
+If you have problems with signals (MySQL dies unexpectedly
+under high load), you may have found an OS bug with threads and
+signals. In this case you can tell MySQL not to use signals by
+configuring with:
+
+@example
+shell> CFLAGS=-DDONT_USE_THR_ALARM \
+ CXXFLAGS=-DDONT_USE_THR_ALARM \
+ ./configure ...
+@end example
+
+This doesn't affect the performance of MySQL, but has the side
+effect that you can't kill clients that are ``sleeping'' on a connection with
+@code{mysqladmin kill} or @code{mysqladmin shutdown}. Instead, the client
+will die when it issues its next command.
+
+With @code{gcc} 2.95.2, you will probably run into the following compile error:
+
+@example
+sql_acl.cc:1456: Internal compiler error in `scan_region', at except.c:2566
+Please submit a full bug report.
+@end example
+
+To fix this you should change to the @code{sql} directory and do a ``cut
+and paste'' of the last @code{gcc} line, but change @code{-O3} to
+@code{-O0} (or add @code{-O0} immediately after @code{gcc} if you don't
+have any @code{-O} option on your compile line.) After this is done you
+can just change back to the top-level directly and run @code{make}
+again.
+
+
+@node SGI-Irix, SCO, Alpha-DEC-OSF1, Other Unix Notes
+@subsubsection SGI Irix Notes
+
+If you are using Irix Version 6.5.3 or newer @code{mysqld} will only be able to
+create threads if you run it as a user with @code{CAP_SCHED_MGT}
+privileges (like @code{root}) or give the @code{mysqld} server this privilege
+with the following shell command:
+
+@example
+shell> chcap "CAP_SCHED_MGT+epi" /opt/mysql/libexec/mysqld
+@end example
+
+You may have to undefine some things in @file{config.h} after running
+@code{configure} and before compiling.
+
+In some Irix implementations, the @code{alloca()} function is broken. If the
+@code{mysqld} server dies on some @code{SELECT} statements, remove the lines
+from @file{config.h} that define @code{HAVE_ALLOC} and @code{HAVE_ALLOCA_H}.
+If @code{mysqladmin create} doesn't work, remove the line from @file{config.h}
+that defines @code{HAVE_READDIR_R}. You may have to remove the
+@code{HAVE_TERM_H} line as well.
+
+SGI recommends that you install all of the patches on this page as a set:
+http://support.sgi.com/surfzone/patches/patchset/6.2_indigo.rps.html
+
+At the very minimum, you should install the latest kernel rollup, the
+latest @code{rld} rollup, and the latest @code{libc} rollup.
+
+You definitely need all the POSIX patches on this page, for pthreads support:
+
+@uref{http://support.sgi.com/surfzone/patches/patchset/6.2_posix.rps.html}
+
+If you get the something like the following error when compiling
+@file{mysql.cc}:
+
+@example
+"/usr/include/curses.h", line 82: error(1084): invalid combination of type
+@end example
+
+Type the following in the top-level directory of your MySQL source
+tree:
+
+@example
+shell> extra/replace bool curses_bool < /usr/include/curses.h > include/curses.h
+shell> make
+@end example
+
+There have also been reports of scheduling problems. If only one thread is
+running, things go slow. Avoid this by starting another client. This may
+lead to a 2-to-10-fold increase in execution speed thereafter for the other
+thread. This is a poorly understood problem with Irix threads; you may have
+to improvise to find solutions until this can be fixed.
+
+If you are compiling with @code{gcc}, you can use the following
+@code{configure} command:
+
+@example
+CC=gcc CXX=gcc CXXFLAGS=-O3 \
+./configure --prefix=/usr/local/mysql --with-thread-safe-client --with-named-thread-libs=-lpthread
+@end example
+
+On Irix 6.5.11 with native Irix C and C++ compilers ver. 7.3.1.2, the
+following is reported to work
+
+@example
+CC=cc CXX=CC CFLAGS='-O3 -n32 -TARG:platform=IP22 -I/usr/local/include \
+-L/usr/local/lib' CXXFLAGS='-O3 -n32 -TARG:platform=IP22 \
+-I/usr/local/include -L/usr/local/lib' ./configure --prefix=/usr/local/mysql \
+--with-berkeley-db --with-innodb \
+--with-libwrap=/usr/local --with-named-curses-libs=/usr/local/lib/libncurses.a
+@end example
+
+
+@node SCO, SCO Unixware, SGI-Irix, Other Unix Notes
+@subsubsection SCO Notes
The current port is tested only on a ``sco3.2v5.0.4'' and
``sco3.2v5.0.5'' system. There has also been a lot of progress on a
port to ``sco 3.2v4.2''.
For the moment the recommended compiler on OpenServer is gcc 2.95.2. With this
-you should be able to compile @strong{MySQL} with just:
+you should be able to compile MySQL with just:
@example
CC=gcc CXX=gcc ./configure ... (options)
@@ -8539,7 +11959,7 @@ install}.
@end enumerate
@item
-Remember to use GNU @code{make} when making @strong{MySQL}.
+Remember to use GNU @code{make} when making MySQL.
@item
If you don't start @code{safe_mysqld} as root, you probably will get only the
@@ -8572,14 +11992,14 @@ You may get some problems with some include files. In this case, you can
find new SCO-specific include files at
@uref{http://www.mysql.com/Downloads/SCO/SCO-3.2v4.2-includes.tar.gz}.
You should unpack this file in the @file{include} directory of your
-@strong{MySQL} source tree.
+MySQL source tree.
@end enumerate
SCO development notes:
@itemize @bullet
@item
-@strong{MySQL} should automatically detect FSU Pthreads and link @code{mysqld}
+MySQL should automatically detect FSU Pthreads and link @code{mysqld}
with @code{-lgthreads -lsocket -lgthreads}.
@item
@@ -8630,13 +12050,14 @@ if they were compiled with @code{icc} or @code{cc}.
Perl works best when compiled with @code{cc}.
-@node SCO Unixware, IBM-AIX, SCO, Source install system issues
-@subsection SCO Unixware Version 7.0 Notes
-You must use a version of @strong{MySQL} at least as recent as Version 3.22.13
+@node SCO Unixware, , SCO, Other Unix Notes
+@subsubsection SCO Unixware Version 7.0 Notes
+
+You must use a version of MySQL at least as recent as Version 3.22.13
because that version fixes some portability problems under Unixware.
-We have been able to compile @strong{MySQL} with the following @code{configure}
+We have been able to compile MySQL with the following @code{configure}
command on Unixware Version 7.0.1:
@example
@@ -8645,1651 +12066,2609 @@ CC=cc CXX=CC ./configure --prefix=/usr/local/mysql
If you want to use @code{gcc}, you must use @code{gcc} 2.95.2 or newer.
-@node IBM-AIX, HP-UX 10.20, SCO Unixware, Source install system issues
-@subsection IBM-AIX notes
-@cindex problems, installing on IBM-AIX
-Automatic detection of @code{xlC} is missing from Autoconf, so a
-@code{configure} command something like this is needed when compiling
-@strong{MySQL} (This example uses the IBM compiler):
+@menu
+* OS/2:: OS/2 Notes
+@end menu
+
+
+@node OS/2, BeOS, Other Unix Notes, Operating System Specific Notes
+@subsection OS/2 Notes
+
+MySQL uses quite a few open files. Because of this, you should add
+something like the following to your @file{CONFIG.SYS} file:
@example
-export CC="xlc_r -ma -O3 -qstrict -qoptimize=3 -qmaxmem=8192 "
-export CXX="xlC_r -ma -O3 -qstrict -qoptimize=3 -qmaxmem=8192"
-export CFLAGS="-I /usr/local/include"
-export LDLFAGS="-L /usr/local/lib"
-export CPPFLAGS=$CFLAGS
-export CXXFLAGS=$CFLAGS
+SET EMXOPT=-c -n -h1024
+@end example
-./configure --prefix=/usr/local \
- --localstatedir=/var/mysql \
- --sysconfdir=/etc/mysql \
- --sbindir='/usr/local/bin' \
- --libexecdir='/usr/local/bin' \
- --enable-thread-safe-client \
- --enable-large-files
+If you don't do this, you will probably run into the following error:
+
+@example
+File 'xxxx' not found (Errcode: 24)
@end example
-Above are the options used to compile the @strong{MySQL} distribution that
-can be found at @uref{http://www-frec.bull.com/}.
+When using MySQL with OS/2 Warp 3, FixPack 29 or above is
+required. With OS/2 Warp 4, FixPack 4 or above is required. This is a
+requirement of the Pthreads library. MySQL must be installed
+in a partition that supports long filenames such as HPFS, FAT32, etc.
-If you change the @code{-O3} to @code{-O2} in the above configure line,
-you must also remove the @code{-qstrict} option (this is a limitation in
-the IBM C compiler).
+The @file{INSTALL.CMD} script must be run from OS/2's own @file{CMD.EXE}
+and may not work with replacement shells such as @file{4OS2.EXE}.
-If you are using @code{gcc} or @code{egcs} to compile @strong{MySQL}, you
-@strong{MUST} use the @code{-fno-exceptions} flag, as the exception
-handling in @code{gcc}/@code{egcs} is not thread safe! (This is tested with
-@code{egcs} 1.1.). There are also some known problems with IBM's assembler,
-which may cause it to generate bad code when used with gcc.
+The @file{scripts/mysql-install-db} script has been renamed. It is now called
+@file{install.cmd} and is a REXX script, which will set up the default
+MySQL security settings and create the WorkPlace Shell icons
+for MySQL.
-We recommend the following @code{configure} line with @code{egcs} and
-@code{gcc 2.95} on AIX:
+Dynamic module support is compiled in but not fully tested. Dynamic
+modules should be compiled using the Pthreads run-time library.
@example
-CC="gcc -pipe -mcpu=power -Wa,-many" \
-CXX="gcc -pipe -mcpu=power -Wa,-many" \
-CXXFLAGS="-felide-constructors -fno-exceptions -fno-rtti" \
-./configure --prefix=/usr/local/mysql --with-low-memory
+gcc -Zdll -Zmt -Zcrtdll=pthrdrtl -I../include -I../regex -I.. \
+ -o example udf_example.cc -L../lib -lmysqlclient udf_example.def
+mv example.dll example.udf
@end example
-The @code{-Wa,-many} is necessary for the compile to be successful. IBM is
-aware of this problem but is in to hurry to fix it because of the workaround
-available. We don't know if the @code{-fno-exceptions} is required with
-@code{gcc 2.95}, but as @strong{MySQL} doesn't use exceptions and the above
-option generates faster code, we recommend that you should always use this
-option with @code{egcs / gcc}.
+@strong{Note:} Due to limitations in OS/2, UDF module name stems must not
+exceed 8 characters. Modules are stored in the @file{/mysql2/udf}
+directory; the @code{safe-mysqld.cmd} script will put this directory in
+the @code{BEGINLIBPATH} environment variable. When using UDF modules,
+specified extensions are ignored --- it is assumed to be @file{.udf}.
+For example, in Unix, the shared module might be named @file{example.so}
+and you would load a function from it like this:
-If you get a problem with assembler code try changing the -mcpu=xxx to
-match your cpu. Typically power2, power, or powerpc may need to be used,
-alternatively you might need to use 604 or 604e. I'm not positive but I
-would think using "power" would likely be safe most of the time, even on
-a power2 machine.
+@example
+mysql> CREATE FUNCTION metaphon RETURNS STRING SONAME "example.so";
+@end example
-If you don't know what your cpu is then do a "uname -m", this will give
-you back a string that looks like "000514676700", with a format of
-xxyyyyyymmss where xx and ss are always 0's, yyyyyy is a unique system
-id and mm is the id of the CPU Planar. A chart of these values can be
-found at
-@uref{http://www.rs6000.ibm.com/doc_link/en_US/a_doc_lib/cmds/aixcmds5/uname.htm}.
-This will give you a machine type and a machine model you can use to
-determine what type of cpu you have.
+Is OS/2, the module would be named @file{example.udf}, but you would not
+specify the module extension:
-If you have problems with signals (@strong{MySQL} dies unexpectedly
-under high load) you may have found an OS bug with threads and
-signals. In this case you can tell @strong{MySQL} not to use signals by
-configuring with:
+@example
+mysql> CREATE FUNCTION metaphon RETURNS STRING SONAME "example";
+@end example
+
+
+@node BeOS, Novell Netware, OS/2, Operating System Specific Notes
+@subsection BeOS Notes
+
+We are really interested in getting MySQL to work on BeOS, but
+unfortunately we don't have any person who knows BeOS or has time to do
+a port.
+
+We are interested in finding someone to do a port, and we will help them
+with any technical questions they may have while doing the port.
+
+We have previously talked with some BeOS developers that have said that
+MySQL is 80% ported to BeOS, but we haven't heard from them
+in a while.
+
+
+@node Novell Netware, , BeOS, Operating System Specific Notes
+@subsection Novell Netware Notes
+
+We are really interested in getting MySQL to work on Netware, but
+unfortunately we don't have any person who knows Netware or has time to do
+a port.
+
+We are interested in finding someone to do a port, and we will help them
+with any technical questions they may have while doing the port.
+
+
+
+
+@node Tutorial, MySQL Database Administration, Installing, Top
+@chapter Introduction to MySQL: A MySQL Tutorial
+
+@cindex tutorial
+@cindex terminal monitor, defined
+@cindex monitor, terminal
+@cindex options, provided by MySQL
+
+@menu
+* Connecting-disconnecting:: Connecting to and disconnecting from the server
+* Entering queries:: Entering queries
+* Database use:: Creating and using a database
+* Getting information:: Getting information about databases and tables
+* Examples:: Examples
+* Batch mode:: Using @code{mysql} in batch mode
+* Twin:: Queries from twin project
+* Apache:: Using MySQL with Apache
+@end menu
+
+This chapter provides a tutorial introduction to MySQL by showing
+how to use the @code{mysql} client program to create and use a simple
+database. @code{mysql} (sometimes referred to as the ``terminal monitor'' or
+just ``monitor'') is an interactive program that allows you to connect to a
+MySQL server, run queries, and view the results. @code{mysql} may
+also be used in batch mode: you place your queries in a file beforehand, then
+tell @code{mysql} to execute the contents of the file. Both ways of using
+@code{mysql} are covered here.
+
+To see a list of options provided by @code{mysql}, invoke it with
+the @code{--help} option:
@example
-shell> CFLAGS=-DDONT_USE_THR_ALARM CXX=gcc \
- CXXFLAGS="-felide-constructors -fno-exceptions -fno-rtti -DDONT_USE_THR_ALARM" \
- ./configure --prefix=/usr/local/mysql --with-debug --with-low-memory
+shell> mysql --help
@end example
-This doesn't affect the performance of @strong{MySQL}, but has the side
-effect that you can't kill clients that are ``sleeping'' on a connection with
-@code{mysqladmin kill} or @code{mysqladmin shutdown}. Instead, the client
-will die when it issues its next command.
+This chapter assumes that @code{mysql} is installed on your machine and that
+a MySQL server is available to which you can connect. If this is
+not true, contact your MySQL administrator. (If @emph{you} are the
+administrator, you will need to consult other sections of this manual.)
-On some versions of AIX, linking with @code{libbind.a} makes
-@code{getservbyname} core dump. This is an AIX bug and should be reported
-to IBM.
+This chapter describes the entire process of setting up and using a
+database. If you are interested only in accessing an already-existing
+database, you may want to skip over the sections that describe how to
+create the database and the tables it contains.
-For AIX 4.2.1 and gcc you have to do the following changes.
+Because this chapter is tutorial in nature, many details are necessarily left
+out. Consult the relevant sections of the manual for more
+information on the topics covered here.
-After configuring, edit @file{config.h} and @file{include/my_config.h}
-and change the line that says
+
+@node Connecting-disconnecting, Entering queries, Tutorial, Tutorial
+@section Connecting to and Disconnecting from the Server
+
+@cindex connecting, to the server
+@cindex disconnecting, from the server
+@cindex server, connecting
+@cindex server, disconnecting
+
+To connect to the server, you'll usually need to provide a MySQL
+user name when you invoke @code{mysql} and, most likely, a password. If the
+server runs on a machine other than the one where you log in, you'll also
+need to specify a hostname. Contact your administrator to find out what
+connection parameters you should use to connect (that is, what host, user name,
+and password to use). Once you know the proper parameters, you should be
+able to connect like this:
@example
-#define HAVE_SNPRINTF 1
+shell> mysql -h host -u user -p
+Enter password: ********
@end example
-to
+The @code{********} represents your password; enter it when @code{mysql}
+displays the @code{Enter password:} prompt.
+
+If that works, you should see some introductory information followed by a
+@code{mysql>} prompt:
+
@example
-#undef HAVE_SNPRINTF
+shell> mysql -h host -u user -p
+Enter password: ********
+Welcome to the MySQL monitor. Commands end with ; or \g.
+Your MySQL connection id is 459 to server version: 3.22.20a-log
+
+Type 'help' for help.
+
+mysql>
@end example
-And finally, in @file{mysqld.cc} you need to add a prototype for initgoups.
+The prompt tells you that @code{mysql} is ready for you to enter commands.
+
+Some MySQL installations allow users to connect as the anonymous
+(unnamed) user to the server running on the local host. If this is the case
+on your machine, you should be able to connect to that server by invoking
+@code{mysql} without any options:
@example
-#ifdef _AIX41
-extern "C" int initgroups(const char *,int);
-#endif
+shell> mysql
@end example
-@node HP-UX 10.20, HP-UX 11.x, IBM-AIX, Source install system issues
-@subsection HP-UX Version 10.20 Notes
+After you have connected successfully, you can disconnect any time by typing
+@code{QUIT} at the @code{mysql>} prompt:
-There are a couple of small problems when compiling @strong{MySQL} on
-HP-UX. We recommend that you use @code{gcc} instead of the HP-UX native
-compiler, because @code{gcc} produces better code!
+@example
+mysql> QUIT
+Bye
+@end example
-We recommend using gcc 2.95 on HP-UX. Don't use high optimization
-flags (like -O6) as this may not be safe on HP-UX.
+You can also disconnect by pressing Control-D.
-Note that MIT-pthreads can't be compiled with the HP-UX compiler
-because it can't compile @code{.S} (assembler) files.
+Most examples in the following sections assume you are connected to the
+server. They indicate this by the @code{mysql>} prompt.
-The following configure line should work:
+
+@node Entering queries, Database use, Connecting-disconnecting, Tutorial
+@section Entering Queries
+
+@cindex running, queries
+@cindex queries, entering
+@cindex entering, queries
+
+Make sure you are connected to the server, as discussed in the previous
+section. Doing so will not in itself select any database to work with, but
+that's okay. At this point, it's more important to find out a little about
+how to issue queries than to jump right in creating tables, loading data
+into them, and retrieving data from them. This section describes the basic
+principles of entering commands, using several queries you can try out to
+familiarize yourself with how @code{mysql} works.
+
+Here's a simple command that asks the server to tell you its version number
+and the current date. Type it in as shown below following the @code{mysql>}
+prompt and hit the RETURN key:
@example
-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
+mysql> SELECT VERSION(), CURRENT_DATE;
++--------------+--------------+
+| version() | CURRENT_DATE |
++--------------+--------------+
+| 3.22.20a-log | 1999-03-19 |
++--------------+--------------+
+1 row in set (0.01 sec)
+mysql>
@end example
-If you are compiling @code{gcc} 2.95 yourself, you should NOT link it with
-the DCE libraries (@code{libdce.a} or @code{libcma.a}) if you want to compile
-@strong{MySQL} with MIT-pthreads. If you mix the DCE and MIT-pthreads
-packages you will get a @code{mysqld} to which you cannot connect. Remove
-the DCE libraries while you compile @code{gcc} 2.95!
+This query illustrates several things about @code{mysql}:
-@node HP-UX 11.x, Mac OS X, HP-UX 10.20, Source install system issues
-@subsection HP-UX Version 11.x Notes
+@itemize @bullet
+@item
+A command normally consists of a SQL statement followed by a semicolon.
+(There are some exceptions where a semicolon is not needed. @code{QUIT},
+mentioned earlier, is one of them. We'll get to others later.)
-For HP-UX Version 11.x we recommend @strong{MySQL} Version 3.23.15 or later.
+@item
+When you issue a command, @code{mysql} sends it to the server for execution
+and displays the results, then prints another @code{mysql>} to indicate
+that it is ready for another command.
-Because of some critical bugs in the standard HP-UX libraries, you should
-install the following patches before trying to run @strong{MySQL} on HP-UX 11.0:
+@item
+@code{mysql} displays query output as a table (rows and columns). The first
+row contains labels for the columns. The rows following are the query
+results. Normally, column labels are the names of the columns you fetch from
+database tables. If you're retrieving the value of an expression rather than
+a table column (as in the example just shown), @code{mysql} labels the column
+using the expression itself.
+
+@item
+@code{mysql} shows how many rows were returned and how long the query took
+to execute, which gives you a rough idea of server performance. These values
+are imprecise because they represent wall clock time (not CPU or machine
+time), and because they are affected by factors such as server load and
+network latency. (For brevity, the ``rows in set'' line is not shown in
+the remaining examples in this chapter.)
+@end itemize
+
+Keywords may be entered in any lettercase. The following queries are
+equivalent:
@example
-PHKL_22840 Streams cumulative
-PHNE_22397 ARPA cumulative
+mysql> SELECT VERSION(), CURRENT_DATE;
+mysql> select version(), current_date;
+mysql> SeLeCt vErSiOn(), current_DATE;
@end example
-This will solve a problem that one gets @code{EWOULDBLOCK} from @code{recv()}
-and @code{EBADF} from @code{accept()} in threaded applications.
+Here's another query. It demonstrates that you can use @code{mysql} as a
+simple calculator:
-If you are using @code{gcc} 2.95.1 on an unpatched HP-UX 11.x system,
-you will get the error:
+@example
+mysql> SELECT SIN(PI()/4), (4+1)*5;
++-------------+---------+
+| SIN(PI()/4) | (4+1)*5 |
++-------------+---------+
+| 0.707107 | 25 |
++-------------+---------+
+@end example
+
+The commands shown thus far have been relatively short, single-line
+statements. You can even enter multiple statements on a single line.
+Just end each one with a semicolon:
@example
-In file included from /usr/include/unistd.h:11,
- from ../include/global.h:125,
- from mysql_priv.h:15,
- from item.cc:19:
-/usr/include/sys/unistd.h:184: declaration of C function ...
-/usr/include/sys/pthread.h:440: previous declaration ...
-In file included from item.h:306,
- from mysql_priv.h:158,
- from item.cc:19:
+mysql> SELECT VERSION(); SELECT NOW();
++--------------+
+| version() |
++--------------+
+| 3.22.20a-log |
++--------------+
+
++---------------------+
+| NOW() |
++---------------------+
+| 1999-03-19 00:15:33 |
++---------------------+
@end example
-The problem is that HP-UX doesn't define @code{pthreads_atfork()} consistently.
-It has conflicting prototypes in
-@file{/usr/include/sys/unistd.h}:184 and
-@file{/usr/include/sys/pthread.h}:440 (details below).
+A command need not be given all on a single line, so lengthy commands that
+require several lines are not a problem. @code{mysql} determines where your
+statement ends by looking for the terminating semicolon, not by looking for
+the end of the input line. (In other words, @code{mysql}
+accepts free-format input: it collects input lines but does not execute them
+until it sees the semicolon.)
-One solution is to copy @file{/usr/include/sys/unistd.h} into
-@file{mysql/include} and edit @file{unistd.h} and change it to match
-the definition in @file{pthread.h}. Here's the diff:
+Here's a simple multiple-line statement:
@example
-183,184c183,184
-< extern int pthread_atfork(void (*prepare)(), void (*parent)(),
-< void (*child)());
----
-> extern int pthread_atfork(void (*prepare)(void), void (*parent)(void),
-> void (*child)(void));
+mysql> SELECT
+ -> USER()
+ -> ,
+ -> CURRENT_DATE;
++--------------------+--------------+
+| USER() | CURRENT_DATE |
++--------------------+--------------+
+| joesmith@@localhost | 1999-03-18 |
++--------------------+--------------+
@end example
-After this, the following configure line should work:
+In this example, notice how the prompt changes from @code{mysql>} to
+@code{->} after you enter the first line of a multiple-line query. This is
+how @code{mysql} indicates that it hasn't seen a complete statement and is
+waiting for the rest. The prompt is your friend, because it provides
+valuable feedback. If you use that feedback, you will always be aware of
+what @code{mysql} is waiting for.
+
+If you decide you don't want to execute a command that you are in the
+process of entering, cancel it by typing @code{\c}:
@example
-CFLAGS="-fomit-frame-pointer -O3 -fpic" CXX=gcc CXXFLAGS="-felide-constructors -fno-exceptions -fno-rtti -O3" ./configure --prefix=/usr/local/mysql --disable-shared
+mysql> SELECT
+ -> USER()
+ -> \c
+mysql>
@end example
-Here is some information that a HP-UX Version 11.x user sent us about compiling
-@strong{MySQL} with HP-UX:x compiler:
+Here, too, notice the prompt. It switches back to @code{mysql>} after you
+type @code{\c}, providing feedback to indicate that @code{mysql} is ready
+for a new command.
+
+The following table shows each of the prompts you may see and summarizes what
+they mean about the state that @code{mysql} is in:
+
+@cindex prompts, meanings
+@multitable @columnfractions .10 .9
+@item @strong{Prompt} @tab @strong{Meaning}
+@item @code{mysql>} @tab Ready for new command.
+@item @code{@ @ @ @ ->} @tab Waiting for next line of multiple-line command.
+@item @code{@ @ @ @ '>} @tab Waiting for next line, collecting a string that begins
+with a single quote (@samp{'}).
+@item @code{@ @ @ @ ">} @tab Waiting for next line, collecting a string that begins
+with a double quote (@samp{"}).
+@end multitable
+
+Multiple-line statements commonly occur by accident when you intend to
+issue a command on a single line, but forget the terminating semicolon. In
+this case, @code{mysql} waits for more input:
@example
- Environment:
- proper compilers.
- setenv CC cc
- setenv CXX aCC
- flags
- setenv CFLAGS -D_REENTRANT
- setenv CXXFLAGS -D_REENTRANT
- setenv CPPFLAGS -D_REENTRANT
- % aCC -V
- aCC: HP ANSI C++ B3910B X.03.14.06
- % cc -V /tmp/empty.c
- cpp.ansi: HP92453-01 A.11.02.00 HP C Preprocessor (ANSI)
- ccom: HP92453-01 A.11.01.00 HP C Compiler
- cc: "/tmp/empty.c", line 1: warning 501: Empty source file.
+mysql> SELECT USER()
+ ->
+@end example
- configuration:
- ./configure --with-pthread \
- --prefix=/source-control/mysql \
- --with-named-thread-libs=-lpthread \
- --with-low-memory
+If this happens to you (you think you've entered a statement but the only
+response is a @code{->} prompt), most likely @code{mysql} is waiting for the
+semicolon. If you don't notice what the prompt is telling you, you might sit
+there for a while before realizing what you need to do. Enter a semicolon to
+complete the statement, and @code{mysql} will execute it:
- added '#define _CTYPE_INCLUDED' to include/m_ctype.h. This
- symbol is the one defined in HP's /usr/include/ctype.h:
+@example
+mysql> SELECT USER()
+ -> ;
++--------------------+
+| USER() |
++--------------------+
+| joesmith@@localhost |
++--------------------+
+@end example
- /* Don't include std ctype.h when this is included */
- #define _CTYPE_H
- #define __CTYPE_INCLUDED
- #define _CTYPE_INCLUDED
- #define _CTYPE_USING /* Don't put names in global namespace. */
+The @code{'>} and @code{">} prompts occur during string collection.
+In MySQL, you can write strings surrounded by either @samp{'}
+or @samp{"} characters (for example, @code{'hello'} or @code{"goodbye"}),
+and @code{mysql} lets you enter strings that span multiple lines. When you
+see a @code{'>} or @code{">} prompt, it means that you've entered a line
+containing a string that begins with a @samp{'} or @samp{"} quote character,
+but have not yet entered the matching quote that terminates the string.
+That's fine if you really are entering a multiple-line string, but how likely
+is that? Not very. More often, the @code{'>} and @code{">} prompts indicate
+that you've inadvertantly left out a quote character. For example:
+
+@example
+mysql> SELECT * FROM my_table WHERE name = "Smith AND age < 30;
+ ">
@end example
-@itemize @bullet
-@item
-I had to use the compile-time flag @code{-D_REENTRANT} to get the compiler
-to recognize the prototype for @code{localtime_r}. Alternatively I could have
-supplied the prototype for @code{localtime_r}. But I wanted to catch other
-bugs without needing to run into them. I wasn't sure where I needed it, so I
-added it to all flags.
-@item
-The optimization flags used by @strong{MySQL} (-O3) are not recognized by HP's
-compilers. I did not change the flags.
-@end itemize
+If you enter this @code{SELECT} statement, then hit RETURN and wait for the
+result, nothing will happen. Instead of wondering why this
+query takes so long, notice the clue provided by the @code{">} prompt. It
+tells you that @code{mysql} expects to see the rest of an unterminated
+string. (Do you see the error in the statement? The string @code{"Smith} is
+missing the second quote.)
-If you get the following error from @code{configure}
+At this point, what do you do? The simplest thing is to cancel the command.
+However, you cannot just type @code{\c} in this case, because @code{mysql}
+interprets it as part of the string that it is collecting! Instead, enter
+the closing quote character (so @code{mysql} knows you've finished the
+string), then type @code{\c}:
@example
-checking for cc option to accept ANSI C... no
-configure: error: MySQL requires a ANSI C compiler (and a C++ compiler). Try gcc. See the Installation chapter in the Reference Manual.
+mysql> SELECT * FROM my_table WHERE name = "Smith AND age < 30;
+ "> "\c
+mysql>
@end example
-Check that you don't have the path to the K&R compiler before the path
-to the HP-UX C and C++ compiler.
+The prompt changes back to @code{mysql>}, indicating that @code{mysql}
+is ready for a new command.
-@node Mac OS X, BEOS, HP-UX 11.x, Source install system issues
-@subsection Mac OS X Notes
+It's important to know what the @code{'>} and @code{">} prompts signify,
+because if you mistakenly enter an unterminated string, any further lines you
+type will appear to be ignored by @code{mysql} --- including a line
+containing @code{QUIT}! This can be quite confusing, especially if you
+don't know that you need to supply the terminating quote before you can
+cancel the current command.
+
+
+@node Database use, Getting information, Entering queries, Tutorial
+@section Creating and Using a Database
+
+@cindex databases, creating
+@cindex databases, using
+@cindex creating, databases
@menu
-* Mac OS X Public Data::
-* Mac OS X Server::
+* Creating database:: Creating a database
+* Creating tables:: Creating a table
+* Loading tables:: Loading data into a table
+* Retrieving data:: Retrieving information from a table
@end menu
-@node Mac OS X Public Data, Mac OS X Server, Mac OS X, Mac OS X
-@subsubsection Mac OS X Public beta
+Now that you know how to enter commands, it's time to access a database.
-@strong{MySQL} should work without any problems on Mac OS X Public Beta
-(Darwin). You don't need the pthread patches for this OS!
+Suppose you have several pets in your home (your menagerie) and you'd
+like to keep track of various types of information about them. You can do so
+by creating tables to hold your data and loading them with the desired
+information. Then you can answer different sorts of questions about your
+animals by retrieving data from the tables. This section shows you how to:
-@node Mac OS X Server, , Mac OS X Public Data, Mac OS X
-@subsubsection Mac OS X Server
+@itemize @bullet
+@item
+Create a database
+@item
+Create a table
+@item
+Load data into the table
+@item
+Retrieve data from the table in various ways
+@item
+Use multiple tables
+@end itemize
-Before trying to configure @strong{MySQL} on Mac OS X server you must
-first install the pthread package from
-@uref{http://www.prnet.de/RegEx/mysql.html}.
+The menagerie database will be simple (deliberately), but it is not difficult
+to think of real-world situations in which a similar type of database might
+be used. For example, a database like this could be used by a farmer to keep
+track of livestock, or by a veterinarian to keep track of patient records.
+A menagerie distribution containing some of the queries and sample data used
+in the following sections can be obtained from the MySQL Web site.
+It's available in either
+@uref{http://www.mysql.com/Downloads/Contrib/Examples/menagerie.tar.gz,compressed @code{tar} format}
+or
+@uref{http://www.mysql.com/Downloads/Contrib/Examples/menagerie.zip,Zip format}.
-Our binary for Mac OS X is compiled on Rhapsody 5.5 with the following
-configure line:
+Use the @code{SHOW} statement to find out what databases currently exist
+on the server:
@example
-CC=gcc CFLAGS="-O2 -fomit-frame-pointer" CXX=gcc CXXFLAGS="-O2 -fomit-frame-pointer" ./configure --prefix=/usr/local/mysql "--with-comment=Official MySQL binary" --with-extra-charsets=complex --disable-shared
+mysql> SHOW DATABASES;
++----------+
+| Database |
++----------+
+| mysql |
+| test |
+| tmp |
++----------+
@end example
-You might want to also add aliases to your shell's resource file to
-access @code{mysql} and @code{mysqladmin} from the command line:
+The list of databases is probably different on your machine, but the
+@code{mysql} and @code{test} databases are likely to be among them. The
+@code{mysql} database is required because it describes user access
+privileges. The @code{test} database is often provided as a workspace for
+users to try things out.
+
+If the @code{test} database exists, try to access it:
@example
-alias mysql '/usr/local/mysql/bin/mysql'
-alias mysqladmin '/usr/local/mysql/bin/mysqladmin'
+mysql> USE test
+Database changed
@end example
-@node BEOS, , Mac OS X, Source install system issues
-@subsection BeOS Notes
+Note that @code{USE}, like @code{QUIT}, does not require a semicolon. (You
+can terminate such statements with a semicolon if you like; it does no harm.)
+The @code{USE} statement is special in another way, too: it must be given on
+a single line.
-We are really interested in getting @strong{MySQL} to work on BeOS, but
-unfortunately we don't have any person who knows BeOS or has time to do
-a port.
+You can use the @code{test} database (if you have access to it) for the
+examples that follow, but anything you create in that database can be
+removed by anyone else with access to it. For this reason, you should
+probably ask your MySQL administrator for permission to use a
+database of your own. Suppose you want to call yours @code{menagerie}. The
+administrator needs to execute a command like this:
-We are interested in finding someone to do a port, and we will help them
-with any technical questions they may have while doing the port.
+@example
+mysql> GRANT ALL ON menagerie.* TO your_mysql_name;
+@end example
-We have previously talked with some BeOS developers that have said that
-@strong{MySQL} is 80% ported to BeOS, but we haven't heard from them
-in a while.
+where @code{your_mysql_name} is the MySQL user name assigned to
+you.
-@node Windows, OS/2, Source install system issues, Installing
-@section Windows Notes
-This section describes installation and use of @strong{MySQL} on Windows.
-This information is also provided in the @file{README} file that comes
-with the @strong{MySQL} Windows distribution.
+@node Creating database, Creating tables, Database use, Database use
+@subsection Creating and Selecting a Database
-@menu
-* Windows installation:: Installing @strong{MySQL} on Windows
-* Win95 start:: Starting @strong{MySQL} on Win95 / Win98
-* NT start:: Starting @strong{MySQL} on NT / Win2000
-* Windows running:: Running @strong{MySQL} on Windows
-* Windows and SSH:: Connecting to a remote @strong{MySQL} from Windows with SSH
-* Windows symbolic links:: Splitting data across different disks under Win32
-* Windows compiling:: Compiling MySQL clients on Windows.
-* Windows vs Unix:: @strong{MySQL}-Windows compared to Unix @strong{MySQL}
-@end menu
+@cindex selecting, databases
+@cindex databases, selecting
-@node Windows installation, Win95 start, Windows, Windows
-@subsection Installing MySQL on Windows
+If the administrator creates your database for you when setting up your
+permissions, you can begin using it. Otherwise, you need to create it
+yourself:
-The following instructions apply to precompiled binary distributions.
-If you download a source distribution, you will have to compile and install
-it yourself.
+@example
+mysql> CREATE DATABASE menagerie;
+@end example
-If you don't have a copy of the @strong{MySQL} distribution, you should
-first download one from @uref{http://www.mysql.com/downloads/mysql-3.23.html}.
+Under Unix, database names are case sensitive (unlike SQL keywords), so you
+must always refer to your database as @code{menagerie}, not as
+@code{Menagerie}, @code{MENAGERIE}, or some other variant. This is also true
+for table names. (Under Windows, this restriction does not apply, although
+you must refer to databases and tables using the same lettercase throughout a
+given query.)
-If you plan to connect to @strong{MySQL} from some other program, you will
-probably also need the @strong{MyODBC} driver. You can find this at the
-@strong{MyODBC} download page
-(@uref{http://www.mysql.com/downloads/api-myodbc.html}).
+Creating a database does not select it for use; you must do that explicitly.
+To make @code{menagerie} the current database, use this command:
-To install either distribution, unzip it in some empty directory and run the
-@code{Setup.exe} program.
+@example
+mysql> USE menagerie
+Database changed
+@end example
-By default, @strong{MySQL}-Windows is configured to be installed in
-@file{C:\mysql}. If you want to install @strong{MySQL} elsewhere,
-install it in @file{C:\mysql} first, then move the installation to
-where you want it. If you do move @strong{MySQL}, you must indicate
-where everything is located by supplying a @code{--basedir} option when
-you start the server. For example, if you have moved the @strong{MySQL}
-distribution to @file{D:\programs\mysql}, you must start @code{mysqld}
-like this:
+Your database needs to be created only once, but you must select it for use
+each time you begin a @code{mysql} session. You can do this by issuing a
+@code{USE} statement as shown above. Alternatively, you can select the
+database on the command line when you invoke @code{mysql}. Just specify its
+name after any connection parameters that you might need to provide. For
+example:
@example
-C:\> D:\programs\mysql\bin\mysqld --basedir D:\programs\mysql
+shell> mysql -h host -u user -p menagerie
+Enter password: ********
@end example
-Use @code{mysqld --help} to display all the options that @code{mysqld}
-understands!
+Note that @code{menagerie} is not your password on the command just shown.
+If you want to supply your password on the command line after the @code{-p}
+option, you must do so with no intervening space (for example, as
+@code{-pmypassword}, not as @code{-p mypassword}). However, putting your
+password on the command line is not recommended, because doing so exposes it
+to snooping by other users logged in on your machine.
-With all newer @strong{MySQL} versions, you can also create a
-@file{C:\my.cnf} file that holds any default options for the
-@strong{MySQL} server. Copy the file @file{\mysql\my-xxxxx.cnf} to
-@file{C:\my.cnf} and edit it to suit your setup. Note that you should
-specify all paths with @samp{/} instead of @samp{\}. If you use
-@samp{\}, you need to specify it twice, because @samp{\} is the escape
-character in @strong{MySQL}. @xref{Option files}.
-Starting with @strong{MySQL} 3.23.38, the Windows distribution includes
-both the normal and the @strong{MySQL-Max} binaries. The main benefit
-of using the normal @code{mysqld.exe} binary is that it's a little
-faster and uses less resources.
+@node Creating tables, Loading tables, Creating database, Database use
+@subsection Creating a Table
-Here is a list of the different @strong{MySQL} servers you can use:
+@cindex tables, creating
+@cindex creating, tables
-@multitable @columnfractions .25 .75
-@item @code{mysqld} @tab
-Compiled with full debugging and automatic memory allocation checking,
-symbolic links, BDB and InnoDB tables.
-@item @code{mysqld-opt} @tab
-Optimized binary with no support for transactional tables.
-@item @code{mysqld-nt} @tab
-Optimized binary for NT with support for named pipes. You can run this
-version on Win98, but in this case no named pipes are created and you must
-have TCP/IP installed.
-@item @code{mysqld-max} @tab
-Optimized binary with support for symbolic links, BDB and InnoDB tables.
-@item @code{mysqld-max-nt} @tab
-Like @code{mysqld-max}, but compiled with support for named pipes.
-@end multitable
+Creating the database is the easy part, but at this point it's empty, as
+@code{SHOW TABLES} will tell you:
-All of the above binaries are optimized for the Pentium Pro processor but
-should work on any Intel processor >= i386.
+@example
+mysql> SHOW TABLES;
+Empty set (0.00 sec)
+@end example
-NOTE: If you want to use InnoDB tables, there are certain startup
-options that must be specified in your @file{my.ini} file! @xref{InnoDB start}.
+The harder part is deciding what the structure of your database should be:
+what tables you will need and what columns will be in each of them.
-@node Win95 start, NT start, Windows installation, Windows
-@subsection Starting MySQL on Windows 95 or Windows 98
+You'll want a table that contains a record for each of your pets. This can
+be called the @code{pet} table, and it should contain, as a bare minimum,
+each animal's name. Because the name by itself is not very interesting, the
+table should contain other information. For example, if more than one person
+in your family keeps pets, you might want to list each animal's owner. You
+might also want to record some basic descriptive information such as species
+and sex.
-@strong{MySQL} uses TCP/IP to connect a client to a server. (This will
-allow any machine on your network to connect to your @strong{MySQL}
-server.) Because of this, you must install TCP/IP on your machine before
-starting @strong{MySQL}. You can find TCP/IP on your Windows CD-ROM.
+How about age? That might be of interest, but it's not a good thing to store
+in a database. Age changes as time passes, which means you'd have to update
+your records often. Instead, it's better to store a fixed value such as
+date of birth. Then, whenever you need age, you can calculate it as the
+difference between the current date and the birth date. MySQL
+provides functions for doing date arithmetic, so this is not difficult.
+Storing birth date rather than age has other advantages, too:
-Note that if you are using an old Win95 release (for example OSR2), it's
-likely that you have an old Winsock package! @strong{MySQL} requires
-Winsock 2! You can get the newest Winsock from
-@uref{http://www.microsoft.com/}. Win98 has the new Winsock 2 library, so
-the above doesn't apply for Win98.
+@itemize @bullet
+@item
+You can use the database for tasks such as generating reminders for upcoming
+pet birthdays. (If you think this type of query is somewhat silly, note that
+it is the same question you might ask in the context of a business database
+to identify clients to whom you'll soon need to send out birthday greetings,
+for that computer-assisted personal touch.)
-To start the @code{mysqld} server, you should start an MS-DOS window and type:
+@item
+You can calculate age in relation to dates other than the current date. For
+example, if you store death date in the database, you can easily calculate
+how old a pet was when it died.
+@end itemize
+
+You can probably think of other types of information that would be useful in
+the @code{pet} table, but the ones identified so far are sufficient for now:
+name, owner, species, sex, birth, and death.
+
+Use a @code{CREATE TABLE} statement to specify the layout of your table:
@example
-C:\> C:\mysql\bin\mysqld
+mysql> CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20),
+ -> species VARCHAR(20), sex CHAR(1), birth DATE, death DATE);
@end example
-This will start @code{mysqld} in the background without a window.
+@code{VARCHAR} is a good choice for the @code{name}, @code{owner}, and
+@code{species} columns because the column values will vary in length. The
+lengths of those columns need not all be the same, and need not be
+@code{20}. You can pick any length from @code{1} to @code{255}, whatever
+seems most reasonable to you. (If you make a poor choice and it turns
+out later that you need a longer field, MySQL provides an
+@code{ALTER TABLE} statement.)
+
+Animal sex can be represented in a variety of ways, for example, @code{"m"}
+and @code{"f"}, or perhaps @code{"male"} and @code{"female"}. It's simplest
+to use the single characters @code{"m"} and @code{"f"}.
+
+The use of the @code{DATE} data type for the @code{birth} and @code{death}
+columns is a fairly obvious choice.
-You can kill the @strong{MySQL} server by executing:
+Now that you have created a table, @code{SHOW TABLES} should produce some
+output:
@example
-C:\> C:\mysql\bin\mysqladmin -u root shutdown
+mysql> SHOW TABLES;
++---------------------+
+| Tables in menagerie |
++---------------------+
+| pet |
++---------------------+
@end example
-Note that Win95 and Win98 don't support creation of named pipes.
-On Win95 and Win98, you can only use named pipes to connect to a
-remote @strong{MySQL} server running on a Windows NT server host.
-(The @strong{MySQL} server must also support named pipes, of
-course. For example, using @code{mysqld-opt} under NT will not allow
-named pipe connections. You should use either @code{mysqld-nt} or
-@code{mysqld-max-nt}.)
+To verify that your table was created the way you expected, use
+a @code{DESCRIBE} statement:
-If @code{mysqld} doesn't start, please check the
-@file{\mysql\data\mysql.err} file to see if the server wrote any message
-there to indicate the cause of the problem. You can also try to start
-the server with @code{mysqld --standalone}; In this case, you may get
-some useful information on the screen that may help solve the problem.
+@example
+mysql> DESCRIBE pet;
++---------+-------------+------+-----+---------+-------+
+| Field | Type | Null | Key | Default | Extra |
++---------+-------------+------+-----+---------+-------+
+| name | varchar(20) | YES | | NULL | |
+| owner | varchar(20) | YES | | NULL | |
+| species | varchar(20) | YES | | NULL | |
+| sex | char(1) | YES | | NULL | |
+| birth | date | YES | | NULL | |
+| death | date | YES | | NULL | |
++---------+-------------+------+-----+---------+-------+
+@end example
-The last option is to start @code{mysqld} with @code{--standalone
---debug}. In this case @code{mysqld} will write a log file
-@file{C:\mysqld.trace} that should contain the reason why @code{mysqld}
-doesn't start. @xref{Making trace files}.
+You can use @code{DESCRIBE} any time, for example, if you forget the names of
+the columns in your table or what types they are.
-@node NT start, Windows running, Win95 start, Windows
-@subsection Starting MySQL on Windows NT or Windows 2000
-The Win95/Win98 section also applies to @strong{MySQL} on NT/Win2000, with
-the following differences:
+@node Loading tables, Retrieving data, Creating tables, Database use
+@subsection Loading Data into a Table
-To get @strong{MySQL} to work with TCP/IP on NT, you must install
-service pack 3 (or newer)!
+@cindex loading, tables
+@cindex tables, loading data
+@cindex data, loading into tables
-Note that everything in the following that applies for NT also applies
-for Win2000!
+After creating your table, you need to populate it. The @code{LOAD DATA} and
+@code{INSERT} statements are useful for this.
-For NT/Win2000, the server name is @code{mysqld-nt}. Normally you
-should install @strong{MySQL} as a service on NT/Win2000:
+Suppose your pet records can be described as shown below.
+(Observe that MySQL expects dates in @code{YYYY-MM-DD} format;
+this may be different than what you are used to.)
-@example
-C:\> C:\mysql\bin\mysqld-nt --install
-@end example
+@multitable @columnfractions .16 .16 .16 .16 .16 .16
+@item @strong{name} @tab @strong{owner} @tab @strong{species} @tab @strong{sex} @tab @strong{birth} @tab @strong{death}
+@item Fluffy @tab Harold @tab cat @tab f @tab 1993-02-04 @tab
+@item Claws @tab Gwen @tab cat @tab m @tab 1994-03-17 @tab
+@item Buffy @tab Harold @tab dog @tab f @tab 1989-05-13 @tab
+@item Fang @tab Benny @tab dog @tab m @tab 1990-08-27 @tab
+@item Bowser @tab Diane @tab dog @tab m @tab 1989-08-31 @tab 1995-07-29
+@item Chirpy @tab Gwen @tab bird @tab f @tab 1998-09-11 @tab
+@item Whistler @tab Gwen @tab bird @tab @tab 1997-12-09 @tab
+@item Slim @tab Benny @tab snake @tab m @tab 1996-04-29 @tab
+@end multitable
-or
+Because you are beginning with an empty table, an easy way to populate it is to
+create a text file containing a row for each of your animals, then load the
+contents of the file into the table with a single statement.
+
+You could create a text file @file{pet.txt} containing one record per line,
+with values separated by tabs, and given in the order in which the columns
+were listed in the @code{CREATE TABLE} statement. For missing values (such
+as unknown sexes or death dates for animals that are still living), you can
+use @code{NULL} values. To represent these in your text file, use
+@code{\N}. For example, the record for Whistler the bird would look like
+this (where the whitespace between values is a single tab character):
+
+@multitable @columnfractions .15 .15 .15 .15 .25 .15
+@item @code{Whistler} @tab @code{Gwen} @tab @code{bird} @tab @code{\N} @tab @code{1997-12-09} @tab @code{\N}
+@end multitable
+
+To load the text file @file{pet.txt} into the @code{pet} table, use this
+command:
@example
-C:\> C:\mysql\bin\mysqld-max-nt --install
+mysql> LOAD DATA LOCAL INFILE "pet.txt" INTO TABLE pet;
@end example
-(Under Windows NT, you can actually install any of the server binaries
-as a service, but only those having names that end with @code{-nt.exe}
-provide support for named pipes.)
+You can specify the column value separator and end of line marker explicitly
+in the @code{LOAD DATA} statement if you wish, but the defaults are tab and
+linefeed. These are sufficient for the statement to read the file
+@file{pet.txt} properly.
-You can start and stop the @strong{MySQL} service with these commands:
+When you want to add new records one at a time, the @code{INSERT} statement
+is useful. In its simplest form, you supply values for each column, in the
+order in which the columns were listed in the @code{CREATE TABLE} statement.
+Suppose Diane gets a new hamster named Puffball. You could add a new record
+using an @code{INSERT} statement like this:
@example
-C:\> NET START mysql
-C:\> NET STOP mysql
+mysql> INSERT INTO pet
+ -> VALUES ('Puffball','Diane','hamster','f','1999-03-30',NULL);
@end example
-Note that in this case you can't use any other options for @code{mysqld-nt}!
+Note that string and date values are specified as quoted strings here. Also,
+with @code{INSERT}, you can insert @code{NULL} directly to represent a
+missing value. You do not use @code{\N} like you do with @code{LOAD DATA}.
-You can also run @code{mysqld-nt} as a stand-alone program on NT if you need
-to start @code{mysqld-nt} with any options! If you start @code{mysqld-nt}
-without options on NT, @code{mysqld-nt} tries to start itself as a service
-with the default service options. If you have stopped @code{mysqld-nt}, you
-have to start it with @code{NET START mysql}.
+From this example, you should be able to see that there would be a lot more
+typing involved to load
+your records initially using several @code{INSERT} statements rather
+than a single @code{LOAD DATA} statement.
-The service is installed with the name @code{MySQL}. Once installed, it must
-be started using the Services Control Manager (SCM) Utility found in the
-Control Panel, or by using the @code{NET START MySQL} command. If any options
-are desired, they must be specified as ``Startup parameters'' in the SCM utility
-before you start the @strong{MySQL} service. Once running, @code{mysqld-nt}
-can be stopped using @code{mysqladmin}, or from the SCM utility or by using
-the command @code{NET STOP MySQL}. If you use SCM to stop @code{mysqld-nt},
-there is a strange message from SCM about @code{mysqld shutdown normally}.
-When run as a service, @code{mysqld-nt} has no access to a console and so no
-messages can be seen.
-On NT you can get the following service error messages:
+@node Retrieving data, , Loading tables, Database use
+@subsection Retrieving Information from a Table
-@multitable @columnfractions .3 .7
-@item Permission Denied @tab Means that it cannot find @code{mysqld-nt.exe}.
-@item Cannot Register @tab Means that the path is incorrect.
-@item Failed to install service. @tab Means that the service is already installed or that the Service Control Manager is in bad state.
-@end multitable
+@cindex data, retrieving
+@cindex tables, retrieving data
+@cindex retrieving, data from tables
+@cindex unloading, tables
-If you have problems installing @code{mysqld-nt} as a service, try starting
-it with the full path:
+@menu
+* Selecting all:: Selecting all data
+* Selecting rows:: Selecting particular rows
+* Selecting columns:: Selecting particular columns
+* Sorting rows:: Sorting rows
+* Date calculations:: Date calculations
+* Working with NULL:: Working with @code{NULL} values
+* Pattern matching:: Pattern matching
+* Counting rows:: Counting rows
+* Multiple tables:: Using More Than one Table
+@end menu
+
+The @code{SELECT} statement is used to pull information from a table.
+The general form of the statement is:
@example
-C:\> C:\mysql\bin\mysqld-nt --install
+SELECT what_to_select
+FROM which_table
+WHERE conditions_to_satisfy
@end example
-If this doesn't work, you can get @code{mysqld-nt} to start properly by fixing
-the path in the registry!
+@code{what_to_select} indicates what you want to see. This can be a list of
+columns, or @code{*} to indicate ``all columns.'' @code{which_table}
+indicates the table from which you want to retrieve data. The @code{WHERE}
+clause is optional. If it's present, @code{conditions_to_satisfy} specifies
+conditions that rows must satisfy to qualify for retrieval.
-If you don't want to start @code{mysqld-nt} as a service, you can start it as
-follows:
+
+@node Selecting all, Selecting rows, Retrieving data, Retrieving data
+@subsubsection Selecting All Data
+
+The simplest form of @code{SELECT} retrieves everything from a table:
@example
-C:\> C:\mysql\bin\mysqld-nt --standalone
+mysql> SELECT * FROM pet;
++----------+--------+---------+------+------------+------------+
+| name | owner | species | sex | birth | death |
++----------+--------+---------+------+------------+------------+
+| Fluffy | Harold | cat | f | 1993-02-04 | NULL |
+| Claws | Gwen | cat | m | 1994-03-17 | NULL |
+| Buffy | Harold | dog | f | 1989-05-13 | NULL |
+| Fang | Benny | dog | m | 1990-08-27 | NULL |
+| Bowser | Diane | dog | m | 1998-08-31 | 1995-07-29 |
+| Chirpy | Gwen | bird | f | 1998-09-11 | NULL |
+| Whistler | Gwen | bird | NULL | 1997-12-09 | NULL |
+| Slim | Benny | snake | m | 1996-04-29 | NULL |
+| Puffball | Diane | hamster | f | 1999-03-30 | NULL |
++----------+--------+---------+------+------------+------------+
@end example
-or
+This form of @code{SELECT} is useful if you want to review your entire table,
+for instance, after you've just loaded it with your initial dataset. As it
+happens, the output just shown reveals an error in your data file: Bowser
+appears to have been born after he died! Consulting your original pedigree
+papers, you find that the correct birth year is 1989, not 1998.
+
+There are are least a couple of ways to fix this:
+
+@itemize @bullet
+@item
+Edit the file @file{pet.txt} to correct the error, then empty the table
+and reload it using @code{DELETE} and @code{LOAD DATA}:
@example
-C:\> C:\mysql\bin\mysqld --standalone --debug
+mysql> SET AUTOCOMMIT=1; # Used for quick re-create of the table
+mysql> DELETE FROM pet;
+mysql> LOAD DATA LOCAL INFILE "pet.txt" INTO TABLE pet;
@end example
-The last version gives you a debug trace in @file{C:\mysqld.trace}.
-@xref{Making trace files}.
+However, if you do this, you must also re-enter the record for Puffball.
-@node Windows running, Windows and SSH, NT start, Windows
-@subsection Running MySQL on Windows
+@item
+Fix only the erroneous record with an @code{UPDATE} statement:
-@cindex TCP/IP
-@cindex named pipes
+@example
+mysql> UPDATE pet SET birth = "1989-08-31" WHERE name = "Bowser";
+@end example
+@end itemize
-@strong{MySQL} supports TCP/IP on all Windows platforms and named pipes on NT.
-The default is to use named pipes for local connections on NT and TCP/IP for
-all other cases if the client has TCP/IP installed. The host name specifies
-which protocol is used:
+As shown above, it is easy to retrieve an entire table. But typically you
+don't want to do that, particularly when the table becomes large. Instead,
+you're usually more interested in answering a particular question, in which
+case you specify some constraints on the information you want. Let's look at
+some selection queries in terms of questions about your pets that they
+answer.
-@multitable @columnfractions .3 .7
-@strong{Host name} @tab @strong{Protocol}
-@item NULL (none) @tab On NT, try named pipes first; if that doesn't work, use TCP/IP. On Win95/Win98, TCP/IP is used.
-@item . @tab Named pipes
-@item localhost @tab TCP/IP to current host
-@item hostname @tab TCP/IP
-@end multitable
-You can force a @strong{MySQL} client to use named pipes by specifying the
-@code{--pipe} option or by specifying @code{.} as the host name. Use the
-@code{--socket} option to specify the name of the pipe.
+@node Selecting rows, Selecting columns, Selecting all, Retrieving data
+@subsubsection Selecting Particular Rows
-You can test whether or not @strong{MySQL} is working by executing the
-following commands:
+@cindex rows, selecting
+@cindex tables, selecting rows
+
+You can select only particular rows from your table. For example, if you want
+to verify the change that you made to Bowser's birth date, select Bowser's
+record like this:
@example
-C:\> C:\mysql\bin\mysqlshow
-C:\> C:\mysql\bin\mysqlshow -u root mysql
-C:\> C:\mysql\bin\mysqladmin version status proc
-C:\> C:\mysql\bin\mysql test
+mysql> SELECT * FROM pet WHERE name = "Bowser";
++--------+-------+---------+------+------------+------------+
+| name | owner | species | sex | birth | death |
++--------+-------+---------+------+------------+------------+
+| Bowser | Diane | dog | m | 1989-08-31 | 1995-07-29 |
++--------+-------+---------+------+------------+------------+
@end example
-If @code{mysqld} is slow to answer to connections on Win95/Win98, there is
-probably a problem with your DNS. In this case, start @code{mysqld} with
-@code{--skip-name-resolve} and use only @code{localhost} and IP numbers in
-the @strong{MySQL} grant tables. You can also avoid DNS when connecting to a
-@code{mysqld-nt} @strong{MySQL} server running on NT by using the
-@code{--pipe} argument to specify use of named pipes. This works for most
-@strong{MySQL} clients.
+The output confirms that the year is correctly recorded now as 1989, not 1998.
-There are two versions of the @strong{MySQL} command-line tool:
-@multitable @columnfractions .25 .75
-@item @code{mysql} @tab Compiled on native Windows, which offers very limited text editing capabilities.
-@item @code{mysqlc} @tab Compiled with the Cygnus GNU compiler and libraries, which offers @code{readline} editing.
-@end multitable
+String comparisons are normally case insensitive, so you can specify the
+name as @code{"bowser"}, @code{"BOWSER"}, etc. The query result will be
+the same.
-If you want to use @code{mysqlc.exe}, you must copy
-@file{C:\mysql\lib\cygwinb19.dll} to your Windows system directory
-(@file{\windows\system} or similar place).
+You can specify conditions on any column, not just @code{name}. For example,
+if you want to know which animals were born after 1998, test the @code{birth}
+column:
-The default privileges on Windows give all local users full privileges
-to all databases without specifying a password. To make @strong{MySQL}
-more secure, you should set a password for all users and remove the row in
-the @code{mysql.user} table that has @code{Host='localhost'} and
-@code{User=''}.
+@example
+mysql> SELECT * FROM pet WHERE birth >= "1998-1-1";
++----------+-------+---------+------+------------+-------+
+| name | owner | species | sex | birth | death |
++----------+-------+---------+------+------------+-------+
+| Chirpy | Gwen | bird | f | 1998-09-11 | NULL |
+| Puffball | Diane | hamster | f | 1999-03-30 | NULL |
++----------+-------+---------+------+------------+-------+
+@end example
-You should also add a password for the @code{root} user. The following
-example starts by removing the anonymous user that can be used by anyone
-to access the @code{test} database, then sets a @code{root} user password:
+You can combine conditions, for example, to locate female dogs:
@example
-C:\> C:\mysql\bin\mysql mysql
-mysql> DELETE FROM user WHERE Host='localhost' AND User='';
-mysql> QUIT
-C:\> C:\mysql\bin\mysqladmin reload
-C:\> C:\mysql\bin\mysqladmin -u root password your_password
+mysql> SELECT * FROM pet WHERE species = "dog" AND sex = "f";
++-------+--------+---------+------+------------+-------+
+| name | owner | species | sex | birth | death |
++-------+--------+---------+------+------------+-------+
+| Buffy | Harold | dog | f | 1989-05-13 | NULL |
++-------+--------+---------+------+------------+-------+
@end example
-After you've set the password, if you want to take down the @code{mysqld}
-server, you can do so using this command:
+The preceding query uses the @code{AND} logical operator. There is also an
+@code{OR} operator:
@example
-C:\> mysqladmin --user=root --password=your_password shutdown
+mysql> SELECT * FROM pet WHERE species = "snake" OR species = "bird";
++----------+-------+---------+------+------------+-------+
+| name | owner | species | sex | birth | death |
++----------+-------+---------+------+------------+-------+
+| Chirpy | Gwen | bird | f | 1998-09-11 | NULL |
+| Whistler | Gwen | bird | NULL | 1997-12-09 | NULL |
+| Slim | Benny | snake | m | 1996-04-29 | NULL |
++----------+-------+---------+------+------------+-------+
@end example
-If you are using the old shareware version of @strong{MySQL} Version
-3.21 under Windows, the above command will fail with an error:
-@code{parse error near 'SET OPTION password'}. The fix is in to upgrade
-to the current @strong{MySQL} version, which is freely available.
+@code{AND} and @code{OR} may be intermixed. If you do that, it's a good idea
+to use parentheses to indicate how conditions should be grouped:
-With the current @strong{MySQL} versions you can easily add new users
-and change privileges with @code{GRANT} and @code{REVOKE} commands.
-@xref{GRANT}.
+@example
+mysql> SELECT * FROM pet WHERE (species = "cat" AND sex = "m")
+ -> OR (species = "dog" AND sex = "f");
++-------+--------+---------+------+------------+-------+
+| name | owner | species | sex | birth | death |
++-------+--------+---------+------+------------+-------+
+| Claws | Gwen | cat | m | 1994-03-17 | NULL |
+| Buffy | Harold | dog | f | 1989-05-13 | NULL |
++-------+--------+---------+------+------------+-------+
+@end example
-@c FIX this is ugly, real ugly.
-@cindex SSH
-@cindex connecting, remotely with SSH
-@node Windows and SSH, Windows symbolic links, Windows running, Windows
-@subsection Connecting to a Remote MySQL from Windows with SSH
-Here is a note about how to connect to get a secure connection to remote
-@strong{MySQL} server with SSH (by David Carlson @email{dcarlson@@mplcomm.com}):
+@node Selecting columns, Sorting rows, Selecting rows, Retrieving data
+@subsubsection Selecting Particular Columns
-@itemize @bullet
-@item
-Install an SSH client on your Windows machine. As a user, the best non-free
-one I've found is from @code{SecureCRT} from @uref{http://www.vandyke.com/}.
-Another option is @code{f-secure} from @uref{http://www.f-secure.com/}. You
-can also find some free ones on @strong{Google} at
-@uref{http://directory.google.com/Top/Computers/Security/Products_and_Tools/Cryptography/SSH/Clients/Windows/}.
+@cindex columns, selecting
+@cindex tables, selecting columns
-@item
-Start your Windows SSH client.
-Set @code{Host_Name = yourmysqlserver_URL_or_IP}.
-Set @code{userid=your_userid} to log in to your server (probably not the same
-as your @strong{MySQL} login/password.
+If you don't want to see entire rows from your table, just name the columns
+in which you're interested, separated by commas. For example, if you want to
+know when your animals were born, select the @code{name} and @code{birth}
+columns:
-@item
-Set up port forwarding. Either do a remote forward (Set @code{local_port: 3306}, @code{remote_host: yourmysqlservername_or_ip}, @code{remote_port: 3306} )
-or a local forward (Set @code{port: 3306}, @code{host: localhost}, @code{remote port: 3306}).
+@example
+mysql> SELECT name, birth FROM pet;
++----------+------------+
+| name | birth |
++----------+------------+
+| Fluffy | 1993-02-04 |
+| Claws | 1994-03-17 |
+| Buffy | 1989-05-13 |
+| Fang | 1990-08-27 |
+| Bowser | 1989-08-31 |
+| Chirpy | 1998-09-11 |
+| Whistler | 1997-12-09 |
+| Slim | 1996-04-29 |
+| Puffball | 1999-03-30 |
++----------+------------+
+@end example
-@item
-Save everything, otherwise you'll have to redo it the next time.
+To find out who owns pets, use this query:
-@item
-Log in to your server with SSH session you just created.
+@example
+mysql> SELECT owner FROM pet;
++--------+
+| owner |
++--------+
+| Harold |
+| Gwen |
+| Harold |
+| Benny |
+| Diane |
+| Gwen |
+| Gwen |
+| Benny |
+| Diane |
++--------+
+@end example
-@item
-On your Windows machine, start some ODBC application (such as Access).
+@findex DISTINCT
+However, notice that the query simply retrieves the @code{owner} field from
+each record, and some of them appear more than once. To minimize the output,
+retrieve each unique output record just once by adding the keyword
+@code{DISTINCT}:
-@item
-Create a new file in Windows and link to @strong{MySQL} using the ODBC
-driver the same way you normally do, EXCEPT type in @code{localhost}
-for the @strong{MySQL} host server --- not @code{yourmysqlservername}.
-@end itemize
+@example
+mysql> SELECT DISTINCT owner FROM pet;
++--------+
+| owner |
++--------+
+| Benny |
+| Diane |
+| Gwen |
+| Harold |
++--------+
+@end example
-You should now have an ODBC connection to @strong{MySQL}, encrypted using SSH.
+You can use a @code{WHERE} clause to combine row selection with column
+selection. For example, to get birth dates for dogs and cats only,
+use this query:
-@cindex symbolic links
-@cindex using multiple disks to start data
-@cindex disks, splitting data across
-@node Windows symbolic links, Windows compiling, Windows and SSH, Windows
-@subsection Splitting Data Across Different Disks on Windows
+@example
+mysql> SELECT name, species, birth FROM pet
+ -> WHERE species = "dog" OR species = "cat";
++--------+---------+------------+
+| name | species | birth |
++--------+---------+------------+
+| Fluffy | cat | 1993-02-04 |
+| Claws | cat | 1994-03-17 |
+| Buffy | dog | 1989-05-13 |
+| Fang | dog | 1990-08-27 |
+| Bowser | dog | 1989-08-31 |
++--------+---------+------------+
+@end example
-Beginning with @strong{MySQL} Version 3.23.16, the @code{mysqld-max}
-and @code{mysql-max-nt} servers in the @strong{MySQL} distribution are
-compiled with the @code{-DUSE_SYMDIR} option. This allows you to put a
-database on different disk by adding a symbolic link to it
-(in a manner similar to the way that symbolic links work on Unix).
-On Windows, you make a symbolic link to a database by creating a file
-that contains the path to the destination directory and saving this in
-the @file{mysql_data} directory under the filename @file{database.sym}.
-Note that the symbolic link will be used only if the directory
-@file{mysql_data_dir\database} doesn't exist.
+@node Sorting rows, Date calculations, Selecting columns, Retrieving data
+@subsubsection Sorting Rows
-For example, if the @strong{MySQL} data directory is @file{C:\mysql\data}
-and you want to have database @code{foo} located at @file{D:\data\foo}, you
-should create the file @file{C:\mysql\data\foo.sym} that contains the
-text @code{D:\data\foo\}. After that, all tables created in the database
-@code{foo} will be created in @file{D:\data\foo}.
+@cindex rows, sorting
+@cindex sorting, table rows
+@cindex sorting, data
+@cindex tables, sorting rows
-Note that because of the speed penalty you get when opening every table,
-we have not enabled this by default even if you have compiled
-@strong{MySQL} with support for this. To enable symlinks you should put
-in your @code{my.cnf} or @code{my.ini} file the following entry:
+You may have noticed in the preceding examples that the result rows are
+displayed in no particular order. However, it's often easier to examine
+query output when the rows are sorted in some meaningful way. To sort a
+result, use an @code{ORDER BY} clause.
+
+Here are animal birthdays, sorted by date:
@example
-[mysqld]
-use-symbolic-links
+mysql> SELECT name, birth FROM pet ORDER BY birth;
++----------+------------+
+| name | birth |
++----------+------------+
+| Buffy | 1989-05-13 |
+| Bowser | 1989-08-31 |
+| Fang | 1990-08-27 |
+| Fluffy | 1993-02-04 |
+| Claws | 1994-03-17 |
+| Slim | 1996-04-29 |
+| Whistler | 1997-12-09 |
+| Chirpy | 1998-09-11 |
+| Puffball | 1999-03-30 |
++----------+------------+
@end example
-In @strong{MySQL} 4.0 we will enable symlinks by default. Then you
-should instead use the @code{skip-symlink} option if you want to
-disable this.
+To sort in reverse order, add the @code{DESC} (descending) keyword to the
+name of the column you are sorting by:
-@cindex compiling, on Windows
-@cindex Windows, compiling on
-@node Windows compiling, Windows vs Unix, Windows symbolic links, Windows
-@subsection Compiling MySQL Clients on Windows
+@example
+mysql> SELECT name, birth FROM pet ORDER BY birth DESC;
++----------+------------+
+| name | birth |
++----------+------------+
+| Puffball | 1999-03-30 |
+| Chirpy | 1998-09-11 |
+| Whistler | 1997-12-09 |
+| Slim | 1996-04-29 |
+| Claws | 1994-03-17 |
+| Fluffy | 1993-02-04 |
+| Fang | 1990-08-27 |
+| Bowser | 1989-08-31 |
+| Buffy | 1989-05-13 |
++----------+------------+
+@end example
-In your source files, you should include @file{windows.h} before you include
-@file{mysql.h}:
+You can sort on multiple columns. For example, to sort by type of
+animal, then by birth date within animal type with youngest animals first,
+use the following query:
@example
-#if defined(_WIN32) || defined(_WIN64)
-#include <windows.h>
-#endif
-#include <mysql.h>
+mysql> SELECT name, species, birth FROM pet ORDER BY species, birth DESC;
++----------+---------+------------+
+| name | species | birth |
++----------+---------+------------+
+| Chirpy | bird | 1998-09-11 |
+| Whistler | bird | 1997-12-09 |
+| Claws | cat | 1994-03-17 |
+| Fluffy | cat | 1993-02-04 |
+| Fang | dog | 1990-08-27 |
+| Bowser | dog | 1989-08-31 |
+| Buffy | dog | 1989-05-13 |
+| Puffball | hamster | 1999-03-30 |
+| Slim | snake | 1996-04-29 |
++----------+---------+------------+
@end example
-You can either link your code with the dynamic @file{libmysql.lib} library,
-which is just a wrapper to load in @file{libmysql.dll} on demand, or link
-with the static @file{mysqlclient.lib} library.
+Note that the @code{DESC} keyword applies only to the column name immediately
+preceding it (@code{birth}); @code{species} values are still sorted in
+ascending order.
-Note that as the mysqlclient libraries are compiled as threaded libraries,
-you should also compile your code to be multi-threaded!
-@cindex Windows, versus Unix
-@cindex operating systems, Windows versus Unix
-@node Windows vs Unix, , Windows compiling, Windows
-@subsection MySQL-Windows Compared to Unix MySQL
+@node Date calculations, Working with NULL, Sorting rows, Retrieving data
+@subsubsection Date Calculations
-@strong{MySQL}-Windows has by now proven itself to be very stable. This version
-of @strong{MySQL} has the same features as the corresponding Unix version
-with the following exceptions:
+@cindex date calculations
+@cindex calculating, dates
+@cindex extracting, dates
+@cindex age, calculating
-@table @strong
-@item Win95 and threads
-Win95 leaks about 200 bytes of main memory for each thread creation.
-Each connection in @strong{MySQL} creates a new thread, so you shouldn't
-run @code{mysqld} for an extended time on Win95 if your server handles
-many connections! WinNT and Win98 don't suffer from this bug.
+MySQL provides several functions that you can use to perform
+calculations on dates, for example, to calculate ages or extract
+parts of dates.
-@item Concurrent reads
-@strong{MySQL} depends on the @code{pread()} and @code{pwrite()} calls to be
-able to mix @code{INSERT} and @code{SELECT}. Currently we use mutexes
-to emulate @code{pread()}/@code{pwrite()}. We will, in the long run,
-replace the file level interface with a virtual interface so that we can
-use the @code{readfile()}/@code{writefile()} interface on NT to get more speed.
-The current implementation limits the number of open files @strong{MySQL}
-can use to 1024, which means that you will not be able to run as many
-concurrent threads on NT as on Unix.
+To determine how many years old each of your pets is, compute the
+difference in the year part of the current date and the birth date, then
+subtract one if the current date occurs earlier in the calendar year than
+the birth date. The following query shows, for each pet, the birth date,
+the current date, and the age in years.
+
+@example
+mysql> SELECT name, birth, CURRENT_DATE,
+ -> (YEAR(CURRENT_DATE)-YEAR(birth))
+ -> - (RIGHT(CURRENT_DATE,5)<RIGHT(birth,5))
+ -> AS age
+ -> FROM pet;
++----------+------------+--------------+------+
+| name | birth | CURRENT_DATE | age |
++----------+------------+--------------+------+
+| Fluffy | 1993-02-04 | 2001-08-29 | 8 |
+| Claws | 1994-03-17 | 2001-08-29 | 7 |
+| Buffy | 1989-05-13 | 2001-08-29 | 12 |
+| Fang | 1990-08-27 | 2001-08-29 | 11 |
+| Bowser | 1989-08-31 | 2001-08-29 | 11 |
+| Chirpy | 1998-09-11 | 2001-08-29 | 2 |
+| Whistler | 1997-12-09 | 2001-08-29 | 3 |
+| Slim | 1996-04-29 | 2001-08-29 | 5 |
+| Puffball | 1999-03-30 | 2001-08-29 | 2 |
++----------+------------+--------------+------+
+@end example
+
+Here, @code{YEAR()} pulls out the year part of a date and @code{RIGHT()}
+pulls off the rightmost five characters that represent the @code{MM-DD}
+(calendar year) part of the date. The part of the expression that
+compares the @code{MM-DD} values evaluates to 1 or 0, which adjusts the
+year difference down a year if @code{CURRENT_DATE} occurs earlier in
+the year than @code{birth}. The full expression is somewhat ungainly,
+so an alias (@code{age}) is used to make the output column label more
+meaningful.
-@item Blocking read
-@strong{MySQL} uses a blocking read for each connection.
-This means that:
+The query works, but the result could be scanned more easily if the rows
+were presented in some order. This can be done by adding an @code{ORDER
+BY name} clause to sort the output by name:
-@itemize @bullet
-@item
-A connection will not be disconnected automatically after 8 hours, as happens
-with the Unix version of @strong{MySQL}.
+@example
+mysql> SELECT name, birth, CURRENT_DATE,
+ -> (YEAR(CURRENT_DATE)-YEAR(birth))
+ -> - (RIGHT(CURRENT_DATE,5)<RIGHT(birth,5))
+ -> AS age
+ -> FROM pet ORDER BY name;
++----------+------------+--------------+------+
+| name | birth | CURRENT_DATE | age |
++----------+------------+--------------+------+
+| Bowser | 1989-08-31 | 2001-08-29 | 11 |
+| Buffy | 1989-05-13 | 2001-08-29 | 12 |
+| Chirpy | 1998-09-11 | 2001-08-29 | 2 |
+| Claws | 1994-03-17 | 2001-08-29 | 7 |
+| Fang | 1990-08-27 | 2001-08-29 | 11 |
+| Fluffy | 1993-02-04 | 2001-08-29 | 8 |
+| Puffball | 1999-03-30 | 2001-08-29 | 2 |
+| Slim | 1996-04-29 | 2001-08-29 | 5 |
+| Whistler | 1997-12-09 | 2001-08-29 | 3 |
++----------+------------+--------------+------+
+@end example
-@item
-If a connection hangs, it's impossible to break it without killing
-@strong{MySQL}.
+To sort the output by @code{age} rather than @code{name}, just use a
+different @code{ORDER BY} clause:
-@item
-@code{mysqladmin kill} will not work on a sleeping connection.
+@example
+mysql> SELECT name, birth, CURRENT_DATE,
+ -> (YEAR(CURRENT_DATE)-YEAR(birth))
+ -> - (RIGHT(CURRENT_DATE,5)<RIGHT(birth,5))
+ -> AS age
+ -> FROM pet ORDER BY age;
++----------+------------+--------------+------+
+| name | birth | CURRENT_DATE | age |
++----------+------------+--------------+------+
+| Chirpy | 1998-09-11 | 2001-08-29 | 2 |
+| Puffball | 1999-03-30 | 2001-08-29 | 2 |
+| Whistler | 1997-12-09 | 2001-08-29 | 3 |
+| Slim | 1996-04-29 | 2001-08-29 | 5 |
+| Claws | 1994-03-17 | 2001-08-29 | 7 |
+| Fluffy | 1993-02-04 | 2001-08-29 | 8 |
+| Fang | 1990-08-27 | 2001-08-29 | 11 |
+| Bowser | 1989-08-31 | 2001-08-29 | 11 |
+| Buffy | 1989-05-13 | 2001-08-29 | 12 |
++----------+------------+--------------+------+
+@end example
-@item
-@code{mysqladmin shutdown} can't abort as long as there are sleeping
-connections.
-@end itemize
+A similar query can be used to determine age at death for animals that have
+died. You determine which animals these are by checking whether or not the
+@code{death} value is @code{NULL}. Then, for those with non-@code{NULL}
+values, compute the difference between the @code{death} and @code{birth}
+values:
-We plan to fix this problem when our Windows developers have figured out a
-nice workaround.
+@example
+mysql> SELECT name, birth, death,
+ -> (YEAR(death)-YEAR(birth)) - (RIGHT(death,5)<RIGHT(birth,5))
+ -> AS age
+ -> FROM pet WHERE death IS NOT NULL ORDER BY age;
++--------+------------+------------+------+
+| name | birth | death | age |
++--------+------------+------------+------+
+| Bowser | 1989-08-31 | 1995-07-29 | 5 |
++--------+------------+------------+------+
+@end example
-@item UDF functions
-For the moment, @strong{MySQL}-Windows does not support user-definable
-functions.
+The query uses @code{death IS NOT NULL} rather than @code{death != NULL}
+because @code{NULL} is a special value. This is explained later.
+@xref{Working with NULL, , Working with @code{NULL}}.
-@item @code{DROP DATABASE}
-You can't drop a database that is in use by some thread.
+What if you want to know which animals have birthdays next month? For this
+type of calculation, year and day are irrelevant; you simply want to extract
+the month part of the @code{birth} column. MySQL provides several
+date-part extraction functions, such as @code{YEAR()}, @code{MONTH()}, and
+@code{DAYOFMONTH()}. @code{MONTH()} is the appropriate function here. To
+see how it works, run a simple query that displays the value of both
+@code{birth} and @code{MONTH(birth)}:
-@item Killing @strong{MySQL} from the task manager
-You can't kill @strong{MySQL} from the task manager or with the shutdown
-utility in Win95. You must take it down with @code{mysqladmin shutdown}.
+@example
+mysql> SELECT name, birth, MONTH(birth) FROM pet;
++----------+------------+--------------+
+| name | birth | MONTH(birth) |
++----------+------------+--------------+
+| Fluffy | 1993-02-04 | 2 |
+| Claws | 1994-03-17 | 3 |
+| Buffy | 1989-05-13 | 5 |
+| Fang | 1990-08-27 | 8 |
+| Bowser | 1989-08-31 | 8 |
+| Chirpy | 1998-09-11 | 9 |
+| Whistler | 1997-12-09 | 12 |
+| Slim | 1996-04-29 | 4 |
+| Puffball | 1999-03-30 | 3 |
++----------+------------+--------------+
+@end example
-@item Case-insensitive names
-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 specified using the same
-case throughout a given statement. @xref{Name case sensitivity}.
+Finding animals with birthdays in the upcoming month is easy, too. Suppose
+the current month is April. Then the month value is @code{4} and you look
+for animals born in May (month 5) like this:
-@item The @samp{\} directory character
-Pathname components in Win95 are separated by the @samp{\} character, which is
-also the escape character in @strong{MySQL}. If you are using @code{LOAD
-DATA INFILE} or @code{SELECT ... INTO OUTFILE}, you must double the @samp{\}
-character:
+@example
+mysql> SELECT name, birth FROM pet WHERE MONTH(birth) = 5;
++-------+------------+
+| name | birth |
++-------+------------+
+| Buffy | 1989-05-13 |
++-------+------------+
+@end example
+
+There is a small complication if the current month is December, of course.
+You don't just add one to the month number (@code{12}) and look for animals
+born in month 13, because there is no such month. Instead, you look for
+animals born in January (month 1).
+
+You can even write the query so that it works no matter what the current
+month is. That way you don't have to use a particular month number
+in the query. @code{DATE_ADD()} allows you to add a time interval to a
+given date. If you add a month to the value of @code{NOW()}, then extract
+the month part with @code{MONTH()}, the result produces the month in which to
+look for birthdays:
@example
-mysql> LOAD DATA INFILE "C:\\tmp\\skr.txt" INTO TABLE skr;
-mysql> SELECT * INTO OUTFILE 'C:\\tmp\\skr.txt' FROM skr;
+mysql> SELECT name, birth FROM pet
+ -> WHERE MONTH(birth) = MONTH(DATE_ADD(NOW(), INTERVAL 1 MONTH));
@end example
-Alternatively, use Unix style filenames with @samp{/} characters:
+A different way to accomplish the same task is to add @code{1} to get the
+next month after the current one (after using the modulo function (@code{MOD})
+to wrap around the month value to @code{0} if it is currently
+@code{12}):
@example
-mysql> LOAD DATA INFILE "C:/tmp/skr.txt" INTO TABLE skr;
-mysql> SELECT * INTO OUTFILE 'C:/tmp/skr.txt' FROM skr;
+mysql> SELECT name, birth FROM pet
+ -> WHERE MONTH(birth) = MOD(MONTH(NOW()), 12) + 1;
@end example
-@item @code{Can't open named pipe} error
-If you use a @strong{MySQL} 3.22 version on NT with the newest mysql-clients
-you will get the following error:
+Note that @code{MONTH} returns a number between 1 and 12. And
+@code{MOD(something,12)} returns a number between 0 and 11. So the
+addition has to be after the @code{MOD()}, otherwise we would go from
+November (11) to January (1).
+
+
+@node Working with NULL, Pattern matching, Date calculations, Retrieving data
+@subsubsection Working with @code{NULL} Values
+
+@findex NULL
+@cindex NULL value
+
+The @code{NULL} value can be surprising until you get used to it.
+Conceptually, @code{NULL} means missing value or unknown value and it
+is treated somewhat differently than other values. To test for @code{NULL},
+you cannot use the arithmetic comparison operators such as @code{=}, @code{<},
+or @code{!=}. To demonstrate this for yourself, try the following query:
@example
-error 2017: can't open named pipe to host: . pipe...
+mysql> SELECT 1 = NULL, 1 != NULL, 1 < NULL, 1 > NULL;
++----------+-----------+----------+----------+
+| 1 = NULL | 1 != NULL | 1 < NULL | 1 > NULL |
++----------+-----------+----------+----------+
+| NULL | NULL | NULL | NULL |
++----------+-----------+----------+----------+
@end example
-@tindex .my.cnf file
-This is because the release version of @strong{MySQL} uses named pipes on NT
-by default. You can avoid this error by using the @code{--host=localhost}
-option to the new @strong{MySQL} clients or create an option file
-@file{C:\my.cnf} that contains the following information:
+Clearly you get no meaningful results from these comparisons. Use
+the @code{IS NULL} and @code{IS NOT NULL} operators instead:
@example
-[client]
-host = localhost
+mysql> SELECT 1 IS NULL, 1 IS NOT NULL;
++-----------+---------------+
+| 1 IS NULL | 1 IS NOT NULL |
++-----------+---------------+
+| 0 | 1 |
++-----------+---------------+
@end example
-@item @code{Access denied for user} error
-If you get the error @code{Access denied for user: 'some-user@@unknown'
-to database 'mysql'} when accessing a @strong{MySQL} server on the same
-machine, this means that @strong{MySQL} can't resolve your host name
-properly.
+In MySQL, 0 or @code{NULL} means false and anything else means true.
+The default truth value from a boolean operation is 1.
-To fix this, you should create a file @file{\windows\hosts} with the
-following information:
+This special treatment of @code{NULL} is why, in the previous section, it
+was necessary to determine which animals are no longer alive using
+@code{death IS NOT NULL} instead of @code{death != NULL}.
+
+
+@node Pattern matching, Counting rows, Working with NULL, Retrieving data
+@subsubsection Pattern Matching
+
+@cindex pattern matching
+@cindex matching, patterns
+@cindex expressions, extended
+
+MySQL provides standard SQL pattern matching as well as a form of
+pattern matching based on extended regular expressions similar to those used
+by Unix utilities such as @code{vi}, @code{grep}, and @code{sed}.
+
+SQL pattern matching allows you to use @samp{_} to match any single
+character and @samp{%} to match an arbitrary number of characters (including
+zero characters). In MySQL, SQL patterns are case insensitive by
+default. Some examples are shown below. Note that you do not use @code{=}
+or @code{!=} when you use SQL patterns; use the @code{LIKE} or @code{NOT
+LIKE} comparison operators instead.
+
+To find names beginning with @samp{b}:
@example
-127.0.0.1 localhost
+mysql> SELECT * FROM pet WHERE name LIKE "b%";
++--------+--------+---------+------+------------+------------+
+| name | owner | species | sex | birth | death |
++--------+--------+---------+------+------------+------------+
+| Buffy | Harold | dog | f | 1989-05-13 | NULL |
+| Bowser | Diane | dog | m | 1989-08-31 | 1995-07-29 |
++--------+--------+---------+------+------------+------------+
@end example
-@item @code{ALTER TABLE}
-While you are executing an @code{ALTER TABLE} statement, the table is locked
-from usage by other threads. This has to do with the fact that on Windows,
-you can't delete a file that is in use by another threads. (In the future,
-we may find some way to work around this problem.)
-
-@item @code{DROP TABLE} on a table that is in use by a @code{MERGE} table will not work
-The @code{MERGE} handler does its table mapping hidden from @strong{MySQL}.
-Because Windows doesn't allow you to drop files that are open, you first
-must flush all @code{MERGE} tables (with @code{FLUSH TABLES}) or drop the
-@code{MERGE} table before dropping the table. We will fix this at the same
-time we introduce @code{VIEW}s.
-@end table
+To find names ending with @samp{fy}:
-Here are some open issues for anyone who might want to help us with the Windows
-release:
+@example
+mysql> SELECT * FROM pet WHERE name LIKE "%fy";
++--------+--------+---------+------+------------+-------+
+| name | owner | species | sex | birth | death |
++--------+--------+---------+------+------------+-------+
+| Fluffy | Harold | cat | f | 1993-02-04 | NULL |
+| Buffy | Harold | dog | f | 1989-05-13 | NULL |
++--------+--------+---------+------+------------+-------+
+@end example
-@cindex Windows, open issues
+To find names containing a @samp{w}:
-@itemize @bullet
-@item
-Make a single-user @code{MYSQL.DLL} server. This should include everything in
-a standard @strong{MySQL} server, except thread creation. This will make
-@strong{MySQL} much easier to use in applications that don't need a true
-client/server and don't need to access the server from other hosts.
+@example
+mysql> SELECT * FROM pet WHERE name LIKE "%w%";
++----------+-------+---------+------+------------+------------+
+| name | owner | species | sex | birth | death |
++----------+-------+---------+------+------------+------------+
+| Claws | Gwen | cat | m | 1994-03-17 | NULL |
+| Bowser | Diane | dog | m | 1989-08-31 | 1995-07-29 |
+| Whistler | Gwen | bird | NULL | 1997-12-09 | NULL |
++----------+-------+---------+------+------------+------------+
+@end example
-@item
-Add some nice start and shutdown icons to the @strong{MySQL} installation.
+To find names containing exactly five characters, use the @samp{_} pattern
+character:
-@item
-Create a tool to manage registry entries for the @strong{MySQL} startup
-options. The registry entry reading is already coded into @file{mysqld.cc},
-but it should be recoded to be more parameter oriented. The tool should
-also be able to update the @file{C:\my.cnf} option file if the user prefers
-to use that instead of the registry.
+@example
+mysql> SELECT * FROM pet WHERE name LIKE "_____";
++-------+--------+---------+------+------------+-------+
+| name | owner | species | sex | birth | death |
++-------+--------+---------+------+------------+-------+
+| Claws | Gwen | cat | m | 1994-03-17 | NULL |
+| Buffy | Harold | dog | f | 1989-05-13 | NULL |
++-------+--------+---------+------+------------+-------+
+@end example
-@item
-When registering @code{mysqld} as a service with @code{--install} (on NT)
-it would be nice if you could also add default options on the command line.
-For the moment, the workaround is to list the parameters in the
-@file{C:\my.cnf} file instead.
+The other type of pattern matching provided by MySQL uses extended
+regular expressions. When you test for a match for this type of pattern, use
+the @code{REGEXP} and @code{NOT REGEXP} operators (or @code{RLIKE} and
+@code{NOT RLIKE}, which are synonyms).
-@item
-It would be real nice to be able to kill @code{mysqld} from the task manager.
-For the moment, you must use @code{mysqladmin shutdown}.
+Some characteristics of extended regular expressions are:
+@itemize @bullet
@item
-Port @code{readline} to Windows for use in the @code{mysql} command line tool.
+@samp{.} matches any single character.
@item
-GUI versions of the standard @strong{MySQL} clients (@code{mysql},
-@code{mysqlshow}, @code{mysqladmin}, and @code{mysqldump}) would be nice.
+A character class @samp{[...]} matches any character within the brackets.
+For example, @samp{[abc]} matches @samp{a}, @samp{b}, or @samp{c}. To name a
+range of characters, use a dash. @samp{[a-z]} matches any lowercase letter,
+whereas @samp{[0-9]} matches any digit.
@item
-It would be nice if the socket read and write functions in @file{net.c} were
-interruptible. This would make it possible to kill open threads with
-@code{mysqladmin kill} on Windows.
+@samp{*} matches zero or more instances of the thing preceding it. For
+example, @samp{x*} matches any number of @samp{x} characters,
+@samp{[0-9]*} matches any number of digits, and @samp{.*} matches any
+number of anything.
@item
-@code{mysqld} always starts in the "C" locale and not in the default locale.
-We would like to have @code{mysqld} use the current locale for the sort order.
+Regular expressions are case sensitive, but you can use a character class to
+match both lettercases if you wish. For example, @samp{[aA]} matches
+lowercase or uppercase @samp{a} and @samp{[a-zA-Z]} matches any letter in
+either case.
@item
-Implement UDF functions with @code{.DLL}s.
+The pattern matches if it occurs anywhere in the value being tested.
+(SQL patterns match only if they match the entire value.)
@item
-Add macros to use the faster thread-safe increment/decrement methods
-provided by Windows.
-
+To anchor a pattern so that it must match the beginning or end of the value
+being tested, use @samp{^} at the beginning or @samp{$} at the end of the
+pattern.
@end itemize
-Other Windows-specific issues are described in the @file{README} file that
-comes with the @strong{MySQL}-Windows distribution.
-
-@node OS/2, MySQL binaries, Windows, Installing
-@section OS/2 Notes
+To demonstrate how extended regular expressions work, the @code{LIKE} queries
+shown above are rewritten below to use @code{REGEXP}.
-@strong{MySQL} uses quite a few open files. Because of this, you should add
-something like the following to your @file{CONFIG.SYS} file:
+To find names beginning with @samp{b}, use @samp{^} to match the beginning of
+the name:
@example
-SET EMXOPT=-c -n -h1024
+mysql> SELECT * FROM pet WHERE name REGEXP "^b";
++--------+--------+---------+------+------------+------------+
+| name | owner | species | sex | birth | death |
++--------+--------+---------+------+------------+------------+
+| Buffy | Harold | dog | f | 1989-05-13 | NULL |
+| Bowser | Diane | dog | m | 1989-08-31 | 1995-07-29 |
++--------+--------+---------+------+------------+------------+
@end example
-If you don't do this, you will probably run into the following error:
+Prior to MySQL Version 3.23.4, @code{REGEXP} is case sensitive,
+and the previous query will return no rows. To match either lowercase or
+uppercase @samp{b}, use this query instead:
@example
-File 'xxxx' not found (Errcode: 24)
+mysql> SELECT * FROM pet WHERE name REGEXP "^[bB]";
@end example
-When using @strong{MySQL} with OS/2 Warp 3, FixPack 29 or above is
-required. With OS/2 Warp 4, FixPack 4 or above is required. This is a
-requirement of the Pthreads library. @strong{MySQL} must be installed
-in a partition that supports long filenames such as HPFS, FAT32, etc.
-
-The @file{INSTALL.CMD} script must be run from OS/2's own @file{CMD.EXE}
-and may not work with replacement shells such as @file{4OS2.EXE}.
+From MySQL 3.23.4 on, to force a @code{REGEXP} comparison to
+be case sensitive, use the @code{BINARY} keyword to make one of the
+strings a binary string. This query will match only lowercase @samp{b}
+at the beginning of a name:
-The @file{scripts/mysql-install-db} script has been renamed. It is now called
-@file{install.cmd} and is a REXX script, which will set up the default
-@strong{MySQL} security settings and create the WorkPlace Shell icons
-for @strong{MySQL}.
+@example
+mysql> SELECT * FROM pet WHERE name REGEXP BINARY "^b";
+@end example
-Dynamic module support is compiled in but not fully tested. Dynamic
-modules should be compiled using the Pthreads run-time library.
+To find names ending with @samp{fy}, use @samp{$} to match the end of the
+name:
@example
-gcc -Zdll -Zmt -Zcrtdll=pthrdrtl -I../include -I../regex -I.. \
- -o example udf_example.cc -L../lib -lmysqlclient udf_example.def
-mv example.dll example.udf
+mysql> SELECT * FROM pet WHERE name REGEXP "fy$";
++--------+--------+---------+------+------------+-------+
+| name | owner | species | sex | birth | death |
++--------+--------+---------+------+------------+-------+
+| Fluffy | Harold | cat | f | 1993-02-04 | NULL |
+| Buffy | Harold | dog | f | 1989-05-13 | NULL |
++--------+--------+---------+------+------------+-------+
@end example
-@strong{Note:} Due to limitations in OS/2, UDF module name stems must not
-exceed 8 characters. Modules are stored in the @file{/mysql2/udf}
-directory; the @code{safe-mysqld.cmd} script will put this directory in
-the @code{BEGINLIBPATH} environment variable. When using UDF modules,
-specified extensions are ignored --- it is assumed to be @file{.udf}.
-For example, in Unix, the shared module might be named @file{example.so}
-and you would load a function from it like this:
+To find names containing a lowercase or uppercase @samp{w}, use this query:
@example
-mysql> CREATE FUNCTION metaphon RETURNS STRING SONAME "example.so";
+mysql> SELECT * FROM pet WHERE name REGEXP "w";
++----------+-------+---------+------+------------+------------+
+| name | owner | species | sex | birth | death |
++----------+-------+---------+------+------------+------------+
+| Claws | Gwen | cat | m | 1994-03-17 | NULL |
+| Bowser | Diane | dog | m | 1989-08-31 | 1995-07-29 |
+| Whistler | Gwen | bird | NULL | 1997-12-09 | NULL |
++----------+-------+---------+------+------------+------------+
@end example
-Is OS/2, the module would be named @file{example.udf}, but you would not
-specify the module extension:
+Because a regular expression pattern matches if it occurs anywhere in the
+value, it is not necessary in the previous query to put a wild card on either
+side of the pattern to get it to match the entire value like it would be if
+you used a SQL pattern.
+
+To find names containing exactly five characters, use @samp{^} and @samp{$}
+to match the beginning and end of the name, and five instances of @samp{.}
+in between:
@example
-mysql> CREATE FUNCTION metaphon RETURNS STRING SONAME "example";
+mysql> SELECT * FROM pet WHERE name REGEXP "^.....$";
++-------+--------+---------+------+------------+-------+
+| name | owner | species | sex | birth | death |
++-------+--------+---------+------+------------+-------+
+| Claws | Gwen | cat | m | 1994-03-17 | NULL |
+| Buffy | Harold | dog | f | 1989-05-13 | NULL |
++-------+--------+---------+------+------------+-------+
@end example
-@cindex binary distributions
-@node MySQL binaries, Post-installation, OS/2, Installing
-@section MySQL Binaries
+You could also write the previous query using the @samp{@{n@}}
+``repeat-@code{n}-times'' operator:
-As a service, we at @strong{MySQL AB} provide a set of binary distributions
-of @strong{MySQL} that are compiled at our site or at sites where customers
-kindly have given us access to their machines.
+@example
+mysql> SELECT * FROM pet WHERE name REGEXP "^.@{5@}$";
++-------+--------+---------+------+------------+-------+
+| name | owner | species | sex | birth | death |
++-------+--------+---------+------+------------+-------+
+| Claws | Gwen | cat | m | 1994-03-17 | NULL |
+| Buffy | Harold | dog | f | 1989-05-13 | NULL |
++-------+--------+---------+------+------------+-------+
+@end example
-These distributions are generated with @code{scripts/make_binary_distribution}
-and are configured with the following compilers and options:
-@table @asis
-@item SunOS 4.1.4 2 sun4c with @code{gcc} 2.7.2.1
-@code{CC=gcc CXX=gcc CXXFLAGS="-O3 -felide-constructors" ./configure --prefix=/usr/local/mysql --disable-shared --with-extra-charsets=complex --enable-assembler}
+@node Counting rows, Multiple tables, Pattern matching, Retrieving data
+@subsubsection Counting Rows
-@item SunOS 5.5.1 (and above) sun4u with @code{egcs} 1.0.3a or 2.90.27 or gcc 2.95.2 and newer
-@code{CC=gcc CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --with-low-memory --with-extra-charsets=complex --enable-assembler}
+@cindex rows, counting
+@cindex tables, counting rows
+@cindex counting, table rows
-@item SunOS 5.6 i86pc with @code{gcc} 2.8.1
-@code{CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql --with-low-memory --with-extra-charsets=complex}
+Databases are often used to answer the question, ``How often does a certain
+type of data occur in a table?'' For example, you might want to know how
+many pets you have, or how many pets each owner has, or you might want to
+perform various kinds of censuses on your animals.
-@item Linux 2.0.33 i386 with @code{pgcc} 2.90.29 (@code{egcs} 1.0.3a)
-@code{CFLAGS="-O3 -mpentium -mstack-align-double" CXX=gcc CXXFLAGS="-O3 -mpentium -mstack-align-double -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --enable-assembler --with-mysqld-ldflags=-all-static --with-extra-charsets=complex}
+Counting the total number of animals you have is the same question as ``How
+many rows are in the @code{pet} table?'' because there is one record per pet.
+The @code{COUNT()} function counts the number of non-@code{NULL} results, so
+the query to count your animals looks like this:
-@item Linux 2.2.x with x686 with @code{gcc} 2.95.2
-@code{CFLAGS="-O3 -mpentiumpro" CXX=gcc CXXFLAGS="-O3 -mpentiumpro -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --enable-assembler --with-mysqld-ldflags=-all-static --disable-shared --with-extra-charset=complex}
+@example
+mysql> SELECT COUNT(*) FROM pet;
++----------+
+| COUNT(*) |
++----------+
+| 9 |
++----------+
+@end example
-@item SCO 3.2v5.0.4 i386 with @code{gcc} 2.7-95q4
-@code{CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql --with-extra-charsets=complex}
+Earlier, you retrieved the names of the people who owned pets. You can
+use @code{COUNT()} if you want to find out how many pets each owner has:
-@item AIX 2 4 with @code{gcc} 2.7.2.2
-@code{CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql --with-extra-charsets=complex}
+@example
+mysql> SELECT owner, COUNT(*) FROM pet GROUP BY owner;
++--------+----------+
+| owner | COUNT(*) |
++--------+----------+
+| Benny | 2 |
+| Diane | 2 |
+| Gwen | 3 |
+| Harold | 2 |
++--------+----------+
+@end example
-@item OSF1 V4.0 564 alpha with @code{gcc} 2.8.1
-@code{CC=gcc CFLAGS=-O CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql --with-low-memory --with-extra-charsets=complex}
+Note the use of @code{GROUP BY} to group together all records for each
+@code{owner}. Without it, all you get is an error message:
-@item Irix 6.3 IP32 with @code{gcc} 2.8.0
-@code{CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql --with-extra-charsets=complex}
+@example
+mysql> SELECT owner, COUNT(owner) FROM pet;
+ERROR 1140 at line 1: Mixing of GROUP columns (MIN(),MAX(),COUNT()...)
+with no GROUP columns is illegal if there is no GROUP BY clause
+@end example
-@item BSDI BSD/OS 3.1 i386 with @code{gcc} 2.7.2.1
-@code{CC=gcc CXX=gcc CXXFLAGS=-O ./configure --prefix=/usr/local/mysql --with-extra-charsets=complex}
+@code{COUNT()} and @code{GROUP BY} are useful for characterizing your
+data in various ways. The following examples show different ways to
+perform animal census operations.
-@item BSDI BSD/OS 2.1 i386 with @code{gcc} 2.7.2
-@code{CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql --with-extra-charsets=complex}
-@end table
+Number of animals per species:
-Anyone who has more optimal options for any of the configurations listed
-above can always mail them to the developer's mailing list at
-@email{internals@@lists.mysql.com}.
+@example
+mysql> SELECT species, COUNT(*) FROM pet GROUP BY species;
++---------+----------+
+| species | COUNT(*) |
++---------+----------+
+| bird | 2 |
+| cat | 2 |
+| dog | 3 |
+| hamster | 1 |
+| snake | 1 |
++---------+----------+
+@end example
-RPM distributions prior to @strong{MySQL} Version 3.22 are user-contributed.
-Beginning with Version 3.22, the RPMs are generated by us at
-@strong{MySQL AB}.
+Number of animals per sex:
-If you want to compile a debug version of @strong{MySQL}, you should add
-@code{--with-debug} or @code{--with-debug=full} to the above configure lines
-and remove any @code{-fomit-frame-pointer} options.
+@example
+mysql> SELECT sex, COUNT(*) FROM pet GROUP BY sex;
++------+----------+
+| sex | COUNT(*) |
++------+----------+
+| NULL | 1 |
+| f | 4 |
+| m | 4 |
++------+----------+
+@end example
-@cindex post-installation, setup and testing
-@cindex testing, post-installation
-@cindex setup, post-installation
-@node Post-installation, Installing many servers, MySQL binaries, Installing
-@section Post-installation Setup and Testing
+(In this output, @code{NULL} indicates sex unknown.)
-@menu
-* mysql_install_db:: Problems running @code{mysql_install_db}
-* Starting server:: Problems starting the @strong{MySQL} server
-* Automatic start:: Starting and stopping @strong{MySQL} automatically
-* Command-line options:: Command-line options
-* Option files:: Option files
-@end menu
+Number of animals per combination of species and sex:
-Once you've installed @strong{MySQL} (from either a binary or source
-distribution), you need to initialize the grant tables, start the server,
-and make sure that the server works okay. You may also wish to arrange
-for the server to be started and stopped automatically when your system
-starts up and shuts down.
+@example
+mysql> SELECT species, sex, COUNT(*) FROM pet GROUP BY species, sex;
++---------+------+----------+
+| species | sex | COUNT(*) |
++---------+------+----------+
+| bird | NULL | 1 |
+| bird | f | 1 |
+| cat | f | 1 |
+| cat | m | 1 |
+| dog | f | 1 |
+| dog | m | 2 |
+| hamster | f | 1 |
+| snake | m | 1 |
++---------+------+----------+
+@end example
-Normally you install the grant tables and start the server like this
-for installation from a source distribution:
-@cindex starting, the server
-@cindex server, starting
+You need not retrieve an entire table when you use @code{COUNT()}. For
+example, the previous query, when performed just on dogs and cats, looks like
+this:
@example
-shell> ./scripts/mysql_install_db
-shell> cd mysql_installation_directory
-shell> ./bin/safe_mysqld --user=mysql &
+mysql> SELECT species, sex, COUNT(*) FROM pet
+ -> WHERE species = "dog" OR species = "cat"
+ -> GROUP BY species, sex;
++---------+------+----------+
+| species | sex | COUNT(*) |
++---------+------+----------+
+| cat | f | 1 |
+| cat | m | 1 |
+| dog | f | 1 |
+| dog | m | 2 |
++---------+------+----------+
@end example
-For a binary distribution (not RPM or pkg packages), do this:
+Or, if you wanted the number of animals per sex only for known-sex animals:
@example
-shell> cd mysql_installation_directory
-shell> ./bin/mysql_install_db
-shell> ./bin/safe_mysqld --user=mysql &
+mysql> SELECT species, sex, COUNT(*) FROM pet
+ -> WHERE sex IS NOT NULL
+ -> GROUP BY species, sex;
++---------+------+----------+
+| species | sex | COUNT(*) |
++---------+------+----------+
+| bird | f | 1 |
+| cat | f | 1 |
+| cat | m | 1 |
+| dog | f | 1 |
+| dog | m | 2 |
+| hamster | f | 1 |
+| snake | m | 1 |
++---------+------+----------+
@end example
-This creates the @code{mysql} database which will hold all database
-privileges, the @code{test} database which you can use to test
-@strong{MySQL} and also privilege entries for the user that run
-@code{mysql_install_db} and a @code{root} user (without any passwords).
-This also starts the @code{mysqld} server.
-@code{mysql_install_db} will not overwrite any old privilege tables, so
-it should be safe to run in any circumstances. If you don't want to
-have the @code{test} database you can remove it with @code{mysqladmin -u
-root drop test}.
+@node Multiple tables, , Counting rows, Retrieving data
+@subsubsection Using More Than one Table
-Testing is most easily done from the top-level directory of the @strong{MySQL}
-distribution. For a binary distribution, this is your installation directory
-(typically something like @file{/usr/local/mysql}). For a source
-distribution, this is the main directory of your @strong{MySQL} source tree.
-@cindex testing, the server
+@cindex tables, multiple
-In the commands shown below in this section and in the following
-subsections, @code{BINDIR} is the path to the location in which programs
-like @code{mysqladmin} and @code{safe_mysqld} are installed. For a
-binary distribution, this is the @file{bin} directory within the
-distribution. For a source distribution, @code{BINDIR} is probably
-@file{/usr/local/bin}, unless you specified an installation directory
-other than @file{/usr/local} when you ran @code{configure}.
-@code{EXECDIR} is the location in which the @code{mysqld} server is
-installed. For a binary distribution, this is the same as
-@code{BINDIR}. For a source distribution, @code{EXECDIR} is probably
-@file{/usr/local/libexec}.
+The @code{pet} table keeps track of which pets you have. If you want to
+record other information about them, such as events in their lives like
+visits to the vet or when litters are born, you need another table. What
+should this table look like? It needs:
-Testing is described in detail below:
-@cindex testing, installation
+@itemize @bullet
+@item
+To contain the pet name so you know which animal each event pertains
+to.
-@enumerate
@item
-If necessary, start the @code{mysqld} server and set up the initial
-@strong{MySQL} grant tables containing the privileges that determine how
-users are allowed to connect to the server. This is normally done with the
-@code{mysql_install_db} script:
+A date so you know when the event occurred.
+
+@item
+A field to describe the event.
+
+@item
+An event type field, if you want to be able to categorize events.
+@end itemize
+
+Given these considerations, the @code{CREATE TABLE} statement for the
+@code{event} table might look like this:
@example
-shell> scripts/mysql_install_db
+mysql> CREATE TABLE event (name VARCHAR(20), date DATE,
+ -> type VARCHAR(15), remark VARCHAR(255));
@end example
-Typically, @code{mysql_install_db} needs to be run only the first time you
-install @strong{MySQL}. Therefore, if you are upgrading an existing
-installation, you can skip this step. (However, @code{mysql_install_db} is
-quite safe to use and will not update any tables that already exist, so if
-you are unsure of what to do, you can always run @code{mysql_install_db}.)
+As with the @code{pet} table, it's easiest to load the initial records
+by creating a tab-delimited text file containing the information:
-@code{mysql_install_db} creates six tables (@code{user}, @code{db},
-@code{host}, @code{tables_priv}, @code{columns_priv}, and @code{func}) in the
-@code{mysql} database. A description of the initial privileges is given in
-@ref{Default privileges}. Briefly, these privileges allow the @strong{MySQL}
-@code{root} user to do anything, and allow anybody to create or use databases
-with a name of @code{'test'} or starting with @code{'test_'}.
+@multitable @columnfractions .15 .15 .15 .55
+@item Fluffy @tab 1995-05-15 @tab litter @tab 4 kittens, 3 female, 1 male
+@item Buffy @tab 1993-06-23 @tab litter @tab 5 puppies, 2 female, 3 male
+@item Buffy @tab 1994-06-19 @tab litter @tab 3 puppies, 3 female
+@item Chirpy @tab 1999-03-21 @tab vet @tab needed beak straightened
+@item Slim @tab 1997-08-03 @tab vet @tab broken rib
+@item Bowser @tab 1991-10-12 @tab kennel
+@item Fang @tab 1991-10-12 @tab kennel
+@item Fang @tab 1998-08-28 @tab birthday @tab Gave him a new chew toy
+@item Claws @tab 1998-03-17 @tab birthday @tab Gave him a new flea collar
+@item Whistler @tab 1998-12-09 @tab birthday @tab First birthday
+@end multitable
-If you don't set up the grant tables, the following error will appear in the
-log file when you start the server:
+Load the records like this:
-@tindex host.frm, problems finding
@example
-mysqld: Can't find file: 'host.frm'
+mysql> LOAD DATA LOCAL INFILE "event.txt" INTO TABLE event;
@end example
-The above may also happen with a binary @strong{MySQL} distribution if you
-don't start @strong{MySQL} by executing exactly @code{./bin/safe_mysqld}!
-@xref{safe_mysqld, , @code{safe_mysqld}}.
+Based on what you've learned from the queries you've run on the @code{pet}
+table, you should be able to perform retrievals on the records in the
+@code{event} table; the principles are the same. But when is the
+@code{event} table by itself insufficient to answer questions you might ask?
-You might need to run @code{mysql_install_db} as @code{root}. However,
-if you prefer, you can run the @strong{MySQL} server as an unprivileged
-(non-@code{root}) user, provided that user can read and write files in
-the database directory. Instructions for running @strong{MySQL} as an
-unprivileged user are given in @ref{Changing MySQL user, , Changing
-@strong{MySQL} user}.
+Suppose you want to find out the ages of each pet when they had their
+litters. The @code{event} table indicates when this occurred, but to
+calculate the age of the mother, you need her birth date. Because that is
+stored in the @code{pet} table, you need both tables for the query:
-If you have problems with @code{mysql_install_db}, see
-@ref{mysql_install_db, , @code{mysql_install_db}}.
+@example
+mysql> SELECT pet.name, (TO_DAYS(date) - TO_DAYS(birth))/365 AS age, remark
+ -> FROM pet, event
+ -> WHERE pet.name = event.name AND type = "litter";
++--------+------+-----------------------------+
+| name | age | remark |
++--------+------+-----------------------------+
+| Fluffy | 2.27 | 4 kittens, 3 female, 1 male |
+| Buffy | 4.12 | 5 puppies, 2 female, 3 male |
+| Buffy | 5.10 | 3 puppies, 3 female |
++--------+------+-----------------------------+
+@end example
-There are some alternatives to running the @code{mysql_install_db}
-script as it is provided in the @strong{MySQL} distribution:
+There are several things to note about this query:
@itemize @bullet
@item
-You may want to edit @code{mysql_install_db} before running it, to change
-the initial privileges that are installed into the grant tables. This is
-useful if you want to install @strong{MySQL} on a lot of machines with the
-same privileges. In this case you probably should need only to add a few
-extra @code{INSERT} statements to the @code{mysql.user} and @code{mysql.db}
-tables!
+The @code{FROM} clause lists two tables because the query needs to pull
+information from both of them.
@item
-If you want to change things in the grant tables after installing them, you
-can run @code{mysql_install_db}, then use @code{mysql -u root mysql} to
-connect to the grant tables as the @strong{MySQL} @code{root} user and issue
-SQL statements to modify the grant tables directly.
+When combining (joining) information from multiple tables, you need to
+specify how records in one table can be matched to records in the other.
+This is easy because they both have a @code{name} column. The query uses
+@code{WHERE} clause to match up records in the two tables based on the
+@code{name} values.
@item
-It is possible to re-create the grant tables completely after they have
-already been created. You might want to do this if you've already installed
-the tables but then want to re-create them after editing
-@code{mysql_install_db}.
+Because the @code{name} column occurs in both tables, you must be specific
+about which table you mean when referring to the column. This is done
+by prepending the table name to the column name.
@end itemize
-For more information about these alternatives, see @ref{Default privileges}.
-
-@item
-Start the @strong{MySQL} server like this:
+You need not have two different tables to perform a join. Sometimes it is
+useful to join a table to itself, if you want to compare records in a table
+to other records in that same table. For example, to find breeding pairs
+among your pets, you can join the @code{pet} table with itself to pair up
+males and females of like species:
@example
-shell> cd mysql_installation_directory
-shell> bin/safe_mysqld &
+mysql> SELECT p1.name, p1.sex, p2.name, p2.sex, p1.species
+ -> FROM pet AS p1, pet AS p2
+ -> WHERE p1.species = p2.species AND p1.sex = "f" AND p2.sex = "m";
++--------+------+--------+------+---------+
+| name | sex | name | sex | species |
++--------+------+--------+------+---------+
+| Fluffy | f | Claws | m | cat |
+| Buffy | f | Fang | m | dog |
+| Buffy | f | Bowser | m | dog |
++--------+------+--------+------+---------+
@end example
-If you have problems starting the server, see @ref{Starting server}.
+In this query, we specify aliases for the table name in order
+to refer to the columns and keep straight which instance of the table
+each column reference is associated with.
-@item
-Use @code{mysqladmin} to verify that the server is running. The following
-commands provide a simple test to check that the server is up and responding
-to connections:
+
+@node Getting information, Examples, Database use, Tutorial
+@section Getting Information About Databases and Tables
+
+@cindex databases, information about
+@cindex tables, information about
+@findex DESCRIBE
+
+What if you forget the name of a database or table, or what the structure of
+a given table is (for example, what its columns are called)? MySQL
+addresses this problem through several statements that provide information
+about the databases and tables it supports.
+
+You have already seen @code{SHOW DATABASES}, which lists the databases
+managed by the server. To find out which database is currently selected,
+use the @code{DATABASE()} function:
@example
-shell> BINDIR/mysqladmin version
-shell> BINDIR/mysqladmin variables
+mysql> SELECT DATABASE();
++------------+
+| DATABASE() |
++------------+
+| menagerie |
++------------+
@end example
-The output from @code{mysqladmin version} varies slightly depending on your
-platform and version of @strong{MySQL}, but should be similar to that shown
-below:
+If you haven't selected any database yet, the result is blank.
+
+To find out what tables the current database contains (for example, when
+you're not sure about the name of a table), use this command:
@example
-shell> BINDIR/mysqladmin version
-mysqladmin Ver 8.14 Distrib 3.23.32, for linux on i586
-Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
-This software comes with ABSOLUTELY NO WARRANTY. This is free software,
-and you are welcome to modify and redistribute it under the GPL license
+mysql> SHOW TABLES;
++---------------------+
+| Tables in menagerie |
++---------------------+
+| event |
+| pet |
++---------------------+
+@end example
-Server version 3.23.32-debug
-Protocol version 10
-Connection Localhost via Unix socket
-TCP port 3306
-UNIX socket /tmp/mysql.sock
-Uptime: 16 sec
+If you want to find out about the structure of a table, the @code{DESCRIBE}
+command is useful; it displays information about each of a table's columns:
-Threads: 1 Questions: 9 Slow queries: 0 Opens: 7 Flush tables: 2 Open tables: 0 Queries per second avg: 0.000 Memory in use: 132K Max memory used: 16773K
+@example
+mysql> DESCRIBE pet;
++---------+-------------+------+-----+---------+-------+
+| Field | Type | Null | Key | Default | Extra |
++---------+-------------+------+-----+---------+-------+
+| name | varchar(20) | YES | | NULL | |
+| owner | varchar(20) | YES | | NULL | |
+| species | varchar(20) | YES | | NULL | |
+| sex | char(1) | YES | | NULL | |
+| birth | date | YES | | NULL | |
+| death | date | YES | | NULL | |
++---------+-------------+------+-----+---------+-------+
@end example
-To get a feeling for what else you can do with @code{BINDIR/mysqladmin},
-invoke it with the @code{--help} option.
+@code{Field} indicates the column name, @code{Type} is the data type for
+the column, @code{Null} indicates whether or not the column can contain
+@code{NULL} values, @code{Key} indicates whether or not the column is
+indexed, and @code{Default} specifies the column's default value.
-@item
-Verify that you can shut down the server:
-@cindex server, shutdown
-@cindex shutting down, the server
+If you have indexes on a table,
+@code{SHOW INDEX FROM tbl_name} produces information about them.
-@example
-shell> BINDIR/mysqladmin -u root shutdown
-@end example
-@item
-Verify that you can restart the server. Do this using @code{safe_mysqld} or
-by invoking @code{mysqld} directly. For example:
+@node Examples, Batch mode, Getting information, Tutorial
+@section Examples of Common Queries
-@cindex server, restart
-@cindex restarting, the server
+@cindex queries, examples
+@cindex examples, queries
+
+Here are examples of how to solve some common problems with
+MySQL.
+
+Some of the examples use the table @code{shop} to hold the price of each
+article (item number) for certain traders (dealers). Supposing that each
+trader has a single fixed price per article, then (@code{item},
+@code{trader}) is a primary key for the records.
+
+Start the command line tool @code{mysql} and select a database:
@example
-shell> BINDIR/safe_mysqld --log &
+mysql your-database-name
@end example
-If @code{safe_mysqld} fails, try running it from the @strong{MySQL}
-installation directory (if you are not already there). If that doesn't work,
-see @ref{Starting server}.
+(In most MySQL installations, you can use the database-name 'test').
-@item
-Run some simple tests to verify that the server is working.
-The output should be similar to what is shown below:
+You can create the example table as:
@example
-shell> BINDIR/mysqlshow
-+-----------+
-| Databases |
-+-----------+
-| mysql |
-+-----------+
+CREATE TABLE shop (
+ article INT(4) UNSIGNED ZEROFILL DEFAULT '0000' NOT NULL,
+ dealer CHAR(20) DEFAULT '' NOT NULL,
+ price DOUBLE(16,2) DEFAULT '0.00' NOT NULL,
+ PRIMARY KEY(article, dealer));
-shell> BINDIR/mysqlshow mysql
-Database: mysql
-+--------------+
-| Tables |
-+--------------+
-| columns_priv |
-| db |
-| func |
-| host |
-| tables_priv |
-| user |
-+--------------+
+INSERT INTO shop VALUES
+(1,'A',3.45),(1,'B',3.99),(2,'A',10.99),(3,'B',1.45),(3,'C',1.69),
+(3,'D',1.25),(4,'D',19.95);
+@end example
-shell> BINDIR/mysql -e "select host,db,user from db" mysql
-+------+--------+------+
-| host | db | user |
-+------+--------+------+
-| % | test | |
-| % | test_% | |
-+------+--------+------+
+Okay, so the example data is:
+
+@example
+mysql> SELECT * FROM shop;
+
++---------+--------+-------+
+| article | dealer | price |
++---------+--------+-------+
+| 0001 | A | 3.45 |
+| 0001 | B | 3.99 |
+| 0002 | A | 10.99 |
+| 0003 | B | 1.45 |
+| 0003 | C | 1.69 |
+| 0003 | D | 1.25 |
+| 0004 | D | 19.95 |
++---------+--------+-------+
@end example
-There is also a benchmark suite in the @file{sql-bench} directory (under the
-@strong{MySQL} installation directory) that you can use to compare how
-@strong{MySQL} performs on different platforms. The @file{sql-bench/Results}
-directory contains the results from many runs against different databases and
-platforms. To run all tests, execute these commands:
+@menu
+* example-Maximum-column:: The maximum value for a column
+* example-Maximum-row:: The row holding the maximum of a certain column
+* example-Maximum-column-group:: Maximum of column per group
+* example-Maximum-column-group-row:: The rows holding the group-wise maximum of a certain field
+* example-user-variables:: Using user variables
+* example-Foreign keys:: Using foreign keys
+* Searching on two keys:: Searching on Two Keys
+* Calculating days:: Calculating visits per day
+@end menu
+
+
+@node example-Maximum-column, example-Maximum-row, Examples, Examples
+@subsection The Maximum Value for a Column
+
+``What's the highest item number?''
@example
-shell> cd sql-bench
-shell> run-all-tests
+SELECT MAX(article) AS article FROM shop
+
++---------+
+| article |
++---------+
+| 4 |
++---------+
@end example
-If you don't have the @file{sql-bench} directory, you are probably using an
-RPM for a binary distribution. (Source distribution RPMs include the
-benchmark directory.) In this case, you must first install the benchmark
-suite before you can use it. Beginning with @strong{MySQL} Version 3.22,
-there are benchmark RPM files named @file{mysql-bench-VERSION-i386.rpm} that
-contain benchmark code and data.
-If you have a source distribution, you can also run the tests in the
-@file{tests} subdirectory. For example, to run @file{auto_increment.tst}, do
-this:
+@node example-Maximum-row, example-Maximum-column-group, example-Maximum-column, Examples
+@subsection The Row Holding the Maximum of a Certain Column
+
+``Find number, dealer, and price of the most expensive article.''
+
+In ANSI SQL this is easily done with a sub-query:
@example
-shell> BINDIR/mysql -vvf test < ./tests/auto_increment.tst
+SELECT article, dealer, price
+FROM shop
+WHERE price=(SELECT MAX(price) FROM shop)
@end example
-The expected results are shown in the @file{./tests/auto_increment.res} file.
+In MySQL (which does not yet have sub-selects), just do it in
+two steps:
+
+@enumerate
+@item
+Get the maximum price value from the table with a @code{SELECT} statement.
+@item
+Using this value compile the actual query:
+@example
+SELECT article, dealer, price
+FROM shop
+WHERE price=19.95
+@end example
@end enumerate
-@node mysql_install_db, Starting server, Post-installation, Post-installation
-@subsection Problems Running @code{mysql_install_db}
-@cindex @code{mysql_install_db} script
-@cindex scripts, @code{mysql_install_db}
+Another solution is to sort all rows descending by price and only
+get the first row using the MySQL specific @code{LIMIT} clause:
-The purpose of the @code{mysql_install_db} script is to generate new
-@strong{MySQL} privilege tables. It will not affect any other data!
-It will also not do anything if you already have @strong{MySQL} privilege
-tables installed!
+@example
+SELECT article, dealer, price
+FROM shop
+ORDER BY price DESC
+LIMIT 1
+@end example
-If you want to re-create your privilege tables, you should take down
-the @code{mysqld} server, if it's running, and then do something like:
+@strong{NOTE}: If there are several most expensive articles (for example, each 19.95)
+the @code{LIMIT} solution shows only one of them!
+
+
+@node example-Maximum-column-group, example-Maximum-column-group-row, example-Maximum-row, Examples
+@subsection Maximum of Column per Group
+
+``What's the highest price per article?''
@example
-mv mysql-data-directory/mysql mysql-data-directory/mysql-old
-mysql_install_db
+SELECT article, MAX(price) AS price
+FROM shop
+GROUP BY article
+
++---------+-------+
+| article | price |
++---------+-------+
+| 0001 | 3.99 |
+| 0002 | 10.99 |
+| 0003 | 1.69 |
+| 0004 | 19.95 |
++---------+-------+
@end example
-This section lists problems you might encounter when you run
-@code{mysql_install_db}:
-@table @strong
-@item @code{mysql_install_db} doesn't install the grant tables
+@node example-Maximum-column-group-row, example-user-variables, example-Maximum-column-group, Examples
+@subsection The Rows Holding the Group-wise Maximum of a Certain Field
-You may find that @code{mysql_install_db} fails to install the grant
-tables and terminates after displaying the following messages:
+``For each article, find the dealer(s) with the most expensive price.''
+
+In ANSI SQL, I'd do it with a sub-query like this:
@example
-starting mysqld daemon with databases from XXXXXX
-mysql daemon ended
+SELECT article, dealer, price
+FROM shop s1
+WHERE price=(SELECT MAX(s2.price)
+ FROM shop s2
+ WHERE s1.article = s2.article);
@end example
-In this case, you should examine the log file very carefully! The log
-should be located in the directory @file{XXXXXX} named by the error message,
-and should indicate why @code{mysqld} didn't start. If you don't understand
-what happened, include the log when you post a bug report using
-@code{mysqlbug}!
-@xref{Bug reports}.
+In MySQL it's best do it in several steps:
-@item There is already a @code{mysqld} daemon running
+@enumerate
+@item
+Get the list of (article,maxprice).
+@item
+For each article get the corresponding rows that have the stored maximum
+price.
+@end enumerate
-In this case, you probably don't have to run @code{mysql_install_db} at
-all. You have to run @code{mysql_install_db} only once, when you install
-@strong{MySQL} the first time.
+This can easily be done with a temporary table:
-@item Installing a second @code{mysqld} daemon doesn't work when one daemon is running
+@example
+CREATE TEMPORARY TABLE tmp (
+ article INT(4) UNSIGNED ZEROFILL DEFAULT '0000' NOT NULL,
+ price DOUBLE(16,2) DEFAULT '0.00' NOT NULL);
-This can happen when you already have an existing @strong{MySQL}
-installation, but want to put a new installation in a different place (for
-example, for testing, or perhaps you simply want to run two installations at
-the same time). Generally the problem that occurs when you try to run the
-second server is that it tries to use the same socket and port as the old one.
-In this case you will get the error message: @code{Can't start server: Bind on
-TCP/IP port: Address already in use} or @code{Can't start server : Bind on
-unix socket...}. @xref{Installing many servers}.
+LOCK TABLES shop read;
-@item You don't have write access to @file{/tmp}
-@cindex write access, tmp
-@cindex temporary file, write access
-@cindex files, @code{tmp}
+INSERT INTO tmp SELECT article, MAX(price) FROM shop GROUP BY article;
-If you don't have write access to create a socket file at the default place
-(in @file{/tmp}) or permission to create temporary files in @file{/tmp,}
-you will get an error when running @code{mysql_install_db} or when
-starting or using @code{mysqld}.
+SELECT shop.article, dealer, shop.price FROM shop, tmp
+WHERE shop.article=tmp.article AND shop.price=tmp.price;
-You can specify a different socket and temporary directory as follows:
+UNLOCK TABLES;
-@tindex TMPDIR environment variable
-@tindex MYSQL_UNIX_PORT environment variable
-@tindex Environment variable, TMPDIR
-@tindex Environment variable, MYSQL_UNIX_PORT
-@example
-shell> TMPDIR=/some_tmp_dir/
-shell> MYSQL_UNIX_PORT=/some_tmp_dir/mysqld.sock
-shell> export TMPDIR MYSQL_UNIX_PORT
+DROP TABLE tmp;
@end example
-@file{some_tmp_dir} should be the path to some directory for which you
-have write permission. @xref{Environment variables}.
+If you don't use a @code{TEMPORARY} table, you must also lock the 'tmp' table.
-After this you should be able to run @code{mysql_install_db} and start
-the server with these commands:
+``Can it be done with a single query?''
+
+Yes, but only by using a quite inefficient trick that I call the
+``MAX-CONCAT trick'':
@example
-shell> scripts/mysql_install_db
-shell> BINDIR/safe_mysqld &
+SELECT article,
+ SUBSTRING( MAX( CONCAT(LPAD(price,6,'0'),dealer) ), 7) AS dealer,
+ 0.00+LEFT( MAX( CONCAT(LPAD(price,6,'0'),dealer) ), 6) AS price
+FROM shop
+GROUP BY article;
+
++---------+--------+-------+
+| article | dealer | price |
++---------+--------+-------+
+| 0001 | B | 3.99 |
+| 0002 | A | 10.99 |
+| 0003 | C | 1.69 |
+| 0004 | D | 19.95 |
++---------+--------+-------+
@end example
-@item @code{mysqld} crashes immediately
+The last example can, of course, be made a bit more efficient by doing the
+splitting of the concatenated column in the client.
-If you are running RedHat Version 5.0 with a version of @code{glibc} older than
-2.0.7-5, you should make sure you have installed all @code{glibc} patches!
-There is a lot of information about this in the @strong{MySQL} mail
-archives. Links to the mail archives are available online at
-@uref{http://www.mysql.com/documentation/}.
-Also, see @ref{Linux}.
-You can also start @code{mysqld} manually using the @code{--skip-grant-tables}
-option and add the privilege information yourself using @code{mysql}:
+@node example-user-variables, example-Foreign keys, example-Maximum-column-group-row, Examples
+@subsection Using user variables
+
+You can use MySQL user variables to remember results without
+having to store them in a temporary variables in the client.
+@xref{Variables}.
+
+For example, to find the articles with the highest and lowest price you
+can do:
@example
-shell> BINDIR/safe_mysqld --skip-grant-tables &
-shell> BINDIR/mysql -u root mysql
+select @@min_price:=min(price),@@max_price:=max(price) from shop;
+select * from shop where price=@@min_price or price=@@max_price;
+
++---------+--------+-------+
+| article | dealer | price |
++---------+--------+-------+
+| 0003 | D | 1.25 |
+| 0004 | D | 19.95 |
++---------+--------+-------+
@end example
-From @code{mysql}, manually execute the SQL commands in
-@code{mysql_install_db}. Make sure you run @code{mysqladmin
-flush-privileges} or @code{mysqladmin reload} afterward to tell the server to
-reload the grant tables.
-@end table
-@node Starting server, Automatic start, mysql_install_db, Post-installation
-@subsection Problems Starting the MySQL Server
-@cindex server, starting problems
-@cindex problems, starting the server
+@node example-Foreign keys, Searching on two keys, example-user-variables, Examples
+@subsection Using Foreign Keys
-If you are going to use tables that support transactions (BDB or InnoDB),
-you should first create a my.cnf file and set startup options
-for the table types you plan to use. @xref{Table types}.
+@cindex foreign keys
+@cindex keys, foreign
-Generally, you start the @code{mysqld} server in one of three ways:
+You don't need foreign keys to join 2 tables.
-@itemize @bullet
-@item
-By invoking @code{mysql.server}. This script is used primarily at
-system startup and shutdown, and is described more fully in
-@ref{Automatic start}.
+The only thing MySQL doesn't do is @code{CHECK} to make sure that
+the keys you use really exist in the table(s) you're referencing and it
+doesn't automatically delete rows from table with a foreign key
+definition. If you use your keys like normal, it'll work just fine:
-@item
-By invoking @code{safe_mysqld}, which tries to determine the proper options
-for @code{mysqld} and then runs it with those options. @xref{safe_mysqld, ,
-@code{safe_mysqld}}.
-@item
-On NT you should install @code{mysqld} as a service as follows:
@example
-bin\mysqld-nt --install # Install MySQL as a service
+CREATE TABLE persons (
+ id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
+ name CHAR(60) NOT NULL,
+ PRIMARY KEY (id)
+);
+
+CREATE TABLE shirts (
+ id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
+ style ENUM('t-shirt', 'polo', 'dress') NOT NULL,
+ color ENUM('red', 'blue', 'orange', 'white', 'black') NOT NULL,
+ owner SMALLINT UNSIGNED NOT NULL REFERENCES persons,
+ PRIMARY KEY (id)
+);
+
+
+INSERT INTO persons VALUES (NULL, 'Antonio Paz');
+
+INSERT INTO shirts VALUES
+(NULL, 'polo', 'blue', LAST_INSERT_ID()),
+(NULL, 'dress', 'white', LAST_INSERT_ID()),
+(NULL, 't-shirt', 'blue', LAST_INSERT_ID());
+
+
+INSERT INTO persons VALUES (NULL, 'Lilliana Angelovska');
+
+INSERT INTO shirts VALUES
+(NULL, 'dress', 'orange', LAST_INSERT_ID()),
+(NULL, 'polo', 'red', LAST_INSERT_ID()),
+(NULL, 'dress', 'blue', LAST_INSERT_ID()),
+(NULL, 't-shirt', 'white', LAST_INSERT_ID());
+
+
+SELECT * FROM persons;
++----+---------------------+
+| id | name |
++----+---------------------+
+| 1 | Antonio Paz |
+| 2 | Lilliana Angelovska |
++----+---------------------+
+
+SELECT * FROM shirts;
++----+---------+--------+-------+
+| id | style | color | owner |
++----+---------+--------+-------+
+| 1 | polo | blue | 1 |
+| 2 | dress | white | 1 |
+| 3 | t-shirt | blue | 1 |
+| 4 | dress | orange | 2 |
+| 5 | polo | red | 2 |
+| 6 | dress | blue | 2 |
+| 7 | t-shirt | white | 2 |
++----+---------+--------+-------+
+
+
+SELECT s.* FROM persons p, shirts s
+ WHERE p.name LIKE 'Lilliana%'
+ AND s.owner = p.id
+ AND s.color <> 'white';
+
++----+-------+--------+-------+
+| id | style | color | owner |
++----+-------+--------+-------+
+| 4 | dress | orange | 2 |
+| 5 | polo | red | 2 |
+| 6 | dress | blue | 2 |
++----+-------+--------+-------+
@end example
-You can now start/stop @code{mysqld} as follows:
+
+@node Searching on two keys, Calculating days, example-Foreign keys, Examples
+@subsection Searching on Two Keys
+
+@findex UNION
+@cindex searching, two keys
+@cindex keys, searching on two
+
+MySQL doesn't yet optimize when you search on two different
+keys combined with @code{OR} (Searching on one key with different @code{OR}
+parts is optimized quite good):
+
@example
-NET START mysql
-NET STOP mysql
+SELECT field1_index, field2_index FROM test_table WHERE field1_index = '1'
+OR field2_index = '1'
@end example
-Note that in this case you can't use any other options for @code{mysqld}!
+The reason is that we haven't yet had time to come up with an efficient
+way to handle this in the general case. (The @code{AND} handling is,
+in comparison, now completely general and works very well).
+
+For the moment you can solve this very efficiently by using a
+@code{TEMPORARY} table. This type of optimization is also very good if
+you are using very complicated queries where the SQL server does the
+optimizations in the wrong order.
-You can remove the service as follows:
@example
-bin\mysqld-nt --remove # remove MySQL as a service
+CREATE TEMPORARY TABLE tmp
+SELECT field1_index, field2_index FROM test_table WHERE field1_index = '1';
+INSERT INTO tmp
+SELECT field1_index, field2_index FROM test_table WHERE field2_index = '1';
+SELECT * from tmp;
+DROP TABLE tmp;
@end example
-@item
-By invoking @code{mysqld} directly.
-@end itemize
+The above way to solve this query is in effect an @code{UNION} of two queries.
-When the @code{mysqld} daemon starts up, it changes directory to the
-data directory. This is where it expects to write log files and the pid
-(process ID) file, and where it expects to find databases.
-The data directory location is hardwired in when the distribution is
-compiled. However, if @code{mysqld} expects to find the data directory
-somewhere other than where it really is on your system, it will not work
-properly. If you have problems with incorrect paths, you can find out
-what options @code{mysqld} allows and what the default path settings are by
-invoking @code{mysqld} with the @code{--help} option. You can override the
-defaults by specifying the correct pathnames as command-line arguments to
-@code{mysqld}. (These options can be used with @code{safe_mysqld} as well.)
+@node Calculating days, , Searching on two keys, Examples
+@subsection Calculating visits per day
-Normally you should need to tell @code{mysqld} only the base directory under
-which @strong{MySQL} is installed. You can do this with the @code{--basedir}
-option. You can also use @code{--help} to check the effect of changing path
-options (note that @code{--help} @emph{must} be the final option of the
-@code{mysqld} command). For example:
+@findex BIT_OR
+@findex BIT_COUNT
+@findex <<
+@cindex bit_functions, example
+
+The following shows an idea of how you can use the bit group functions
+to calculate the number of days per month a user has visited a web page.
@example
-shell> EXECDIR/mysqld --basedir=/usr/local --help
+CREATE TABLE t1 (year YEAR(4), month INT(2) UNSIGNED ZEROFILL, day INT(2) UNSIGNED ZEROFILL);
+INSERT INTO t1 VALUES(2000,1,1),(2000,1,20),(2000,1,30),(2000,2,2),(2000,2,23),(2000,2,23);
+
+SELECT year,month,BIT_COUNT(BIT_OR(1<<day)) AS days FROM t1 GROUP BY year,month;
+
+Which returns:
+
++------+-------+------+
+| year | month | days |
++------+-------+------+
+| 2000 | 01 | 3 |
+| 2000 | 02 | 2 |
++------+-------+------+
@end example
-Once you determine the path settings you want, start the server without
-the @code{--help} option.
+The above calculates how many different days was used for a given
+year/month combination, with automatic removal of duplicate entries.
-Whichever method you use to start the server, if it fails to start up
-correctly, check the log file to see if you can find out why. Log files
-are located in the data directory (typically
-@file{/usr/local/mysql/data} for a binary distribution,
-@file{/usr/local/var} for a source distribution,
-@file{\mysql\data\mysql.err} on Windows.) Look in the data directory for
-files with names of the form @file{host_name.err} and
-@file{host_name.log} where @code{host_name} is the name of your server
-host. Then check the last few lines of these files:
+
+@node Batch mode, Twin, Examples, Tutorial
+@section Using @code{mysql} in Batch Mode
+
+@cindex modes, batch
+@cindex batch mode
+@cindex running, batch mode
+@cindex script files
+@cindex files, script
+
+In the previous sections, you used @code{mysql} interactively to enter
+queries and view the results. You can also run @code{mysql} in batch
+mode. To do this, put the commands you want to run in a file, then
+tell @code{mysql} to read its input from the file:
@example
-shell> tail host_name.err
-shell> tail host_name.log
+shell> mysql < batch-file
@end example
-If you find something like the following in the log file:
+If you need to specify connection parameters on the command line, the
+command might look like this:
+
@example
-000729 14:50:10 bdb: Recovery function for LSN 1 27595 failed
-000729 14:50:10 bdb: warning: ./test/t1.db: No such file or directory
-000729 14:50:10 Can't init databases
+shell> mysql -h host -u user -p < batch-file
+Enter password: ********
@end example
-This means that you didn't start @code{mysqld} with @code{--bdb-no-recover}
-and Berkeley DB found something wrong with its log files when it
-tried to recover your databases. To be able to continue, you should
-move away the old Berkeley DB log file from the database directory to
-some other place, where you can later examine these. The log files are
-named @file{log.0000000001}, where the number will increase over time.
+When you use @code{mysql} this way, you are creating a script file, then
+executing the script.
-If you are running @code{mysqld} with BDB table support and @code{mysqld} core
-dumps at start this could be because of some problems with the BDB
-recover log. In this case you can try starting @code{mysqld} with
-@code{--bdb-no-recover}. If this helps, then you should remove all
-@file{log.*} files from the data directory and try starting @code{mysqld}
-again.
+Why use a script? Here are a few reasons:
-If you get the following error, it means that some other program (or another
-@code{mysqld} server) is already using the TCP/IP port or socket
-@code{mysqld} is trying to use:
+@itemize @bullet
+@item
+If you run a query repeatedly (say, every day or every week), making it a
+script allows you to avoid retyping it each time you execute it.
+
+@item
+You can generate new queries from existing ones that are similar by copying
+and editing script files.
+
+@item
+Batch mode can also be useful while you're developing a query, particularly
+for multiple-line commands or multiple-statement sequences of commands. If
+you make a mistake, you don't have to retype everything. Just edit your
+script to correct the error, then tell @code{mysql} to execute it again.
+
+@item
+If you have a query that produces a lot of output, you can run the output
+through a pager rather than watching it scroll off the top of your screen:
@example
-Can't start server: Bind on TCP/IP port: Address already in use
- or
-Can't start server : Bind on unix socket...
+shell> mysql < batch-file | more
@end example
-Use @code{ps} to make sure that you don't have another @code{mysqld} server
-running. If you can't find another server running, you can try to execute
-the command @code{telnet your-host-name tcp-ip-port-number} and press
-@code{RETURN} a couple of times. If you don't get an error message like
-@code{telnet: Unable to connect to remote host: Connection refused},
-something is using the TCP/IP port @code{mysqld} is trying to use.
-See @ref{mysql_install_db} and @ref{Multiple servers}.
-
-If @code{mysqld} is currently running, you can find out what path settings
-it is using by executing this command:
+@item
+You can catch the output in a file for further processing:
@example
-shell> mysqladmin variables
+shell> mysql < batch-file > mysql.out
@end example
-or
+@item
+You can distribute your script to other people so they can run the commands,
+too.
+
+@item
+Some situations do not allow for interactive use, for example, when you run
+a query from a @code{cron} job. In this case, you must use batch mode.
+@end itemize
+
+The default output format is different (more concise) when you run
+@code{mysql} in batch mode than when you use it interactively. For
+example, the output of @code{SELECT DISTINCT species FROM pet} looks like
+this when run interactively:
@example
-shell> mysqladmin -h 'your-host-name' variables
++---------+
+| species |
++---------+
+| bird |
+| cat |
+| dog |
+| hamster |
+| snake |
++---------+
@end example
-If @code{safe_mysqld} starts the server but you can't connect to it,
-you should make sure you have an entry in @file{/etc/hosts} that looks like
-this:
+But like this when run in batch mode:
@example
-127.0.0.1 localhost
+species
+bird
+cat
+dog
+hamster
+snake
@end example
-This problem occurs only on systems that don't have a working thread
-library and for which @strong{MySQL} must be configured to use MIT-pthreads.
+If you want to get the interactive output format in batch mode, use
+@code{mysql -t}. To echo to the output the commands that are executed, use
+@code{mysql -vvv}.
-If you can't get @code{mysqld} to start you can try to make a trace file
-to find the problem. @xref{Making trace files}.
-If you are using InnoDB tables, refer to the InnoDB-specific startup
-options. @xref{InnoDB start}.
+@node Twin, Apache, Batch mode, Tutorial
+@section Queries from Twin Project
-If you are using BDB (Berkeley DB) tables, you should familiarize
-yourself with the different BDB specific startup options. @xref{BDB start}.
+@cindex Twin Studies, queries
+@cindex queries, Twin Studeis project
-@node Automatic start, Command-line options, Starting server, Post-installation
-@subsection Starting and Stopping MySQL Automatically
-@cindex starting, the server automatically
-@cindex stopping, the server
-@cindex server, starting and stopping
+At Analytikerna and Lentus, we have been doing the systems and field work
+for a big research project. This project is a collaboration between the
+Institute of Environmental Medicine at Karolinska Institutet Stockholm
+and the Section on Clinical Research in Aging and Psychology at the
+University of Southern California.
-The @code{mysql.server} and @code{safe_mysqld} scripts can be used to start
-the server automatically at system startup time. @code{mysql.server} can also
-be used to stop the server.
+The project involves a screening part where all twins in Sweden older
+than 65 years are interviewed by telephone. Twins who meet certain
+criteria are passed on to the next stage. In this latter stage, twins who
+want to participate are visited by a doctor/nurse team. Some of the
+examinations include physical and neuropsychological examination,
+laboratory testing, neuroimaging, psychological status assessment, and family
+history collection. In addition, data are collected on medical and
+environmental risk factors.
-The @code{mysql.server} script can be used to start or stop the server
-by invoking it with @code{start} or @code{stop} arguments:
+More information about Twin studies can be found at:
@example
-shell> mysql.server start
-shell> mysql.server stop
+@url{http://www.imm.ki.se/TWIN/TWINUKW.HTM}
@end example
-@code{mysql.server} can be found in the @file{share/mysql} directory
-under the @strong{MySQL} installation directory or in the @file{support-files}
-directory of the @strong{MySQL} source tree.
+The latter part of the project is administered with a Web interface
+written using Perl and MySQL.
-Before @code{mysql.server} starts the server, it changes directory to
-the @strong{MySQL} installation directory, then invokes @code{safe_mysqld}.
-You might need to edit @code{mysql.server} if you have a binary distribution
-that you've installed in a non-standard location. Modify it to @code{cd}
-into the proper directory before it runs @code{safe_mysqld}. If you want the
-server to run as some specific user, add an appropriate @code{user} line
-to the @file{/etc/my.cnf} file, as shown later in this section.
+Each night all data from the interviews are moved into a MySQL
+database.
-@code{mysql.server stop} brings down the server by sending a signal to it.
-You can take down the server manually by executing @code{mysqladmin shutdown}.
+@menu
+* Twin pool:: Find all non-distributed twins
+* Twin event:: Show a table on twin pair status
+@end menu
-You might want to add these start and stop commands to the appropriate places
-in your @file{/etc/rc*} files when you start using @strong{MySQL} for
-production applications. Note that if you modify @code{mysql.server}, then
-upgrade @strong{MySQL} sometime, your modified version will be overwritten,
-so you should make a copy of your edited version that you can reinstall.
-If your system uses @file{/etc/rc.local} to start external scripts, you
-should append the following to it:
+@node Twin pool, Twin event, Twin, Twin
+@subsection Find all Non-distributed Twins
+
+The following query is used to determine who goes into the second part of the
+project:
+
@example
-/bin/sh -c 'cd /usr/local/mysql ; ./bin/safe_mysqld --user=mysql &'
+select
+ concat(p1.id, p1.tvab) + 0 as tvid,
+ concat(p1.christian_name, " ", p1.surname) as Name,
+ p1.postal_code as Code,
+ p1.city as City,
+ pg.abrev as Area,
+ if(td.participation = "Aborted", "A", " ") as A,
+ p1.dead as dead1,
+ l.event as event1,
+ td.suspect as tsuspect1,
+ id.suspect as isuspect1,
+ td.severe as tsevere1,
+ id.severe as isevere1,
+ p2.dead as dead2,
+ l2.event as event2,
+ h2.nurse as nurse2,
+ h2.doctor as doctor2,
+ td2.suspect as tsuspect2,
+ id2.suspect as isuspect2,
+ td2.severe as tsevere2,
+ id2.severe as isevere2,
+ l.finish_date
+from
+ twin_project as tp
+ /* For Twin 1 */
+ left join twin_data as td on tp.id = td.id and tp.tvab = td.tvab
+ left join informant_data as id on tp.id = id.id and tp.tvab = id.tvab
+ left join harmony as h on tp.id = h.id and tp.tvab = h.tvab
+ left join lentus as l on tp.id = l.id and tp.tvab = l.tvab
+ /* For Twin 2 */
+ left join twin_data as td2 on p2.id = td2.id and p2.tvab = td2.tvab
+ left join informant_data as id2 on p2.id = id2.id and p2.tvab = id2.tvab
+ left join harmony as h2 on p2.id = h2.id and p2.tvab = h2.tvab
+ left join lentus as l2 on p2.id = l2.id and p2.tvab = l2.tvab,
+ person_data as p1,
+ person_data as p2,
+ postal_groups as pg
+where
+ /* p1 gets main twin and p2 gets his/her twin. */
+ /* ptvab is a field inverted from tvab */
+ p1.id = tp.id and p1.tvab = tp.tvab and
+ p2.id = p1.id and p2.ptvab = p1.tvab and
+ /* Just the sceening survey */
+ tp.survey_no = 5 and
+ /* Skip if partner died before 65 but allow emigration (dead=9) */
+ (p2.dead = 0 or p2.dead = 9 or
+ (p2.dead = 1 and
+ (p2.death_date = 0 or
+ (((to_days(p2.death_date) - to_days(p2.birthday)) / 365)
+ >= 65))))
+ and
+ (
+ /* Twin is suspect */
+ (td.future_contact = 'Yes' and td.suspect = 2) or
+ /* Twin is suspect - Informant is Blessed */
+ (td.future_contact = 'Yes' and td.suspect = 1 and id.suspect = 1) or
+ /* No twin - Informant is Blessed */
+ (ISNULL(td.suspect) and id.suspect = 1 and id.future_contact = 'Yes') or
+ /* Twin broken off - Informant is Blessed */
+ (td.participation = 'Aborted'
+ and id.suspect = 1 and id.future_contact = 'Yes') or
+ /* Twin broken off - No inform - Have partner */
+ (td.participation = 'Aborted' and ISNULL(id.suspect) and p2.dead = 0))
+ and
+ l.event = 'Finished'
+ /* Get at area code */
+ and substring(p1.postal_code, 1, 2) = pg.code
+ /* Not already distributed */
+ and (h.nurse is NULL or h.nurse=00 or h.doctor=00)
+ /* Has not refused or been aborted */
+ and not (h.status = 'Refused' or h.status = 'Aborted'
+ or h.status = 'Died' or h.status = 'Other')
+order by
+ tvid;
@end example
-You can also add options for @code{mysql.server} in a global
-@file{/etc/my.cnf} file. A typical @file{/etc/my.cnf} file might look like
-this:
+Some explanations:
+@table @asis
+@item @code{concat(p1.id, p1.tvab) + 0 as tvid}
+We want to sort on the concatenated @code{id} and @code{tvab} in
+numerical order. Adding @code{0} to the result causes MySQL to
+treat the result as a number.
+@item column @code{id}
+This identifies a pair of twins. It is a key in all tables.
+@item column @code{tvab}
+This identifies a twin in a pair. It has a value of @code{1} or @code{2}.
+@item column @code{ptvab}
+This is an inverse of @code{tvab}. When @code{tvab} is @code{1} this is
+@code{2}, and vice versa. It exists to save typing and to make it easier for
+MySQL to optimize the query.
+@end table
+
+This query demonstrates, among other things, how to do lookups on a
+table from the same table with a join (@code{p1} and @code{p2}). In the example, this
+is used to check whether a twin's partner died before the age of 65. If so,
+the row is not returned.
+
+All of the above exist in all tables with twin-related information. We
+have a key on both @code{id,tvab} (all tables), and @code{id,ptvab}
+(@code{person_data}) to make queries faster.
+
+On our production machine (A 200MHz UltraSPARC), this query returns
+about 150-200 rows and takes less than one second.
+
+The current number of records in the tables used above:
+@multitable @columnfractions .3 .5
+@item @strong{Table} @tab @strong{Rows}
+@item @code{person_data} @tab 71074
+@item @code{lentus} @tab 5291
+@item @code{twin_project} @tab 5286
+@item @code{twin_data} @tab 2012
+@item @code{informant_data} @tab 663
+@item @code{harmony} @tab 381
+@item @code{postal_groups} @tab 100
+@end multitable
+
+
+@node Twin event, , Twin pool, Twin
+@subsection Show a Table on Twin Pair Status
+
+Each interview ends with a status code called @code{event}. The query
+shown below is used to display a table over all twin pairs combined by
+event. This indicates in how many pairs both twins are finished, in how many
+pairs one twin is finished and the other refused, and so on.
@example
-[mysqld]
-datadir=/usr/local/mysql/var
-socket=/tmp/mysqld.sock
-port=3306
-user=mysql
+select
+ t1.event,
+ t2.event,
+ count(*)
+from
+ lentus as t1,
+ lentus as t2,
+ twin_project as tp
+where
+ /* We are looking at one pair at a time */
+ t1.id = tp.id
+ and t1.tvab=tp.tvab
+ and t1.id = t2.id
+ /* Just the sceening survey */
+ and tp.survey_no = 5
+ /* This makes each pair only appear once */
+ and t1.tvab='1' and t2.tvab='2'
+group by
+ t1.event, t2.event;
-[mysql.server]
-basedir=/usr/local/mysql
@end example
-The @code{mysql.server} script understands the following options:
-@code{datadir}, @code{basedir}, and @code{pid-file}.
-The following table shows which option groups each of the startup scripts
-read from option files:
+@node Apache, , Twin, Tutorial
+@section Using MySQL with Apache
-@multitable @columnfractions .20 .80
-@item @strong{Script} @tab @strong{Option groups}
-@item @code{mysqld} @tab @code{mysqld} and @code{server}
-@item @code{mysql.server} @tab @code{mysql.server}, @code{mysqld}, and @code{server}
-@item @code{safe_mysqld} @tab @code{mysql.server}, @code{mysqld}, and @code{server}
-@end multitable
+@cindex Apache
-@xref{Option files}.
+The Contrib section includes programs that let you authenticate your
+users from a MySQL database and also let you log your log files
+into a MySQL table. @xref{Contrib}.
+
+You can change the Apache logging format to be easily readable by
+MySQL by putting the following into the Apache configuration file:
+
+@example
+LogFormat \
+ "\"%h\",%@{%Y%m%d%H%M%S@}t,%>s,\"%b\",\"%@{Content-Type@}o\", \
+ \"%U\",\"%@{Referer@}i\",\"%@{User-Agent@}i\""
+@end example
+
+In MySQL you can do something like this:
+
+@example
+LOAD DATA INFILE '/local/access_log' INTO TABLE table_name
+FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\'
+@end example
+
+
+
+
+@node MySQL Database Administration, MySQL Optimization, Tutorial, Top
+@chapter MySQL Database Administration
+
+@menu
+* Configuring MySQL:: Configuring MySQL
+* Privilege system:: General Security Issues and the MySQL Access Privilege System
+* User Account Management:: MySQL User Account Management
+* Disaster Prevention:: Disaster Prevention and Recovery
+* Database Administration:: Database Administration Language Reference
+* Localization:: MySQL Localization and International Usage
+* Server-Side Scripts:: MySQL Server-Side Scripts and Utilities
+* Client-Side Scripts:: MySQL Client-Side Scripts and Utilities
+* Log Files:: The MySQL Log Files
+* Replication:: Replication in MySQL
+@end menu
+
+
+@node Configuring MySQL, Privilege system, MySQL Database Administration, MySQL Database Administration
+@section Configuring MySQL
+
+
+@menu
+* Command-line options:: mysqld Command-line Options
+* Option files:: my.cnf Option Files
+* Installing many servers:: Installing Many Servers on the Same Machine
+* Multiple servers:: Running Multiple MySQL Servers on the Same Machine
+@end menu
+
+
+@node Command-line options, Option files, Configuring MySQL, Configuring MySQL
+@subsection mysqld Command-line Options
@findex command-line options
@cindex options, command-line
@cindex mysqld options
-@node Command-line options, Option files, Automatic start, Post-installation
-@subsection mysqld Command-line Options
@code{mysqld} accepts the following command-line options:
@@ -10304,7 +14683,7 @@ this.
@item --big-tables
Allow big result sets by saving all temporary sets on file. It solves
most 'table full' errors, but also slows down the queries where
-in-memory tables would suffice. Since Version 3.23.2, @strong{MySQL} is
+in-memory tables would suffice. Since Version 3.23.2, MySQL is
able to solve it automatically by using memory for small temporary
tables and switching to disk tables where necessary.
@@ -10334,7 +14713,7 @@ Set the default character set. @xref{Character sets}.
Set the default table type for tables. @xref{Table types}.
@item --debug[...]=
-If @strong{MySQL} is configured with @code{--with-debug}, you can use this
+If MySQL is configured with @code{--with-debug}, you can use this
option to get a trace file of what @code{mysqld} is doing.
@xref{Making trace files}.
@@ -10353,7 +14732,7 @@ mysqld server; One should not use this option if one doesn't know
exactly what it does!
@item --flush
-Flush all changes to disk after each SQL command. Normally @strong{MySQL}
+Flush all changes to disk after each SQL command. Normally MySQL
only does a write of all changes to disk after each SQL command and lets
the operating system handle the syncing to disk.
@xref{Crashing}.
@@ -10401,12 +14780,15 @@ system supports the @code{mlockall()} system call (like Solaris). This
may help if you have a problem where the operating system is causing
@code{mysqld} to swap on disk.
-@item --myisam-recover [=option[,option...]]] where option is one of DEFAULT, BACKUP, FORCE or QUICK.
-If this option is used, @code{mysqld} will on open check if the table is
-marked as crashed or if if the table wasn't closed properly. (The last
-option only works if you are running with @code{--skip-locking}). If this
-is the case @code{mysqld} will run check on the table. If the table was corrupted,
-@code{mysqld} will attempt to repair it.
+@item --myisam-recover [=option[,option...]]] where option is any combination
+of @code{DEFAULT}, @code{BACKUP}, @code{FORCE} or @code{QUICK}. You can
+also set this explicitely to @code{""} if you want to disable this
+option. If this option is used, @code{mysqld} will on open check if the
+table is marked as crashed or if if the table wasn't closed properly.
+(The last option only works if you are running with
+@code{--skip-locking}). If this is the case @code{mysqld} will run
+check on the table. If the table was corrupted, @code{mysqld} will
+attempt to repair it.
The following options affects how the repair works.
@@ -10422,7 +14804,7 @@ The following options affects how the repair works.
delete blocks.
@end multitable
-Before a table is automatically repaired, @strong{MySQL} will add a note
+Before a table is automatically repaired, MySQL will add a note
about this in the error log. If you want to be able to recover from most
things without user intervention, you should use the options
@code{BACKUP,FORCE}. This will force a repair of a table even if some rows
@@ -10454,15 +14836,10 @@ Skip some optimize stages. Implies @code{--skip-delay-key-write}.
@item --safe-show-database
Don't show databases for which the user doesn't have any privileges.
-@item --secure
-IP numbers returned by the @code{gethostbyname()} system call are
-checked to make sure they resolve back to the original hostname. This
-makes it harder for someone on the outside to get access by pretending
-to be another host. This option also adds some sanity checks of
-hostnames. The option is turned off by default in @strong{MySQL} Version 3.21
-because sometimes it takes a long time to perform backward resolutions.
-@strong{MySQL} Version 3.22 caches hostnames (unless @code{--skip-host-cache}
-is used) and has this option enabled by default.
+@item --safe-user-create
+If this is enabled, a user can't create new users with the GRANT
+command, if the user doesn't have @code{INSERT} privilege to the
+@code{mysql.user} table or any column in this table.
@item --skip-concurrent-insert
Turn off the ability to select and insert at the same time on @code{MyISAM}
@@ -10485,7 +14862,7 @@ on every connect instead. @xref{DNS}.
@item --skip-locking
Don't use system locking. To use @code{isamchk} or @code{myisamchk} you must
-shut down the server. @xref{Stability}. Note that in @strong{MySQL} Version
+shut down the server. @xref{Stability}. Note that in MySQL Version
3.23 you can use @code{REPAIR} and @code{CHECK} to repair/check @code{MyISAM}
tables.
@@ -10507,7 +14884,7 @@ Don't delete or rename files that a symlinked file in the data directory
points to.
@item --skip-safemalloc
-If @strong{MySQL} is configured with @code{--with-debug=full}, all programs
+If MySQL is configured with @code{--with-debug=full}, all programs
will check the memory for overruns for every memory allocation and memory
freeing. As this checking is very slow, you can avoid this, when you don't
need memory checking, by using this option.
@@ -10527,6 +14904,15 @@ Disable using thread priorities for faster response time.
Socket file to use for local connections instead of default
@code{/tmp/mysql.sock}.
+@item --sql-mode=option[,option[,option...]]
+Option can be any combination of: @code{REAL_AS_FLOAT},
+@code{PIPES_AS_CONCAT}, @code{ANSI_QUOTES}, @code{IGNORE_SPACE},
+@code{SERIALIZE}, @code{ONLY_FULL_GROUP_BY}. It can also be empty
+(@code{""}) if you want to reset this.
+
+By specifying all of the above options is same as using --ansi.
+With this option one can turn on only needed SQL modes. @xref{ANSI mode}.
+
@item transaction-isolation= @{ READ-UNCOMMITTED | READ-COMMITTED | REPEATABLE-READ | SERIALIZABLE @}
Sets the default transaction isolation level. @xref{SET TRANSACTION}.
@@ -10546,17 +14932,19 @@ Print out warnings like @code{Aborted connection...} to the @code{.err} file.
@xref{Communication errors}.
@end table
+
+@node Option files, Installing many servers, Command-line options, Configuring MySQL
+@subsection my.cnf Option Files
+
@cindex default options
@cindex option files
@cindex creating, default startup options
@cindex startup options, default
-@node Option files, , Command-line options, Post-installation
-@subsection Option Files
-@strong{MySQL} can, since Version 3.22, read default startup options for the
+MySQL can, since Version 3.22, read default startup options for the
server and for clients from option files.
-@strong{MySQL} reads default options from the following files on Unix:
+MySQL reads default options from the following files on Unix:
@tindex .my.cnf file
@multitable @columnfractions .3 .7
@@ -10567,7 +14955,7 @@ server and for clients from option files.
@item @code{~/.my.cnf} @tab User-specific options
@end multitable
-@code{DATADIR} is the @strong{MySQL} data directory (typically
+@code{DATADIR} is the MySQL data directory (typically
@file{/usr/local/mysql/data} for a binary installation or
@file{/usr/local/var} for a source installation). Note that this is the
directory that was specified at configuration time, not the one specified
@@ -10575,7 +14963,7 @@ with @code{--datadir} when @code{mysqld} starts up! (@code{--datadir} has no
effect on where the server looks for option files, because it looks for them
before it processes any command-line arguments.)
-@strong{MySQL} reads default options from the following files on Windows:
+MySQL reads default options from the following files on Windows:
@multitable @columnfractions .3 .7
@item @strong{Filename} @tab @strong{Purpose}
@@ -10586,10 +14974,10 @@ before it processes any command-line arguments.)
Note that on Windows, you should specify all paths with @code{/} instead of
@code{\}. If you use @code{\}, you need to specify this twice, as
-@code{\} is the escape character in @strong{MySQL}.
+@code{\} is the escape character in MySQL.
-@cindex Environment variables
-@strong{MySQL} tries to read option files in the order listed above. If
+@cindex environment variables
+MySQL tries to read option files in the order listed above. If
multiple option files exist, an option specified in a file read later takes
precedence over the same option specified in a file read earlier. Options
specified on the command line take precedence over options specified in any
@@ -10628,7 +15016,7 @@ This syntax must be used to set a @code{mysqld} variable.
@end table
The @code{client} group allows you to specify options that apply to all
-@strong{MySQL} clients (not @code{mysqld}). This is the perfect group to use
+MySQL clients (not @code{mysqld}). This is the perfect group to use
to specify the password you use to connect to the server. (But make
sure the option file is readable and writable only by yourself.)
@@ -10674,13 +15062,13 @@ interactive-timeout
If you have a source distribution, you will find sample configuration
files named @file{my-xxxx.cnf} in the @file{support-files} directory.
If you have a binary distribution, look in the @file{DIR/support-files}
-directory, where @code{DIR} is the pathname to the @strong{MySQL}
+directory, where @code{DIR} is the pathname to the MySQL
installation directory (typically @file{/usr/local/mysql}). Currently
there are sample configuration files for small, medium, large, and very
large systems. You can copy @file{my-xxxx.cnf} to your home directory
(rename the copy to @file{.my.cnf}) to experiment with this.
-All @strong{MySQL} clients that support option files support the
+All MySQL clients that support option files support the
following options:
@multitable @columnfractions .40 .60
@@ -10700,7 +15088,7 @@ before any command-line arguments. This works nicely for programs that use
the last instance of an option that is specified multiple times. If you have
an old program that handles multiply-specified options this way but doesn't
read option files, you need add only two lines to give it that capability.
-Check the source code of any of the standard @strong{MySQL} clients to see
+Check the source code of any of the standard MySQL clients to see
how to do this.
In shell scripts you can use the @file{my_print_defaults} command to parse the
@@ -10716,25 +15104,27 @@ shell> my_print_defaults client mysql
The above output contains all options for the groups 'client' and 'mysql'.
-@node Installing many servers, Upgrade, Post-installation, Installing
-@section Installing Many Servers on the Same Machine
+
+@node Installing many servers, Multiple servers, Option files, Configuring MySQL
+@subsection Installing Many Servers on the Same Machine
+
@cindex post-install, many servers
@cindex Installing many servers
@cindex Starting many servers
In some cases you may want to have many different @code{mysqld} daemons
(servers) running on the same machine. You may for example want to run
-a new version of @strong{MySQL} for testing together with an old version
+a new version of MySQL for testing together with an old version
that is in production. Another case is when you want to give different
users access to different @code{mysqld} servers that they manage themselves.
One way to get a new server running is by starting it with a different
socket and port as follows:
-@tindex MYSQL_UNIX_PORT environment variable
-@tindex MYSQL_TCP_PORT environment variable
-@tindex Environment variable, MYSQL_UNIX_PORT
-@tindex Environment variable, MYSQL_TCP_PORT
+@tindex @code{MYSQL_UNIX_PORT} environment variable
+@tindex @code{MYSQL_TCP_PORT} environment variable
+@tindex environment variable, @code{MYSQL_UNIX_PORT}
+@tindex environment variable, @code{MYSQL_TCP_PORT}
@example
shell> MYSQL_UNIX_PORT=/tmp/mysqld-new.sock
shell> MYSQL_TCP_PORT=3307
@@ -10784,1301 +15174,203 @@ If you want more performance, you can also specify the following differently:
@xref{Command-line options}.
-If you are installing binary @strong{MySQL} versions (.tar files) and
+If you are installing binary MySQL versions (.tar files) and
start them with @code{./bin/safe_mysqld} then in most cases the only
option you need to add/change is the @code{socket} and @code{port}
argument to @code{safe_mysqld}.
-@node Upgrade, , Installing many servers, Installing
-@section Upgrading/Downgrading MySQL
-@cindex upgrading
-@cindex downgrading
-
-You can always move the @strong{MySQL} form and data files between
-different versions on the same architecture as long as you have the same
-base version of @strong{MySQL}. The current base version is
-3. If you change the character set when running @strong{MySQL} (which may
-also change the sort order), you must run @code{myisamchk -r -q} on all
-tables. Otherwise your indexes may not be ordered correctly.
-
-If you are afraid of new versions, you can always rename your old
-@code{mysqld} to something like @code{mysqld}-'old-version-number'. If
-your new @code{mysqld} then does something unexpected, you can simply shut it
-down and restart with your old @code{mysqld}!
-
-When you do an upgrade you should also back up your old databases, of course.
-
-If after an upgrade, you experience problems with recompiled client programs,
-like @code{Commands out of sync} or unexpected core dumps, you probably have
-used an old header or library file when compiling your programs. In this
-case you should check the date for your @file{mysql.h} file and
-@file{libmysqlclient.a} library to verify that they are from the new
-@strong{MySQL} distribution. If not, please recompile your programs!
-
-If you get some problems that the new @code{mysqld} server doesn't want to
-start or that you can't connect without a password, check that you don't
-have some old @file{my.cnf} file from your old installation! You can
-check this with: @code{program-name --print-defaults}. If this outputs
-anything other than the program name, you have an active @code{my.cnf}
-file that will affect things!
-
-It is a good idea to rebuild and reinstall the @code{Msql-Mysql-modules}
-distribution whenever you install a new release of @strong{MySQL},
-particularly if you notice symptoms such as all your @code{DBI} scripts
-dumping core after you upgrade @strong{MySQL}.
@menu
-* Upgrading-from-3.23::
-* Upgrading-from-3.22:: Upgrading from a 3.22 version to 3.23
-* Upgrading-from-3.21:: Upgrading from a 3.21 version to 3.22
-* Upgrading-from-3.20:: Upgrading from a 3.20 version to 3.21
-* Upgrading-to-arch:: Upgrading to another architecture
+* Multiple servers:: Running Multiple MySQL Servers on the Same Machine
@end menu
-@cindex compatibility, between MySQL versions
-@cindex upgrading, 3.23 to 4.0
-@node Upgrading-from-3.23, Upgrading-from-3.22, Upgrade, Upgrade
-@subsection Upgrading From Version 3.23 to Version 4.0
-
-You can use your old data files without any modification with Version 4.0
-
-All old clients will work with a Version 4.0 server.
-
-The following lists tell what you have to watch out for when upgrading to
-Version 4.0;
-
-@itemize @bullet
-@item
-You should use @code{TRUNCATE TABLE} when you want to delete all rows
-from a table and you don't care of how many rows where deleted.
-(Because @code{TRUNCATE TABLE} is faster than @code{DELETE FROM table_name}).
-@item
-You will get an error if you have an active @code{LOCK TABLES} or
-transaction when trying to execute @code{TRUNCATE TABLE} or @code{DROP
-DATABASE}.
-@end itemize
-
-@cindex compatibility, between MySQL versions
-@cindex upgrading, 3.22 to 3.23
-@node Upgrading-from-3.22, Upgrading-from-3.21, Upgrading-from-3.23, Upgrade
-@subsection Upgrading From Version 3.22 to Version 3.23
-
-@strong{MySQL} Version 3.23 supports tables of the new @code{MyISAM} type and
-the old @code{ISAM} type. You don't have to convert your old tables to
-use these with Version 3.23. By default, all new tables will be created with
-type @code{MyISAM} (unless you start @code{mysqld} with the
-@code{--default-table-type=isam} option). You can change an @code{ISAM}
-table to a @code{MyISAM} table with @code{ALTER TABLE table_name TYPE=MyISAM}
-or the Perl script @code{mysql_convert_table_format}.
-
-Version 3.22 and 3.21 clients will work without any problems with a Version
-3.23 server.
-
-The following lists tell what you have to watch out for when upgrading to
-Version 3.23:
-
-@itemize @bullet
-@item
-All tables that uses the @code{tis620} character set must be fixed
-with @code{myisamchk -r} or @code{REPAIR TABLE}.
-@item
-If you do a @code{DROP DATABASE} on a symbolic linked database, both the
-link and the original database is deleted. (This didn't happen in 3.22
-because configure didn't detect the @code{readlink} system call).
-@item
-@code{OPTIMIZE TABLE} now only works for @strong{MyISAM} tables.
-For other table types, you can use @code{ALTER TABLE} to optimize the table.
-During @code{OPTIMIZE TABLE} the table is now locked from other threads.
-@item
-The @strong{MySQL} client @code{mysql} is now by default started with the
-option @code{--no-named-commands (-g)}. This option can be disabled with
-@code{--enable-named-commands (-G)}. This may cause incompatibility problems in
-some cases, for example in SQL scripts that use named commands without a
-semicolon! Long format commands still work from the first line.
-@item
-If you are using the @code{german} character sort order, you must repair
-all your tables with @code{isamchk -r}, as we have made some changes in
-the sort order!
-@item The default return type of @code{IF} will now depend on both arguments
-and not only the first argument.
-@item @code{AUTO_INCREMENT} will not work with negative numbers. The reason
-for this is that negative numbers caused problems when wrapping from -1 to 0.
-@code{AUTO_INCREMENT} is now for MyISAM tables handled at a lower level and
-is much faster than before. For MyISAM tables old numbers are also not reused
-anymore, even if you delete some rows from the table.
-@item @code{CASE}, @code{DELAYED}, @code{ELSE}, @code{END}, @code{FULLTEXT}, @code{INNER}, @code{RIGHT}, @code{THEN} and @code{WHEN} are now reserved words.
-@item @code{FLOAT(X)} is now a true floating-point type and not a value with
-a fixed number of decimals.
-@item When declaring @code{DECIMAL(length,dec)} the length argument no
-longer includes a place for the sign or the decimal point.
-@item A @code{TIME} string must now be of one of the following formats:
-@code{[[[DAYS] [H]H:]MM:]SS[.fraction]} or
-@code{[[[[[H]H]H]H]MM]SS[.fraction]}
-@item @code{LIKE} now compares strings using the same character
-comparison rules as @code{'='}. If you require the old behavior, you
-can compile @strong{MySQL} with the @code{CXXFLAGS=-DLIKE_CMP_TOUPPER}
-flag.
-@item @code{REGEXP} is now case insensitive for normal (not binary) strings.
-@item When you check/repair tables you should use @code{CHECK TABLE}
-or @code{myisamchk} for @code{MyISAM} tables (@code{.MYI}) and
-@code{isamchk} for ISAM (@code{.ISM}) tables.
-@item If you want your @code{mysqldump} files to be compatible between
-@strong{MySQL} Version 3.22 and Version 3.23, you should not use the
-@code{--opt} or @code{--full} option to @code{mysqldump}.
-@item Check all your calls to @code{DATE_FORMAT()} to make sure there is a
-@samp{%} before each format character. (Later @strong{MySQL} Version 3.22
-did allow this syntax.)
-@item
-@code{mysql_fetch_fields_direct} is now a function (it was a macro) and
-it returns a pointer to a @code{MYSQL_FIELD} instead of a
-@code{MYSQL_FIELD}.
-@item
-@code{mysql_num_fields()} can no longer be used on a @code{MYSQL*} object (it's
-now a function that takes @code{MYSQL_RES*} as an argument. You should now
-use @code{mysql_field_count()} instead.
-@item
-In @strong{MySQL} Version 3.22, the output of @code{SELECT DISTINCT ...} was
-almost always sorted. In Version 3.23, you must use @code{GROUP BY} or
-@code{ORDER BY} to obtain sorted output.
-@item
-@code{SUM()} now returns @code{NULL}, instead of 0, if there is no matching
-rows. This is according to ANSI SQL.
-@item An @code{AND} or @code{OR} with @code{NULL} values will now return
-@code{NULL} instead of 0. This mostly affects queries that use @code{NOT}
-on an @code{AND/OR} expression as @code{NOT NULL} = @code{NULL}.
-@code{LPAD()} and @code{RPAD()} will shorten the result string if it's longer
-than the length argument.
-@end itemize
-
-@cindex compatibility, between MySQL versions
-@node Upgrading-from-3.21, Upgrading-from-3.20, Upgrading-from-3.22, Upgrade
-@subsection Upgrading from Version 3.21 to Version 3.22
-@cindex upgrading, 3.21 to 3.22
-
-Nothing that affects compatibility has changed between Version 3.21 and 3.22.
-The only pitfall is that new tables that are created with @code{DATE} type
-columns will use the new way to store the date. You can't access these new
-fields from an old version of @code{mysqld}.
-
-After installing @strong{MySQL} Version 3.22, you should start the new server
-and then run the @code{mysql_fix_privilege_tables} script. This will add the
-new privileges that you need to use the @code{GRANT} command. If you forget
-this, you will get @code{Access denied} when you try to use @code{ALTER
-TABLE}, @code{CREATE INDEX}, or @code{DROP INDEX}. If your @strong{MySQL} root
-user requires a password, you should give this as an argument to
-@code{mysql_fix_privilege_tables}.
-
-The C API interface to @code{mysql_real_connect()} has changed. If you have
-an old client program that calls this function, you must place a @code{0} for
-the new @code{db} argument (or recode the client to send the @code{db}
-element for faster connections). You must also call @code{mysql_init()}
-before calling @code{mysql_real_connect()}! This change was done to allow
-the new @code{mysql_options()} function to save options in the @code{MYSQL}
-handler structure.
-
-The @code{mysqld} variable @code{key_buffer} has changed names to
-@code{key_buffer_size}, but you can still use the old name in your
-startup files.
-
-@node Upgrading-from-3.20, Upgrading-to-arch, Upgrading-from-3.21, Upgrade
-@subsection Upgrading from Version 3.20 to Version 3.21
-@cindex upgrading, 3.20 to 3.21
-
-If you are running a version older than Version 3.20.28 and want to
-switch to Version 3.21, you need to do the following:
-
-You can start the @code{mysqld} Version 3.21 server with @code{safe_mysqld
---old-protocol} to use it with clients from a Version 3.20 distribution.
-In this case, the new client function @code{mysql_errno()} will not
-return any server error, only @code{CR_UNKNOWN_ERROR} (but it
-works for client errors), and the server uses the old @code{password()}
-checking rather than the new one.
-
-If you are @strong{NOT} using the @code{--old-protocol} option to
-@code{mysqld}, you will need to make the following changes:
-
-@itemize @bullet
-@item
-All client code must be recompiled. If you are using ODBC, you must get
-the new @strong{MyODBC} 2.x driver.
-@item
-The script @code{scripts/add_long_password} must be run to convert the
-@code{Password} field in the @code{mysql.user} table to @code{CHAR(16)}.
-@item
-All passwords must be reassigned in the @code{mysql.user} table (to get 62-bit
-rather than 31-bit passwords).
-@item
-The table format hasn't changed, so you don't have to convert any tables.
-@end itemize
-
-@strong{MySQL} Version 3.20.28 and above can handle the new @code{user} table
-format without affecting clients. If you have a @strong{MySQL} version earlier
-than Version 3.20.28, passwords will no longer work with it if you convert the
-@code{user} table. So to be safe, you should first upgrade to at least Version
-3.20.28 and then upgrade to Version 3.21.
-
-@cindex Protocol mismatch
-The new client code works with a 3.20.x @code{mysqld} server, so
-if you experience problems with 3.21.x, you can use the old 3.20.x server
-without having to recompile the clients again.
-If you are not using the @code{--old-protocol} option to @code{mysqld},
-old clients will issue the error message:
-
-@example
-ERROR: Protocol mismatch. Server Version = 10 Client Version = 9
-@end example
-
-The new Perl @code{DBI}/@code{DBD} interface also supports the old
-@code{mysqlperl} interface. The only change you have to make if you use
-@code{mysqlperl} is to change the arguments to the @code{connect()} function.
-The new arguments are: @code{host}, @code{database}, @code{user},
-@code{password} (the @code{user} and @code{password} arguments have changed
-places).
-@xref{Perl DBI Class, , Perl @code{DBI} Class}.
-
-The following changes may affect queries in old applications:
-
-@itemize @bullet
-@item
-@code{HAVING} must now be specified before any @code{ORDER BY} clause.
-@item
-The parameters to @code{LOCATE()} have been swapped.
-@item
-There are some new reserved words. The most notable are @code{DATE},
-@code{TIME}, and @code{TIMESTAMP}.
-@end itemize
-
-@cindex upgrading, different architecture
-@node Upgrading-to-arch, , Upgrading-from-3.20, Upgrade
-@subsection Upgrading to Another Architecture
-
-If you are using @strong{MySQL} Version 3.23, you can copy the @code{.frm},
-@code{.MYI}, and @code{.MYD} files between different architectures that
-support the same floating-point format. (@strong{MySQL} takes care of any
-byte swapping issues.)
-
-The @strong{MySQL} @code{ISAM} data and index files (@file{.ISD} and
-@file{*.ISM}, respectively) are architecture-dependent and in some cases
-OS-dependent. If you want to move your applications to another machine
-that has a different architecture or OS than your current machine, you
-should not try to move a database by simply copying the files to the
-other machine. Use @code{mysqldump} instead.
-
-By default, @code{mysqldump} will create a file full of SQL statements.
-You can then transfer the file to the other machine and feed it as input
-to the @code{mysql} client.
+@node Multiple servers, , Installing many servers, Configuring MySQL
+@subsection Running Multiple MySQL Servers on the Same Machine
-Try @code{mysqldump --help} to see what options are available.
-If you are moving the data to a newer version of @strong{MySQL}, you should use
-@code{mysqldump --opt} with the newer version to get a fast, compact dump.
+@cindex multiple servers
+@cindex servers, multiple
+@cindex running, multiple servers
-The easiest (although not the fastest) way to move a database between two
-machines is to run the following commands on the machine on which the
-database is located:
+There are circumstances when you might want to run multiple servers on the same
+machine. For example, you might want to test a new MySQL release
+while leaving your existing production setup undisturbed. Or you might
+be an Internet service provider that wants to provide independent
+MySQL installations for different customers.
-@example
-shell> mysqladmin -h 'other hostname' create db_name
-shell> mysqldump --opt db_name \
- | mysql -h 'other hostname' db_name
-@end example
+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, ,
+@code{mysqld_multi}}.
-If you want to copy a database from a remote machine over a slow network,
-you can use:
+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> mysqladmin create db_name
-shell> mysqldump -h 'other hostname' --opt --compress db_name \
- | mysql db_name
+shell> ./configure --with-tcp-port=port_number \
+ --with-unix-socket-path=file_name \
+ --prefix=/usr/local/mysql-3.22.9
@end example
-You can also store the result in a file, then transfer the file to the
-target machine and load the file into the database there. For example,
-you can dump a database to a file on the source machine like this:
-
-@example
-shell> mysqldump --quick db_name | gzip > db_name.contents.gz
-@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 MySQL installation is located.
-(The file created in this example is compressed.) Transfer the file
-containing the database contents to the target machine and run these commands
-there:
+You can check the socket used by any currently executing MySQL server
+with this command:
@example
-shell> mysqladmin create db_name
-shell> gunzip < db_name.contents.gz | mysql db_name
+shell> mysqladmin -h hostname --port=port_number variables
@end example
-@cindex @code{mysqldump}
-@cindex @code{mysqlimport}
-You can also use @code{mysqldump} and @code{mysqlimport} to accomplish
-the database transfer.
-For big tables, this is much faster than simply using @code{mysqldump}.
-In the commands shown below, @code{DUMPDIR} represents the full pathname
-of the directory you use to store the output from @code{mysqldump}.
-
-First, create the directory for the output files and dump the database:
+Note that if you specify ``@code{localhost}'' as a hostname, @code{mysqladmin}
+will default to using Unix sockets instead of TCP/IP.
-@example
-shell> mkdir DUMPDIR
-shell> mysqldump --tab=DUMPDIR db_name
-@end example
+If you have a MySQL server running on the port you used, you will
+get a list of some of the most important configurable variables in
+MySQL, including the socket name.
-Then transfer the files in the @code{DUMPDIR} directory to some corresponding
-directory on the target machine and load the files into @strong{MySQL}
-there:
+You don't have to recompile a new 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> mysqladmin create db_name # create database
-shell> cat DUMPDIR/*.sql | mysql db_name # create tables in database
-shell> mysqlimport db_name DUMPDIR/*.txt # load data into tables
+shell> /path/to/safe_mysqld --socket=file_name --port=port_number
@end example
-Also, don't forget to copy the @code{mysql} database, because that's where the
-grant tables (@code{user}, @code{db}, @code{host}) are stored. You may have
-to run commands as the @strong{MySQL} @code{root} user on the new machine
-until you have the @code{mysql} database in place.
-
-After you import the @code{mysql} database on the new machine, execute
-@code{mysqladmin flush-privileges} so that the server reloads the grant table
-information.
-
-@cindex compatibility, with ANSI SQL
-@cindex standards compatibility
-@cindex extensions, to ANSI SQL
-@cindex ANSI SQL92, extensions to
-@node Compatibility, Privilege system, Installing, Top
-@chapter How Standards-compatible Is MySQL?
-
-@menu
-* Extensions to ANSI:: @strong{MySQL} extensions to ANSI SQL92
-* ANSI mode:: Running @strong{MySQL} in ANSI mode
-* Differences from ANSI:: @strong{MySQL} differences compared to ANSI SQL92
-* Missing functions:: Functionality missing from @strong{MySQL}
-* Standards:: What standards does @strong{MySQL} follow?
-* Commit-rollback:: How to cope without @code{COMMIT}-@code{ROLLBACK}
-@end menu
-
-This chapter describes how @strong{MySQL} relates to the ANSI SQL standards.
-@strong{MySQL} has many extensions to the ANSI SQL standards, and here you
-will find out what they are, and how to use them. You will also find
-information about functionality missing from @strong{MySQL}, and how to work
-around some differences.
-
-@node Extensions to ANSI, ANSI mode, Compatibility, Compatibility
-@section MySQL Extensions to ANSI SQL92
-
-@strong{MySQL} includes some extensions that you probably will not find in
-other SQL databases. Be warned that if you use them, your code will not be
-portable to other SQL servers. In some cases, you can write code that
-includes @strong{MySQL} extensions, but is still portable, by using comments
-of the form @code{/*! ... */}. In this case, @strong{MySQL} will parse and
-execute the code within the comment as it would any other @strong{MySQL}
-statement, but other SQL servers will ignore the extensions. For 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}.
-@example
-SELECT /*! STRAIGHT_JOIN */ col_name FROM table1,table2 WHERE ...
-@end example
+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.
-If you add a version number after the @code{'!'}, the syntax will only be
-executed if the @strong{MySQL} version is equal to or newer than the used
-version number:
+@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!
-@example
-CREATE /*!32302 TEMPORARY */ TABLE (a int);
-@end example
+If you want to use another database directory for the second server, you
+can use the @code{--datadir=path} option to @code{safe_mysqld}.
-The above means that if you have Version 3.23.02 or newer, then @strong{MySQL}
-will use the @code{TEMPORARY} keyword.
+@strong{NOTE} also that starting several 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.
-@strong{MySQL} extensions are listed below:
+When you want to connect to a 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
-The field types @code{MEDIUMINT}, @code{SET}, @code{ENUM}, and the
-different @code{BLOB} and @code{TEXT} types.
-
-@item
-The field attributes @code{AUTO_INCREMENT}, @code{BINARY}, @code{NULL},
-@code{UNSIGNED}, and @code{ZEROFILL}.
-
-@item
-All string comparisons are case insensitive by default, with sort
-ordering determined by the current character set (ISO-8859-1 Latin1 by
-default). If you don't like this, you should declare your columns with
-the @code{BINARY} attribute or use the @code{BINARY} cast, which causes
-comparisons to be done according to the ASCII order used on the
-@strong{MySQL} server host.
-
-@item
-@strong{MySQL} maps each database to a directory under the @strong{MySQL}
-data directory, and tables within a database to filenames in the database
-directory.
-
-This has a few implications:
-
-@cindex database names, case sensitivity
-@cindex table names, case sensitivity
-@cindex case sensitivity, of database names
-@cindex case sensitivity, of table names
-
-@itemize @minus
-
-@item
-Database names and table names are case sensitive in @strong{MySQL} on
-operating systems that have case-sensitive filenames (like most Unix
-systems). @xref{Name case sensitivity}.
-
-@item
-Database, table, index, column, or alias names may begin with a digit
-(but may not consist solely of digits).
-
-@item
-You can use standard system commands to backup, rename, move, delete, and copy
-tables. For example, to rename a table, rename the @file{.MYD}, @file{.MYI},
-and @file{.frm} files to which the table corresponds.
-@end itemize
-
-@item
-In SQL statements, you can access tables from different databases
-with the @code{db_name.tbl_name} syntax. Some SQL servers provide
-the same functionality but call this @code{User space}.
-@strong{MySQL} doesn't support tablespaces as in:
-@code{create table ralph.my_table...IN my_tablespace}.
-
-@item
-@code{LIKE} is allowed on numeric columns.
-
-@item
-Use of @code{INTO OUTFILE} and @code{STRAIGHT_JOIN} in a @code{SELECT}
-statement. @xref{SELECT, , @code{SELECT}}.
-
-@item
-The @code{SQL_SMALL_RESULT} option in a @code{SELECT} statement.
-
-@item
-@code{EXPLAIN SELECT} to get a description on how tables are joined.
-
-@item
-Use of index names, indexes on a prefix of a field, and use of
-@code{INDEX} or @code{KEY} in a @code{CREATE TABLE}
-statement. @xref{CREATE TABLE, , @code{CREATE TABLE}}.
-
-@item
-Use of @code{TEMPORARY} or @code{IF NOT EXISTS} with @code{CREATE TABLE}.
-
-@item
-Use of @code{COUNT(DISTINCT list)} where 'list' is more than one element.
-
-@item
-Use of @code{CHANGE col_name}, @code{DROP col_name}, or @code{DROP
-INDEX}, @code{IGNORE} or @code{RENAME} in an @code{ALTER TABLE}
-statement. @xref{ALTER TABLE, , @code{ALTER TABLE}}.
-
-@item
-Use of @code{RENAME TABLE}. @xref{RENAME TABLE, , @code{RENAME TABLE}}.
-
-@item
-Use of multiple @code{ADD}, @code{ALTER}, @code{DROP}, or @code{CHANGE}
-clauses in an @code{ALTER TABLE} statement.
-
-@item
-Use of @code{DROP TABLE} with the keywords @code{IF EXISTS}.
-
-@item
-You can drop multiple tables with a single @code{DROP TABLE} statement.
-
-@item
-The @code{LIMIT} clause of the @code{DELETE} statement.
-
-@item
-The @code{DELAYED} clause of the @code{INSERT} and @code{REPLACE}
-statements.
-
-@item
-The @code{LOW_PRIORITY} clause of the @code{INSERT}, @code{REPLACE},
-@code{DELETE}, and @code{UPDATE} statements.
-
-@cindex Oracle compatibility
-@cindex compatibility, with Oracle
-@item
-Use of @code{LOAD DATA INFILE}. In many cases, this syntax is compatible with
-Oracle's @code{LOAD DATA INFILE}. @xref{LOAD DATA, , @code{LOAD DATA}}.
-
-@item
-The @code{ANALYZE TABLE}, @code{CHECK TABLE}, @code{OPTIMIZE TABLE}, and
-@code{REPAIR TABLE} statements.
-
-@item
-The @code{SHOW} statement.
-@xref{SHOW, , @code{SHOW}}.
-
-@item
-Strings may be enclosed by either @samp{"} or @samp{'}, not just by @samp{'}.
-
-@item
-Use of the escape @samp{\} character.
-
-@item
-The @code{SET OPTION} statement. @xref{SET OPTION, , @code{SET OPTION}}.
-
-@item
-You don't need to name all selected columns in the @code{GROUP BY} part.
-This gives better performance for some very specific, but quite normal
-queries.
-@xref{Group by functions}.
-
-@item
-One can specify @code{ASC} and @code{DESC} with @code{GROUP BY}.
-
-@item
-To make it easier for users who come from other SQL environments,
-@strong{MySQL} supports aliases for many functions. For example, all
-string functions support both ANSI SQL syntax and ODBC syntax.
-
-@item
-@strong{MySQL} understands the @code{||} and @code{&&} operators to mean
-logical OR and AND, as in the C programming language. In @strong{MySQL},
-@code{||} and @code{OR} are synonyms, as are @code{&&} and @code{AND}.
-Because of this nice syntax, @strong{MySQL} doesn't support
-the ANSI SQL @code{||} operator for string concatenation; use
-@code{CONCAT()} instead. Because @code{CONCAT()} takes any number
-of arguments, it's easy to convert use of the @code{||} operator to
-@strong{MySQL}.
-
-@item
-@code{CREATE DATABASE} or @code{DROP DATABASE}.
-@xref{CREATE DATABASE, , @code{CREATE DATABASE}}.
-
-@cindex PostgreSQL compatibility
-@cindex compatibility, with PostgreSQL
-@item
-The @code{%} operator is a synonym for @code{MOD()}. That is,
-@code{N % M} is equivalent to @code{MOD(N,M)}. @code{%} is supported
-for C programmers and for compatibility with PostgreSQL.
-
-@item
-The @code{=}, @code{<>}, @code{<=} ,@code{<}, @code{>=},@code{>},
-@code{<<}, @code{>>}, @code{<=>}, @code{AND}, @code{OR}, or @code{LIKE}
-operators may be used in column comparisons to the left of the
-@code{FROM} in @code{SELECT} statements. For example:
-
-@example
-mysql> SELECT col1=1 AND col2=2 FROM tbl_name;
-@end example
-
-@item
-The @code{LAST_INSERT_ID()} function.
-@xref{mysql_insert_id, , @code{mysql_insert_id()}}.
-
-@item
-The @code{REGEXP} and @code{NOT REGEXP} extended regular expression
-operators.
-
-@item
-@code{CONCAT()} or @code{CHAR()} with one argument or more than two
-arguments. (In @strong{MySQL}, these functions can take any number of
-arguments.)
-
-@item The @code{BIT_COUNT()}, @code{CASE}, @code{ELT()},
-@code{FROM_DAYS()}, @code{FORMAT()}, @code{IF()}, @code{PASSWORD()},
-@code{ENCRYPT()}, @code{md5()}, @code{ENCODE()}, @code{DECODE()},
-@code{PERIOD_ADD()}, @code{PERIOD_DIFF()}, @code{TO_DAYS()}, or
-@code{WEEKDAY()} functions.
-
-@item
-Use of @code{TRIM()} to trim substrings. ANSI SQL only supports removal
-of single characters.
-
-@item
-The @code{GROUP BY} functions @code{STD()}, @code{BIT_OR()}, and
-@code{BIT_AND()}.
-
-@item
-Use of @code{REPLACE} instead of @code{DELETE} + @code{INSERT}.
-@xref{REPLACE, , @code{REPLACE}}.
-
-@item
-The @code{FLUSH flush_option} statement.
-
-@item
-The possibility to set variables in a statement with @code{:=}:
-@example
-SELECT @@a:=SUM(total),@@b=COUNT(*),@@a/@@b AS avg FROM test_table;
-SELECT @@t1:=(@@t2:=1)+@@t3:=4,@@t1,@@t2,@@t3;
-@end example
-
-@end itemize
-
-@node ANSI mode, Differences from ANSI, Extensions to ANSI, Compatibility
-@section Running MySQL in ANSI Mode
-@cindex running, ANSI mode
-@cindex ANSI mode, running
-
-If you start @code{mysqld} with the @code{--ansi} option, the following behavior
-of @strong{MySQL} changes:
+Start the client with @code{--host 'hostname' --port=port_number} to connect
+with TCP/IP, or @code{[--host localhost] --socket=file_name} to connect via
+a Unix socket.
-@itemize @bullet
-@item
-@code{||} is string concatenation instead of @code{OR}.
@item
-You can have any number of spaces between a function name and the @samp{(}.
-This forces all function names to be treated as reserved words.
-@item
-@samp{"} will be an identifier quote character (like the @strong{MySQL}
-@samp{`} quote character) and not a string quote character.
-@item
-@code{REAL} will be a synonym for @code{FLOAT} instead of a synonym of
-@code{DOUBLE}.
-@item
-The default transaction isolation level is @code{SERIALIZABLE}.
-@xref{SET TRANSACTION}.
-@end itemize
-
-@node Differences from ANSI, Missing functions, ANSI mode, Compatibility
-@section MySQL Differences Compared to ANSI SQL92
-
-We try to make @strong{MySQL} follow the ANSI SQL standard and the
-ODBC SQL standard, but in some cases @strong{MySQL} does some things
-differently:
+In your C or Perl programs, you can give the port or socket arguments
+when connecting to the MySQL server.
-@itemize @bullet
-@item
-@code{--} is only a comment if followed by a white space. @xref{Missing
-comments}.
-@item
-For @code{VARCHAR} columns, trailing spaces are removed when the value is
-stored. @xref{Bugs}.
@item
-In some cases, @code{CHAR} columns are silently changed to @code{VARCHAR}
-columns. @xref{Silent column changes}.
-@item
-Privileges for a table are not automatically revoked when you delete a
-table. You must explicitly issue a @code{REVOKE} to revoke privileges for
-a table. @xref{GRANT, , @code{GRANT}}.
-@item
-@code{NULL AND FALSE} will evaluate to @code{NULL} and not to @code{FALSE}.
-This is because we don't think it's good to have to evaluate a lot of
-extra conditions in this case.
-@end itemize
-
-@node Missing functions, Standards, Differences from ANSI, Compatibility
-@section Functionality Missing from MySQL
-@cindex missing functionality
-@cindex functionality, missing
-
-The following functionality is missing in the current version of
-@strong{MySQL}. For a prioritized list indicating when new extensions
-may be added to @strong{MySQL}, you should consult
-@uref{http://www.mysql.com/documentation/manual.php?section=TODO, the
-online @strong{MySQL} TODO list}. That is the latest version of the TODO
-list in this manual. @xref{TODO}.
-
-@menu
-* Missing Sub-selects:: Sub-selects
-* Missing SELECT INTO TABLE:: @code{SELECT INTO TABLE}
-* Missing Transactions:: Transactions
-* Missing Triggers:: Triggers
-* Missing Foreign Keys:: Foreign Keys
-* Missing Views:: Views
-* Missing comments:: @samp{--} as the start of a comment
-@end menu
-
-@node Missing Sub-selects, Missing SELECT INTO TABLE, Missing functions, Missing functions
-@subsection Sub-selects
-@cindex sub-selects
-
-The following will not yet work in @strong{MySQL}:
-
-@example
-SELECT * FROM table1 WHERE id IN (SELECT id FROM table2);
-SELECT * FROM table1 WHERE id NOT IN (SELECT id FROM table2);
-SELECT * FROM table1 WHERE NOT EXISTS (SELECT id FROM table2 where table1.id=table2.id);
-@end example
-
-However, in many cases you can rewrite the query without a sub-select:
-
-@example
-SELECT table1.* FROM table1,table2 WHERE table1.id=table2.id;
-SELECT table1.* FROM table1 LEFT JOIN table2 ON table1.id=table2.id where table2.id IS NULL
-@end example
-
-For more complicated subqueries you can often create temporary tables
-to hold the subquery. In some cases, however this option will not
-work. The most frequently encountered of these cases arises with
-@code{DELETE} statements, for which standard SQL does not support joins
-(except in sub-selects). For this situation there are two options
-available until subqueries are supported by @strong{MySQL}.
-
-The first option is to use a procedural programming language (such as
-Perl or PHP) to submit a @code{SELECT} query to obtain the primary keys
-for the records to be deleted, and then use these values to construct
-the @code{DELETE} statement (@code{DELETE FROM ... WHERE ... IN (key1,
-key2, ...)}).
-
-The second option is to use interactive SQL to contruct a set of
-@code{DELETE} statements automatically, using the @strong{MySQL}
-extension @code{CONCAT()} (in lieu of the standard @code{||} operator).
-For example:
-
-@example
-SELECT CONCAT('DELETE FROM tab1 WHERE pkid = ', tab1.pkid, ';')
- FROM tab1, tab2
- WHERE tab1.col1 = tab2.col2;
-@end example
-
-You can place this query in a script file and redirect input from it to
-the @code{mysql} command-line interpreter, piping its output back to a
-second instance of the interpreter:
-
-@example
-prompt> mysql --skip-column-names mydb < myscript.sql | mysql mydb
-@end example
-
-@strong{MySQL} only supports @code{INSERT ... SELECT ...} and
-@code{REPLACE ... SELECT ...} Independent sub-selects will probably
-be available in Version 4.0. You can now use the function @code{IN()} in
-other contexts, however.
-
-@node Missing SELECT INTO TABLE, Missing Transactions, Missing Sub-selects, Missing functions
-@subsection @code{SELECT INTO TABLE}
-@findex SELECT INTO TABLE
-
-@strong{MySQL} doesn't yet support the Oracle SQL extension:
-@code{SELECT ... INTO TABLE ...}. @strong{MySQL} supports instead the
-ANSI SQL syntax @code{INSERT INTO ... SELECT ...}, which is basically
-the same thing. @xref{INSERT SELECT}.
-
-@example
-INSERT INTO tblTemp2 (fldID) SELECT tblTemp1.fldOrder_ID FROM tblTemp1 WHERE
-tblTemp1.fldOrder_ID > 100;
-@end example
-
-Alternatively, you can use @code{SELECT INTO OUTFILE...} or @code{CREATE
-TABLE ... SELECT} to solve your problem.
-
-@node Missing Transactions, Missing Triggers, Missing SELECT INTO TABLE, Missing functions
-@subsection Transactions
-@cindex transactions, support
-
-As @strong{MySQL} does nowadays support transactions, the following
-discussion is only valid if you are only using the non-transaction-safe
-table types. @xref{COMMIT}.
-
-The question is often asked, by the curious and the critical, ``Why is
-@strong{MySQL} not a transactional database?'' or ``Why does @strong{MySQL}
-not support transactions?''
-
-@strong{MySQL} has made a conscious decision to support another paradigm
-for data integrity, ``atomic operations.'' It is our thinking and
-experience that atomic operations offer equal or even better integrity
-with much better performance. We, nonetheless, appreciate and understand
-the transactional database paradigm and plan, within the next few releases,
-to introduce transaction-safe tables on a per table basis. We will be
-giving our users the possibility to decide if they need the speed of
-atomic operations or if they need to use transactional features in their
-applications.
-
-How does one use the features of @strong{MySQL} to maintain rigorous integrity
-and how do these features compare with the transactional paradigm?
-
-First, in the transactional paradigm, if your applications are written
-in a way that is dependent on the calling of ``rollback'' instead of
-``commit'' in critical situations, then transactions are more
-convenient. Moreover, transactions ensure that unfinished updates or
-corrupting activities are not committed to the database; the server is
-given the opportunity to do an automatic rollback and your database is
-saved.
-
-@strong{MySQL}, in almost all cases, allows you to solve for potential
-problems by including simple checks before updates and by running simple
-scripts that check the databases for inconsistencies and automatically
-repair or warn if such occurs. Note that just by using the
-@strong{MySQL} log or even adding one extra log, one can normally fix
-tables perfectly with no data integrity loss.
-
-Moreover, fatal transactional updates can be rewritten to be
-atomic. In fact,we will go so far as to say that all integrity problems
-that transactions solve can be done with @code{LOCK TABLES} or atomic updates,
-ensuring that you never will get an automatic abort from the database,
-which is a common problem with transactional databases.
-
-Not even transactions can prevent all loss if the server goes down. In
-such cases even a transactional system can lose data. The difference
-between different systems lies in just how small the time-lap is where
-they could lose data. No system is 100% secure, only ``secure
-enough.'' Even Oracle, reputed to be the safest of transactional
-databases, is reported to sometimes lose data in such situations.
-
-To be safe with @strong{MySQL}, you only need to have backups and have
-the update logging turned on. With this you can recover from any
-situation that you could with any transactional database. It is, of
-course, always good to have backups, independent of which database you
-use.
-
-The transactional paradigm has its benefits and its drawbacks. Many
-users and application developers depend on the ease with which they can
-code around problems where an abort appears to be, or is necessary, and they
-may have to do a little more work with @strong{MySQL} to either think
-differently or write more. If you are new to the atomic operations
-paradigm, or more familiar or more comfortable with transactions, do not
-jump to the conclusion that @strong{MySQL} has not addressed these
-issues. Reliability and integrity are foremost in our minds. Recent
-estimates indicate that there are more than 1,000,000 @code{mysqld} servers
-currently running, many of which are in production environments. We
-hear very, very seldom from our users that they have lost any data, and
-in almost all of those cases user error is involved. This is, in our
-opinion, the best proof of @strong{MySQL}'s stability and reliability.
-
-Lastly, in situations where integrity is of highest importance,
-@strong{MySQL}'s current features allow for transaction-level or better
-reliability and integrity. If you lock tables with @code{LOCK TABLES}, all
-updates will stall until any integrity checks are made. If you only obtain
-a read lock (as opposed to a write lock), then reads and inserts are
-still allowed to happen. The new inserted records will not be seen by
-any of the clients that have a @code{READ} lock until they release their read
-locks. With @code{INSERT DELAYED} you can queue inserts into a local queue,
-until the locks are released, without having the client wait for the insert
-to complete. @xref{INSERT DELAYED}.
-
-``Atomic,'' in the sense that we mean it, is nothing magical. It only means
-that you can be sure that while each specific update is running, no other
-user can interfere with it, and there will never be an automatic
-rollback (which can happen on transaction based systems if you are not
-very careful). @strong{MySQL} also guarantees that there will not be
-any dirty reads. You can find some example of how to write atomic updates
-in the commit-rollback section. @xref{Commit-rollback}.
-
-We have thought quite a bit about integrity and performance, and we
-believe that our atomic operations paradigm allows for both high
-reliability and extremely high performance, on the order of three to
-five times the speed of the fastest and most optimally tuned of
-transactional databases. We didn't leave out transactions because they
-are hard to do. The main reason we went with atomic operations as
-opposed to transactions is that by doing this we could apply many speed
-optimizations that would not otherwise have been possible.
-
-Many of our users who have speed foremost in their minds are not at all
-concerned about transactions. For them transactions are not an
-issue. For those of our users who are concerned with or have wondered
-about transactions vis-a-vis @strong{MySQL}, there is a ``@strong{MySQL}
-way'' as we have outlined above. For those where safety is more
-important than speed, we recommend them to use the @code{BDB}
-or @code{InnoDB} tables for all their critical
-data. @xref{Table types}.
-
-One final note: We are currently working on a safe replication schema
-that we believe to be better than any commercial replication system we
-know of. This system will work most reliably under the atomic
-operations, non-transactional, paradigm. Stay tuned.
-
-@node Missing Triggers, Missing Foreign Keys, Missing Transactions, Missing functions
-@subsection Stored Procedures and Triggers
-@cindex stored procedures and triggers, defined
-@cindex procedures, stored
-@cindex triggers, stored
-
-
-A stored procedure is a set of SQL commands that can be compiled and stored
-in the server. Once this has been done, clients don't need to keep reissuing
-the entire query but can refer to the stored procedure. This provides better
-performance because the query has to be parsed only once, and less information
-needs to be sent between the server and the client. You can also raise the
-conceptual level by having libraries of functions in the server.
-
-A trigger is a stored procedure that is invoked when a particular event
-occurs. For example, you can install a stored procedure that is triggered
-each time a record is deleted from a transaction table and that automatically
-deletes the corresponding customer from a customer table when all his
-transactions are deleted.
-
-The planned update language will be able to
-handle stored procedures, but without triggers. Triggers usually slow
-down everything, even queries for which they are not needed.
-
-To see when @strong{MySQL} might get stored procedures, see @ref{TODO}.
-
-@node Missing Foreign Keys, Missing Views, Missing Triggers, Missing functions
-@subsection Foreign Keys
-@cindex foreign keys
-@cindex keys, foreign
-
-Note that foreign keys in SQL are not used to join tables, but are used
-mostly for checking referential integrity (foreign key constraints). If
-you want to get results from multiple tables from a @code{SELECT}
-statement, you do this by joining tables:
+If your are using the Perl @code{DBD::mysql} module you can read the options
+from the MySQL option files. @xref{Option files}.
@example
-SELECT * from table1,table2 where table1.id = table2.id;
+$dsn = "DBI:mysql:test;mysql_read_default_group=client;mysql_read_default_file=/usr/local/mysql/data/my.cnf"
+$dbh = DBI->connect($dsn, $user, $password);
@end example
-@xref{JOIN, , @code{JOIN}}. @xref{example-Foreign keys}.
-
-The @code{FOREIGN KEY} syntax in @strong{MySQL} exists only for compatibility
-with other SQL vendors' @code{CREATE TABLE} commands; it doesn't do
-anything. The @code{FOREIGN KEY} syntax without @code{ON DELETE ...} is
-mostly used for documentation purposes. Some ODBC applications may use this
-to produce automatic @code{WHERE} clauses, but this is usually easy to
-override. @code{FOREIGN KEY} is sometimes used as a constraint check, but
-this check is unnecessary in practice if rows are inserted into the tables in
-the right order. @strong{MySQL} only supports these clauses because some
-applications require them to exist (regardless of whether or not they
-work).
-
-In @strong{MySQL}, you can work around the problem of @code{ON DELETE
-...} not being implemented by adding the appropriate @code{DELETE} statement to
-an application when you delete records from a table that has a foreign key.
-In practice this is as quick (in some cases quicker) and much more portable
-than using foreign keys.
-
-In the near future we will extend the @code{FOREIGN KEY} implementation so
-that at least the information will be saved in the table specification file
-and may be retrieved by @code{mysqldump} and ODBC. At a later stage we will
-implement the foreign key constraints for application that can't easily be
-coded to avoid them.
-
-@menu
-* Broken Foreign KEY:: Reasons NOT to use foreign keys constraints
-@end menu
-
-@node Broken Foreign KEY, , Missing Foreign Keys, Missing Foreign Keys
-@subsubsection Reasons NOT to Use Foreign Keys constraints
-@cindex foreign keys, reasons not to use
-
-There are so many problems with foreign key constraints that we don't
-know where to start:
-
-@itemize @bullet
-@item
-Foreign key constraints make life very complicated, because the foreign
-key definitions must be stored in a database and implementing them would
-destroy the whole ``nice approach'' of using files that can be moved,
-copied, and removed.
-
-@item
-The speed impact is terrible for @code{INSERT} and @code{UPDATE}
-statements, and in this case almost all @code{FOREIGN KEY} constraint
-checks are useless because you usually insert records in the right
-tables in the right order, anyway.
-
-@item
-There is also a need to hold locks on many more tables when updating one
-table, because the side effects can cascade through the entire database. It's
-MUCH faster to delete records from one table first and subsequently delete
-them from the other tables.
-
-@item
-You can no longer restore a table by doing a full delete from the table
-and then restoring all records (from a new source or from a backup).
-
-@item
-If you use foreign key constraints you can't dump and restore tables
-unless you do so in a very specific order.
-
@item
-It's very easy to do ``allowed'' circular definitions that make the
-tables impossible to re-create each table with a single create statement,
-even if the definition works and is usable.
-
-@item
-It's very easy to overlook @code{FOREIGN KEY ... ON DELETE} rules when
-one codes an application. It's not unusual that one loses a lot of
-important information just because a wrong or misused @code{ON DELETE} rule.
-@end itemize
-
-The only nice aspect of @code{FOREIGN KEY} is that it gives ODBC and some
-other client programs the ability to see how a table is connected and to use
-this to show connection diagrams and to help in building applications.
-
-@strong{MySQL} will soon store @code{FOREIGN KEY} definitions so that a
-client can ask for and receive an answer about how the original
-connection was made. The current @file{.frm} file format does not have
-any place for it. At a later stage we will implement the foreign key
-constraints for application that can't easily be coded to avoid them.
-
-@node Missing Views, Missing comments, Missing Foreign Keys, Missing functions
-@subsection Views
-@cindex views
-
-@strong{MySQL} doesn't yet support views, but we plan to implement these
-to about 4.1.
-
-Views are mostly useful for letting users access a set of relations as one
-table (in read-only mode). Many SQL databases don't allow one to update
-any rows in a view, but you have to do the updates in the separate tables.
-
-As @strong{MySQL} is mostly used in applications and on web system where
-the application writer has full control on the database usage, most of
-our users haven't regarded views to be very important. (At least no one
-has been interested enough in this to be prepared to finance the
-implementation of views).
-
-One doesn't need views in @strong{MySQL} to restrict access to columns
-as @strong{MySQL} has a very sophisticated privilege
-system. @xref{Privilege system}.
-
-@node Missing comments, , Missing Views, Missing functions
-@subsection @samp{--} as the Start of a Comment
-@cindex comments, starting
-@cindex starting, comments
-
-Some other SQL databases use @samp{--} to start comments. @strong{MySQL}
-has @samp{#} as the start comment character, even if the @code{mysql}
-command-line tool removes all lines that start with @samp{--}.
-You can also use the C comment style @code{/* this is a comment */} with
-@strong{MySQL}.
-@xref{Comments}.
-
-@strong{MySQL} Version 3.23.3 and above supports the @samp{--} comment style
-only if the comment is followed by a space. This is because this
-degenerate comment style has caused many problems with automatically
-generated SQL queries that have used something like the following code,
-where we automatically insert the value of the payment for
-@code{!payment!}:
-
-@example
-UPDATE tbl_name SET credit=credit-!payment!
-@end example
-
-What do you think will happen when the value of @code{payment} is negative?
-
-Because @code{1--1} is legal in SQL, we think it is terrible that
-@samp{--} means start comment.
-
-In @strong{MySQL} Version 3.23 you can, however, use:
-@code{1-- This is a comment}
-
-The following discussion only concerns you if you are running a @strong{MySQL}
-version earlier than Version 3.23:
-
-If you have a SQL program in a text file that contains @samp{--} comments
-you should use:
-
-@example
-shell> replace " --" " #" < text-file-with-funny-comments.sql \
- | mysql database
-@end example
-
-instead of the usual:
-
-@example
-shell> mysql database < text-file-with-funny-comments.sql
-@end example
-
-You can also edit the command file ``in place'' to change the @samp{--}
-comments to @samp{#} comments:
-
-@example
-shell> replace " --" " #" -- text-file-with-funny-comments.sql
-@end example
-
-Change them back with this command:
-
-@example
-shell> replace " #" " --" -- text-file-with-funny-comments.sql
-@end example
-
-@node Standards, Commit-rollback, Missing functions, Compatibility
-@section What Standards Does MySQL Follow?
-
-Entry level SQL92. ODBC levels 0-2.
-
-@node Commit-rollback, , Standards, Compatibility
-@section How to Cope Without @code{COMMIT}/@code{ROLLBACK}
-@findex COMMIT
-@findex ROLLBACK
-@cindex transaction-safe tables
-@cindex tables, updating
-@cindex updating, tables
-@cindex @code{BDB} tables
-@cindex @code{InnoDB} tables
-
-The following mostly applies only for @code{ISAM}, @code{MyISAM}, and
-@code{HEAP} tables. If you only use transaction-safe tables (@code{BDB}
-or @code{InnoDB} tables) in an an update, you can do
-@code{COMMIT} and @code{ROLLBACK} also with @strong{MySQL}.
-@xref{COMMIT}.
-
-The problem with handling @code{COMMIT}-@code{ROLLBACK} efficiently with
-the above table types would require a completely different table layout
-than @strong{MySQL} uses today. The table type would also need extra
-threads that do automatic cleanups on the tables, and the disk usage
-would be much higher. This would make these table types about 2-4 times
-slower than they are today.
-
-For the moment, we prefer implementing the SQL server language (something
-like stored procedures). With this you would very seldom really need
-@code{COMMIT}-@code{ROLLBACK.} This would also give much better performance.
-
-Loops that need transactions normally can be coded with the help of
-@code{LOCK TABLES}, and you don't need cursors when you can update records
-on the fly.
-
-We at TcX had a greater need for a real fast database than a 100%
-general database. Whenever we find a way to implement these features without
-any speed loss, we will probably do it. For the moment, there are many more
-important things to do. Check the TODO for how we prioritize things at
-the moment. (Customers with higher levels of support can alter this, so
-things may be reprioritized.)
-
-The current problem is actually @code{ROLLBACK}. Without
-@code{ROLLBACK}, you can do any kind of @code{COMMIT} action with
-@code{LOCK TABLES}. To support @code{ROLLBACK} with the above table
-types, @strong{MySQL} would have to be changed to store all old records
-that were updated and revert everything back to the starting point if
-@code{ROLLBACK} was issued. For simple cases, this isn't that hard to do
-(the current @code{isamlog} could be used for this purpose), but it
-would be much more difficult to implement @code{ROLLBACK} for
-@code{ALTER/DROP/CREATE TABLE}.
-
-To avoid using @code{ROLLBACK}, you can use the following strategy:
+@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}.
-@enumerate
-@item
-Use @code{LOCK TABLES ...} to lock all the tables you want to access.
-@item
-Test conditions.
-@item
-Update if everything is okay.
@item
-Use @code{UNLOCK TABLES} to release your locks.
-@end enumerate
-
-This is usually a much faster method than using transactions with possible
-@code{ROLLBACK}s, although not always. The only situation this solution
-doesn't handle is when someone kills the threads in the middle of an
-update. In this case, all locks will be released but some of the updates may
-not have been executed.
-
-You can also use functions to update records in a single operation.
-You can get a very efficient application by using the following techniques:
-
-@itemize @bullet
-@item Modify fields relative to their current value.
-@item Update only those fields that actually have changed.
+@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
-For example, when we are doing updates to some customer information, we
-update only the customer data that has changed and test only that none of
-the changed data, or data that depend on the changed data, has changed
-compared to the original row. The test for changed data is done with the
-@code{WHERE} clause in the @code{UPDATE} statement. If the record wasn't
-updated, we give the client a message: "Some of the data you have changed
-have been changed by another user". Then we show the old row versus the new
-row in a window, so the user can decide which version of the customer record
-he should use.
-
-This gives us something that is similar to column locking but is actually
-even better, because we only update some of the columns, using values that
-are relative to their current values. This means that typical @code{UPDATE}
-statements look something like these:
-
-@example
-UPDATE tablename SET pay_back=pay_back+'relative change';
-UPDATE customer
- SET
- customer_date='current_date',
- address='new address',
- phone='new phone',
- money_he_owes_us=money_he_owes_us+'new_money'
- WHERE
- customer_id=id AND address='old address' AND phone='old phone';
-@end example
+@node Privilege system, User Account Management, Configuring MySQL, MySQL Database Administration
+@section General Security Issues and the MySQL Access Privilege System
-As you can see, this is very efficient and works even if another client has
-changed the values in the @code{pay_back} or @code{money_he_owes_us} columns.
-
-@findex mysql_insert_id()
-@findex LAST_INSERT_ID()
-In many cases, users have wanted @code{ROLLBACK} and/or @code{LOCK
-TABLES} for the purpose of managing unique identifiers for some tables. This
-can be handled much more efficiently by using an @code{AUTO_INCREMENT} column
-and either the SQL function @code{LAST_INSERT_ID()} or the C API function
-@code{mysql_insert_id()}. @xref{mysql_insert_id, , @code{mysql_insert_id()}}.
-
-@cindex rows, locking
-At @strong{MySQL AB}, we have never had any need for row-level locking
-because we have always been able to code around it. Some cases really need
-row locking, but they are very few. If you want row-level locking, you
-can use a flag column in the table and do something like this:
-
-@example
-UPDATE tbl_name SET row_flag=1 WHERE id=ID;
-@end example
-
-@strong{MySQL} returns 1 for the number of affected rows if the row was
-found and @code{row_flag} wasn't already 1 in the original row.
-
-You can think of it as @strong{MySQL} changed the above query to:
-
-@example
-UPDATE tbl_name SET row_flag=1 WHERE id=ID and row_flag <> 1;
-@end example
-
-@node Privilege system, Reference, Compatibility, Top
-@chapter The MySQL Access Privilege System
@cindex system, security
@cindex access privileges
@cindex privileges, access
@cindex security system
@cindex ACLs
-
-@strong{MySQL} has an advanced but non-standard security/privilege
+MySQL has an advanced but non-standard security/privilege
system. This section describes how it works.
@menu
* General security:: General security
-* Security:: How to make @strong{MySQL} secure against crackers
-* Privileges options::
+* Security:: How to make MySQL secure against crackers
+* Privileges options:: Startup Options for @code{mysqld} Concerning Security
* What Privileges:: What the privilege system does
-* User names:: @strong{MySQL} user names and passwords
-* Connecting:: Connecting to the @strong{MySQL} server
-* Password security:: Keeping your password secure
-* Privileges provided:: Privileges provided by @strong{MySQL}
* Privileges:: How the privilege system works
+* Privileges provided:: Privileges provided by MySQL
+* Connecting:: Connecting to the MySQL server
* Connection access:: Access control, stage 1: Connection verification
* Request access:: Access control, stage 2: Request verification
-* Privilege changes:: When privilege changes take effect
-* Default privileges:: Setting up the initial @strong{MySQL} privileges
-* Adding users:: Adding new users to @strong{MySQL}
-* Passwords:: How to set up passwords
* Access denied:: Causes of @code{Access denied} errors
@end menu
+
@node General security, Security, Privilege system, Privilege system
-@section General Security
+@subsection General Security Guidelines
-Anyone using @strong{MySQL} on a computer connected to the Internet
+Anyone using MySQL on a computer connected to the Internet
should read this section to avoid the most common security mistakes.
In discussing security, we emphasize the necessity of fully protecting the
-entire server host (not simply the @strong{MySQL} server) against all types
+entire server host (not simply the MySQL server) against all types
of applicable attacks: eavesdropping, altering, playback, and denial of
service. We do not cover all aspects of availability and fault tolerance
here.
-@strong{MySQL} uses security based on Access Control Lists (ACLs) for all
+MySQL uses security based on Access Control Lists (ACLs) for all
connections, queries, and other operations that a user may attempt to
perform. There is also some support for SSL-encrypted connections
-between @strong{MySQL} clients and servers. Many of the concepts
-discussed here are not specific to @strong{MySQL} at all; the same
+between MySQL clients and servers. Many of the concepts
+discussed here are not specific to MySQL at all; the same
general ideas apply to almost all applications.
-When running @strong{MySQL}, follow these guidelines whenever possible:
+When running MySQL, follow these guidelines whenever possible:
@itemize @bullet
@item
-DON'T EVER GIVE ANYONE (EXCEPT THE @strong{MySQL} ROOT USER) ACCESS TO THE
+DON'T EVER GIVE ANYONE (EXCEPT THE MySQL ROOT USER) ACCESS TO THE
@code{user} TABLE IN THE @code{mysql} DATABASE! The encrypted password
-is the real password in @strong{MySQL}. If you know the password listed in
+is the real password in MySQL. If you know the password listed in
the @code{user} table for a given user, you can easily log in as that
user if you have access to the host listed for that account.
@item
-Learn the @strong{MySQL} access privilege system. The @code{GRANT} and
-@code{REVOKE} commands are used for controlling access to @strong{MySQL}. Do
+Learn the MySQL access privilege system. The @code{GRANT} and
+@code{REVOKE} commands are used for controlling access to MySQL. Do
not grant any more privileges than necessary. Never grant privileges to all
hosts.
@@ -12087,9 +15379,9 @@ Checklist:
@item
Try @code{mysql -u root}. If you are able to connect successfully to the
server without being asked for a password, you have problems. Anyone
-can connect to your @strong{MySQL} server as the @strong{MySQL}
+can connect to your MySQL server as the MySQL
@code{root} user with full privileges!
-Review the @strong{MySQL} installation instructions, paying particular
+Review the MySQL installation instructions, paying particular
attention to the item about setting a @code{root} password.
@item
Use the command @code{SHOW GRANTS} and check to see who has access to
@@ -12112,18 +15404,18 @@ a little lamb.'' This is easy to remember and type, but difficult to guess
for someone who does not know it.
@item
Invest in a firewall. This protects you from at least 50% of all types of
-exploits in any software. Put @strong{MySQL} behind the firewall or in
+exploits in any software. Put MySQL behind the firewall or in
a demilitarized zone (DMZ).
Checklist:
@itemize @minus
@item
Try to scan your ports from the Internet using a tool such as
-@code{nmap}. @strong{MySQL} uses port 3306 by default. This port should
+@code{nmap}. MySQL uses port 3306 by default. This port should
be inaccessible from untrusted hosts. Another simple way to check whether
-or not your @strong{MySQL} port is open is to try the following command
+or not your MySQL port is open is to try the following command
from some remote machine, where @code{server_host} is the hostname of
-your @strong{MySQL} server:
+your MySQL server:
@example
shell> telnet server_host 3306
@@ -12151,7 +15443,7 @@ denial-of-service type attacks can be performed on such
databases. The simplest way to protect from this type of attack is to use
apostrophes around the numeric constants: @code{SELECT * FROM table
WHERE ID='234'} rather than @code{SELECT * FROM table WHERE ID=234}.
-@strong{MySQL} automatically converts this string to a number and
+MySQL automatically converts this string to a number and
strips all non-numeric symbols from it.
Checklist:
@@ -12161,7 +15453,7 @@ All Web applications:
@itemize @bullet
@item
Try to enter @samp{'} and @samp{"} in all your Web forms. If you get any kind
-of @strong{MySQL} error, investigate the problem right away.
+of MySQL error, investigate the problem right away.
@item
Try to modify any dynamic URLs by adding @code{%22} (@samp{"}), @code{%23}
(@samp{#}), and @code{%27} (@samp{'}) in the URL.
@@ -12172,10 +15464,10 @@ should be safe against this and similar attacks.
@item
Try to enter characters, spaces, and special symbols instead of numbers in
numeric fields. Your application should remove them before passing them to
-@strong{MySQL} or your application should generate an error. Passing
-unchecked values to @strong{MySQL} is very dangerous!
+MySQL or your application should generate an error. Passing
+unchecked values to MySQL is very dangerous!
@item
-Check data sizes before passing them to @strong{MySQL}.
+Check data sizes before passing them to MySQL.
@item
Consider having your application connect to the database using a
different user name than the one you use for administrative purposes. Do
@@ -12186,15 +15478,15 @@ Users of PHP:
@itemize @bullet
@item Check out the @code{addslashes()} function.
As of PHP 4.0.3, a @code{mysql_escape_string()} function is available
-that is based on the function of the same name in the @strong{MySQL} C API.
+that is based on the function of the same name in the MySQL C API.
@end itemize
@item
-Users of @strong{MySQL} C API:
+Users of MySQL C API:
@itemize @bullet
@item Check out the @code{mysql_escape_string()} API call.
@end itemize
@item
-Users of @strong{MySQL}++:
+Users of MySQL++:
@itemize @bullet
@item Check out the @code{escape} and @code{quote} modifiers for query streams.
@end itemize
@@ -12214,12 +15506,12 @@ Users of Java JDBC:
Do not transmit plain (unencrypted) data over the Internet. These data are
accessible to everyone who has the time and ability to intercept it and use
it for their own purposes. Instead, use an encrypted protocol such as SSL or
-SSH. @strong{MySQL} supports internal SSL connections as of Version 3.23.9.
+SSH. MySQL supports internal SSL connections as of Version 3.23.9.
SSH port-forwarding can be used to create an encrypted (and compressed)
tunnel for the communication.
@item
Learn to use the @code{tcpdump} and @code{strings} utilities. For most cases,
-you can check whether or not @strong{MySQL} data streams are unencrypted
+you can check whether or not MySQL data streams are unencrypted
by issuing a command like the following:
@example
@@ -12232,12 +15524,14 @@ actually mean that it is encrypted. If you need high security, you should
consult with a security expert.
@end itemize
+
@node Security, Privileges options, General security, Privilege system
-@section How to Make MySQL Secure Against Crackers
+@subsection How to Make MySQL Secure Against Crackers
+
@cindex crackers, security against
@cindex security, against crackers
-When you connect to a @strong{MySQL} server, you normally should use a
+When you connect to a MySQL server, you normally should use a
password. The password is not transmitted in clear text over the
connection, however the encryption algorithm is not very strong, and
with some effort a clever attacker can crack the password if he is able
@@ -12248,24 +15542,24 @@ communication.
All other information is transferred as text that can be read by anyone
who is able to watch the connection. If you are concerned about this,
-you can use the compressed protocol (in @strong{MySQL} Version 3.22 and above)
+you can use the compressed protocol (in MySQL Version 3.22 and above)
to make things much harder. To make things even more secure you should use
@code{ssh}. You can find an open source @code{ssh} client at
@uref{http://www.openssh.org}, and a commercial @code{ssh} client at
@uref{http://www.ssh.com}. With this, you can get an encrypted TCP/IP
-connection between a @strong{MySQL} server and a @strong{MySQL} client.
+connection between a MySQL server and a MySQL client.
-To make a @strong{MySQL} system secure, you should strongly consider the
+To make a MySQL system secure, you should strongly consider the
following suggestions:
@itemize @bullet
@item
-Use passwords for all @strong{MySQL} users. Remember that anyone can log in
+Use passwords for all MySQL users. Remember that anyone can log in
as any other person as simply as @code{mysql -u other_user db_name} if
@code{other_user} has no password. It is common behavior with client/server
applications that the client may specify any user name. You can change the
password of all users by editing the @code{mysql_install_db} script before
-you run it, or only the password for the @strong{MySQL} @code{root} user like
+you run it, or only the password for the MySQL @code{root} user like
this:
@example
@@ -12276,7 +15570,7 @@ mysql> FLUSH PRIVILEGES;
@end example
@item
-Don't run the @strong{MySQL} daemon as the Unix @code{root} user. This is
+Don't run the MySQL daemon as the Unix @code{root} user. This is
very dangerous, because any user with @code{FILE} privileges will be able
to create files as @code{root} (for example, @code{~root/.bashrc}). To
prevent this, @code{mysqld} will refuse to run as @code{root} unless it
@@ -12286,7 +15580,7 @@ is specified directly using a @code{--user=root} option.
You can also create a new Unix user @code{mysql} to make everything
even more secure. If you run @code{mysqld} as another Unix user,
you don't need to change the @code{root} user name in the @code{user}
-table, because @strong{MySQL} user names have nothing to do with Unix
+table, because MySQL user names have nothing to do with Unix
user names. To start @code{mysqld} as another Unix user, add a @code{user}
line that specifies the user name to the @code{[mysqld]} group of the
@file{/etc/my.cnf} option file or the @file{my.cnf} option file in the
@@ -12299,7 +15593,7 @@ user=mysql
This will cause the server to start as the designated user whether you
start it manually or by using @code{safe_mysqld} or @code{mysql.server}.
-For more details, see @ref{Changing MySQL user, , Changing @strong{MySQL}
+For more details, see @ref{Changing MySQL user, , Changing MySQL
user}.
@item
@@ -12321,7 +15615,7 @@ see if another user issues an @code{UPDATE user SET
password=PASSWORD('not_secure')} query.
@code{mysqld} reserves an extra connection for users who have the
-@strong{process} privilege, so that a @strong{MySQL} @code{root} user can log
+@strong{process} privilege, so that a MySQL @code{root} user can log
in and check things even if all normal connections are in use.
@item
@@ -12338,11 +15632,10 @@ by using @code{LOAD DATA} to load @file{/etc/passwd} into a table, which
can then be read with @code{SELECT}.
@item
-If you don't trust your DNS, you should use IP numbers instead of hostnames
-in the grant tables. In principle, the @code{--secure} option to
-@code{mysqld} should make hostnames safe. In any case, you should be very
-careful about creating grant table entries using hostname values that
-contain wild cards!
+If you don't trust your DNS, you should use IP numbers instead of
+hostnames in the grant tables. In any case, you should be very careful
+about creating grant table entries using hostname values that contain
+wild cards!
@item
If you want to restrict the number of connections for a single user, you
@@ -12350,21 +15643,32 @@ can do this by setting the @code{max_user_connections} variable in
@code{mysqld}.
@end itemize
+
+
@node Privileges options, What Privileges, Security, Privilege system
-@section Startup Options for @code{mysqld} Concerning Security
+@subsection Startup Options for @code{mysqld} Concerning Security
-The following @code{mysqld} options affect networking security:
+The following @code{mysqld} options affect security:
@table @code
-@item --secure
-IP numbers returned by the @code{gethostbyname()} system call are
-checked to make sure they resolve back to the original hostname. This
-makes it harder for someone on the outside to get access by pretending
-to be another host. This option also adds some sanity checks of
-hostnames. The option is turned off by default in @strong{MySQL} Version
-3.21 because sometimes it takes a long time to perform backward resolutions.
-@strong{MySQL} Version 3.22 caches hostnames and has this option enabled by
-default.
+@item --safe-show-database
+With this option,
+@code{SHOW DATABASES} returns only those databases for which the user has
+some kind of privilege.
+
+@item --safe-user-create
+If this is enabled, an user can't create new users with the @code{GRANT}
+command, if the user doesn't have @code{INSERT} privilege to the
+@code{mysql.user} table. If you want to give a user access to just create
+new users with those privileges that the user has right to grant, you should
+give the user the following privilege:
+
+@example
+GRANT INSERT(user) on mysql.user to 'user'@'hostname';
+@end example
+
+This will ensure that the user can't change any privilege columns directly,
+but has to use the @code{GRANT} command to give privileges to other users.
@item --skip-grant-tables
This option causes the server not to use the privilege system at all. This
@@ -12386,275 +15690,243 @@ support Unix sockets.
With this option, the
@code{SHOW DATABASES} statement doesn't return anything.
-@item --safe-show-database
-With this option,
-@code{SHOW DATABASES} returns only those databases for which the user has
-some kind of privilege.
-
@end table
-@node What Privileges, User names, Privileges options, Privilege system
-@section What the Privilege System Does
+
+@node What Privileges, Privileges, Privileges options, Privilege system
+@subsection What the Privilege System Does
+
@cindex system, privilege
@cindex privilege system
@cindex passwords, security
-The primary function of the @strong{MySQL} privilege system is to
+The primary function of the MySQL privilege system is to
authenticate a user connecting from a given host, and to associate that user
with privileges on a database such as
@strong{select}, @strong{insert}, @strong{update} and @strong{delete}.
Additional functionality includes the ability to have an anonymous user and
-to grant privileges for @strong{MySQL}-specific functions such as @code{LOAD
+to grant privileges for MySQL-specific functions such as @code{LOAD
DATA INFILE} and administrative operations.
-@node User names, Connecting, What Privileges, Privilege system
-@section MySQL User Names and Passwords
-@cindex user names, and passwords
-@cindex passwords, for users
-There are several distinctions between the way user names and passwords are
-used by @strong{MySQL} and the way they are used by Unix or Windows:
+@node Privileges, Privileges provided, What Privileges, Privilege system
+@subsection How the Privilege System Works
-@itemize @bullet
-@item
-User names, as used by @strong{MySQL} for authentication purposes, have
-nothing to do with Unix user names (login names) or Windows user names. Most
-@strong{MySQL} clients by default try to log in using the current Unix user
-name as the @strong{MySQL} user name, but that is for convenience only.
-Client programs allow a different name to be specified with the @code{-u} or
-@code{--user} options. This means that you can't make a database secure in
-any way unless all @strong{MySQL} user names have passwords. Anyone may
-attempt to connect to the server using any name, and they will succeed if
-they specify any name that doesn't have a password.
+@cindex privilege system, described
-@item
-@strong{MySQL} user names can be up to 16 characters long; Unix user names
-typically are limited to 8 characters.
+The MySQL privilege system ensures that all users may do exactly the
+things that they are supposed to be allowed to do. When you connect to a
+MySQL server, your identity is determined by @strong{the host from
+which you connect} and @strong{the user name you specify}. The system grants
+privileges according to your identity and @strong{what you want to do}.
+MySQL considers both your hostname and user name in identifying you
+because there is little reason to assume that a given user name belongs to
+the same person everywhere on the Internet. For example, the user
+@code{bill} who connects from @code{whitehouse.gov} need not be the same
+person as the user @code{bill} who connects from @code{microsoft.com}.
+MySQL handles this by allowing you to distinguish users on different
+hosts that happen to have the same name: you can grant @code{bill} one set
+of privileges for connections from @code{whitehouse.gov}, and a different set
+of privileges for connections from @code{microsoft.com}.
+
+MySQL access control involves two stages:
+
+@itemize @bullet
@item
-@strong{MySQL} passwords have nothing to do with Unix passwords. There is no
-necessary connection between the password you use to log in to a Unix machine
-and the password you use to access a database on that machine.
+Stage 1: The server checks whether or not you are even allowed to connect.
@item
-@strong{MySQL} encrypts passwords using a different algorithm than the
-one used during the Unix login process. See the descriptions of the
-@code{PASSWORD()} and @code{ENCRYPT()} functions in @ref{Miscellaneous
-functions}. Note that even if the password is stored 'scrambled', and
-knowing your 'scrambled' password is enough to be able to connect to
-the @strong{MySQL} server!
+Stage 2: Assuming you can connect, the server checks each request you issue
+to see whether or not you have sufficient privileges to perform it. For
+example, if you try to select rows from a table in a database or drop a table
+from the database, the server makes sure you have the @strong{select}
+privilege for the table or the @strong{drop} privilege for the database.
@end itemize
-@strong{MySQL} users and they privileges are normally created with the
-@code{GRANT} command. @xref{GRANT}.
-
-When you login to a @strong{MySQL} server with a command line client you
-should specify the password with @code{--password=your-password}.
-@xref{Connecting}.
-
-@example
-mysql --user=monty --password=guess database_name
-@end example
-
-If you want the client to prompt for a password, you should use
-@code{--password} without any argument
-
-@example
-mysql --user=monty --password database_name
-@end example
-
-or the short form:
+The server uses the @code{user}, @code{db}, and @code{host} tables in the
+@code{mysql} database at both stages of access control. The fields in these
+grant tables are shown below:
-@example
-mysql -u monty -p database_name
-@end example
+@multitable @columnfractions .2 .25 .25 .25
+@item @strong{Table name} @tab @code{user} @tab @code{db} @tab @code{host}
-Note that in the last example the password is @strong{NOT} 'database_name'.
+@item @strong{Scope fields} @tab @code{Host} @tab @code{Host} @tab @code{Host}
+@item @tab @code{User} @tab @code{Db} @tab @code{Db}
+@item @tab @code{Password} @tab @code{User} @tab
-If you want to use the -p option to supply a password you should do like this:
+@item @strong{Privilege fields} @tab @code{Select_priv} @tab @code{Select_priv} @tab @code{Select_priv}
+@item @tab @code{Insert_priv} @tab @code{Insert_priv} @tab @code{Insert_priv}
+@item @tab @code{Update_priv} @tab @code{Update_priv} @tab @code{Update_priv}
+@item @tab @code{Delete_priv} @tab @code{Delete_priv} @tab @code{Delete_priv}
+@item @tab @code{Index_priv} @tab @code{Index_priv} @tab @code{Index_priv}
+@item @tab @code{Alter_priv} @tab @code{Alter_priv} @tab @code{Alter_priv}
+@item @tab @code{Create_priv} @tab @code{Create_priv} @tab @code{Create_priv}
+@item @tab @code{Drop_priv} @tab @code{Drop_priv} @tab @code{Drop_priv}
+@item @tab @code{Grant_priv} @tab @code{Grant_priv} @tab @code{Grant_priv}
+@item @tab @code{References_priv} @tab @tab
+@item @tab @code{Reload_priv} @tab @tab
+@item @tab @code{Shutdown_priv} @tab @tab
+@item @tab @code{Process_priv} @tab @tab
+@item @tab @code{File_priv} @tab @tab
+@end multitable
-@example
-mysql -u monty -pguess database_name
-@end example
+For the second stage of access control (request verification), the server
+may, if the request involves tables, additionally consult the
+@code{tables_priv} and @code{columns_priv} tables. The fields in these
+tables are shown below:
-On some system the library call that @strong{MySQL} uses to prompt for a
-password will automaticly cut the password to 8 characters. Internally
-@strong{MySQL} doesn't have any limit for the length of the password.
+@multitable @columnfractions .2 .25 .25
+@item @strong{Table name} @tab @code{tables_priv} @tab @code{columns_priv}
-@node Connecting, Password security, User names, Privilege system
-@section Connecting to the MySQL Server
-@cindex connecting, to the server
-@cindex default hostname
-@cindex hostname, default
-@cindex server, connecting
+@item @strong{Scope fields} @tab @code{Host} @tab @code{Host}
+@item @tab @code{Db} @tab @code{Db}
+@item @tab @code{User} @tab @code{User}
+@item @tab @code{Table_name} @tab @code{Table_name}
+@item @tab @tab @code{Column_name}
-@strong{MySQL} client programs generally require that you specify connection
-parameters when you want to access a @strong{MySQL} server: the host you want
-to connect to, your user name, and your password. For example, the
-@code{mysql} client can be started like this (optional arguments are enclosed
-between @samp{[} and @samp{]}):
+@item @strong{Privilege fields} @tab @code{Table_priv} @tab @code{Column_priv}
+@item @tab @code{Column_priv} @tab
-@example
-shell> mysql [-h host_name] [-u user_name] [-pyour_pass]
-@end example
+@item @strong{Other fields} @tab @code{Timestamp} @tab @code{Timestamp}
+@item @tab @code{Grantor} @tab
+@end multitable
-Alternate forms of the @code{-h}, @code{-u}, and @code{-p} options are
-@code{--host=host_name}, @code{--user=user_name}, and
-@code{--password=your_pass}. Note that there is @emph{no space} between
-@code{-p} or @code{--password=} and the password following it.
+Each grant table contains scope fields and privilege fields.
-@strong{NOTE:} Specifying a password on the command line is not secure!
-Any user on your system may then find out your password by typing a command
-like: @code{ps auxww}. @xref{Option files}.
+Scope fields determine the scope of each entry in the tables, that is, the
+context in which the entry applies. For example, a @code{user} table entry
+with @code{Host} and @code{User} values of @code{'thomas.loc.gov'} and
+@code{'bob'} would be used for authenticating connections made to the server
+by @code{bob} from the host @code{thomas.loc.gov}. Similarly, a @code{db}
+table entry with @code{Host}, @code{User}, and @code{Db} fields of
+@code{'thomas.loc.gov'}, @code{'bob'} and @code{'reports'} would be used when
+@code{bob} connects from the host @code{thomas.loc.gov} to access the
+@code{reports} database. The @code{tables_priv} and @code{columns_priv}
+tables contain scope fields indicating tables or table/column combinations
+to which each entry applies.
-@code{mysql} uses default values for connection parameters that are missing
-from the command line:
+@cindex case sensitivity, in access checking
+For access-checking purposes, comparisons of @code{Host} values are
+case insensitive. @code{User}, @code{Password}, @code{Db}, and
+@code{Table_name} values are case sensitive.
+@code{Column_name} values are case insensitive in MySQL Version
+3.22.12 or later.
-@itemize @bullet
-@item
-The default hostname is @code{localhost}.
+Privilege fields indicate the privileges granted by a table entry, that is,
+what operations can be performed. The server combines the information in the
+various grant tables to form a complete description of a user's privileges.
+The rules used to do this are described in @ref{Request access}.
-@item
-The default user name is your Unix login name.
+Scope fields are strings, declared as shown below; the default value for
+each is the empty string:
-@item
-No password is supplied if @code{-p} is missing.
-@end itemize
+@multitable @columnfractions .15 .15 .7
+@item @strong{Field name} @tab @strong{Type}
+@item @code{Host} @tab @code{CHAR(60)}
+@item @code{User} @tab @code{CHAR(16)}
+@item @code{Password} @tab @code{CHAR(16)}
+@item @code{Db} @tab @code{CHAR(64)} @tab (@code{CHAR(60)} for the
+@code{tables_priv} and @code{columns_priv} tables)
+@item @code{Table_name} @tab @code{CHAR(60)}
+@item @code{Column_name} @tab @code{CHAR(60)}
+@end multitable
-Thus, for a Unix user @code{joe}, the following commands are equivalent:
+In the @code{user}, @code{db} and @code{host} tables,
+all privilege fields are declared as @code{ENUM('N','Y')} --- each can have a
+value of @code{'N'} or @code{'Y'}, and the default value is @code{'N'}.
-@example
-shell> mysql -h localhost -u joe
-shell> mysql -h localhost
-shell> mysql -u joe
-shell> mysql
-@end example
+In the @code{tables_priv} and @code{columns_priv} tables, the privilege
+fields are declared as @code{SET} fields:
-Other @strong{MySQL} clients behave similarly.
+@multitable @columnfractions .2 .2 .6
+@item @strong{Table name} @tab @strong{Field name} @tab @strong{Possible set elements}
+@item @code{tables_priv} @tab @code{Table_priv} @tab @code{'Select', 'Insert',
+'Update', 'Delete', 'Create', 'Drop', 'Grant', 'References', 'Index', 'Alter'}
+@item @code{tables_priv} @tab @code{Column_priv} @tab @code{'Select', 'Insert',
+'Update', 'References'}
+@item @code{columns_priv} @tab @code{Column_priv} @tab @code{'Select', 'Insert',
+'Update', 'References'}
+@end multitable
-On Unix systems, you can specify different default values to be used when you
-make a connection, so that you need not enter them on the command line each
-time you invoke a client program. This can be done in a couple of ways:
+Briefly, the server uses the grant tables like this:
@itemize @bullet
@item
-@tindex .my.cnf file
-You can specify connection parameters in the @code{[client]} section of the
-@file{.my.cnf} configuration file in your home directory. The relevant
-section of the file might look like this:
-
-@example
-[client]
-host=host_name
-user=user_name
-password=your_pass
-@end example
-
-@xref{Option files}.
+The @code{user} table scope fields determine whether to allow or reject
+incoming connections. For allowed connections, any privileges granted in
+the @code{user} table indicate the user's global (superuser) privileges.
+These privileges apply to @strong{all} databases on the server.
@item
-@tindex MYSQL_HOST environment variable
-@tindex Environment variable, MYSQL_HOST
-@tindex MYSQL_PWD environment variable
-@tindex Environment variable, MYSQL_PWD
-@tindex USER environment variable
-@tindex Environment variable, USER
-You can specify connection parameters using environment variables. The
-host can be specified for @code{mysql} using @code{MYSQL_HOST}. The
-@strong{MySQL} user name can be specified using @code{USER} (this is for
-Windows only). The password can be specified using @code{MYSQL_PWD}
-(but this is insecure; see the next section). @xref{Environment variables}.
-@end itemize
-
-@node Password security, Privileges provided, Connecting, Privilege system
-@section Keeping Your Password Secure
-
-It is inadvisable to specify your password in a way that exposes it to
-discovery by other users. The methods you can use to specify your password
-when you run client programs are listed below, along with an assessment of
-the risks of each method:
+The @code{db} and @code{host} tables are used together:
-@itemize @bullet
+@itemize @minus
@item
-Never give a normal user access to the @code{mysql.user} table. Knowing
-the encrypted password for a user makes it possible to login as this
-user. The passwords are only scrambled so that one shouldn't be able to
-see the real password you used (if you happen to use a similar password
-with your other applications).
+The @code{db} table scope fields determine which users can access which
+databases from which hosts. The privilege fields determine which operations
+are allowed.
@item
-Use a @code{-pyour_pass} or @code{--password=your_pass} option on the command
-line. This is convenient but insecure, because your password becomes visible
-to system status programs (such as @code{ps}) that may be invoked by other
-users to display command lines. (@strong{MySQL} clients typically overwrite
-the command-line argument with zeroes during their initialization sequence,
-but there is still a brief interval during which the value is visible.)
+The @code{host} table is used as an extension of the @code{db} table when you
+want a given @code{db} table entry to apply to several hosts. For example,
+if you want a user to be able to use a database from several hosts in
+your network, leave the @code{Host} value empty in the user's @code{db} table
+entry, then populate the @code{host} table with an entry for each of those
+hosts. This mechanism is described more detail in @ref{Request access}.
+@end itemize
@item
-Use a @code{-p} or @code{--password} option (with no @code{your_pass} value
-specified). In this case, the client program solicits the password from
-the terminal:
-@findex -p option
-@findex -password option
-
-@example
-shell> mysql -u user_name -p
-Enter password: ********
-@end example
+The @code{tables_priv} and @code{columns_priv} tables are similar to
+the @code{db} table, but are more fine-grained: they apply at the
+table and column levels rather than at the database level.
+@end itemize
-The @samp{*} characters represent your password.
+Note that administrative privileges (@strong{reload}, @strong{shutdown},
+etc.) are specified only in the @code{user} table. This is because
+administrative operations are operations on the server itself and are not
+database-specific, so there is no reason to list such privileges in the
+other grant tables. In fact, only the @code{user} table need
+be consulted to determine whether or not you can perform an administrative
+operation.
-It is more secure to enter your password this way than to specify it on the
-command line because it is not visible to other users. However, this method
-of entering a password is suitable only for programs that you run
-interactively. If you want to invoke a client from a script that runs
-non-interactively, there is no opportunity to enter the password from the
-terminal. On some systems, you may even find that the first line of your
-script is read and interpreted (incorrectly) as your password!
+The @strong{file} privilege is specified only in the @code{user} table, too.
+It is not an administrative privilege as such, but your ability to read or
+write files on the server host is independent of the database you are
+accessing.
-@item
-@tindex .my.cnf file
-Store your password in a configuration file. For example, you can list your
-password in the @code{[client]} section of the @file{.my.cnf} file in your
-home directory:
+The @code{mysqld} server reads the contents of the grant tables once, when it
+starts up. Changes to the grant tables take effect as indicated in
+@ref{Privilege changes}.
-@example
-[client]
-password=your_pass
-@end example
+When you modify the contents of the grant tables, it is a good idea to make
+sure that your changes set up privileges the way you want. For help in
+diagnosing problems, see @ref{Access denied}. For advice on security issues,
+@pxref{Security}.
-If you store your password in @file{.my.cnf}, the file should not be group or
-world readable or writable. Make sure the file's access mode is @code{400}
-or @code{600}.
+A useful
+diagnostic tool is the @code{mysqlaccess} script, which Yves Carlier has
+provided for the MySQL distribution. Invoke @code{mysqlaccess} with
+the @code{--help} option to find out how it works.
+Note that @code{mysqlaccess} checks access using only the @code{user},
+@code{db} and @code{host} tables. It does not check table- or column-level
+privileges.
-@xref{Option files}.
-@item
-You can store your password in the @code{MYSQL_PWD} environment variable, but
-this method must be considered extremely insecure and should not be used.
-Some versions of @code{ps} include an option to display the environment of
-running processes; your password will be in plain sight for all to see if
-you set @code{MYSQL_PWD}. Even on systems without such a version of
-@code{ps}, it is unwise to assume there is no other method to observe process
-environments. @xref{Environment variables}.
-@end itemize
-All in all, the safest methods are to have the client program prompt for the
-password or to specify the password in a properly protected @file{.my.cnf}
-file.
+@node Privileges provided, Connecting, Privileges, Privilege system
+@subsection Privileges Provided by MySQL
-@node Privileges provided, Privileges, Password security, Privilege system
-@section Privileges Provided by MySQL
@cindex privilege information, location
Information about user privileges is stored in the @code{user}, @code{db},
@code{host}, @code{tables_priv}, and @code{columns_priv} tables in the
@code{mysql} database (that is, in the database named @code{mysql}). The
-@strong{MySQL} server reads the contents of these tables when it starts up
+MySQL server reads the contents of these tables when it starts up
and under the circumstances indicated in @ref{Privilege changes}.
The names used in this manual to refer to the privileges provided by
-@strong{MySQL} are shown below, along with the table column name associated
+MySQL are shown below, along with the table column name associated
with each privilege in the grant tables and the context in which the
privilege applies:
@@ -12700,7 +15972,7 @@ databases and tables, or to drop (remove) existing databases and tables.
Note that if you grant the @strong{drop} privilege for the @code{mysql}
database to a user, that user can drop the database in which the
-@strong{MySQL} access privileges are stored!
+MySQL access privileges are stored!
The @strong{grant} privilege allows you to give to other users those
privileges you yourself possess.
@@ -12708,7 +15980,7 @@ privileges you yourself possess.
The @strong{file} privilege gives you permission to read and write files on
the server using the @code{LOAD DATA INFILE} and @code{SELECT ... INTO
OUTFILE} statements. Any user to whom this privilege is granted can read or
-write any file that the @strong{MySQL} server can read or write.
+write any file that the MySQL server can read or write.
The remaining privileges are used for administrative operations, which are
performed using the @code{mysqladmin} program. The table below shows which
@@ -12773,12 +16045,12 @@ Privileges on the @code{mysql} database can be used to change passwords
and other access privilege information. (Passwords are stored
encrypted, so a malicious user cannot simply read them to know the plain
text password). If they can access the @code{mysql.user} password
-column, they can use it to log into the @strong{MySQL} server
+column, they can use it to log into the MySQL server
for the given user. (With sufficient privileges, the same user can
replace a password with a different one.)
@end itemize
-There are some things that you cannot do with the @strong{MySQL}
+There are some things that you cannot do with the MySQL
privilege system:
@itemize @bullet
@@ -12791,216 +16063,103 @@ You cannot specify that a user has privileges to create or drop tables
in a database but not to create or drop the database itself.
@end itemize
-@node Privileges, Connection access, Privileges provided, Privilege system
-@section How the Privilege System Works
-@cindex privilege system, described
-
-The @strong{MySQL} privilege system ensures that all users may do exactly the
-things that they are supposed to be allowed to do. When you connect to a
-@strong{MySQL} server, your identity is determined by @strong{the host from
-which you connect} and @strong{the user name you specify}. The system grants
-privileges according to your identity and @strong{what you want to do}.
-
-@strong{MySQL} considers both your hostname and user name in identifying you
-because there is little reason to assume that a given user name belongs to
-the same person everywhere on the Internet. For example, the user
-@code{bill} who connects from @code{whitehouse.gov} need not be the same
-person as the user @code{bill} who connects from @code{microsoft.com}.
-@strong{MySQL} handles this by allowing you to distinguish users on different
-hosts that happen to have the same name: you can grant @code{bill} one set
-of privileges for connections from @code{whitehouse.gov}, and a different set
-of privileges for connections from @code{microsoft.com}.
-
-@strong{MySQL} access control involves two stages:
-
-@itemize @bullet
-@item
-Stage 1: The server checks whether or not you are even allowed to connect.
-
-@item
-Stage 2: Assuming you can connect, the server checks each request you issue
-to see whether or not you have sufficient privileges to perform it. For
-example, if you try to select rows from a table in a database or drop a table
-from the database, the server makes sure you have the @strong{select}
-privilege for the table or the @strong{drop} privilege for the database.
-@end itemize
-
-The server uses the @code{user}, @code{db}, and @code{host} tables in the
-@code{mysql} database at both stages of access control. The fields in these
-grant tables are shown below:
-@multitable @columnfractions .2 .25 .25 .25
-@item @strong{Table name} @tab @code{user} @tab @code{db} @tab @code{host}
+@node Connecting, Connection access, Privileges provided, Privilege system
+@subsection Connecting to the MySQL Server
-@item @strong{Scope fields} @tab @code{Host} @tab @code{Host} @tab @code{Host}
-@item @tab @code{User} @tab @code{Db} @tab @code{Db}
-@item @tab @code{Password} @tab @code{User} @tab
-
-@item @strong{Privilege fields} @tab @code{Select_priv} @tab @code{Select_priv} @tab @code{Select_priv}
-@item @tab @code{Insert_priv} @tab @code{Insert_priv} @tab @code{Insert_priv}
-@item @tab @code{Update_priv} @tab @code{Update_priv} @tab @code{Update_priv}
-@item @tab @code{Delete_priv} @tab @code{Delete_priv} @tab @code{Delete_priv}
-@item @tab @code{Index_priv} @tab @code{Index_priv} @tab @code{Index_priv}
-@item @tab @code{Alter_priv} @tab @code{Alter_priv} @tab @code{Alter_priv}
-@item @tab @code{Create_priv} @tab @code{Create_priv} @tab @code{Create_priv}
-@item @tab @code{Drop_priv} @tab @code{Drop_priv} @tab @code{Drop_priv}
-@item @tab @code{Grant_priv} @tab @code{Grant_priv} @tab @code{Grant_priv}
-@item @tab @code{References_priv} @tab @tab
-@item @tab @code{Reload_priv} @tab @tab
-@item @tab @code{Shutdown_priv} @tab @tab
-@item @tab @code{Process_priv} @tab @tab
-@item @tab @code{File_priv} @tab @tab
-@end multitable
-
-For the second stage of access control (request verification), the server
-may, if the request involves tables, additionally consult the
-@code{tables_priv} and @code{columns_priv} tables. The fields in these
-tables are shown below:
-
-@multitable @columnfractions .2 .25 .25
-@item @strong{Table name} @tab @code{tables_priv} @tab @code{columns_priv}
-
-@item @strong{Scope fields} @tab @code{Host} @tab @code{Host}
-@item @tab @code{Db} @tab @code{Db}
-@item @tab @code{User} @tab @code{User}
-@item @tab @code{Table_name} @tab @code{Table_name}
-@item @tab @tab @code{Column_name}
+@cindex connecting, to the server
+@cindex default hostname
+@cindex hostname, default
+@cindex server, connecting
-@item @strong{Privilege fields} @tab @code{Table_priv} @tab @code{Column_priv}
-@item @tab @code{Column_priv} @tab
+MySQL client programs generally require that you specify connection
+parameters when you want to access a MySQL server: the host you want
+to connect to, your user name, and your password. For example, the
+@code{mysql} client can be started like this (optional arguments are enclosed
+between @samp{[} and @samp{]}):
-@item @strong{Other fields} @tab @code{Timestamp} @tab @code{Timestamp}
-@item @tab @code{Grantor} @tab
-@end multitable
+@example
+shell> mysql [-h host_name] [-u user_name] [-pyour_pass]
+@end example
-Each grant table contains scope fields and privilege fields.
+Alternate forms of the @code{-h}, @code{-u}, and @code{-p} options are
+@code{--host=host_name}, @code{--user=user_name}, and
+@code{--password=your_pass}. Note that there is @emph{no space} between
+@code{-p} or @code{--password=} and the password following it.
-Scope fields determine the scope of each entry in the tables, that is, the
-context in which the entry applies. For example, a @code{user} table entry
-with @code{Host} and @code{User} values of @code{'thomas.loc.gov'} and
-@code{'bob'} would be used for authenticating connections made to the server
-by @code{bob} from the host @code{thomas.loc.gov}. Similarly, a @code{db}
-table entry with @code{Host}, @code{User}, and @code{Db} fields of
-@code{'thomas.loc.gov'}, @code{'bob'} and @code{'reports'} would be used when
-@code{bob} connects from the host @code{thomas.loc.gov} to access the
-@code{reports} database. The @code{tables_priv} and @code{columns_priv}
-tables contain scope fields indicating tables or table/column combinations
-to which each entry applies.
+@strong{NOTE:} Specifying a password on the command line is not secure!
+Any user on your system may then find out your password by typing a command
+like: @code{ps auxww}. @xref{Option files}.
-@cindex case sensitivity, in access checking
-For access-checking purposes, comparisons of @code{Host} values are
-case insensitive. @code{User}, @code{Password}, @code{Db}, and
-@code{Table_name} values are case sensitive.
-@code{Column_name} values are case insensitive in @strong{MySQL} Version
-3.22.12 or later.
+@code{mysql} uses default values for connection parameters that are missing
+from the command line:
-Privilege fields indicate the privileges granted by a table entry, that is,
-what operations can be performed. The server combines the information in the
-various grant tables to form a complete description of a user's privileges.
-The rules used to do this are described in @ref{Request access}.
+@itemize @bullet
+@item
+The default hostname is @code{localhost}.
-Scope fields are strings, declared as shown below; the default value for
-each is the empty string:
+@item
+The default user name is your Unix login name.
-@multitable @columnfractions .15 .15 .7
-@item @strong{Field name} @tab @strong{Type}
-@item @code{Host} @tab @code{CHAR(60)}
-@item @code{User} @tab @code{CHAR(16)}
-@item @code{Password} @tab @code{CHAR(16)}
-@item @code{Db} @tab @code{CHAR(64)} @tab (@code{CHAR(60)} for the
-@code{tables_priv} and @code{columns_priv} tables)
-@item @code{Table_name} @tab @code{CHAR(60)}
-@item @code{Column_name} @tab @code{CHAR(60)}
-@end multitable
+@item
+No password is supplied if @code{-p} is missing.
+@end itemize
-In the @code{user}, @code{db} and @code{host} tables,
-all privilege fields are declared as @code{ENUM('N','Y')} --- each can have a
-value of @code{'N'} or @code{'Y'}, and the default value is @code{'N'}.
+Thus, for a Unix user @code{joe}, the following commands are equivalent:
-In the @code{tables_priv} and @code{columns_priv} tables, the privilege
-fields are declared as @code{SET} fields:
+@example
+shell> mysql -h localhost -u joe
+shell> mysql -h localhost
+shell> mysql -u joe
+shell> mysql
+@end example
-@multitable @columnfractions .2 .2 .6
-@item @strong{Table name} @tab @strong{Field name} @tab @strong{Possible set elements}
-@item @code{tables_priv} @tab @code{Table_priv} @tab @code{'Select', 'Insert',
-'Update', 'Delete', 'Create', 'Drop', 'Grant', 'References', 'Index', 'Alter'}
-@item @code{tables_priv} @tab @code{Column_priv} @tab @code{'Select', 'Insert',
-'Update', 'References'}
-@item @code{columns_priv} @tab @code{Column_priv} @tab @code{'Select', 'Insert',
-'Update', 'References'}
-@end multitable
+Other MySQL clients behave similarly.
-Briefly, the server uses the grant tables like this:
+On Unix systems, you can specify different default values to be used when you
+make a connection, so that you need not enter them on the command line each
+time you invoke a client program. This can be done in a couple of ways:
@itemize @bullet
@item
-The @code{user} table scope fields determine whether to allow or reject
-incoming connections. For allowed connections, any privileges granted in
-the @code{user} table indicate the user's global (superuser) privileges.
-These privileges apply to @strong{all} databases on the server.
-
-@item
-The @code{db} and @code{host} tables are used together:
+@tindex .my.cnf file
+You can specify connection parameters in the @code{[client]} section of the
+@file{.my.cnf} configuration file in your home directory. The relevant
+section of the file might look like this:
-@itemize @minus
-@item
-The @code{db} table scope fields determine which users can access which
-databases from which hosts. The privilege fields determine which operations
-are allowed.
+@example
+[client]
+host=host_name
+user=user_name
+password=your_pass
+@end example
-@item
-The @code{host} table is used as an extension of the @code{db} table when you
-want a given @code{db} table entry to apply to several hosts. For example,
-if you want a user to be able to use a database from several hosts in
-your network, leave the @code{Host} value empty in the user's @code{db} table
-entry, then populate the @code{host} table with an entry for each of those
-hosts. This mechanism is described more detail in @ref{Request access}.
-@end itemize
+@xref{Option files}.
@item
-The @code{tables_priv} and @code{columns_priv} tables are similar to
-the @code{db} table, but are more fine-grained: they apply at the
-table and column levels rather than at the database level.
+@tindex @code{MYSQL_HOST} environment variable
+@tindex environment variable, @code{MYSQL_HOST}
+@tindex @code{MYSQL_PWD} environment variable
+@tindex environment variable, @code{MYSQL_PWD}
+@tindex @code{USER} environment variable
+@tindex environment variable, @code{USER}
+You can specify connection parameters using environment variables. The
+host can be specified for @code{mysql} using @code{MYSQL_HOST}. The
+MySQL user name can be specified using @code{USER} (this is for
+Windows only). The password can be specified using @code{MYSQL_PWD}
+(but this is insecure; see the next section). @xref{Environment variables}.
@end itemize
-Note that administrative privileges (@strong{reload}, @strong{shutdown},
-etc.) are specified only in the @code{user} table. This is because
-administrative operations are operations on the server itself and are not
-database-specific, so there is no reason to list such privileges in the
-other grant tables. In fact, only the @code{user} table need
-be consulted to determine whether or not you can perform an administrative
-operation.
-
-The @strong{file} privilege is specified only in the @code{user} table, too.
-It is not an administrative privilege as such, but your ability to read or
-write files on the server host is independent of the database you are
-accessing.
-
-The @code{mysqld} server reads the contents of the grant tables once, when it
-starts up. Changes to the grant tables take effect as indicated in
-@ref{Privilege changes}.
-
-When you modify the contents of the grant tables, it is a good idea to make
-sure that your changes set up privileges the way you want. For help in
-diagnosing problems, see @ref{Access denied}. For advice on security issues,
-@pxref{Security}.
-A useful
-diagnostic tool is the @code{mysqlaccess} script, which Yves Carlier has
-provided for the @strong{MySQL} distribution. Invoke @code{mysqlaccess} with
-the @code{--help} option to find out how it works.
-Note that @code{mysqlaccess} checks access using only the @code{user},
-@code{db} and @code{host} tables. It does not check table- or column-level
-privileges.
+@node Connection access, Request access, Connecting, Privilege system
+@subsection Access Control, Stage 1: Connection Verification
-@node Connection access, Request access, Privileges, Privilege system
-@section Access Control, Stage 1: Connection Verification
@cindex access control
@cindex control access
@cindex connecting, verification
@cindex testing, connection to the server
-When you attempt to connect to a @strong{MySQL} server, the server accepts or
+When you attempt to connect to a MySQL server, the server accepts or
rejects the connection based on your identity and whether or not you can
verify your identity by supplying the correct password. If not, the server
denies access to you completely. Otherwise, the server accepts the
@@ -13013,7 +16172,7 @@ Your identity is based on two pieces of information:
The host from which you connect
@item
-Your @strong{MySQL} user name
+Your MySQL user name
@end itemize
Identity checking is performed using the three @code{user} table scope fields
@@ -13043,7 +16202,7 @@ You can find more information about this in the next chapter.
@cindex netmask notation, in @code{mysql.user} table
@item
-As of @strong{MySQL} Version 3.23, for @code{Host} values specified as
+As of MySQL Version 3.23, for @code{Host} values specified as
IP numbers, you can specify a netmask indicating how many address bits to
use for the network number. For example:
@@ -13058,7 +16217,7 @@ user_ip & netmask = host_ip.
@end example
In the above example all IP:s in the interval 192.58.197.0 -
-192.58.197.255 can connect to the @strong{MySQL} server.
+192.58.197.255 can connect to the MySQL server.
@item
@cindex anonymous user
@@ -13077,12 +16236,12 @@ matches, it means the user must connect without specifying a password.
@findex PASSWORD()
Non-blank @code{Password} values represent encrypted passwords.
-@strong{MySQL} does not store passwords in plaintext form for anyone to
+MySQL does not store passwords in plaintext form for anyone to
see. Rather, the password supplied by a user who is attempting to
connect is encrypted (using the @code{PASSWORD()} function). The
encrypted password is then used when the client/server is checking if
the password is correct (This is done without the encrypted password
-ever traveling over the connection.) Note that from @strong{MySQL}'s
+ever traveling over the connection.) Note that from MySQL's
point of view the encrypted password is the REAL password, so you should
not give anyone access to it! In particular, don't give normal users
read access to the tables in the @code{mysql} database!
@@ -13107,7 +16266,7 @@ connections:
Because you can use IP wild-card values in the @code{Host} field (for example,
@code{'144.155.166.%'} to match every host on a subnet), there is the
possibility that someone might try to exploit this capability by naming a
-host @code{144.155.166.somewhere.com}. To foil such attempts, @strong{MySQL}
+host @code{144.155.166.somewhere.com}. To foil such attempts, MySQL
disallows matching on hostnames that start with digits and a dot. Thus, if
you have a host named something like @code{1.2.foo.com}, its name will never
match the @code{Host} column of the grant tables. Only an IP number can
@@ -13199,8 +16358,9 @@ as the @code{User} field value, but by the entry with no user name!
If you have problems connecting to the server, print out the @code{user}
table and sort it by hand to see where the first match is being made.
-@node Request access, Privilege changes, Connection access, Privilege system
-@section Access Control, Stage 2: Request Verification
+
+@node Request access, Access denied, Connection access, Privilege system
+@subsection Access Control, Stage 2: Request Verification
Once you establish a connection, the server enters Stage 2. For each request
that comes in on the connection, the server checks whether you have
@@ -13223,7 +16383,7 @@ database administrators. For other users, you should leave the privileges
in the @code{user} table set to @code{'N'} and grant privileges on a
database-specific basis only, using the @code{db} and @code{host} tables.
-@cindex Anonymous user
+@cindex anonymous user
@cindex wild cards, in @code{mysql.db} table
@cindex wild cards, in @code{mysql.host} table
The @code{db} and @code{host} tables grant database-specific privileges.
@@ -13313,7 +16473,7 @@ by checking the @code{db} and @code{host} tables:
@item
The server looks in the @code{db} table for a match on the @code{Host},
@code{Db}, and @code{User} fields. The @code{Host} and @code{User} fields are
-matched to the connecting user's hostname and @strong{MySQL} user name. The
+matched to the connecting user's hostname and MySQL user name. The
@code{Db} field is matched to the database the user wants to access. If
there is no entry for the @code{Host} and @code{User}, access is denied.
@@ -13398,8 +16558,657 @@ Naturally, you should always test your entries in the grant tables (for
example, using @code{mysqlaccess}) to make sure your access privileges are
actually set up the way you think they are.
-@node Privilege changes, Default privileges, Request access, Privilege system
-@section When Privilege Changes Take Effect
+
+@node Access denied, , Request access, Privilege system
+@subsection Causes of @code{Access denied} Errors
+
+If you encounter @code{Access denied} errors when you try to connect to the
+MySQL server, the list below indicates some courses of
+action you can take to correct the problem:
+
+@itemize @bullet
+@item
+After installing MySQL, did you run the @code{mysql_install_db}
+script to set up the initial grant table contents? If not, do so.
+@xref{Default privileges}. Test the initial privileges by executing
+this command:
+
+@example
+shell> mysql -u root test
+@end example
+
+The server should let you connect without error. You should also make sure
+you have a file @file{user.MYD} in the MySQL database directory.
+Ordinarily, this is @file{PATH/var/mysql/user.MYD}, where @code{PATH} is the
+pathname to the MySQL installation root.
+
+@item
+After a fresh installation, you should connect to the server and set up
+your users and their access permissions:
+
+@example
+shell> mysql -u root mysql
+@end example
+
+The server should let you connect because the MySQL @code{root} user
+has no password initially. That is also a security risk, so setting the
+@code{root} password is something you should do while you're setting up
+your other MySQL users.
+
+If you try to connect as @code{root} and get this error:
+
+@example
+Access denied for user: '@@unknown' to database mysql
+@end example
+
+this means that you don't have an entry in the @code{user} table with a
+@code{User} column value of @code{'root'} and that @code{mysqld} cannot
+resolve the hostname for your client. In this case, you must restart the
+server with the @code{--skip-grant-tables} option and edit your
+@file{/etc/hosts} or @file{\windows\hosts} file to add an entry for your
+host.
+
+@item
+If you get an error like the following:
+
+@example
+shell> mysqladmin -u root -pxxxx ver
+Access denied for user: 'root@@localhost' (Using password: YES)
+@end example
+
+It means that you are using a wrong password. @xref{Passwords}.
+
+If you have forgot the root password, you can restart @code{mysqld} with
+@code{--skip-grant-tables} to change the password. You can find more
+about this option later on in this manual section.
+
+If you get the above error even if you haven't specified a password,
+this means that you a wrong password in some @code{my.ini}
+file. @xref{Option files}. You can avoid using option files with the @code{--no-defaults} option, as follows:
+
+@example
+shell> mysqladmin --no-defaults -u root ver
+@end example
+
+@item
+@cindex @code{mysql_fix_privilege_tables}
+If you updated an existing MySQL installation from a version earlier
+than Version 3.22.11 to Version 3.22.11 or later, did you run the
+@code{mysql_fix_privilege_tables} script? If not, do so. The structure of
+the grant tables changed with MySQL Version 3.22.11 when the
+@code{GRANT} statement became functional.
+
+@item
+If your privileges seem to have changed in the middle of a session, it may be
+that a superuser has changed them. Reloading the grant tables affects new
+client connections, but it also affects existing connections as indicated in
+@ref{Privilege changes}.
+
+@item
+If you can't get your password to work, remember that you must use
+the @code{PASSWORD()} function if you set the password with the
+@code{INSERT}, @code{UPDATE}, or @code{SET PASSWORD} statements. The
+@code{PASSWORD()} function is unnecessary if you specify the password using
+the @code{GRANT ... INDENTIFIED BY} statement or the @code{mysqladmin
+password} command.
+@xref{Passwords}.
+
+@item
+@code{localhost} is a synonym for your local hostname, and is also the
+default host to which clients try to connect if you specify no host
+explicitly. However, connections to @code{localhost} do not work if you are
+running on a system that uses MIT-pthreads (@code{localhost} connections are
+made using Unix sockets, which are not supported by MIT-pthreads). To avoid
+this problem on such systems, you should use the @code{--host} option to name
+the server host explicitly. This will make a TCP/IP connection to the
+@code{mysqld} server. In this case, you must have your real hostname in
+@code{user} table entries on the server host. (This is true even if you are
+running a client program on the same host as the server.)
+
+@item
+If you get an @code{Access denied} error when trying to connect to the
+database with @code{mysql -u user_name db_name}, you may have a problem
+with the @code{user} table. Check this by executing @code{mysql -u root
+mysql} and issuing this SQL statement:
+
+@example
+mysql> SELECT * FROM user;
+@end example
+
+The result should include an entry with the @code{Host} and @code{User}
+columns matching your computer's hostname and your MySQL user name.
+
+@item
+The @code{Access denied} error message will tell you who you are trying
+to log in as, the host from which you are trying to connect, and whether
+or not you were using a password. Normally, you should have one entry in
+the @code{user} table that exactly matches the hostname and user name
+that were given in the error message. For example if you get an error
+message that contains @code{Using password: NO}, this means that you
+tried to login without an password.
+
+@item
+If you get the following error when you try to connect from a different host
+than the one on which the MySQL server is running, then there is no
+row in the @code{user} table that matches that host:
+
+@example
+Host ... is not allowed to connect to this MySQL server
+@end example
+
+You can fix this by using the command-line tool @code{mysql} (on the
+server host!) to add a row to the @code{user}, @code{db}, or @code{host}
+table for the user/hostname combination from which you are trying to
+connect and then execute @code{mysqladmin flush-privileges}. If you are
+not running MySQL Version 3.22 and you don't know the IP number or
+hostname of the machine from which you are connecting, you should put an
+entry with @code{'%'} as the @code{Host} column value in the @code{user}
+table and restart @code{mysqld} with the @code{--log} option on the
+server machine. After trying to connect from the client machine, the
+information in the MySQL log will indicate how you really did
+connect. (Then replace the @code{'%'} in the @code{user} table entry
+with the actual hostname that shows up in the log. Otherwise, you'll
+have a system that is insecure.)
+
+Another reason for this error on Linux is that you are using a binary
+MySQL version that is compiled with a different glibc version
+than the one you are using. In this case you should either upgrade your
+OS/glibc or download the source MySQL version and compile this
+yourself. A source RPM is normally trivial to compile and install, so
+this isn't a big problem.
+
+@item
+If you get an error message where the hostname is not shown or where the
+hostname is an IP, even if you try to connect with a hostname:
+
+@example
+shell> mysqladmin -u root -pxxxx -h some-hostname ver
+Access denied for user: 'root@' (Using password: YES)
+@end example
+
+This means that MySQL got some error when trying to resolve the
+IP to a hostname. In this case you can execute @code{mysqladmin
+flush-hosts} to reset the internal DNS cache. @xref{DNS}.
+
+Some permanent solutions are:
+
+@itemize @minus
+@item
+Try to find out what is wrong with your DNS server and fix this.
+
+@item
+Specify IPs instead of hostnames in the MySQL privilege tables.
+
+@item
+Start @code{mysqld} with @code{--skip-name-resolve}.
+
+@item
+Start @code{mysqld} with @code{--skip-host-cache}.
+
+@item
+Connect to @code{localhost} if you are running the server and the client
+on the same machine.
+
+@item
+Put the client machine names in @code{/etc/hosts}.
+@end itemize
+
+@item
+If @code{mysql -u root test} works but @code{mysql -h your_hostname -u root
+test} results in @code{Access denied}, then you may not have the correct name
+for your host in the @code{user} table. A common problem here is that the
+@code{Host} value in the user table entry specifies an unqualified hostname,
+but your system's name resolution routines return a fully qualified domain
+name (or vice-versa). For example, if you have an entry with host
+@code{'tcx'} in the @code{user} table, but your DNS tells MySQL that
+your hostname is @code{'tcx.subnet.se'}, the entry will not work. Try adding
+an entry to the @code{user} table that contains the IP number of your host as
+the @code{Host} column value. (Alternatively, you could add an entry to the
+@code{user} table with a @code{Host} value that contains a wild card---for
+example, @code{'tcx.%'}. However, use of hostnames ending with @samp{%} is
+@emph{insecure} and is @emph{not} recommended!)
+
+@item
+If @code{mysql -u user_name test} works but @code{mysql -u user_name
+other_db_name} doesn't work, you don't have an entry for @code{other_db_name}
+listed in the @code{db} table.
+
+@item
+If @code{mysql -u user_name db_name} works when executed on the server
+machine, but @code{mysql -u host_name -u user_name db_name} doesn't work when
+executed on another client machine, you don't have the client machine listed
+in the @code{user} table or the @code{db} table.
+
+@item
+If you can't figure out why you get @code{Access denied}, remove from the
+@code{user} table all entries that have @code{Host} values containing
+wild cards (entries that contain @samp{%} or @samp{_}). A very common error
+is to insert a new entry with @code{Host}=@code{'%'} and
+@code{User}=@code{'some user'}, thinking that this will allow you to specify
+@code{localhost} to connect from the same machine. The reason that this
+doesn't work is that the default privileges include an entry with
+@code{Host}=@code{'localhost'} and @code{User}=@code{''}. Because that entry
+has a @code{Host} value @code{'localhost'} that is more specific than
+@code{'%'}, it is used in preference to the new entry when connecting from
+@code{localhost}! The correct procedure is to insert a second entry with
+@code{Host}=@code{'localhost'} and @code{User}=@code{'some_user'}, or to
+remove the entry with @code{Host}=@code{'localhost'} and
+@code{User}=@code{''}.
+
+@item
+If you get the following error, you may have a problem with the @code{db} or
+@code{host} table:
+
+@example
+Access to database denied
+@end example
+
+If the entry selected from the @code{db} table has an empty value in the
+@code{Host} column, make sure there are one or more corresponding entries in
+the @code{host} table specifying which hosts the @code{db} table entry
+applies to.
+
+If you get the error when using the SQL commands @code{SELECT ...
+INTO OUTFILE} or @code{LOAD DATA INFILE}, your entry in the @code{user} table
+probably doesn't have the @strong{file} privilege enabled.
+
+@item
+@cindex configuration files
+@cindex environment variables
+@tindex .my.cnf file
+Remember that client programs will use connection parameters specified
+in configuration files or environment variables. @xref{Environment
+variables}. If a client seems to be sending the wrong default
+connection parameters when you don't specify them on the command line,
+check your environment and the @file{.my.cnf} file in your home
+directory. You might also check the system-wide MySQL
+configuration files, though it is far less likely that client connection
+parameters will be specified there. @xref{Option files}. If you get
+@code{Access denied} when you run a client without any options, make
+sure you haven't specified an old password in any of your option files!
+@xref{Option files}.
+
+@item
+If you make changes to the grant tables directly (using an @code{INSERT} or
+@code{UPDATE} statement) and your changes seem to be ignored, remember
+that you must issue a @code{FLUSH PRIVILEGES} statement or execute a
+@code{mysqladmin flush-privileges} command to cause the server to re-read
+the privilege tables. Otherwise your changes have no effect until the
+next time the server is restarted. Remember that after you set the
+@code{root} password with an @code{UPDATE} command, you won't need to
+specify it until after you flush the privileges, because the server
+won't know you've changed the password yet!
+
+@item
+If you have access problems with a Perl, PHP, Python, or ODBC program, try to
+connect to the server with @code{mysql -u user_name db_name} or @code{mysql
+-u user_name -pyour_pass db_name}. If you are able to connect using the
+@code{mysql} client, there is a problem with your program and not with the
+access privileges. (Note that there is no space between @code{-p} and the
+password; you can also use the @code{--password=your_pass} syntax to specify
+the password. If you use the @code{-p} option alone, MySQL will
+prompt you for the password.)
+
+@item
+For testing, start the @code{mysqld} daemon with the
+@code{--skip-grant-tables} option. Then you can change the MySQL
+grant tables and use the @code{mysqlaccess} script to check whether or not
+your modifications have the desired effect. When you are satisfied with your
+changes, execute @code{mysqladmin flush-privileges} to tell the @code{mysqld}
+server to start using the new grant tables. @strong{Note:} Reloading the
+grant tables overrides the @code{--skip-grant-tables} option. This allows
+you to tell the server to begin using the grant tables again without bringing
+it down and restarting it.
+
+@item
+If everything else fails, start the @code{mysqld} daemon with a debugging
+option (for example, @code{--debug=d,general,query}). This will print host and
+user information about attempted connections, as well as information about
+each command issued. @xref{Making trace files}.
+
+@item
+If you have any other problems with the MySQL grant tables and
+feel you must post the problem to the mailing list, always provide a
+dump of the MySQL grant tables. You can dump the tables with
+the @code{mysqldump mysql} command. As always, post your problem using
+the @code{mysqlbug} script. @xref{Bug reports}. In some cases you may need
+to restart @code{mysqld} with @code{--skip-grant-tables} to run
+@code{mysqldump}.
+@end itemize
+
+
+@node User Account Management, Disaster Prevention, Privilege system, MySQL Database Administration
+@section MySQL User Account Management
+
+@menu
+* GRANT:: @code{GRANT} and @code{REVOKE} Syntax
+* User names:: MySQL User Names and Passwords
+* Privilege changes:: When Privilege Changes Take Effect
+* Default privileges:: Setting Up the Initial MySQL Privileges
+* Adding users:: Adding New Users to MySQL
+* Passwords:: Setting Up Passwords
+* Password security:: Keeping Your Password Secure
+@end menu
+
+
+@node GRANT, User names, User Account Management, User Account Management
+@subsection @code{GRANT} and @code{REVOKE} Syntax
+
+@findex GRANT
+@findex REVOKE
+
+@cindex privileges, granting
+@cindex privileges, revoking
+@cindex global privileges
+@cindex revoking, privleges
+@cindex granting, privleges
+
+@example
+GRANT priv_type [(column_list)] [, priv_type [(column_list)] ...]
+ ON @{tbl_name | * | *.* | db_name.*@}
+ TO user_name [IDENTIFIED BY 'password']
+ [, user_name [IDENTIFIED BY 'password'] ...]
+ [WITH GRANT OPTION]
+
+REVOKE priv_type [(column_list)] [, priv_type [(column_list)] ...]
+ ON @{tbl_name | * | *.* | db_name.*@}
+ FROM user_name [, user_name ...]
+@end example
+
+@code{GRANT} is implemented in MySQL Version 3.22.11 or later. For
+earlier MySQL versions, the @code{GRANT} statement does nothing.
+
+The @code{GRANT} and @code{REVOKE} commands allow system administrators
+to create users and grant and revoke rights to MySQL users at
+four privilege levels:
+
+@table @strong
+@item Global level
+Global privileges apply to all databases on a given server. These privileges
+are stored in the @code{mysql.user} table.
+
+@item Database level
+Database privileges apply to all tables in a given database. These privileges
+are stored in the @code{mysql.db} and @code{mysql.host} tables.
+
+@item Table level
+Table privileges apply to all columns in a given table. These privileges are
+stored in the @code{mysql.tables_priv} table.
+
+@item Column level
+Column privileges apply to single columns in a given table. These privileges are
+stored in the @code{mysql.columns_priv} table.
+@end table
+
+If you give a grant for a users that doesn't exists, that user is created.
+For examples of how @code{GRANT} works, see @ref{Adding users}.
+
+For the @code{GRANT} and @code{REVOKE} statements, @code{priv_type} may be
+specified as any of the following:
+
+@example
+ALL PRIVILEGES FILE RELOAD
+ALTER INDEX SELECT
+CREATE INSERT SHUTDOWN
+DELETE PROCESS UPDATE
+DROP REFERENCES USAGE
+@end example
+
+@code{ALL} is a synonym for @code{ALL PRIVILEGES}. @code{REFERENCES} is not
+yet implemented. @code{USAGE} is currently a synonym for ``no privileges.''
+It can be used when you want to create a user that has no privileges.
+
+To revoke the @strong{grant} privilege from a user, use a @code{priv_type}
+value of @code{GRANT OPTION}:
+
+@example
+REVOKE GRANT OPTION ON ... FROM ...;
+@end example
+
+The only @code{priv_type} values you can specify for a table are @code{SELECT},
+@code{INSERT}, @code{UPDATE}, @code{DELETE}, @code{CREATE}, @code{DROP},
+@code{GRANT}, @code{INDEX}, and @code{ALTER}.
+
+The only @code{priv_type} values you can specify for a column (that is, when
+you use a @code{column_list} clause) are @code{SELECT}, @code{INSERT}, and
+@code{UPDATE}.
+
+You can set global privileges by using @code{ON *.*} syntax. You can set
+database privileges by using @code{ON db_name.*} syntax. If you specify
+@code{ON *} and you have a current database, you will set the privileges for
+that database. (@strong{WARNING:} If you specify @code{ON *} and you
+@emph{don't} have a current database, you will affect the global privileges!)
+
+In order to accommodate granting rights to users from arbitrary hosts,
+MySQL supports specifying the @code{user_name} value in the form
+@code{user@@host}. If you want to specify a @code{user} string
+containing special characters (such as @samp{-}), or a @code{host} string
+containing special characters or wild-card characters (such as @samp{%}), you
+can quote the user or host name (for example, @code{'test-user'@@'test-hostname'}).
+
+You can specify wild cards in the hostname. For example,
+@code{user@@"%.loc.gov"} applies to @code{user} for any host in the
+@code{loc.gov} domain, and @code{user@@"144.155.166.%"} applies to @code{user}
+for any host in the @code{144.155.166} class C subnet.
+
+The simple form @code{user} is a synonym for @code{user@@"%"}.
+@strong{NOTE:} If you allow anonymous users to connect to the MySQL
+server (which is the default), you should also add all local users as
+@code{user@@localhost} because otherwise the anonymous user entry for the
+local host in the @code{mysql.user} table will be used when the user tries to
+log into the MySQL server from the local machine! Anonymous users
+are defined by inserting entries with @code{User=''} into the
+@code{mysql.user} table. You can verify if this applies to you by executing
+this query:
+
+@example
+mysql> SELECT Host,User FROM mysql.user WHERE User='';
+@end example
+
+For the moment, @code{GRANT} only supports host, table, database, and
+column names up to 60 characters long. A user name can be up to 16
+characters.
+
+The privileges for a table or column are formed from the
+logical OR of the privileges at each of the four privilege
+levels. For example, if the @code{mysql.user} table specifies that a
+user has a global @strong{select} privilege, this can't be denied by an
+entry at the database, table, or column level.
+
+The privileges for a column can be calculated as follows:
+
+@example
+global privileges
+OR (database privileges AND host privileges)
+OR table privileges
+OR column privileges
+@end example
+
+In most cases, you grant rights to a user at only one of the privilege
+levels, so life isn't normally as complicated as above. The details of the
+privilege-checking procedure are presented in
+@ref{Privilege system}.
+
+If you grant privileges for a user/hostname combination that does not exist
+in the @code{mysql.user} table, an entry is added and remains there until
+deleted with a @code{DELETE} command. In other words, @code{GRANT} may
+create @code{user} table entries, but @code{REVOKE} will not remove them;
+you must do that explicitly using @code{DELETE}.
+
+@cindex passwords, setting
+In MySQL Version 3.22.12 or later,
+if a new user is created or if you have global grant privileges, the user's
+password will be set to the password specified by the @code{IDENTIFIED BY}
+clause, if one is given. If the user already had a password, it is replaced
+by the new one.
+
+@strong{WARNING:} If you create a new user but do not specify an
+@code{IDENTIFIED BY} clause, the user has no password. This is insecure.
+
+Passwords can also be set with the @code{SET PASSWORD} command.
+@xref{SET OPTION, , @code{SET OPTION}}.
+
+If you grant privileges for a database, an entry in the @code{mysql.db}
+table is created if needed. When all privileges for the database have been
+removed with @code{REVOKE}, this entry is deleted.
+
+If a user doesn't have any privileges on a table, the table is not displayed
+when the user requests a list of tables (for example, with a @code{SHOW TABLES}
+statement).
+
+The @code{WITH GRANT OPTION} clause gives the user the ability to give
+to other users any privileges the user has at the specified privilege level.
+You should be careful to whom you give the @strong{grant} privilege, as two
+users with different privileges may be able to join privileges!
+
+You cannot grant another user a privilege you don't have yourself;
+the @strong{grant} privilege allows you to give away only those privileges
+you possess.
+
+Be aware that when you grant a user the @strong{grant} privilege at a
+particular privilege level, any privileges the user already possesses (or
+is given in the future!) at that level are also grantable by that user.
+Suppose you grant a user the @strong{insert} privilege on a database. If
+you then grant the @strong{select} privilege on the database and specify
+@code{WITH GRANT OPTION}, the user can give away not only the @strong{select}
+privilege, but also @strong{insert}. If you then grant the @strong{update}
+privilege to the user on the database, the user can give away the
+@strong{insert}, @strong{select} and @strong{update}.
+
+You should not grant @strong{alter} privileges to a normal user. If you
+do that, the user can try to subvert the privilege system by renaming
+tables!
+
+Note that if you are using table or column privileges for even one user, the
+server examines table and column privileges for all users and this will slow
+down MySQL a bit.
+
+When @code{mysqld} starts, all privileges are read into memory.
+Database, table, and column privileges take effect at once, and
+user-level privileges take effect the next time the user connects.
+Modifications to the grant tables that you perform using @code{GRANT} or
+@code{REVOKE} are noticed by the server immediately.
+If you modify the grant tables manually (using @code{INSERT}, @code{UPDATE},
+etc.), you should execute a @code{FLUSH PRIVILEGES} statement or run
+@code{mysqladmin flush-privileges} to tell the server to reload the grant
+tables.
+@xref{Privilege changes}.
+
+@cindex ANSI SQL, differences from
+The biggest differences between the ANSI SQL and MySQL versions of
+@code{GRANT} are:
+
+@itemize @bullet
+@item
+In MySQL privileges are given for an username + hostname combination
+and not only for an username.
+
+@item
+ANSI SQL doesn't have global or database-level privileges, and ANSI SQL
+doesn't support all privilege types that MySQL supports.
+MySQL doesn't support the ANSI SQL @code{TRIGGER}, @code{EXECUTE} or
+@code{UNDER} privileges.
+
+@item
+ANSI SQL privileges are structured in a hierarchal manner. If you remove
+an user, all privileges the user has granted are revoked. In
+MySQL the granted privileges are not automatically revoked, but
+you have to revoke these yourself if needed.
+
+@item
+If you in MySQL have the @code{INSERT} grant on only part of the
+columns in a table, you can execute @code{INSERT} statements on the
+table; The columns for which you don't have the @code{INSERT} privilege
+will set to their default values. ANSI SQL requires you to have the
+@code{INSERT} privilege on all columns.
+
+@item
+When you drop a table in ANSI SQL, all privileges for the table are revoked.
+If you revoke a privilege in ANSI SQL, all privileges that were granted based
+on this privilege are also revoked. In MySQL, privileges can be
+dropped only with explicit @code{REVOKE} commands or by manipulating the
+MySQL grant tables.
+@end itemize
+
+
+@node User names, Privilege changes, GRANT, User Account Management
+@subsection MySQL User Names and Passwords
+
+@cindex user names, and passwords
+@cindex passwords, for users
+
+There are several distinctions between the way user names and passwords are
+used by MySQL and the way they are used by Unix or Windows:
+
+@itemize @bullet
+@item
+User names, as used by MySQL for authentication purposes, have
+nothing to do with Unix user names (login names) or Windows user names. Most
+MySQL clients by default try to log in using the current Unix user
+name as the MySQL user name, but that is for convenience only.
+Client programs allow a different name to be specified with the @code{-u} or
+@code{--user} options. This means that you can't make a database secure in
+any way unless all MySQL user names have passwords. Anyone may
+attempt to connect to the server using any name, and they will succeed if
+they specify any name that doesn't have a password.
+
+@item
+MySQL user names can be up to 16 characters long; Unix user names
+typically are limited to 8 characters.
+
+@item
+MySQL passwords have nothing to do with Unix passwords. There is no
+necessary connection between the password you use to log in to a Unix machine
+and the password you use to access a database on that machine.
+
+@item
+MySQL encrypts passwords using a different algorithm than the
+one used during the Unix login process. See the descriptions of the
+@code{PASSWORD()} and @code{ENCRYPT()} functions in @ref{Miscellaneous
+functions}. Note that even if the password is stored 'scrambled', and
+knowing your 'scrambled' password is enough to be able to connect to
+the MySQL server!
+@end itemize
+
+MySQL users and they privileges are normally created with the
+@code{GRANT} command. @xref{GRANT}.
+
+When you login to a MySQL server with a command line client you
+should specify the password with @code{--password=your-password}.
+@xref{Connecting}.
+
+@example
+mysql --user=monty --password=guess database_name
+@end example
+
+If you want the client to prompt for a password, you should use
+@code{--password} without any argument
+
+@example
+mysql --user=monty --password database_name
+@end example
+
+or the short form:
+
+@example
+mysql -u monty -p database_name
+@end example
+
+Note that in the last example the password is @strong{NOT} 'database_name'.
+
+If you want to use the @code{-p} option to supply a password you should do like this:
+
+@example
+mysql -u monty -pguess database_name
+@end example
+
+On some system the library call that MySQL uses to prompt for a
+password will automatically cut the password to 8 characters. Internally
+MySQL doesn't have any limit for the length of the password.
+
+
+@node Privilege changes, Default privileges, User names, User Account Management
+@subsection When Privilege Changes Take Effect
When @code{mysqld} starts, all grant table contents are read into memory and
become effective at that point.
@@ -13431,6 +17240,10 @@ command.
Global privilege changes and password changes take effect the next time the
client connects.
+
+@node Default privileges, Adding users, Privilege changes, User Account Management
+@subsection Setting Up the Initial MySQL Privileges
+
@cindex privileges, default
@cindex default, privileges
@cindex root password
@@ -13438,10 +17251,8 @@ client connects.
@cindex users, root
@cindex anonymous user
@cindex password, root user
-@node Default privileges, Adding users, Privilege changes, Privilege system
-@section Setting Up the Initial MySQL Privileges
-After installing @strong{MySQL}, you set up the initial access privileges by
+After installing MySQL, you set up the initial access privileges by
running @code{scripts/mysql_install_db}.
@xref{Quick install}.
The @code{mysql_install_db} script starts up the @code{mysqld}
@@ -13450,7 +17261,7 @@ of privileges:
@itemize @bullet
@item
-The @strong{MySQL} @code{root} user is created as a superuser who can do
+The MySQL @code{root} user is created as a superuser who can do
anything. Connections must be made from the local host.
@strong{NOTE:}
@@ -13473,7 +17284,7 @@ Other privileges are denied. For example, normal users can't use
@xref{Windows running}.
Because your installation is initially wide open, one of the first things you
-should do is specify a password for the @strong{MySQL}
+should do is specify a password for the MySQL
@code{root} user. You can do this as follows (note that you specify the
password using the @code{PASSWORD()} function):
@@ -13484,7 +17295,7 @@ mysql> UPDATE user SET Password=PASSWORD('new_password')
mysql> FLUSH PRIVILEGES;
@end example
-You can, in @strong{MySQL} Version 3.22 and above, use the @code{SET PASSWORD}
+You can, in MySQL Version 3.22 and above, use the @code{SET PASSWORD}
statement:
@example
@@ -13530,21 +17341,24 @@ the database directory, which is listed when you run @code{mysqld
--help}.) Then run the @code{mysql_install_db} script, possibly after
editing it first to have the privileges you want.
-@strong{NOTE:} For @strong{MySQL} versions older than Version 3.22.10,
+@strong{NOTE:} For MySQL versions older than Version 3.22.10,
you should NOT delete the @file{.frm} files. If you accidentally do this,
-you should copy them back from your @strong{MySQL} distribution before
+you should copy them back from your MySQL distribution before
running @code{mysql_install_db}.
+
+@node Adding users, Passwords, Default privileges, User Account Management
+@subsection Adding New Users to MySQL
+
+@findex GRANT statement
+@findex statements, GRANT
+
@cindex privileges, adding
@cindex adding, new user privileges
@cindex user privileges, adding
-@findex GRANT statement
-@findex statements, GRANT
-@node Adding users, Passwords, Default privileges, Privilege system
-@section Adding New Users to MySQL
You can add users two different ways: by using @code{GRANT} statements
-or by manipulating the @strong{MySQL} grant tables directly. The
+or by manipulating the MySQL grant tables directly. The
preferred method is to use @code{GRANT} statements, because they are
more concise and less error-prone. @xref{GRANT}.
@@ -13555,7 +17369,7 @@ The examples below show how to use the @code{mysql} client to set up new
users. These examples assume that privileges are set up according to the
defaults described in the previous section. This means that to make changes,
you must be on the same machine where @code{mysqld} is running, you must
-connect as the @strong{MySQL} @code{root} user, and the @code{root} user must
+connect as the MySQL @code{root} user, and the @code{root} user must
have the @strong{insert} privilege for the @code{mysql} database and the
@strong{reload} administrative privilege. Also, if you have changed the
@code{root} user password, you must specify it for the @code{mysql} commands
@@ -13620,7 +17434,7 @@ mysql> INSERT INTO user (Host,User,Password)
mysql> FLUSH PRIVILEGES;
@end example
-Depending on your @strong{MySQL} version, you may have to use a different
+Depending on your MySQL version, you may have to use a different
number of @code{'Y'} values above (versions prior to Version 3.22.11 had fewer
privilege columns). For the @code{admin} user, the more readable extended
@code{INSERT} syntax that is available starting with Version 3.22.11 is used.
@@ -13661,7 +17475,7 @@ mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
@end example
The reason that we do to grant statements for the user 'custom' is that
-we want the give the user access to @strong{MySQL} both from the local
+we want the give the user access to MySQL both from the local
machine with Unix sockets and from the remote machine 'whitehouse.gov'
over TCP/IP.
@@ -13724,15 +17538,18 @@ mysql> FLUSH PRIVILEGES;
You can also use @code{xmysqladmin}, @code{mysql_webadmin}, and even
@code{xmysql} to insert, change, and update values in the grant tables.
You can find these utilities in the
-@uref{http://www.mysql.com/Downloads/Contrib/,Contrib directory of the @strong{MySQL}
+@uref{http://www.mysql.com/Downloads/Contrib/,Contrib directory of the MySQL
Website}.
-@cindex passwords, setting
+
+@node Passwords, Password security, Adding users, User Account Management
+@subsection Setting Up Passwords
+
@findex PASSWORD()
@findex SET PASSWORD statement
+
+@cindex passwords, setting
@cindex setting, passwords
-@node Passwords, Access denied, Adding users, Privilege system
-@section Setting Up Passwords
In most cases you should use @code{GRANT} to set up your users/passwords,
so the following only applies for advanced users. @xref{GRANT, , @code{GRANT}}.
@@ -13754,10 +17571,13 @@ mysql> FLUSH PRIVILEGES;
The result is that the plaintext value @code{'biscuit'} is stored as the
password in the @code{user} table. When the user @code{jeffrey} attempts to
connect to the server using this password, the @code{mysql} client encrypts
-it with @code{PASSWORD()} and sends the result to the server. The server
-compares the value in the @code{user} table (the encrypted value of
-@code{'biscuit'}) to the encrypted password (which is @emph{not}
-@code{'biscuit'}). The comparison fails and the server rejects the
+it with @code{PASSWORD()}, generates an authentification vector
+based on @strong{encrypted} password and a random number,
+obtained from server, and sends the result to the server.
+The server uses the @code{password} value in the @code{user} table
+(that is @strong{not encrypted} value @code{'biscuit'})
+to perform the same calculations, and compares results.
+The comparison fails and the server rejects the
connection:
@example
@@ -13798,398 +17618,9646 @@ shell> mysqladmin -u jeffrey password biscuit
@strong{NOTE:} @code{PASSWORD()} does not perform password encryption in the
same way that Unix passwords are encrypted. You should not assume that if
-your Unix password and your @strong{MySQL} password are the same, that
+your Unix password and your MySQL password are the same, that
@code{PASSWORD()} will result in the same encrypted value as is stored in the
Unix password file. @xref{User names}.
-@node Access denied, , Passwords, Privilege system
-@section Causes of @code{Access denied} Errors
-If you encounter @code{Access denied} errors when you try to connect to the
-@strong{MySQL} server, the list below indicates some courses of
-action you can take to correct the problem:
+@node Password security, , Passwords, User Account Management
+@subsection Keeping Your Password Secure
+
+It is inadvisable to specify your password in a way that exposes it to
+discovery by other users. The methods you can use to specify your password
+when you run client programs are listed below, along with an assessment of
+the risks of each method:
@itemize @bullet
@item
-After installing @strong{MySQL}, did you run the @code{mysql_install_db}
-script to set up the initial grant table contents? If not, do so.
-@xref{Default privileges}. Test the initial privileges by executing
-this command:
+Never give a normal user access to the @code{mysql.user} table. Knowing
+the encrypted password for a user makes it possible to login as this
+user. The passwords are only scrambled so that one shouldn't be able to
+see the real password you used (if you happen to use a similar password
+with your other applications).
+
+@item
+Use a @code{-pyour_pass} or @code{--password=your_pass} option on the command
+line. This is convenient but insecure, because your password becomes visible
+to system status programs (such as @code{ps}) that may be invoked by other
+users to display command lines. (MySQL clients typically overwrite
+the command-line argument with zeroes during their initialization sequence,
+but there is still a brief interval during which the value is visible.)
+
+@item
+Use a @code{-p} or @code{--password} option (with no @code{your_pass} value
+specified). In this case, the client program solicits the password from
+the terminal:
+@findex -p option
+@findex -password option
@example
-shell> mysql -u root test
+shell> mysql -u user_name -p
+Enter password: ********
@end example
-The server should let you connect without error. You should also make sure
-you have a file @file{user.MYD} in the @strong{MySQL} database directory.
-Ordinarily, this is @file{PATH/var/mysql/user.MYD}, where @code{PATH} is the
-pathname to the @strong{MySQL} installation root.
+The @samp{*} characters represent your password.
+
+It is more secure to enter your password this way than to specify it on the
+command line because it is not visible to other users. However, this method
+of entering a password is suitable only for programs that you run
+interactively. If you want to invoke a client from a script that runs
+non-interactively, there is no opportunity to enter the password from the
+terminal. On some systems, you may even find that the first line of your
+script is read and interpreted (incorrectly) as your password!
@item
-After a fresh installation, you should connect to the server and set up
-your users and their access permissions:
+@tindex .my.cnf file
+Store your password in a configuration file. For example, you can list your
+password in the @code{[client]} section of the @file{.my.cnf} file in your
+home directory:
@example
-shell> mysql -u root mysql
+[client]
+password=your_pass
@end example
-The server should let you connect because the @strong{MySQL} @code{root} user
-has no password initially. That is also a security risk, so setting the
-@code{root} password is something you should do while you're setting up
-your other @strong{MySQL} users.
+If you store your password in @file{.my.cnf}, the file should not be group or
+world readable or writable. Make sure the file's access mode is @code{400}
+or @code{600}.
+
+@xref{Option files}.
+@item
+You can store your password in the @code{MYSQL_PWD} environment variable, but
+this method must be considered extremely insecure and should not be used.
+Some versions of @code{ps} include an option to display the environment of
+running processes; your password will be in plain sight for all to see if
+you set @code{MYSQL_PWD}. Even on systems without such a version of
+@code{ps}, it is unwise to assume there is no other method to observe process
+environments. @xref{Environment variables}.
+@end itemize
+
+All in all, the safest methods are to have the client program prompt for the
+password or to specify the password in a properly protected @file{.my.cnf}
+file.
+
+
+@node Disaster Prevention, Database Administration, User Account Management, MySQL Database Administration
+@section Disaster Prevention and Recovery
+
+@menu
+* Backup:: Database Backups
+* BACKUP TABLE:: @code{BACKUP TABLE} Syntax
+* RESTORE TABLE:: @code{RESTORE TABLE} Syntax
+* CHECK TABLE:: @code{CHECK TABLE} Syntax
+* REPAIR TABLE:: @code{REPAIR TABLE} Syntax
+* Table maintenance:: Using @code{myisamchk} for Table Maintenance and Crash Recovery
+* Maintenance regimen:: Setting Up a Table Maintenance Regimen
+* Table-info:: Getting Information About a Table
+@end menu
-If you try to connect as @code{root} and get this error:
+
+@node Backup, BACKUP TABLE, Disaster Prevention, Disaster Prevention
+@subsection Database Backups
+
+@cindex databases, backups
+@cindex backups
+
+Because MySQL tables are stored as files, it is easy to do a
+backup. To get a consistent backup, do a @code{LOCK TABLES} on the
+relevant tables followed by @code{FLUSH TABLES} for the tables.
+@xref{LOCK TABLES, , @code{LOCK TABLES}}.
+@xref{FLUSH, , @code{FLUSH}}.
+You only need a read lock; this allows other threads to continue to
+query the tables while you are making a copy of the files in the
+database directory. The @code{FLUSH TABLE} is needed to ensure that
+the all active index pages is written to disk before you start the backup.
+
+If you want to make a SQL level backup of a table, you can use
+@code{SELECT INTO OUTFILE} or @code{BACKUP TABLE}. @xref{SELECT}.
+@xref{BACKUP TABLE}.
+
+Another way to back up a database is to use the @code{mysqldump} program or
+the @code{mysqlhotcopy script}. @xref{mysqldump, , @code{mysqldump}}.
+@xref{mysqlhotcopy, , @code{mysqlhotcopy}}.
+
+@enumerate
+@item
+Do a full backup of your databases:
@example
-Access denied for user: '@@unknown' to database mysql
+shell> mysqldump --tab=/path/to/some/dir --opt --full
+
+or
+
+shell> mysqlhotcopy database /path/to/some/dir
@end example
-this means that you don't have an entry in the @code{user} table with a
-@code{User} column value of @code{'root'} and that @code{mysqld} cannot
-resolve the hostname for your client. In this case, you must restart the
-server with the @code{--skip-grant-tables} option and edit your
-@file{/etc/hosts} or @file{\windows\hosts} file to add an entry for your
-host.
+You can also simply copy all table files (@file{*.frm}, @file{*.MYD}, and
+@file{*.MYI} files) as long as the server isn't updating anything.
+The script @code{mysqlhotcopy} does use this method.
@item
-If you get an error like the following:
+@cindex log files, names
+Stop @code{mysqld} if it's running, then start it with the
+@code{--log-update[=file_name]} option. @xref{Update log}. The update
+log file(s) provide you with the information you need to replicate
+changes to the database that are made subsequent to the point at which
+you executed @code{mysqldump}.
+@end enumerate
+
+If you have to restore something, try to recover your tables using
+@code{REPAIR TABLE} or @code{myisamchk -r} first. That should work in
+99.9% of all cases. If @code{myisamchk} fails, try the following
+procedure: (This will only work if you have started MySQL with
+@code{--log-update}. @xref{Update log}.):
+
+@enumerate
+@item
+Restore the original @code{mysqldump} backup.
+@item
+Execute the following command to re-run the updates in the binary log:
@example
-shell> mysqladmin -u root -pxxxx ver
-Access denied for user: 'root@@localhost' (Using password: YES)
+shell> mysqlbinlog hostname-bin.[0-9]* | mysql
@end example
-It means that you are using a wrong password. @xref{Passwords}.
+If you are using the update log you can use:
-If you have forgot the root password, you can restart @code{mysqld} with
-@code{--skip-grant-tables} to change the password. You can find more
-about this option later on in this manual section.
+@example
+shell> ls -1 -t -r hostname.[0-9]* | xargs cat | mysql
+@end example
+@end enumerate
-If you get the above error even if you haven't specified a password,
-this means that you a wrong password in some @code{my.ini}
-file. @xref{Option files}. You can avoid using option files with the @code{--no-defaults} option, as follows:
+@code{ls} is used to get all the update log files in the right order.
+
+You can also do selective backups with @code{SELECT * INTO OUTFILE 'file_name'
+FROM tbl_name} and restore with @code{LOAD DATA INFILE 'file_name' REPLACE
+...} To avoid duplicate records, you need a @code{PRIMARY KEY} or a
+@code{UNIQUE} key in the table. The @code{REPLACE} keyword causes old records
+to be replaced with new ones when a new record duplicates an old record on
+a unique key value.
+
+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}.
+
+If you are using a Veritas file system, you can do:
+
+@enumerate
+@item
+Execute in a client (perl ?) @code{FLUSH TABLES WITH READ LOCK}
+
+@item
+Fork a shell or execute in another client @code{mount vxfs snapshot}.
+
+@item
+Execute in the first client @code{UNLOCK TABLES}
+
+@item
+Copy files from snapshot
+
+@item
+Unmount snapshot
+@end enumerate
+
+
+@node BACKUP TABLE, RESTORE TABLE, Backup, Disaster Prevention
+@subsection @code{BACKUP TABLE} Syntax
+
+@findex BACKUP TABLE
+
+@cindex backups, database
@example
-shell> mysqladmin --no-defaults -u root ver
+BACKUP TABLE tbl_name[,tbl_name...] TO '/path/to/backup/directory'
@end example
+Make a copy of all the table files to the backup directory that are the
+minimum needed to restore it. Currenlty only works for @code{MyISAM}
+tables. For @code{MyISAM} table, copies @code{.frm} (definition) and
+@code{.MYD} (data) files. The index file can be rebuilt from those two.
+
+Before using this command, please see @xref{Backup}.
+
+During the backup, read lock will be held for each table, one at time,
+as they are being backed up. If you want to backup several tables as
+a snapshot, you must first issue @code{LOCK TABLES} obtaining a read
+lock for each table in the group.
+
+The command returns a table with the following columns:
+
+@multitable @columnfractions .35 .65
+@item @strong{Column} @tab @strong{Value}
+@item Table @tab Table name
+@item Op @tab Always ``backup''
+@item Msg_type @tab One of @code{status}, @code{error}, @code{info} or @code{warning}.
+@item Msg_text @tab The message.
+@end multitable
+
+Note that @code{BACKUP TABLE} is only available in MySQL
+version 3.23.25 and later.
+
+
+@node RESTORE TABLE, CHECK TABLE, BACKUP TABLE, Disaster Prevention
+@subsection @code{RESTORE TABLE} Syntax
+
+@findex RESTORE TABLE
+
+@example
+RESTORE TABLE tbl_name[,tbl_name...] FROM '/path/to/backup/directory'
+@end example
+
+Restores the table(s) from the backup that was made with
+@code{BACKUP TABLE}. Existing tables will not be overwritten - if you
+try to restore over an existing table, you will get an error. Restore
+will take longer than BACKUP due to the need to rebuilt the index. The
+more keys you have, the longer it is going to take. Just as
+@code{BACKUP TABLE}, currently only works of @code{MyISAM} tables.
+
+
+The command returns a table with the following columns:
+
+@multitable @columnfractions .35 .65
+@item @strong{Column} @tab @strong{Value}
+@item Table @tab Table name
+@item Op @tab Always ``restore''
+@item Msg_type @tab One of @code{status}, @code{error}, @code{info} or @code{warning}.
+@item Msg_text @tab The message.
+@end multitable
+
+
+@node CHECK TABLE, REPAIR TABLE, RESTORE TABLE, Disaster Prevention
+@subsection @code{CHECK TABLE} Syntax
+
+@findex CHECK TABLE
+
+@example
+CHECK TABLE tbl_name[,tbl_name...] [option [option...]]
+
+option = QUICK | FAST | MEDIUM | EXTENDED | CHANGED
+@end example
+
+@code{CHECK TABLE} only works on @code{MyISAM} tables. On
+@code{MyISAM} tables it's the same thing as running @code{myisamchk -m
+table_name} on the table.
+
+If you don't specify any option @code{MEDIUM} is used.
+
+Checks the table(s) for errors. For @code{MyISAM} tables the key statistics
+is updated. The command returns a table with the following columns:
+
+@multitable @columnfractions .35 .65
+@item @strong{Column} @tab @strong{Value}
+@item Table @tab Table name.
+@item Op @tab Always ``check''.
+@item Msg_type @tab One of @code{status}, @code{error}, @code{info}, or @code{warning}.
+@item Msg_text @tab The message.
+@end multitable
+
+Note that you can get many rows of information for each checked
+table. The last row will be of @code{Msg_type status} and should
+normally be @code{OK}. If you don't get @code{OK}, or @code{Not
+checked} you should normally run a repair of the table. @xref{Table
+maintenance}. @code{Not checked} means that the table the given @code{TYPE}
+told MySQL that there wasn't any need to check the table.
+
+The different check types stand for the following:
+
+@multitable @columnfractions .20 .80
+@item @strong{Type} @tab @strong{Meaning}
+@item @code{QUICK} @tab Don't scan the rows to check for wrong links.
+@item @code{FAST} @tab Only check tables which haven't been closed properly.
+@item @code{CHANGED} @tab Only check tables which have been changed since last check or haven't been closed properly.
+@item @code{MEDIUM} @tab Scan rows to verify that deleted links are ok. This also calculates a key checksum for the rows and verifies this with a calcualted checksum for the keys.
+@item @code{EXTENDED} @tab Do a full key lookup for all keys for each row. This ensures that the table is 100 % consistent, but will take a long time!
+@end multitable
+
+For dynamic sized @code{MyISAM} tables a started check will always
+do a @code{MEDIUM} check. For static size rows we skip the row scan
+for @code{QUICK} and @code{FAST} as the rows are very seldom corrupted.
+
+You can combine check options as in:
+
+@example
+CHECK TABLE test_table FAST QUICK;
+@end example
+
+Which only would do a quick check on the table if it wasn't closed properly.
+
+@strong{NOTE:} that in some case @code{CHECK TABLE} will change the
+table! This happens if the table is marked as 'corrupted' or 'not
+closed properly' but @code{CHECK TABLE} didn't find any problems in the
+table. In this case @code{CHECK TABLE} will mark the table as ok.
+
+If a table is corrupted, then it's most likely that the problem is in
+the indexes and not in the data part. All of the above check types
+checks the indexes throughly and should thus find most errors.
+
+If you just want to check a table that you assume is ok, you should use
+no check options or the @code{QUICK} option. The later should be used
+when you are in a hurry and can take the very small risk that
+@code{QUICK} didn't find an error in the data file (In most cases
+MySQL should find, under normal usage, any error in the data
+file. If this happens then the table will be marked as 'corrupted',
+in which case the table can't be used until it's repaired).
+
+@code{FAST} and @code{CHANGED} are mostly intended to be used from a
+script (for example to be executed from cron) if you want to check your
+table from time to time. In most cases you @code{FAST} is to be prefered
+over @code{CHANGED}. (The only case when it isn't is when you suspect a
+bug you have found a bug in the @code{MyISAM} code.).
+
+@code{EXTENDED} is only to be used after you have run a normal check but
+still get strange errors from a table when MySQL tries to
+update a row or find a row by key (this is VERY unlikely to happen if a
+normal check has succeeded!).
+
+Some things reported by check table, can't be corrected automatically:
+
+@itemize @bullet
@item
-@cindex @code{mysql_fix_privilege_tables}
-If you updated an existing @strong{MySQL} installation from a version earlier
-than Version 3.22.11 to Version 3.22.11 or later, did you run the
-@code{mysql_fix_privilege_tables} script? If not, do so. The structure of
-the grant tables changed with @strong{MySQL} Version 3.22.11 when the
-@code{GRANT} statement became functional.
+@code{Found row where the auto_increment column has the value 0}.
+
+This means that you have in the table a row where the
+@code{auto_increment} index column contains the value 0.
+(It's possible to create a row where the auto_increment column is 0 by
+explicitely setting the column to 0 with an @code{UPDATE} statement)
+
+This isn't an error in itself, but could cause trouble if you decide to
+dump the table and restore it or do an @code{ALTER TABLE} on the
+table. In this case the auto_increment column will change value,
+according to the rules of auto_increment columns, which could cause
+problems like a duplicate key error.
+
+To get rid of the warning, just execute an @code{UPDATE} statement
+to set the column to some other value than 0.
+@end itemize
+
+
+@node REPAIR TABLE, Table maintenance, CHECK TABLE, Disaster Prevention
+@subsection @code{REPAIR TABLE} Syntax
+
+@findex REPAIR TABLE
+
+@example
+REPAIR TABLE tbl_name[,tbl_name...] [QUICK] [EXTENDED]
+@end example
+
+@code{REPAIR TABLE} only works on @code{MyISAM} tables and is the same
+as running @code{myisamchk -r table_name} on the table.
+
+Normally you should never have to run this command, but if disaster strikes
+you are very likely to get back all your data from a MyISAM table with
+@code{REPAIR TABLE}. If your tables get corrupted a lot you should
+try to find the reason for this! @xref{Crashing}. @xref{MyISAM table problems}.
+
+@code{REPAIR TABLE} repairs a possible corrupted table. The command returns a
+table with the following columns:
+
+@multitable @columnfractions .35 .65
+@item @strong{Column} @tab @strong{Value}
+@item Table @tab Table name
+@item Op @tab Always ``repair''
+@item Msg_type @tab One of @code{status}, @code{error}, @code{info} or @code{warning}.
+@item Msg_text @tab The message.
+@end multitable
+
+Note that you can get many rows of information for each repaired
+table. The last one row will be of @code{Msg_type status} and should
+normally be @code{OK}. If you don't get @code{OK}, you should try
+repairing the table with @code{myisamchk -o}, as @code{REPAIR TABLE}
+does not yet implement all the options of @code{myisamchk}. In the near
+future, we will make it more flexible.
+
+If @code{QUICK} is given then MySQL will try to do a
+@code{REPAIR} of only the index tree.
+
+If you use @code{EXTENDED} then MySQL will create the index row
+by row instead of creating one index at a time with sorting; This may be
+better than sorting on fixed-length keys if you have long @code{char()}
+keys that compress very good.
+
+
+@node Table maintenance, Maintenance regimen, REPAIR TABLE, Disaster Prevention
+@subsection Using @code{myisamchk} for Table Maintenance and Crash Recovery
+
+Starting with MySQL Version 3.23.13, you can check MyISAM
+tables with the @code{CHECK TABLE} command. @xref{CHECK TABLE}. You can
+repair tables with the @code{REPAIR TABLE} command. @xref{REPAIR TABLE}.
+
+To check/repair MyISAM tables (@code{.MYI} and @code{.MYD}) you should
+use the @code{myisamchk} utility. To check/repair ISAM tables
+(@code{.ISM} and @code{.ISD}) you should use the @code{isamchk}
+utility. @xref{Table types}.
+
+In the following text we will talk about @code{myisamchk}, but everything
+also applies to the old @code{isamchk}.
+
+You can use the @code{myisamchk} utility to get information about your
+database tables, check and repair them, or optimize them. The following
+sections describe how to invoke @code{myisamchk} (including a
+description of its options), how to set up a table maintenance schedule,
+and how to use @code{myisamchk} to perform its various functions.
+
+You can, in most cases, also use the command @code{OPTIMIZE TABLES} to
+optimize and repair tables, but this is not as fast or reliable (in case
+of real fatal errors) as @code{myisamchk}. On the other hand,
+@code{OPTIMIZE TABLE} is easier to use and you don't have to worry about
+flushing tables.
+@xref{OPTIMIZE TABLE, , @code{OPTIMIZE TABLE}}.
+
+Even that the repair in @code{myisamchk} is quite secure, it's always a
+good idea to make a backup BEFORE doing a repair (or anything that could
+make a lot of changes to a table)
+
+@menu
+* myisamchk syntax:: @code{myisamchk} Invocation Syntax
+* myisamchk general options:: General Options for @code{myisamchk}
+* myisamchk check options:: Check Options for @code{myisamchk}
+* myisamchk repair options:: Repair Options for myisamchk
+* myisamchk other options:: Other Options for @code{myisamchk}
+* myisamchk memory:: @code{myisamchk} Memory Usage
+* Crash recovery:: Using @code{myisamchk} for Crash Recovery
+* Check:: How to Check Tables for Errors
+* Repair:: How to Repair Tables
+* Optimization:: Table Optimization
+@end menu
+
+
+@node myisamchk syntax, myisamchk general options, Table maintenance, Table maintenance
+@subsubsection @code{myisamchk} Invocation Syntax
+
+@code{myisamchk} is invoked like this:
+
+@example
+shell> myisamchk [options] tbl_name
+@end example
+
+The @code{options} specify what you want @code{myisamchk} to do. They are
+described below. (You can also get a list of options by invoking
+@code{myisamchk --help}.) With no options, @code{myisamchk} simply checks your
+table. To get more information or to tell @code{myisamchk} to take corrective
+action, specify options as described below and in the following sections.
+
+@code{tbl_name} is the database table you want to check/repair. If you run
+@code{myisamchk} somewhere other than in the database directory, you must
+specify the path to the file, because @code{myisamchk} has no idea where your
+database is located. Actually, @code{myisamchk} doesn't care whether or not
+the files you are working on are located in a database directory; you can
+copy the files that correspond to a database table into another location and
+perform recovery operations on them there.
+You can name several tables on the @code{myisamchk} command line if you
+wish. You can also specify a name as an index file
+name (with the @file{.MYI} suffix), which allows you to specify all
+tables in a directory by using the pattern @file{*.MYI}.
+For example, if you are in a database directory, you can check all the
+tables in the directory like this:
+
+@example
+shell> myisamchk *.MYI
+@end example
+
+If you are not in the database directory, you can check all the tables there
+by specifying the path to the directory:
+
+@example
+shell> myisamchk /path/to/database_dir/*.MYI
+@end example
+
+You can even check all tables in all databases by specifying a wild card
+with the path to the MySQL data directory:
+
+@example
+shell> myisamchk /path/to/datadir/*/*.MYI
+@end example
+
+The recommended way to quickly check all tables is:
+
+@example
+myisamchk --silent --fast /path/to/datadir/*/*.MYI
+isamchk --silent /path/to/datadir/*/*.ISM
+@end example
+
+If you want to check all tables and repair all tables that are corrupted,
+you can use the following line:
+
+@example
+myisamchk --silent --force --fast --update-state -O key_buffer=64M -O sort_buffer=64M -O read_buffer=1M -O write_buffer=1M /path/to/datadir/*/*.MYI
+isamchk --silent --force -O key_buffer=64M -O sort_buffer=64M -O read_buffer=1M -O write_buffer=1M /path/to/datadir/*/*.ISM
+@end example
+
+The above assumes that you have more than 64 M free.
+
+Note that if you get an error like:
+
+@example
+myisamchk: warning: 1 clients is using or hasn't closed the table properly
+@end example
+
+This means that you are trying to check a table that has been updated by
+the another program (like the @code{mysqld} server) that hasn't yet closed
+the file or that has died without closing the file properly.
+
+If you @code{mysqld} is running, you must force a sync/close of all
+tables with @code{FLUSH TABLES} and ensure that no one is using the
+tables while you are running @code{myisamchk}. In MySQL Version 3.23
+the easiest way to avoid this problem is to use @code{CHECK TABLE}
+instead of @code{myisamchk} to check tables.
+
+@menu
+* myisamchk general options:: General Options for @code{myisamchk}
+* myisamchk check options:: Check Options for @code{myisamchk}
+* myisamchk repair options:: Repair Options for myisamchk
+* myisamchk other options:: Other Options for @code{myisamchk}
+@end menu
+
+
+@node myisamchk general options, myisamchk check options, myisamchk syntax, Table maintenance
+@subsubsection General Options for @code{myisamchk}
+
+@cindex options, @code{myisamchk}
+@cindex @code{myisamchk}, options
+
+@code{myisamchk} supports the following options.
+
+@table @code
+@item -# or --debug=debug_options
+Output debug log. The @code{debug_options} string often is
+@code{'d:t:o,filename'}.
+@item -? or --help
+Display a help message and exit.
+@item -O var=option, --set-variable var=option
+Set the value of a variable. The possible variables and their default values
+for myisamchk can be examined with @code{myisamchk --help}:
+@multitable @columnfractions .3 .7
+@item key_buffer_size @tab 523264
+@item read_buffer_size @tab 262136
+@item write_buffer_size @tab 262136
+@item sort_buffer_size @tab 2097144
+@item sort_key_blocks @tab 16
+@item decode_bits @tab 9
+@end multitable
+
+@code{sort_buffer_size} is used when the keys are repaired by sorting
+keys, which is the normal case when you use @code{--recover}.
+
+@code{key_buffer_size} is used when you are checking the table with
+@code{--extended-check} or when the keys are repaired by inserting key
+row by row in to the table (like when doing normal inserts). Repairing
+through the key buffer is used in the following cases:
+
+@itemize @bullet
@item
-If your privileges seem to have changed in the middle of a session, it may be
-that a superuser has changed them. Reloading the grant tables affects new
-client connections, but it also affects existing connections as indicated in
-@ref{Privilege changes}.
+If you use @code{--safe-recover}.
+@item
+If you are using a @code{FULLTEXT} index.
+@item
+If the temporary files needed to sort the keys would be more than twice
+as big as when creating the key file directly. This is often the case
+when you have big @code{CHAR}, @code{VARCHAR} or @code{TEXT} keys as the
+sort needs to store the whole keys during sorting. If you have lots
+of temporary space and you can force @code{myisamchk} to repair by sorting
+you can use the @code{--sort-recover} option.
+@end itemize
+
+Reparing through the key buffer takes much less disk space than using
+sorting, but is also much slower.
+
+If you want a faster repair, set the above variables to about 1/4 of your
+available memory. You can set both variables to big values, as only one
+of the above buffers will be used at a time.
+
+@item -s or --silent
+Silent mode. Write output only when errors occur. You can use @code{-s}
+twice (@code{-ss}) to make @code{myisamchk} very silent.
+@item -v or --verbose
+Verbose mode. Print more information. This can be used with @code{-d} and
+@code{-e}. Use @code{-v} multiple times (@code{-vv}, @code{-vvv}) for more
+verbosity!
+@item -V or --version
+Print the @code{myisamchk} version and exit.
+@item -w or, --wait
+Instead of giving an error if the table is locked, wait until the table
+is unlocked before continuing. Note that if you are running @code{mysqld}
+on the table with @code{--skip-locking}, the table can only be locked
+by another @code{myisamchk} command.
+@end table
+
+
+@node myisamchk check options, myisamchk repair options, myisamchk general options, Table maintenance
+@subsubsection Check Options for @code{myisamchk}
+
+@cindex check options, myisamchk
+@cindex tables, checking
+
+@table @code
+@item -c or --check
+Check table for errors. This is the default operation if you are not
+giving @code{myisamchk} any options that override this.
+
+@item -e or --extend-check
+Check the table VERY thoroughly (which is quite slow if you have many
+indexes). This option should only be used in extreme cases. Normally,
+@code{myisamchk} or @code{myisamchk --medium-check} should, in most
+cases, be able to find out if there are any errors in the table.
+
+If you are using @code{--extended-check} and have much memory, you should
+increase the value of @code{key_buffer_size} a lot!
+
+@item -F or --fast
+Check only tables that haven't been closed properly.
+@item -C or --check-only-changed
+Check only tables that have changed since the last check.
+@item -f or --force
+Restart @code{myisamchk} with @code{-r} (repair) on the table, if
+@code{myisamchk} finds any errors in the table.
+@item -i or --information
+Print informational statistics about the table that is checked.
+@item -m or --medium-check
+Faster than extended-check, but only finds 99.99% of all errors.
+Should, however, be good enough for most cases.
+@item -U or --update-state
+Store in the @file{.MYI} file when the table was checked and if the table crashed. This should be used to get full benefit of the
+@code{--check-only-changed} option, but you shouldn't use this
+option if the @code{mysqld} server is using the table and you are
+running @code{mysqld} with @code{--skip-locking}.
+@item -T or --read-only
+Don't mark table as checked. This is useful if you use @code{myisamchk}
+to check a table that is in use by some other application that doesn't
+use locking (like @code{mysqld --skip-locking}).
+@end table
+
+
+@node myisamchk repair options, myisamchk other options, myisamchk check options, Table maintenance
+@subsubsection Repair Options for myisamchk
+
+@cindex repair options, myisamchk
+@cindex files, repairing
+
+The following options are used if you start @code{myisamchk} with
+@code{-r} or @code{-o}:
+
+@table @code
+@item -D # or --data-file-length=#
+Max length of data file (when re-creating data file when it's 'full').
+@item -e or --extend-check
+Try to recover every possible row from the data file.
+Normally this will also find a lot of garbage rows. Don't use this option
+if you are not totally desperate.
+@item -f or --force
+Overwrite old temporary files (@code{table_name.TMD}) instead of aborting.
+@item -k # or keys-used=#
+If you are using ISAM, tells the ISAM table handler to update only the
+first @code{#} indexes. If you are using @code{MyISAM}, tells which keys
+to use, where each binary bit stands for one key (first key is bit 0).
+This can be used to get faster inserts! Deactivated indexes can be
+reactivated by using @code{myisamchk -r}. keys.
+@item -l or --no-symlinks
+Do not follow symbolic links. Normally @code{myisamchk} repairs the
+table a symlink points at. This option doesn't exist in MySQL 4.0,
+as MySQL 4.0 will not remove symlinks during repair.
+@item -r or --recover
+Can fix almost anything except unique keys that aren't unique
+(which is an extremely unlikely error with ISAM/MyISAM tables).
+If you want to recover a table, this is the option to try first. Only if
+myisamchk reports that the table can't be recovered by @code{-r}, you
+should then try @code{-o}. (Note that in the unlikely case that @code{-r}
+fails, the data file is still intact.)
+If you have lots of memory, you should increase the size of
+@code{sort_buffer_size}!
+@item -o or --safe-recover
+Uses an old recovery method (reads through all rows in order and updates
+all index trees based on the found rows); this is a magnitude slower
+than @code{-r}, but can handle a couple of very unlikely cases that
+@code{-r} cannot handle. This recovery method also uses much less disk
+space than @code{-r}. Normally one should always first repair with
+@code{-r}, and only if this fails use @code{-o}.
+
+If you have lots of memory, you should increase the size of
+@code{key_buffer_size}!
+@item -n or --sort-recover
+Force @code{myisamchk} to use sorting to resolve the keys even if the
+temporary files should be very big. This will not have any effect if you have
+fulltext keys in the table.
+
+@item --character-sets-dir=...
+Directory where character sets are stored.
+@item --set-character-set=name
+Change the character set used by the index
+@item .t or --tmpdir=path
+Path for storing temporary files. If this is not set, @code{myisamchk} will
+use the environment variable @code{TMPDIR} for this.
+@item -q or --quick
+Faster repair by not modifying the data file. One can give a second
+@code{-q} to force @code{myisamchk} to modify the original datafile in case
+of duplicate keys
+@item -u or --unpack
+Unpack file packed with myisampack.
+@end table
+
+
+@node myisamchk other options, myisamchk memory, myisamchk repair options, Table maintenance
+@subsubsection Other Options for @code{myisamchk}
+
+Other actions that @code{myisamchk} can do, besides repair and check tables:
+@table @code
+@item -a or --analyze
+Analyze the distribution of keys. This improves join performance by
+enabling the join optimizer to better choose in which order it should
+join the tables and which keys it should use:
+@code{myisamchk --describe --verbose table_name'} or using @code{SHOW KEYS} in
+MySQL.
+@item -d or --description
+Prints some information about table.
+@item -A or --set-auto-increment[=value]
+Force auto_increment to start at this or higher value. If no value is
+given, then sets the next auto_increment value to the highest used value
+for the auto key + 1.
+@item -S or --sort-index
+Sort the index tree blocks in high-low order.
+This will optimize seeks and will make table scanning by key faster.
+@item -R or --sort-records=#
+Sorts records according to an index. This makes your data much more localized
+and may speed up ranged @code{SELECT} and @code{ORDER BY} operations on
+this index. (It may be VERY slow to do a sort the first time!)
+To find out a table's index numbers, use @code{SHOW INDEX}, which shows a
+table's indexes in the same order that @code{myisamchk} sees them. Indexes are
+numbered beginning with 1.
+@end table
+
+
+@node myisamchk memory, Crash recovery, myisamchk other options, Table maintenance
+@subsubsection @code{myisamchk} Memory Usage
+
+@cindex memory usage, myisamchk
+
+Memory allocation is important when you run @code{myisamchk}.
+@code{myisamchk} uses no more memory than you specify with the @code{-O}
+options. If you are going to use @code{myisamchk} on very large files,
+you should first decide how much memory you want it to use. The default
+is to use only about 3M to fix things. By using larger values, you can
+get @code{myisamchk} to operate faster. For example, if you have more
+than 32M RAM, you could use options such as these (in addition to any
+other options you might specify):
+
+@example
+shell> myisamchk -O sort=16M -O key=16M -O read=1M -O write=1M ...
+@end example
+
+Using @code{-O sort=16M} should probably be enough for most cases.
+
+Be aware that @code{myisamchk} uses temporary files in @code{TMPDIR}. If
+@code{TMPDIR} points to a memory file system, you may easily get out of
+memory errors. If this happens, set @code{TMPDIR} to point at some directory
+with more space and restart @code{myisamchk}.
+
+When repairing, @code{myisamchk} will also need a lot of disk space:
+
+@itemize @bullet
@item
-If you can't get your password to work, remember that you must use
-the @code{PASSWORD()} function if you set the password with the
-@code{INSERT}, @code{UPDATE}, or @code{SET PASSWORD} statements. The
-@code{PASSWORD()} function is unnecessary if you specify the password using
-the @code{GRANT ... INDENTIFIED BY} statement or the @code{mysqladmin
-password} command.
-@xref{Passwords}.
+Double the size of the record file (the original one and a copy). This
+space is not needed if one does a repair with @code{--quick}, as in this
+case only the index file will be re-created. This space is needed on the
+same disk as the original record file!
+@item
+Space for the new index file that replaces the old one. The old
+index file is truncated at start, so one usually ignore this space.
+This space is needed on the same disk as the original index file!
+@item
+When using @code{--recover} or @code{--sort-recover}
+(but not when using @code{--safe-recover}, you will need space for a
+sort buffer for:
+@code{(largest_key + row_pointer_length)*number_of_rows * 2}.
+You can check the length of the keys and the row_pointer_length with
+@code{myisamchk -dv table}.
+This space is allocated on the temporary disk (specified by @code{TMPDIR} or
+@code{--tmpdir=#}).
+@end itemize
+
+If you have a problem with disk space during repair, you can try to use
+@code{--safe-recover} instead of @code{--recover}.
+
+
+@node Crash recovery, Check, myisamchk memory, Table maintenance
+@subsubsection Using @code{myisamchk} for Crash Recovery
+
+@cindex crash, recovery
+@cindex recovery, from crash
+
+If you run @code{mysqld} with @code{--skip-locking} (which is the default on
+some systems, like Linux), you can't reliably use @code{myisamchk} to
+check a table when @code{mysqld} is using the same table. If you
+can be sure that no one is accessing the tables through @code{mysqld}
+while you run @code{myisamchk}, you only have to do @code{mysqladmin
+flush-tables} before you start checking the tables. If you can't
+guarantee the above, then you must take down @code{mysqld} while you
+check the tables. If you run @code{myisamchk} while @code{mysqld} is updating
+the tables, you may get a warning that a table is corrupt even if it
+isn't.
+
+If you are not using @code{--skip-locking}, you can use @code{myisamchk}
+to check tables at any time. While you do this, all clients that try
+to update the table will wait until @code{myisamchk} is ready before
+continuing.
+
+If you use @code{myisamchk} to repair or optimize tables, you
+@strong{MUST} always ensure that the @code{mysqld} server is not using
+the table (this also applies if you are using @code{--skip-locking}).
+If you don't take down @code{mysqld} you should at least do a
+@code{mysqladmin flush-tables} before you run @code{myisamchk}.
+
+This chapter describes how to check for and deal with data corruption
+in MySQL databases. If your tables get corrupted a lot you should
+try to find the reason for this! @xref{Crashing}.
+The @code{MyISAM} table section contains reason for why a table could be
+corrupted. @xref{MyISAM table problems}.
+
+When performing crash recovery, it is important to understand that each table
+@code{tbl_name} in a database corresponds to three files in the database
+directory:
+
+@multitable @columnfractions .2 .8
+@item @strong{File} @tab @strong{Purpose}
+@item @file{tbl_name.frm} @tab Table definition (form) file
+@item @file{tbl_name.MYD} @tab Data file
+@item @file{tbl_name.MYI} @tab Index file
+@end multitable
+
+Each of these three file types is subject to corruption in various ways, but
+problems occur most often in data files and index files.
+
+@code{myisamchk} works by creating a copy of the @file{.MYD} (data) file
+row by row. It ends the repair stage by removing the old @file{.MYD}
+file and renaming the new file to the original file name. If you use
+@code{--quick}, @code{myisamchk} does not create a temporary @file{.MYD}
+file, but instead assumes that the @file{.MYD} file is correct and only
+generates a new index file without touching the @file{.MYD} file. This
+is safe, because @code{myisamchk} automatically detects if the
+@file{.MYD} file is corrupt and aborts the repair in this case. You can
+also give two @code{--quick} options to @code{myisamchk}. In this case,
+@code{myisamchk} does not abort on some errors (like duplicate key) but
+instead tries to resolve them by modifying the @file{.MYD}
+file. Normally the use of two @code{--quick} options is useful only if
+you have too little free disk space to perform a normal repair. In this
+case you should at least make a backup before running @code{myisamchk}.
+
+
+@node Check, Repair, Crash recovery, Table maintenance
+@subsubsection How to Check Tables for Errors
+
+@cindex checking, tables for errors
+@cindex tables, error checking
+@cindex errors, checking tables for
+
+To check a MyISAM table, use the following commands:
+
+@table @code
+@item myisamchk tbl_name
+This finds 99.99% of all errors. What it can't find is corruption that
+involves @strong{ONLY} the data file (which is very unusual). If you want
+to check a table, you should normally run @code{myisamchk} without options or
+with either the @code{-s} or @code{--silent} option.
+
+@item myisamchk -m tbl_name
+This finds 99.999% of all errors. It checks first all index entries for errors and
+then it reads through all rows. It calculates a checksum for all keys in
+the rows and verifies that they checksum matches the checksum for the keys
+in the index tree.
+
+@item myisamchk -e tbl_name
+This does a complete and thorough check of all data (@code{-e} means
+``extended check''). It does a check-read of every key for each row to verify
+that they indeed point to the correct row. This may take a LONG time on a
+big table with many keys. @code{myisamchk} will normally stop after the first
+error it finds. If you want to obtain more information, you can add the
+@code{--verbose} (@code{-v}) option. This causes @code{myisamchk} to keep
+going, up through a maximum of 20 errors. In normal usage, a simple
+@code{myisamchk} (with no arguments other than the table name) is sufficient.
+
+@item myisamchk -e -i tbl_name
+Like the previous command, but the @code{-i} option tells @code{myisamchk} to
+print some informational statistics, too.
+@end table
+
+
+@node Repair, Optimization, Check, Table maintenance
+@subsubsection How to Repair Tables
+
+@cindex tables, repairing
+@cindex repairing, tables
+
+In the following section we only talk about using @code{myisamchk} on
+@code{MyISAM} tables (extensions @code{.MYI} and @code{.MYD}). If you
+are using @code{ISAM} tables (extensions @code{.ISM} and @code{.ISD}),
+you should use @code{isamchk} instead.
+
+Starting with MySQL Version 3.23.14, you can repair MyISAM
+tables with the @code{REPAIR TABLE} command. @xref{REPAIR TABLE}.
+
+The symptoms of a corrupted table include queries that abort unexpectedly
+and observable errors such as these:
+
+@itemize @bullet
@item
-@code{localhost} is a synonym for your local hostname, and is also the
-default host to which clients try to connect if you specify no host
-explicitly. However, connections to @code{localhost} do not work if you are
-running on a system that uses MIT-pthreads (@code{localhost} connections are
-made using Unix sockets, which are not supported by MIT-pthreads). To avoid
-this problem on such systems, you should use the @code{--host} option to name
-the server host explicitly. This will make a TCP/IP connection to the
-@code{mysqld} server. In this case, you must have your real hostname in
-@code{user} table entries on the server host. (This is true even if you are
-running a client program on the same host as the server.)
+@file{tbl_name.frm} is locked against change
+@item
+Can't find file @file{tbl_name.MYI} (Errcode: ###)
+@item
+Unexpected end of file
+@item
+Record file is crashed
+@item
+Got error ### from table handler
+To get more information about the error you can run @code{perror ###}. Here
+is the most common errors that indicates a problem with the table:
+
+@example
+shell> perror 126 127 132 134 135 136 141 144 145
+126 = Index file is crashed / Wrong file format
+127 = Record-file is crashed
+132 = Old database file
+134 = Record was already deleted (or record file crashed)
+135 = No more room in record file
+136 = No more room in index file
+141 = Duplicate unique key or constraint on write or update
+144 = Table is crashed and last repair failed
+145 = Table was marked as crashed and should be repaired
+@end example
+
+Note that error 135, no more room in record file, is not an error that
+can be fixed by a simple repair. In this case you have to do:
+
+@example
+ALTER TABLE table MAX_ROWS=xxx AVG_ROW_LENGTH=yyy;
+@end example
+
+@end itemize
+
+In the other cases, you must repair your tables. @code{myisamchk}
+can usually detect and fix most things that go wrong.
+
+The repair process involves up to four stages, described below. Before you
+begin, you should @code{cd} to the database directory and check the
+permissions of the table files. Make sure they are readable by the Unix user
+that @code{mysqld} runs as (and to you, because you need to access the files
+you are checking). If it turns out you need to modify files, they must also
+be writable by you.
+
+If you are using MySQL Version 3.23.16 and above, you can (and
+should) use the @code{CHECK} and @code{REPAIR} commands to check and repair
+@code{MyISAM} tables. @xref{CHECK TABLE}. @xref{REPAIR TABLE}.
+
+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
+if you want to use the extended features that @code{isamchk}/@code{myisamchk} provides.
+
+If you are going to repair a table from the command line, you must first
+take down the @code{mysqld} server. Note that when you do
+@code{mysqladmin shutdown} on a remote server, the @code{mysqld} server
+will still be alive for a while after @code{mysqladmin} returns, until
+all queries are stopped and all keys have been flushed to disk.
+
+@noindent
+@strong{Stage 1: Checking your tables}
+
+Run @code{myisamchk *.MYI} or @code{myisamchk -e *.MYI} if you have
+more time. Use the @code{-s} (silent) option to suppress unnecessary
+information.
+
+If the @code{mysqld} server is done you should use the --update option to tell
+@code{myisamchk} to mark the table as 'checked'.
+
+You have to repair only those tables for which @code{myisamchk} announces an
+error. For such tables, proceed to Stage 2.
+
+If you get weird errors when checking (such as @code{out of
+memory} errors), or if @code{myisamchk} crashes, go to Stage 3.
+
+@noindent
+@strong{Stage 2: Easy safe repair}
+
+NOTE: If you want repairing to go much faster, you should add: @code{-O
+sort_buffer=# -O key_buffer=#} (where # is about 1/4 of the available
+memory) to all @code{isamchk/myisamchk} commands.
+
+First, try @code{myisamchk -r -q tbl_name} (@code{-r -q} means ``quick
+recovery mode''). This will attempt to repair the index file without
+touching the data file. If the data file contains everything that it
+should and the delete links point at the correct locations within the
+data file, this should work, and the table is fixed. Start repairing the
+next table. Otherwise, use the following procedure:
+
+@enumerate
@item
-If you get an @code{Access denied} error when trying to connect to the
-database with @code{mysql -u user_name db_name}, you may have a problem
-with the @code{user} table. Check this by executing @code{mysql -u root
-mysql} and issuing this SQL statement:
+Make a backup of the data file before continuing.
+
+@item
+Use @code{myisamchk -r tbl_name} (@code{-r} means ``recovery mode''). This will
+remove incorrect records and deleted records from the data file and
+reconstruct the index file.
+
+@item
+If the preceding step fails, use @code{myisamchk --safe-recover tbl_name}.
+Safe recovery mode uses an old recovery method that handles a few cases that
+regular recovery mode doesn't (but is slower).
+@end enumerate
+
+If you get weird errors when repairing (such as @code{out of
+memory} errors), or if @code{myisamchk} crashes, go to Stage 3.
+
+@noindent
+@strong{Stage 3: Difficult repair}
+
+You should only reach this stage if the first 16K block in the index file is
+destroyed or contains incorrect information, or if the index file is
+missing. In this case, it's necessary to create a new index file. Do so as
+follows:
+
+@enumerate
+@item
+Move the data file to some safe place.
+
+@item
+Use the table description file to create new (empty) data and index files:
@example
-mysql> SELECT * FROM user;
+shell> mysql db_name
+mysql> SET AUTOCOMMIT=1;
+mysql> TRUNCATE TABLE table_name;
+mysql> quit
@end example
-The result should include an entry with the @code{Host} and @code{User}
-columns matching your computer's hostname and your @strong{MySQL} user name.
+If your SQL version doesn't have @code{TRUNCATE TABLE}, use @code{DELETE FROM
+table_name} instead.
@item
-The @code{Access denied} error message will tell you who you are trying
-to log in as, the host from which you are trying to connect, and whether
-or not you were using a password. Normally, you should have one entry in
-the @code{user} table that exactly matches the hostname and user name
-that were given in the error message. For example if you get an error
-message that contains @code{Using password: NO}, this means that you
-tried to login without an password.
+Copy the old data file back onto the newly created data file.
+(Don't just move the old file back onto the new file; you want to retain
+a copy in case something goes wrong.)
+@end enumerate
+
+Go back to Stage 2. @code{myisamchk -r -q} should work now. (This shouldn't
+be an endless loop.)
+
+@noindent
+@strong{Stage 4: Very difficult repair}
+You should reach this stage only if the description file has also
+crashed. That should never happen, because the description file isn't changed
+after the table is created:
+
+@enumerate
@item
-If you get the following error when you try to connect from a different host
-than the one on which the @strong{MySQL} server is running, then there is no
-row in the @code{user} table that matches that host:
+Restore the description file from a backup and go back to Stage 3. You can
+also restore the index file and go back to Stage 2. In the latter case, you
+should start with @code{myisamchk -r}.
+
+@item
+If you don't have a backup but know exactly how the table was created, create
+a copy of the table in another database. Remove the new data file, then move
+the description and index files from the other database to your crashed
+database. This gives you new description and index files, but leaves
+the data file alone. Go back to Stage 2 and attempt to reconstruct
+the index file.
+@end enumerate
+
+
+@node Optimization, , Repair, Table maintenance
+@subsubsection Table Optimization
+
+@cindex tables, optimizing
+@cindex optimizing, tables
+
+To coalesce fragmented records and eliminate wasted space resulting from
+deleting or updating records, run @code{myisamchk} in recovery mode:
@example
-Host ... is not allowed to connect to this MySQL server
+shell> myisamchk -r tbl_name
@end example
-You can fix this by using the command-line tool @code{mysql} (on the
-server host!) to add a row to the @code{user}, @code{db}, or @code{host}
-table for the user/hostname combination from which you are trying to
-connect and then execute @code{mysqladmin flush-privileges}. If you are
-not running @strong{MySQL} Version 3.22 and you don't know the IP number or
-hostname of the machine from which you are connecting, you should put an
-entry with @code{'%'} as the @code{Host} column value in the @code{user}
-table and restart @code{mysqld} with the @code{--log} option on the
-server machine. After trying to connect from the client machine, the
-information in the @strong{MySQL} log will indicate how you really did
-connect. (Then replace the @code{'%'} in the @code{user} table entry
-with the actual hostname that shows up in the log. Otherwise, you'll
-have a system that is insecure.)
+You can optimize a table in the same way using the SQL @code{OPTIMIZE TABLE}
+statement. @code{OPTIMIZE TABLE} does a repair of the table, a key
+analyzes and also sorts the index tree to give faster key lookups.
+There is also no possibility of unwanted interaction between a utility
+and the server, because the server does all the work when you use
+@code{OPTIMIZE TABLE}. @xref{OPTIMIZE TABLE}.
-Another reason for this error on Linux is that you are using a binary
-@strong{MySQL} version that is compiled with a different glibc version
-than the one you are using. In this case you should either upgrade your
-OS/glibc or download the source @strong{MySQL} version and compile this
-yourself. A source RPM is normally trivial to compile and install, so
-this isn't a big problem.
+@code{myisamchk} also has a number of other options you can use to improve
+the performance of a table:
+
+@table @code
+@item -S, --sort-index
+@item -R index_num, --sort-records=index_num
+@item -a, --analyze
+@end table
+
+For a full description of the option. @xref{myisamchk syntax}.
+
+
+@node Maintenance regimen, Table-info, Table maintenance, Disaster Prevention
+@subsection Setting Up a Table Maintenance Regimen
+
+@cindex maintaining, tables
+@cindex tables, maintenance regimen
+
+Starting with MySQL Version 3.23.13, you can check MyISAM
+tables with the @code{CHECK TABLE} command. @xref{CHECK TABLE}. You can
+repair tables with the @code{REPAIR TABLE} command. @xref{REPAIR TABLE}.
+
+It is a good idea to perform table checks on a regular basis rather than
+waiting for problems to occur. For maintenance purposes, you can use
+@code{myisamchk -s} to check tables. The @code{-s} option (short for
+@code{--silent}) causes @code{myisamchk} to run in silent mode, printing
+messages only when errors occur.
+
+@tindex .pid (process ID) file
+It's also a good idea to check tables when the server starts up.
+For example, whenever the machine has done a reboot in the middle of an
+update, you usually need to check all the tables that could have been
+affected. (This is an ``expected crashed table''.) You could add a test to
+@code{safe_mysqld} that runs @code{myisamchk} to check all tables that have
+been modified during the last 24 hours if there is an old @file{.pid}
+(process ID) file left after a reboot. (The @file{.pid} file is created by
+@code{mysqld} when it starts up and removed when it terminates normally. The
+presence of a @file{.pid} file at system startup time indicates that
+@code{mysqld} terminated abnormally.)
+
+An even better test would be to check any table whose last-modified time
+is more recent than that of the @file{.pid} file.
+
+You should also check your tables regularly during normal system
+operation. At MySQL AB, we run a @code{cron} job to check all
+our important tables once a week, using a line like this in a @file{crontab}
+file:
+
+@example
+35 0 * * 0 /path/to/myisamchk --fast --silent /path/to/datadir/*/*.MYI
+@end example
+
+This prints out information about crashed tables so we can examine and repair
+them when needed.
+
+As we haven't had any unexpectedly crashed tables (tables that become
+corrupted for reasons other than hardware trouble)
+for a couple of years now (this is really true), once a week is
+more than enough for us.
+
+We recommend that to start with, you execute @code{myisamchk -s} each
+night on all tables that have been updated during the last 24 hours,
+until you come to trust MySQL as much as we do.
+
+@cindex tables, defragment
+Normally you don't need to maintain MySQL tables that much. If
+you are changing tables with dynamic size rows (tables with @code{VARCHAR},
+@code{BLOB} or @code{TEXT} columns) or have tables with many deleted rows
+you may want to from time to time (once a month?) defragment/reclaim space
+from the tables.
+
+You can do this by using @code{OPTIMIZE TABLE} on the tables in question or
+if you can take the @code{mysqld} server down for a while do:
+
+@example
+isamchk -r --silent --sort-index -O sort_buffer_size=16M */*.ISM
+myisamchk -r --silent --sort-index -O sort_buffer_size=16M */*.MYI
+@end example
+
+
+@node Table-info, , Maintenance regimen, Disaster Prevention
+@subsection Getting Information About a Table
+
+@cindex tables, information
+
+To get a description of a table or statistics about it, use the commands shown
+below. We explain some of the information in more detail later:
+
+@table @code
+@item myisamchk -d tbl_name
+Runs @code{myisamchk} in ``describe mode'' to produce a description of
+your table. If you start the MySQL server using the
+@code{--skip-locking} option, @code{myisamchk} may report an error for a
+table that is updated while it runs. However, because @code{myisamchk}
+doesn't change the table in describe mode, there isn't any risk of
+destroying data.
+
+@item myisamchk -d -v tbl_name
+To produce more information about what @code{myisamchk} is doing, add @code{-v}
+to tell it to run in verbose mode.
+
+@item myisamchk -eis tbl_name
+Shows only the most important information from a table. It is slow because it
+must read the whole table.
+
+@item myisamchk -eiv tbl_name
+This is like @code{-eis}, but tells you what is being done.
+@end table
+
+@cindex examples, @code{myisamchk} output
+@cindex @code{myisamchk}, example output
+Example of @code{myisamchk -d} output:
+@example
+MyISAM file: company.MYI
+Record format: Fixed length
+Data records: 1403698 Deleted blocks: 0
+Recordlength: 226
+
+table description:
+Key Start Len Index Type
+1 2 8 unique double
+2 15 10 multip. text packed stripped
+3 219 8 multip. double
+4 63 10 multip. text packed stripped
+5 167 2 multip. unsigned short
+6 177 4 multip. unsigned long
+7 155 4 multip. text
+8 138 4 multip. unsigned long
+9 177 4 multip. unsigned long
+ 193 1 text
+@end example
+
+Example of @code{myisamchk -d -v} output:
+@example
+MyISAM file: company
+Record format: Fixed length
+File-version: 1
+Creation time: 1999-10-30 12:12:51
+Recover time: 1999-10-31 19:13:01
+Status: checked
+Data records: 1403698 Deleted blocks: 0
+Datafile parts: 1403698 Deleted data: 0
+Datafilepointer (bytes): 3 Keyfile pointer (bytes): 3
+Max datafile length: 3791650815 Max keyfile length: 4294967294
+Recordlength: 226
+
+table description:
+Key Start Len Index Type Rec/key Root Blocksize
+1 2 8 unique double 1 15845376 1024
+2 15 10 multip. text packed stripped 2 25062400 1024
+3 219 8 multip. double 73 40907776 1024
+4 63 10 multip. text packed stripped 5 48097280 1024
+5 167 2 multip. unsigned short 4840 55200768 1024
+6 177 4 multip. unsigned long 1346 65145856 1024
+7 155 4 multip. text 4995 75090944 1024
+8 138 4 multip. unsigned long 87 85036032 1024
+9 177 4 multip. unsigned long 178 96481280 1024
+ 193 1 text
+@end example
+
+Example of @code{myisamchk -eis} output:
+@example
+Checking MyISAM file: company
+Key: 1: Keyblocks used: 97% Packed: 0% Max levels: 4
+Key: 2: Keyblocks used: 98% Packed: 50% Max levels: 4
+Key: 3: Keyblocks used: 97% Packed: 0% Max levels: 4
+Key: 4: Keyblocks used: 99% Packed: 60% Max levels: 3
+Key: 5: Keyblocks used: 99% Packed: 0% Max levels: 3
+Key: 6: Keyblocks used: 99% Packed: 0% Max levels: 3
+Key: 7: Keyblocks used: 99% Packed: 0% Max levels: 3
+Key: 8: Keyblocks used: 99% Packed: 0% Max levels: 3
+Key: 9: Keyblocks used: 98% Packed: 0% Max levels: 4
+Total: Keyblocks used: 98% Packed: 17%
+
+Records: 1403698 M.recordlength: 226 Packed: 0%
+Recordspace used: 100% Empty space: 0% Blocks/Record: 1.00
+Record blocks: 1403698 Delete blocks: 0
+Recorddata: 317235748 Deleted data: 0
+Lost space: 0 Linkdata: 0
+
+User time 1626.51, System time 232.36
+Maximum resident set size 0, Integral resident set size 0
+Non physical pagefaults 0, Physical pagefaults 627, Swaps 0
+Blocks in 0 out 0, Messages in 0 out 0, Signals 0
+Voluntary context switches 639, Involuntary context switches 28966
+@end example
+
+Example of @code{myisamchk -eiv} output:
+@example
+Checking MyISAM file: company
+Data records: 1403698 Deleted blocks: 0
+- check file-size
+- check delete-chain
+block_size 1024:
+index 1:
+index 2:
+index 3:
+index 4:
+index 5:
+index 6:
+index 7:
+index 8:
+index 9:
+No recordlinks
+- check index reference
+- check data record references index: 1
+Key: 1: Keyblocks used: 97% Packed: 0% Max levels: 4
+- check data record references index: 2
+Key: 2: Keyblocks used: 98% Packed: 50% Max levels: 4
+- check data record references index: 3
+Key: 3: Keyblocks used: 97% Packed: 0% Max levels: 4
+- check data record references index: 4
+Key: 4: Keyblocks used: 99% Packed: 60% Max levels: 3
+- check data record references index: 5
+Key: 5: Keyblocks used: 99% Packed: 0% Max levels: 3
+- check data record references index: 6
+Key: 6: Keyblocks used: 99% Packed: 0% Max levels: 3
+- check data record references index: 7
+Key: 7: Keyblocks used: 99% Packed: 0% Max levels: 3
+- check data record references index: 8
+Key: 8: Keyblocks used: 99% Packed: 0% Max levels: 3
+- check data record references index: 9
+Key: 9: Keyblocks used: 98% Packed: 0% Max levels: 4
+Total: Keyblocks used: 9% Packed: 17%
+
+- check records and index references
+[LOTS OF ROW NUMBERS DELETED]
+
+Records: 1403698 M.recordlength: 226 Packed: 0%
+Recordspace used: 100% Empty space: 0% Blocks/Record: 1.00
+Record blocks: 1403698 Delete blocks: 0
+Recorddata: 317235748 Deleted data: 0
+Lost space: 0 Linkdata: 0
+
+User time 1639.63, System time 251.61
+Maximum resident set size 0, Integral resident set size 0
+Non physical pagefaults 0, Physical pagefaults 10580, Swaps 0
+Blocks in 4 out 0, Messages in 0 out 0, Signals 0
+Voluntary context switches 10604, Involuntary context switches 122798
+@end example
+
+Here are the sizes of the data and index files for the table used in the
+preceding examples:
+
+@example
+-rw-rw-r-- 1 monty tcx 317235748 Jan 12 17:30 company.MYD
+-rw-rw-r-- 1 davida tcx 96482304 Jan 12 18:35 company.MYM
+@end example
+
+Explanations for the types of information @code{myisamchk} produces are
+given below. The ``keyfile'' is the index file. ``Record'' and ``row''
+are synonymous:
+
+@table @code
+@item ISAM file
+Name of the ISAM (index) file.
+
+@item Isam-version
+Version of ISAM format. Currently always 2.
+
+@item Creation time
+When the data file was created.
+
+@item Recover time
+When the index/data file was last reconstructed.
+
+@item Data records
+How many records are in the table.
+
+@item Deleted blocks
+How many deleted blocks still have reserved space.
+You can optimize your table to minimize this space.
+@xref{Optimization}.
+
+@item Datafile: Parts
+For dynamic record format, this indicates how many data blocks there are. For
+an optimized table without fragmented records, this is the same as @code{Data
+records}.
+
+@item Deleted data
+How many bytes of non-reclaimed deleted data there are.
+You can optimize your table to minimize this space.
+@xref{Optimization}.
+
+@item Datafile pointer
+The size of the data file pointer, in bytes. It is usually 2, 3, 4, or 5
+bytes. Most tables manage with 2 bytes, but this cannot be controlled
+from MySQL yet. For fixed tables, this is a record address. For
+dynamic tables, this is a byte address.
+
+@item Keyfile pointer
+The size of the index file pointer, in bytes. It is usually 1, 2, or 3
+bytes. Most tables manage with 2 bytes, but this is calculated
+automatically by MySQL. It is always a block address.
+
+@item Max datafile length
+How long the table's data file (@code{.MYD} file) can become, in bytes.
+
+@item Max keyfile length
+How long the table's key file (@code{.MYI} file) can become, in bytes.
+
+@item Recordlength
+How much space each record takes, in bytes.
+
+@item Record format
+The format used to store table rows.
+The examples shown above use @code{Fixed length}.
+Other possible values are @code{Compressed} and @code{Packed}.
+
+@item table description
+A list of all keys in the table. For each key, some low-level information
+is presented:
+
+@table @code
+@item Key
+This key's number.
+
+@item Start
+Where in the record this index part starts.
+
+@item Len
+How long this index part is. For packed numbers, this should always be
+the full length of the column. For strings, it may be shorter than the full
+length of the indexed column, because you can index a prefix of a string
+column.
+
+@item Index
+@code{unique} or @code{multip.} (multiple). Indicates whether or not one value
+can exist multiple times in this index.
+
+@item Type
+What data-type this index part has. This is an ISAM data-type
+with the options @code{packed}, @code{stripped} or @code{empty}.
+
+@item Root
+Address of the root index block.
+
+@item Blocksize
+The size of each index block. By default this is 1024, but the value may be
+changed at compile time.
+
+@item Rec/key
+This is a statistical value used by the optimizer. It tells how many
+records there are per value for this key. A unique key always has a
+value of 1. This may be updated after a table is loaded (or greatly
+changed) with @code{myisamchk -a}. If this is not updated at all, a default
+value of 30 is given.
+@end table
@item
-If you get an error message where the hostname is not shown or where the
-hostname is an IP, even if you try to connect with a hostname:
+In the first example above, the 9th key is a multi-part key with two parts.
+
+@item Keyblocks used
+What percentage of the keyblocks are used. Because the table used in the
+examples had just been reorganized with @code{myisamchk}, the values are very
+high (very near the theoretical maximum).
+
+@item Packed
+MySQL tries to pack keys with a common suffix. This can only be used
+for @code{CHAR}/@code{VARCHAR}/@code{DECIMAL} keys. For long strings like
+names, this can significantly reduce the space used. In the third example
+above, the 4th key is 10 characters long and a 60% reduction in space is
+achieved.
+
+@item Max levels
+How deep the B-tree for this key is. Large tables with long keys get high
+values.
+
+@item Records
+How many rows are in the table.
+
+@item M.recordlength
+The average record length. For tables with fixed-length records, this is the
+exact record length.
+
+@item Packed
+MySQL strips spaces from the end of strings. The @code{Packed}
+value indicates the percentage of savings achieved by doing this.
+
+@item Recordspace used
+What percentage of the data file is used.
+
+@item Empty space
+What percentage of the data file is unused.
+
+@item Blocks/Record
+Average number of blocks per record (that is, how many links a fragmented
+record is composed of). This is always 1 for fixed-format tables. This value
+should stay as close to 1.0 as possible. If it gets too big, you can
+reorganize the table with @code{myisamchk}.
+@xref{Optimization}.
+
+@item Recordblocks
+How many blocks (links) are used. For fixed format, this is the same as the number
+of records.
+
+@item Deleteblocks
+How many blocks (links) are deleted.
+
+@item Recorddata
+How many bytes in the data file are used.
+
+@item Deleted data
+How many bytes in the data file are deleted (unused).
+
+@item Lost space
+If a record is updated to a shorter length, some space is lost. This is
+the sum of all such losses, in bytes.
+
+@item Linkdata
+When the dynamic table format is used, record fragments are linked with
+pointers (4 to 7 bytes each). @code{Linkdata} is the sum of the amount of
+storage used by all such pointers.
+@end table
+
+If a table has been compressed with @code{myisampack}, @code{myisamchk
+-d} prints additional information about each table column. See
+@ref{myisampack, , @code{myisampack}}, for an example of this
+information and a description of what it means.
+
+
+@node Database Administration, Localization, Disaster Prevention, MySQL Database Administration
+@section Database Administration Language Reference
+
+
+@menu
+* OPTIMIZE TABLE:: @code{OPTIMIZE TABLE} Syntax
+* ANALYZE TABLE:: @code{ANALYZE TABLE} Syntax
+* FLUSH:: @code{FLUSH} Syntax
+* KILL:: @code{KILL} Syntax
+* SHOW:: @code{SHOW} Syntax
+@end menu
+
+
+@node OPTIMIZE TABLE, ANALYZE TABLE, Database Administration, Database Administration
+@subsection @code{OPTIMIZE TABLE} Syntax
+
+@findex OPTIMIZE TABLE
+
+@cindex tables, defragmenting
+@cindex tables, fragmentation
@example
-shell> mysqladmin -u root -pxxxx -h some-hostname ver
-Access denied for user: 'root@' (Using password: YES)
+OPTIMIZE TABLE tbl_name[,tbl_name]...
@end example
-This means that @strong{MySQL} got some error when trying to resolve the
-IP to a hostname. In this case you can execute @code{mysqladmin
-flush-hosts} to reset the internal DNS cache. @xref{DNS}.
+@code{OPTIMIZE TABLE} should be used if you have deleted a large part of a
+table or if you have made many changes to a table with variable-length rows
+(tables that have @code{VARCHAR}, @code{BLOB}, or @code{TEXT} columns).
+Deleted records are maintained in a linked list and subsequent @code{INSERT}
+operations reuse old record positions. You can use @code{OPTIMIZE TABLE} to
+reclaim the unused space and to defragment the data file.
-Some permanent solutions are:
+For the moment @code{OPTIMIZE TABLE} only works on @strong{MyISAM} and
+@code{BDB} tables. For @code{BDB} tables, @code{OPTIMIZE TABLE} is
+currently mapped to @code{ANALYZE TABLE}. @xref{ANALYZE TABLE}.
-@itemize @minus
+You can get optimize table to work on other table types by starting
+@code{mysqld} with @code{--skip-new} or @code{--safe-mode}, but in this
+case @code{OPTIMIZE TABLE} is just mapped to @code{ALTER TABLE}.
+
+@code{OPTIMIZE TABLE} works the following way:
+@itemize @bullet
@item
-Try to find out what is wrong with your DNS server and fix this.
+If the table has deleted or split rows, repair the table.
@item
-Specify IPs instead of hostnames in the @strong{MySQL} privilege tables.
+If the index pages are not sorted, sort them.
@item
-Start @code{mysqld} with @code{--skip-name-resolve}.
+If the statistics are not up to date (and the repair couldn't be done
+by sorting the index), update them.
+@end itemize
+
+@code{OPTIMIZE TABLE} for @code{MyISAM} tables is equvialent of running
+@code{myisamchk --quick --check-changed-tables --sort-index --analyze}
+on the table.
+
+Note that the table is locked during the time @code{OPTIMIZE TABLE} is
+running!
+
+
+@node ANALYZE TABLE, FLUSH, OPTIMIZE TABLE, Database Administration
+@subsection @code{ANALYZE TABLE} Syntax
+
+@findex ANALYZE TABLE
+
+@example
+ANALYZE TABLE tbl_name[,tbl_name...]
+@end example
+
+Analyze and store the key distribution for the table. During the
+analyze the table is locked with a read lock. This works on
+@code{MyISAM} and @code{BDB} tables.
+
+This is equivalent to running @code{myisamchk -a} on the table.
+
+MySQL uses the stored key distribution to decide in which order
+tables should be joined when one does a join on something else than a
+constant.
+
+The command returns a table with the following columns:
+
+@multitable @columnfractions .35 .65
+@item @strong{Column} @tab @strong{Value}
+@item Table @tab Table name
+@item Op @tab Always ``analyze''
+@item Msg_type @tab One of @code{status}, @code{error}, @code{info} or @code{warning}.
+@item Msg_text @tab The message.
+@end multitable
+
+You can check the stored key distribution with the @code{SHOW INDEX} command.
+@xref{SHOW DATABASE INFO}.
+
+If the table hasn't changed since the last @code{ANALYZE TABLE} command,
+the table will not be analyzed again.
+
+
+@node FLUSH, KILL, ANALYZE TABLE, Database Administration
+@subsection @code{FLUSH} Syntax
+
+@findex FLUSH
+
+@cindex @code{mysqladmin}
+@cindex clearing, caches
+@cindex caches, clearing
+
+@example
+FLUSH flush_option [,flush_option]
+@end example
+
+You should use the @code{FLUSH} command if you want to clear some of the
+internal caches MySQL uses. To execute @code{FLUSH}, you must have
+the @strong{RELOAD} privilege.
+
+@code{flush_option} can be any of the following:
+
+@multitable @columnfractions .15 .85
+@item @code{HOSTS} @tab Empties the host cache tables. You should flush the
+host tables if some of your hosts change IP number or if you get the
+error message @code{Host ... is blocked}. When more than
+@code{max_connect_errors} errors occur in a row for a given host while
+connection to the MySQL server, MySQL assumes
+something is wrong and blocks the host from further connection requests.
+Flushing the host tables allows the host to attempt to connect
+again. @xref{Blocked host}.) You can start @code{mysqld} with
+@code{-O max_connection_errors=999999999} to avoid this error message.
+
+@item @code{LOGS} @tab Closes and reopens all log files.
+If you have specified the update log file or a binary log file without
+an extension, the extension number of the log file will be incremented
+by one relative to the previous file. If you have used an extension in
+the file name, MySQL will close and reopen the update log file.
+@xref{Update log}. This is the same thing as sending the @code{SIGHUP}
+signal to the @code{mysqld} server.
+
+@item @code{PRIVILEGES} @tab Reloads the privileges from the grant tables in
+the @code{mysql} database.
+
+@item @code{TABLES} @tab Closes all open tables and force all tables in use to be closed.
+
+@item @code{[TABLE | TABLES] table_name [,table_name...]} @tab Flushes only the given tables.
+
+@item @code{TABLES WITH READ LOCK} @tab Closes all open tables and locks all tables for all databases with a read until one executes @code{UNLOCK TABLES}. This is very convenient way to get backups if you have a file system, like Veritas,that can take snapshots in time.
+
+@item @code{STATUS} @tab Resets most status variables to zero. This is something one should only use when debugging a query.
+@end multitable
+
+You can also access each of the commands shown above with the @code{mysqladmin}
+utility, using the @code{flush-hosts}, @code{flush-logs}, @code{reload},
+or @code{flush-tables} commands.
+
+Take also a look at the @code{RESET} command used with
+replication. @xref{Replication SQL}.
+
+
+
+@node KILL, SHOW, FLUSH, Database Administration
+@subsection @code{KILL} Syntax
+
+@findex KILL
+
+@cindex @code{mysqladmin}
+
+@example
+KILL thread_id
+@end example
+
+Each connection to @code{mysqld} runs in a separate thread. You can see
+which threads are running with the @code{SHOW PROCESSLIST} command and kill
+a thread with the @code{KILL thread_id} command.
+
+If you have the @strong{process} privilege, you can see and kill all threads.
+Otherwise, you can see and kill only your own threads.
+
+You can also use the @code{mysqladmin processlist} and @code{mysqladmin kill}
+commands to examine and kill threads.
+
+When you do a @code{KILL}, a thread specific @code{kill flag} is set for
+the thread.
+
+In most cases it may take some time for the thread to die as the kill
+flag is only checked at specific intervals.
+
+@itemize @bullet
@item
-Start @code{mysqld} with @code{--skip-host-cache}.
+In @code{SELECT}, @code{ORDER BY} and @code{GROUP BY} loops, the flag is
+checked after reading a block of rows. If the kill flag is set the
+statement is aborted
@item
-Connect to @code{localhost} if you are running the server and the client
-on the same machine.
+When doing an @code{ALTER TABLE} the kill flag is checked before each block of
+rows are read from the original table. If the kill flag was set the command
+is aborted and the temporary table is deleted.
@item
-Put the client machine names in @code{/etc/hosts}.
+When doing an @code{UPDATE TABLE} and @code{DELETE TABLE}, the kill flag
+is checked after each block read and after each updated or delete
+row. If the kill flag is set the statement is aborted. Note that if you
+are not using transactions, the changes will not be rolled back!
+@item
+@code{GET_LOCK()} will abort with @code{NULL}.
+@item
+An @code{INSERT DELAYED} thread will quickly flush all rows it has in
+memory and die.
+@item
+If the thread is in the table lock handler (state: @code{Locked}),
+the table lock will be quickly aborted.
+@item
+If the thread is waiting for free disk space in a @code{write} call, the
+write is aborted with an disk full error message.
@end itemize
+
+@menu
+* SHOW:: @code{SHOW} Syntax
+@end menu
+
+
+@node SHOW, , KILL, Database Administration
+@subsection @code{SHOW} Syntax
+
+@c FIX more index hits needed
+
+@findex SHOW DATABASE INFO
+@findex SHOW DATABASES
+@findex SHOW TABLES
+@findex SHOW COLUMNS
+@findex SHOW FIELDS
+@findex SHOW INDEX
+@findex SHOW KEYS
+@findex SHOW STATUS
+@findex SHOW VARIABLES
+@findex SHOW PROCESSLIST
+@findex SHOW TABLE STATUS
+@findex SHOW GRANTS
+@findex SHOW CREATE TABLE
+@findex SHOW MASTER STATUS
+@findex SHOW MASTER LOGS
+@findex SHOW SLAVE STATUS
+
+@example
+ SHOW DATABASES [LIKE wild]
+or SHOW [OPEN] TABLES [FROM db_name] [LIKE wild]
+or SHOW [FULL] COLUMNS FROM tbl_name [FROM db_name] [LIKE wild]
+or SHOW INDEX FROM tbl_name [FROM db_name]
+or SHOW TABLE STATUS [FROM db_name] [LIKE wild]
+or SHOW STATUS [LIKE wild]
+or SHOW VARIABLES [LIKE wild]
+or SHOW LOGS
+or SHOW [FULL] PROCESSLIST
+or SHOW GRANTS FOR user
+or SHOW CREATE TABLE table_name
+or SHOW MASTER STATUS
+or SHOW MASTER LOGS
+or SHOW SLAVE STATUS
+@end example
+
+@code{SHOW} provides information about databases, tables, columns, or
+status information about the server. If the @code{LIKE wild} part is
+used, the @code{wild} string can be a string that uses the SQL @samp{%}
+and @samp{_} wild-card characters.
+
+@menu
+* SHOW DATABASE INFO:: Retrieving information about Database, Tables, Columns, and Indexes
+* SHOW TABLE STATUS:: @code{SHOW TABLE STATUS}
+* SHOW STATUS:: @code{SHOW STATUS}
+* SHOW VARIABLES:: @code{SHOW VARIABLES}
+* SHOW LOGS:: @code{SHOW LOGS}
+* SHOW PROCESSLIST:: @code{SHOW PROCESSLIST}
+* SHOW GRANTS:: @code{SHOW GRANTS}
+* SHOW CREATE TABLE:: @code{SHOW CREATE TABLE}
+@end menu
+
+
+@node SHOW DATABASE INFO, SHOW TABLE STATUS, SHOW, SHOW
+@subsubsection Retrieving information about Database, Tables, Columns, and Indexes
+
+@cindex displaying, information, @code{SHOW}
+
+You can use @code{db_name.tbl_name} as an alternative to the @code{tbl_name
+FROM db_name} syntax. These two statements are equivalent:
+
+@example
+mysql> SHOW INDEX FROM mytable FROM mydb;
+mysql> SHOW INDEX FROM mydb.mytable;
+@end example
+
+@code{SHOW DATABASES} lists the databases on the MySQL server
+host. You can also get this list using the @code{mysqlshow} command.
+
+@code{SHOW TABLES} lists the tables in a given database. You can also
+get this list using the @code{mysqlshow db_name} command.
+
+@strong{NOTE:} If a user doesn't have any privileges for a table, the table
+will not show up in the output from @code{SHOW TABLES} or @code{mysqlshow
+db_name}.
+
+@code{SHOW OPEN TABLES} lists the tables that are currently open in
+the table cache. @xref{Table cache}. The @code{Comment} field tells
+how many times the table is @code{cached} and @code{in_use}.
+
+@code{SHOW COLUMNS} lists the columns in a given table. If you specify
+the @code{FULL} option, you will also get the privileges you have for
+each column. If the column types are different than you expect them to
+be based on a @code{CREATE TABLE} statement, note that MySQL
+sometimes changes column types. @xref{Silent column changes}.
+
+The @code{DESCRIBE} statement provides information similar to
+@code{SHOW COLUMNS}.
+@xref{DESCRIBE, , @code{DESCRIBE}}.
+
+@code{SHOW FIELDS} is a synonym for @code{SHOW COLUMNS}, and
+@code{SHOW KEYS} is a synonym for @code{SHOW INDEX}. You can also
+list a table's columns or indexes with @code{mysqlshow db_name tbl_name}
+or @code{mysqlshow -k db_name tbl_name}.
+
+@code{SHOW INDEX} returns the index information in a format that closely
+resembles the @code{SQLStatistics} call in ODBC. The following columns
+are returned:
+
+@multitable @columnfractions .35 .65
+@item @strong{Column} @tab @strong{Meaning}
+@item @code{Table} @tab Name of the table.
+@item @code{Non_unique} @tab 0 if the index can't contain duplicates.
+@item @code{Key_name} @tab Name of the index.
+@item @code{Seq_in_index} @tab Column sequence number in index,
+ starting with 1.
+@item @code{Column_name} @tab Column name.
+@item @code{Collation} @tab How the column is sorted in the index.
+ In MySQL, this can have values
+ @samp{A} (Ascending) or @code{NULL} (Not
+ sorted).
+@item @code{Cardinality} @tab Number of unique values in the index.
+ This is updated by running
+ @code{isamchk -a}.
+@item @code{Sub_part} @tab Number of indexed characters if the
+ column is only partly indexed.
+ @code{NULL} if the entire key is indexed.
+@item @code{Comment} @tab Various remarks. For now, it tells
+ whether index is FULLTEXT or not.
+@end multitable
+
+Note that as the @code{Cardinality} is counted based on statistics
+stored as integers, it's not necessarily accurate for small tables.
+
+
+@node SHOW TABLE STATUS, SHOW STATUS, SHOW DATABASE INFO, SHOW
+@subsubsection @code{SHOW TABLE STATUS}
+
+@cindex displaying, table status
+@cindex tables, displaying status
+@cindex status, tables
+
+@example
+SHOW TABLE STATUS [FROM db_name] [LIKE wild]
+@end example
+
+@code{SHOW TABLE STATUS} (new in Version 3.23) works likes @code{SHOW
+STATUS}, but provides a lot of information about each table. You can
+also get this list using the @code{mysqlshow --status db_name} command.
+The following columns are returned:
+
+@multitable @columnfractions .30 .70
+@item @strong{Column} @tab @strong{Meaning}
+@item @code{Name} @tab Name of the table.
+@item @code{Type} @tab Type of table. @xref{Table types}.
+@item @code{Row_format} @tab The row storage format (Fixed, Dynamic, or Compressed).
+@item @code{Rows} @tab Number of rows.
+@item @code{Avg_row_length} @tab Average row length.
+@item @code{Data_length} @tab Length of the data file.
+@item @code{Max_data_length} @tab Max length of the data file.
+@item @code{Index_length} @tab Length of the index file.
+@item @code{Data_free} @tab Number of allocated but not used bytes.
+@item @code{Auto_increment} @tab Next autoincrement value.
+@item @code{Create_time} @tab When the table was created.
+@item @code{Update_time} @tab When the data file was last updated.
+@item @code{Check_time} @tab When the table was last checked.
+@item @code{Create_options} @tab Extra options used with @code{CREATE TABLE}.
+@item @code{Comment} @tab The comment used when creating the table (or some information why MySQL couldn't access the table information).
+@end multitable
+
+@code{InnoDB} tables will report the free space in the tablespace
+in the table comment.
+
+
+@node SHOW STATUS, SHOW VARIABLES, SHOW TABLE STATUS, SHOW
+@subsubsection @code{SHOW STATUS}
+
+@cindex @code{mysqladmin}
+@code{SHOW STATUS} provides server status information
+(like @code{mysqladmin extended-status}). The output resembles that shown
+below, though the format and numbers probably differ:
+
+@example
++--------------------------+------------+
+| Variable_name | Value |
++--------------------------+------------+
+| Aborted_clients | 0 |
+| Aborted_connects | 0 |
+| Bytes_received | 155372598 |
+| Bytes_sent | 1176560426 |
+| Connections | 30023 |
+| Created_tmp_disk_tables | 0 |
+| Created_tmp_tables | 8340 |
+| Created_tmp_files | 60 |
+| Delayed_insert_threads | 0 |
+| Delayed_writes | 0 |
+| Delayed_errors | 0 |
+| Flush_commands | 1 |
+| Handler_delete | 462604 |
+| Handler_read_first | 105881 |
+| Handler_read_key | 27820558 |
+| Handler_read_next | 390681754 |
+| Handler_read_prev | 6022500 |
+| Handler_read_rnd | 30546748 |
+| Handler_read_rnd_next | 246216530 |
+| Handler_update | 16945404 |
+| Handler_write | 60356676 |
+| Key_blocks_used | 14955 |
+| Key_read_requests | 96854827 |
+| Key_reads | 162040 |
+| Key_write_requests | 7589728 |
+| Key_writes | 3813196 |
+| Max_used_connections | 0 |
+| Not_flushed_key_blocks | 0 |
+| Not_flushed_delayed_rows | 0 |
+| Open_tables | 1 |
+| Open_files | 2 |
+| Open_streams | 0 |
+| Opened_tables | 44600 |
+| Questions | 2026873 |
+| Select_full_join | 0 |
+| Select_full_range_join | 0 |
+| Select_range | 99646 |
+| Select_range_check | 0 |
+| Select_scan | 30802 |
+| Slave_running | OFF |
+| Slave_open_temp_tables | 0 |
+| Slow_launch_threads | 0 |
+| Slow_queries | 0 |
+| Sort_merge_passes | 30 |
+| Sort_range | 500 |
+| Sort_rows | 30296250 |
+| Sort_scan | 4650 |
+| Table_locks_immediate | 1920382 |
+| Table_locks_waited | 0 |
+| Threads_cached | 0 |
+| Threads_created | 30022 |
+| Threads_connected | 1 |
+| Threads_running | 1 |
+| Uptime | 80380 |
++--------------------------+------------+
+@end example
+
+@cindex variables, status
+The status variables listed above have the following meaning:
+
+@multitable @columnfractions .35 .65
+@item @strong{Variable} @tab @strong{Meaning}
+@item @code{Aborted_clients} @tab Number of connections aborted because the client died without closing the connection properly. @xref{Communication errors}.
+@item @code{Aborted_connects} @tab Number of tries to connect to the MySQL server that failed. @xref{Communication errors}.
+@item @code{Bytes_received} @tab Number of bytes received from all clients.
+@item @code{Bytes_sent} @tab Number of bytes sent to all clients.
+@item @code{Connections} @tab Number of connection attempts to the MySQL server.
+@item @code{Created_tmp_disk_tables} @tab Number of implicit temporary tables on disk created while executing statements.
+@item @code{Created_tmp_tables} @tab Number of implicit temporary tables in memory created while executing statements.
+@item @code{Created_tmp_files} @tab How many temporary files @code{mysqld} have created.
+@item @code{Delayed_insert_threads} @tab Number of delayed insert handler threads in use.
+@item @code{Delayed_writes} @tab Number of rows written with @code{INSERT DELAYED}.
+@item @code{Delayed_errors} @tab Number of rows written with @code{INSERT DELAYED} for which some error occurred (probably @code{duplicate key}).
+@item @code{Flush_commands} @tab Number of executed @code{FLUSH} commands.
+@item @code{Handler_delete} @tab Number of times a row was deleted from a table.
+@item @code{Handler_read_first} @tab Number of times the first entry was read from an index.
+If this is high, it suggests that the server is doing a lot of full index scans, for example,
+@code{SELECT col1 FROM foo}, assuming that col1 is indexed.
+@item @code{Handler_read_key} @tab Number of requests to read a row based on a key. If this
+is high, it is a good indication that your queries and tables are properly indexed.
+@item @code{Handler_read_next} @tab Number of requests to read next row in key order. This
+will be incremented if you are querying an index column with a range constraint. This also
+will be incremented if you are doing an index scan.
+@item @code{Handler_read_rnd} @tab Number of requests to read a row based on a fixed position.
+This will be high if you are doing a lot of queries that require sorting of the result.
+@item @code{Handler_read_rnd_next} @tab Number of requests to read the next row in the datafile.
+This will be high if you are doing a lot of table scans. Generally this suggests that your tables
+are not properly indexed or that your queries are not written to take advantage of the indexes you
+have.
+@item @code{Handler_update} @tab Number of requests to update a row in a table.
+@item @code{Handler_write} @tab Number of requests to insert a row in a table.
+@item @code{Key_blocks_used} @tab The number of used blocks in the key cache.
+@item @code{Key_read_requests} @tab The number of requests to read a key block from the cache.
+@item @code{Key_reads} @tab The number of physical reads of a key block from disk.
+@item @code{Key_write_requests} @tab The number of requests to write a key block to the cache.
+@item @code{Key_writes} @tab The number of physical writes of a key block to disk.
+@item @code{Max_used_connections} @tab The maximum number of connections in use simultaneously.
+@item @code{Not_flushed_key_blocks} @tab Keys blocks in the key cache that has changed but hasn't yet been flushed to disk.
+@item @code{Not_flushed_delayed_rows} @tab Number of rows waiting to be written in @code{INSERT DELAY} queues.
+@item @code{Open_tables} @tab Number of tables that are open.
+@item @code{Open_files} @tab Number of files that are open.
+@item @code{Open_streams} @tab Number of streams that are open (used mainly for logging).
+@item @code{Opened_tables} @tab Number of tables that have been opened.
+@item @code{Select_full_join} @tab Number of joins without keys (Should be 0).
+@item @code{Select_full_range_join} @tab Number of joins where we used a range search on reference table.
+@item @code{Select_range} @tab Number of joins where we used ranges on the first table. (It's normally not critical even if this is big.)
+@item @code{Select_scan} @tab Number of joins where we scanned the first table.
+@item @code{Select_range_check} @tab Number of joins without keys where we check for key usage after each row (Should be 0).
+@item @code{Questions} @tab Number of queries sent to the server.
+@item @code{Slave_open_temp_tables} @tab Number of temporary tables currently
+open by the slave thread
+@item @code{Slow_launch_threads} @tab Number of threads that have taken more than @code{slow_launch_time} to connect.
+@item @code{Slow_queries} @tab Number of queries that have taken more than @code{long_query_time}. @xref{Slow query log}.
+@item @code{Sort_merge_passes} @tab Number of merges the sort has to do. If this value is large you should consider increasing @code{sort_buffer}.
+@item @code{Sort_range} @tab Number of sorts that where done with ranges.
+@item @code{Sort_rows} @tab Number of sorted rows.
+@item @code{Sort_scan} @tab Number of sorts that where done by scanning the table.
+@item @code{Table_locks_immediate} @tab Number of times a table lock was
+acquired immediately. Available after 3.23.33.
+@item @code{Table_locks_waited} @tab Number of times a table lock could not
+be acquired immediately and a wait was needed. If this is high, and you
+have performance problems, you should first optimize your queries, and then
+either split your table(s) or use replication. Available after 3.23.33.
+@item @code{Threads_cached} @tab Number of threads in the thread cache.
+@item @code{Threads_connected} @tab Number of currently open connections.
+@item @code{Threads_created} @tab Number of threads created to handle connections.
+@item @code{Threads_running} @tab Number of threads that are not sleeping.
+@item @code{Uptime} @tab How many seconds the server has been up.
+@end multitable
+
+Some comments about the above:
+
+@itemize @bullet
@item
-If @code{mysql -u root test} works but @code{mysql -h your_hostname -u root
-test} results in @code{Access denied}, then you may not have the correct name
-for your host in the @code{user} table. A common problem here is that the
-@code{Host} value in the user table entry specifies an unqualified hostname,
-but your system's name resolution routines return a fully qualified domain
-name (or vice-versa). For example, if you have an entry with host
-@code{'tcx'} in the @code{user} table, but your DNS tells @strong{MySQL} that
-your hostname is @code{'tcx.subnet.se'}, the entry will not work. Try adding
-an entry to the @code{user} table that contains the IP number of your host as
-the @code{Host} column value. (Alternatively, you could add an entry to the
-@code{user} table with a @code{Host} value that contains a wild card---for
-example, @code{'tcx.%'}. However, use of hostnames ending with @samp{%} is
-@emph{insecure} and is @emph{not} recommended!)
+If @code{Opened_tables} is big, then your @code{table_cache}
+variable is probably too small.
+@item
+If @code{key_reads} is big, then your @code{key_cache} is probably too
+small. The cache hit rate can be calculated with
+@code{key_reads}/@code{key_read_requests}.
+@item
+If @code{Handler_read_rnd} is big, then you probably have a lot of
+queries that require MySQL to scan whole tables or you have
+joins that don't use keys properly.
+@item
+If @code{Threads_created} is big, you may want to increase the
+@code{thread_cache_size} variable.
+@end itemize
+
+
+@node SHOW VARIABLES, SHOW LOGS, SHOW STATUS, SHOW
+@subsubsection @code{SHOW VARIABLES}
+
+@example
+SHOW VARIABLES [LIKE wild]
+@end example
+
+@code{SHOW VARIABLES} shows the values of some MySQL system
+variables. You can also get this information using the @code{mysqladmin
+variables} command. If the default values are unsuitable, you can set most
+of these variables using command-line options when @code{mysqld} starts up.
+@xref{Command-line options}.
+
+The output resembles that shown below, though the format and numbers may
+differ somewhat:
+
+@example
++-------------------------+---------------------------+
+| Variable_name | Value |
++-------------------------+---------------------------+
+| ansi_mode | OFF |
+| back_log | 50 |
+| basedir | /my/monty/ |
+| bdb_cache_size | 16777216 |
+| bdb_log_buffer_size | 32768 |
+| bdb_home | /my/monty/data/ |
+| bdb_max_lock | 10000 |
+| bdb_logdir | |
+| bdb_shared_data | OFF |
+| bdb_tmpdir | /tmp/ |
+| binlog_cache_size | 32768 |
+| concurrent_insert | ON |
+| connect_timeout | 5 |
+| datadir | /my/monty/data/ |
+| delay_key_write | ON |
+| delayed_insert_limit | 100 |
+| delayed_insert_timeout | 300 |
+| delayed_queue_size | 1000 |
+| flush | OFF |
+| flush_time | 0 |
+| have_bdb | YES |
+| have_innodb | YES |
+| have_raid | YES |
+| have_ssl | NO |
+| init_file | |
+| interactive_timeout | 28800 |
+| join_buffer_size | 131072 |
+| key_buffer_size | 16776192 |
+| language | /my/monty/share/english/ |
+| large_files_support | ON |
+| log | OFF |
+| log_update | OFF |
+| log_bin | OFF |
+| log_slave_updates | OFF |
+| long_query_time | 10 |
+| low_priority_updates | OFF |
+| lower_case_table_names | 0 |
+| max_allowed_packet | 1048576 |
+| max_binlog_cache_size | 4294967295 |
+| max_connections | 100 |
+| max_connect_errors | 10 |
+| max_delayed_threads | 20 |
+| max_heap_table_size | 16777216 |
+| max_join_size | 4294967295 |
+| max_sort_length | 1024 |
+| max_tmp_tables | 32 |
+| max_write_lock_count | 4294967295 |
+| myisam_recover_options | DEFAULT |
+| myisam_sort_buffer_size | 8388608 |
+| net_buffer_length | 16384 |
+| net_read_timeout | 30 |
+| net_retry_count | 10 |
+| net_write_timeout | 60 |
+| open_files_limit | 0 |
+| pid_file | /my/monty/data/donna.pid |
+| port | 3306 |
+| protocol_version | 10 |
+| record_buffer | 131072 |
+| query_buffer_size | 0 |
+| safe_show_database | OFF |
+| server_id | 0 |
+| skip_locking | ON |
+| skip_networking | OFF |
+| skip_show_database | OFF |
+| slow_launch_time | 2 |
+| socket | /tmp/mysql.sock |
+| sort_buffer | 2097116 |
+| table_cache | 64 |
+| table_type | MYISAM |
+| thread_cache_size | 4 |
+| thread_stack | 65536 |
+| tmp_table_size | 1048576 |
+| tmpdir | /tmp/ |
+| version | 3.23.29a-gamma-debug |
+| wait_timeout | 28800 |
++-------------------------+---------------------------+
+@end example
+
+Each option is described below. Values for buffer sizes, lengths, and stack
+sizes are given in bytes. You can specify values with a suffix of @samp{K}
+or @samp{M} to indicate kilobytes or megabytes. For example, @code{16M}
+indicates 16 megabytes. The case of suffix letters does not matter;
+@code{16M} and @code{16m} are equivalent:
+
+@cindex variables, values
+@table @code
+@item @code{ansi_mode}.
+Is @code{ON} if @code{mysqld} was started with @code{--ansi}.
+@xref{ANSI mode}.
+
+@item @code{back_log}
+The number of outstanding connection requests MySQL can have. This
+comes into play when the main MySQL thread gets @strong{VERY}
+many connection requests in a very short time. It then takes some time
+(although very little) for the main thread to check the connection and start
+a new thread. The @code{back_log} value indicates how many requests can be
+stacked during this short time before MySQL momentarily stops
+answering new requests. You need to increase this only if you expect a large
+number of connections in a short period of time.
+
+In other words, this value is the size of the listen queue for incoming
+TCP/IP connections. Your operating system has its own limit on the size
+of this queue. The manual page for the Unix @code{listen(2)} system
+call should have more details. Check your OS documentation for the
+maximum value for this variable. Attempting to set @code{back_log}
+higher than your operating system limit will be ineffective.
+
+@item @code{basedir}
+The value of the @code{--basedir} option.
+
+@item @code{bdb_cache_size}
+The buffer that is allocated to cache index and rows for @code{BDB}
+tables. If you don't use @code{BDB} tables, you should start
+@code{mysqld} with @code{--skip-bdb} to not waste memory for this
+cache.
+
+@item @code{bdb_log_buffer_size}
+The buffer that is allocated to cache index and rows for @code{BDB}
+tables. If you don't use @code{BDB} tables, you should set this to 0 or
+start @code{mysqld} with @code{--skip-bdb} to not waste memory for this
+cache.
+
+@item @code{bdb_home}
+The value of the @code{--bdb-home} option.
+
+@item @code{bdb_max_lock}
+The maximum number of locks (1000 by default) you can have active on a
+BDB table. You should increase this if you get errors of type @code{bdb:
+Lock table is out of available locks} or @code{Got error 12 from ...}
+when you have do long transactions or when @code{mysqld} has to examine
+a lot of rows to calculate the query.
+
+@item @code{bdb_logdir}
+The value of the @code{--bdb-logdir} option.
+
+@item @code{bdb_shared_data}
+Is @code{ON} if you are using @code{--bdb-shared-data}.
+
+@item @code{bdb_tmpdir}
+The value of the @code{--bdb-tmpdir} option.
+
+@item @code{binlog_cache_size}. The size of the cache to hold the SQL
+statements for the binary log during a transaction. If you often use
+big, multi-statement transactions you can increase this to get more
+performance. @xref{COMMIT}.
+
+@item @code{character_set}
+The default character set.
+
+@item @code{character_sets}
+The supported character sets.
+
+@item @code{concurrent_inserts}
+If @code{ON} (the default), MySQL will allow you to use @code{INSERT}
+on @code{MyISAM} tables at the same time as you run @code{SELECT} queries
+on them. You can turn this option off by starting @code{mysqld} with @code{--safe}
+or @code{--skip-new}.
+
+@cindex timeout
+@item @code{connect_timeout}
+The number of seconds the @code{mysqld} server is waiting for a connect
+packet before responding with @code{Bad handshake}.
+
+@item @code{datadir}
+The value of the @code{--datadir} option.
+
+@item @code{delay_key_write}
+If enabled (is on by default), MySQL will honor the
+@code{delay_key_write} option @code{CREATE TABLE}. This means that the
+key buffer for tables with this option will not get flushed on every
+index update, but only when a table is closed. This will speed up
+writes on keys a lot, but you should add automatic checking of all tables
+with @code{myisamchk --fast --force} if you use this. Note that if you
+start @code{mysqld} with the @code{--delay-key-write-for-all-tables}
+option this means that all tables will be treated as if they were
+created with the @code{delay_key_write} option. You can clear this flag
+by starting @code{mysqld} with @code{--skip-new} or @code{--safe-mode}.
+
+@item @code{delayed_insert_limit}
+After inserting @code{delayed_insert_limit} rows, the @code{INSERT
+DELAYED} handler will check if there are any @code{SELECT} statements
+pending. If so, it allows these to execute before continuing.
+
+@item @code{delayed_insert_timeout}
+How long a @code{INSERT DELAYED} thread should wait for @code{INSERT}
+statements before terminating.
+
+@item @code{delayed_queue_size}
+What size queue (in rows) should be allocated for handling @code{INSERT
+DELAYED}. If the queue becomes full, any client that does @code{INSERT
+DELAYED} will wait until there is room in the queue again.
+
+@item @code{flush}
+This is @code{ON} if you have started MySQL with the @code{--flush}
+option.
+
+@item @code{flush_time}
+If this is set to a non-zero value, then every @code{flush_time} seconds all
+tables will be closed (to free up resources and sync things to disk). We
+only recommend this option on Win95, Win98, or on systems where you have
+very little resources.
+
+@item @code{have_bdb}
+@code{YES} if @code{mysqld} supports Berkeley DB tables. @code{DISABLED}
+if @code{--skip-bdb} is used.
+@item @code{have_innodb}
+@code{YES} if @code{mysqld} supports InnoDB tables. @code{DISABLED}
+if @code{--skip-innodb} is used.
+@item @code{have_raid}
+@code{YES} if @code{mysqld} supports the @code{RAID} option.
+@item @code{have_ssl}
+@code{YES} if @code{mysqld} supports SSL (encryption) on the client/server
+protocol.
+
+@item @code{init_file}
+The name of the file specified with the @code{--init-file} option when
+you start the server. This is a file of SQL statements you want the
+server to execute when it starts.
+
+@item @code{interactive_timeout}
+The number of seconds the server waits for activity on an interactive
+connection before closing it. An interactive client is defined as a
+client that uses the @code{CLIENT_INTERACTIVE} option to
+@code{mysql_real_connect()}. See also @code{wait_timeout}.
+
+@item @code{join_buffer_size}
+The size of the buffer that is used for full joins (joins that do not
+use indexes). The buffer is allocated one time for each full join
+between two tables. Increase this value to get a faster full join when
+adding indexes is not possible. (Normally the best way to get fast joins
+is to add indexes.)
+
+@c Make texi2html support index @anchor{Index cache size}. Then change
+@c some xrefs to point here
+@cindex indexes, block size
+@item @code{key_buffer_size}
+Index blocks are buffered and are shared by all threads.
+@code{key_buffer_size} is the size of the buffer used for index blocks.
+
+Increase this to get better index handling (for all reads and multiple
+writes) to as much as you can afford; 64M on a 256M machine that mainly
+runs MySQL is quite common. If you, however, make this too big
+(more than 50% of your total memory?) your system may start to page and
+become REALLY slow. Remember that because MySQL does not cache
+data read, that you will have to leave some room for the OS filesystem
+cache.
+
+You can check the performance of the key buffer by doing @code{show
+status} and examine the variables @code{Key_read_requests},
+@code{Key_reads}, @code{Key_write_requests}, and @code{Key_writes}. The
+@code{Key_reads/Key_read_request} ratio should normally be < 0.01.
+The @code{Key_write/Key_write_requests} is usually near 1 if you are
+using mostly updates/deletes but may be much smaller if you tend to
+do updates that affect many at the same time or if you are
+using @code{delay_key_write}. @xref{SHOW}.
+
+To get even more speed when writing many rows at the same time, use
+@code{LOCK TABLES}. @xref{LOCK TABLES, , @code{LOCK TABLES}}.
+
+@item @code{language}
+The language used for error messages.
+
+@item @code{large_file_support}
+If @code{mysqld} was compiled with options for big file support.
+
+@item @code{locked_in_memory}
+If @code{mysqld} was locked in memory with @code{--memlock}
+
+@item @code{log}
+If logging of all queries is enabled.
+
+@item @code{log_update}
+If the update log is enabled.
+
+@item @code{log_bin}
+If the binary log is enabled.
+
+@item @code{log_slave_updates}
+If the updates from the slave should be logged.
+
+@item @code{long_query_time}
+If a query takes longer than this (in seconds), the @code{Slow_queries} counter
+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}
+If set to 1 table names are stored in lowercase on disk and table
+names will be case-insensitive.
+@xref{Name case sensitivity}.
+
+@item @code{max_allowed_packet}
+The maximum size of one packet. The message buffer is initialized to
+@code{net_buffer_length} bytes, but can grow up to @code{max_allowed_packet}
+bytes when needed. This value by default is small, to catch big (possibly
+wrong) packets. You must increase this value if you are using big
+@code{BLOB} columns. It should be as big as the biggest @code{BLOB} you want
+to use. The current protocol limits @code{max_allowed_packet} to 16M.
+
+@item @code{max_binlog_cache_size}
+If a multi-statement transaction requires more than this amount of memory,
+one will get the error "Multi-statement transaction required more than
+'max_binlog_cache_size' bytes of storage".
+
+@item @code{max_binlog_size}
+Available after 3.23.33. If a write to the binary (replication) log exceeds
+the given value, rotate the logs. You cannot set it to less than 1024 bytes,
+or more than 1 GB. Default is 1 GB.
+
+@item @code{max_connections}
+The number of simultaneous clients allowed. Increasing this value increases
+the number of file descriptors that @code{mysqld} requires. See below for
+comments on file descriptor limits. @xref{Too many connections}.
+
+@item @code{max_connect_errors}
+If there is more than this number of interrupted connections from a host
+this host will be blocked from further connections. You can unblock a host
+with the command @code{FLUSH HOSTS}.
+
+@item @code{max_delayed_threads}
+Don't start more than this number of threads to handle @code{INSERT DELAYED}
+statements. If you try to insert data into a new table after all @code{INSERT
+DELAYED} threads are in use, the row will be inserted as if the
+@code{DELAYED} attribute wasn't specified.
+
+@item @code{max_heap_table_size}
+Don't allow creation of heap tables bigger than this.
+
+@item @code{max_join_size}
+Joins that are probably going to read more than @code{max_join_size}
+records return an error. Set this value if your users tend to perform joins
+that lack a @code{WHERE} clause, that take a long time, and that return
+millions of rows.
+
+@item @code{max_sort_length}
+The number of bytes to use when sorting @code{BLOB} or @code{TEXT}
+values (only the first @code{max_sort_length} bytes of each value
+are used; the rest are ignored).
+
+@item @code{max_user_connections}
+The maximum number of active connections for a single user (0 = no limit).
+
+@item @code{max_tmp_tables}
+(This option doesn't yet do anything.)
+Maximum number of temporary tables a client can keep open at the same time.
+
+@item @code{max_write_lock_count}
+After this many write locks, allow some read locks to run in between.
+
+@item @code{myisam_recover_options}
+The value of the @code{--myisam-recover} option.
+
+@item @code{myisam_sort_buffer_size}
+The buffer that is allocated when sorting the index when doing a
+@code{REPAIR} or when creating indexes with @code{CREATE INDEX} or
+@code{ALTER TABLE}.
+
+@item @code{myisam_max_extra_sort_file_size}.
+If the creating of the temporary file for fast index creation would be
+this much bigger than using the key cache, then prefer the key cache
+method. This is mainly used to force long character keys in large
+tables to use the slower key cache method to create the index.
+@strong{NOTE} that this parameter is given in megabytes!
+
+@item @code{myisam_max_sort_file_size}
+The maximum size of the temporary file MySQL is allowed to use
+while recreating the index (during @code{REPAIR}, @code{ALTER TABLE}
+or @code{LOAD DATA INFILE}. If the file size would be bigger than this,
+the index will be created through the key cache (which is slower).
+@strong{NOTE} that this parameter is given in megabytes!
+
+@item @code{net_buffer_length}
+The communication buffer is reset to this size between queries. This
+should not normally be changed, but if you have very little memory, you
+can set it to the expected size of a query. (That is, the expected length of
+SQL statements sent by clients. If statements exceed this length, the buffer
+is automatically enlarged, up to @code{max_allowed_packet} bytes.)
+
+@item @code{net_read_timeout}
+Number of seconds to wait for more data from a connection before aborting
+the read. Note that when we don't expect data from a connection, the timeout
+is defined by @code{write_timeout}. See also @code{slave_read_timeout}.
+
+@item @code{net_retry_count}
+If a read on a communication port is interrupted, retry this many times
+before giving up. This value should be quite high on @code{FreeBSD} as
+internal interrupts are sent to all threads.
+
+@item @code{net_write_timeout}
+Number of seconds to wait for a block to be written to a connection before
+aborting the write.
+
+@item @code{open_files_limit}
+If this is not 0, then @code{mysqld} will use this value to reserve file
+descriptors to use with @code{setrlimit()}. If this value is 0 then
+@code{mysqld} will reserve @code{max_connections*5} or
+@code{max_connections + table_cache*2} (whichever is larger) number of
+files. You should try increasing this if @code{mysqld} gives you the
+error 'Too many open files'.
+
+@item @code{pid_file}
+The value of the @code{--pid-file} option.
+
+@item @code{port}
+The value of the @code{--port} option.
+
+@item @code{protocol_version}
+The protocol version used by the MySQL server.
+
+@item @code{record_buffer}
+Each thread that does a sequential scan allocates a buffer of this
+size for each table it scans. If you do many sequential scans, you may
+want to increase this value.
+
+@item @code{record_rnd_buffer}
+When reading rows in sorted order after a sort, the rows are read through this
+buffer to avoid a disk seeks. If not set, then it's set to the value of
+@code{record_buffer}.
+
+@item @code{query_buffer_size}
+The initial allocation of the query buffer. If most of your queries are
+long (like when inserting blobs), you should increase this!
+
+@item @code{safe_show_databases}
+Don't show databases for which the user doesn't have any database or
+table privileges. This can improve security if you're concerned about
+people being able to see what databases other users have. See also
+@code{skip_show_databases}.
+
+@item @code{server_id}
+The value of the @code{--server-id} option.
+
+@item @code{skip_locking}
+Is OFF if @code{mysqld} uses external locking.
+
+@item @code{skip_networking}
+Is ON if we only allow local (socket) connections.
+
+@item @code{skip_show_databases}
+This prevents people from doing @code{SHOW DATABASES} if they don't have
+the @code{PROCESS_PRIV} privilege. This can improve security if you're
+concerned about people being able to see what databases other users
+have. See also @code{safe_show_databases}.
+
+@item @code{slave_read_timeout}
+Number of seconds to wait for more data from a master/slave connection
+before aborting the read.
+
+@item @code{slow_launch_time}
+If creating the thread takes longer than this value (in seconds), the
+@code{Slow_launch_threads} counter will be incremented.
+
+@item @code{socket}
+The Unix socket used by the server.
+
+@item @code{sort_buffer}
+Each thread that needs to do a sort allocates a buffer of this
+size. Increase this value for faster @code{ORDER BY} or @code{GROUP BY}
+operations.
+@xref{Temporary files}.
+
+@item @code{table_cache}
+The number of open tables for all threads. Increasing this value
+increases the number of file descriptors that @code{mysqld} requires.
+MySQL needs two file descriptors for each unique open table.
+See below for comments on file descriptor limits. You can check if you
+need to increase the table cache by checking the @code{Opened_tables}
+variable. @xref{SHOW}. If this variable is big and you don't do
+@code{FLUSH TABLES} a lot (which just forces all tables to be closed and
+reopenend), then you should increase the value of this variable.
+
+Make sure that your operating system can handle the number of open file
+descriptors implied by the @code{table_cache} setting. If @code{table_cache}
+is set too high, MySQL may run out of file descriptors and refuse
+connections, fail to perform queries, and be very unreliable.
+
+For information about how the table cache works, see @ref{Table cache}.
+
+@item @code{table_type}
+The default table type
+
+@item @code{thread_cache_size}
+How many threads we should keep in a cache for reuse. When a
+client disconnects, the client's threads are put in the cache if there
+aren't more than @code{thread_cache_size} threads from before. All new
+threads are first taken from the cache, and only when the cache is empty
+is a new thread created. This variable can be increased to improve
+performance if you have a lot of new connections. (Normally this doesn't
+give a notable performance improvement if you have a good
+thread implementation.) By examing the difference between
+the @code{Connections} and @code{Threads_created} you can see how efficient
+the current thread cache is for you.
+
+@item @code{thread_concurrency}
+On Solaris, @code{mysqld} will call @code{thr_setconcurrency()} with
+this value. @code{thr_setconcurrency()} permits the application to give
+the threads system a hint for the desired number of threads that should
+be run at the same time.
+
+@item @code{thread_stack}
+The stack size for each thread. Many of the limits detected by the
+@code{crash-me} test are dependent on this value. The default is
+large enough for normal operation. @xref{MySQL Benchmarks}.
+
+@item @code{timezone}
+The timezone for the server.
+
+@item @code{tmp_table_size}
+If an in-memory temporary table exceeds this size, MySQL
+will automatically convert it to an on-disk @code{MyISAM} table.
+Increase the value of @code{tmp_table_size} if you do many advanced
+@code{GROUP BY} queries and you have lots of memory.
+
+@item @code{tmpdir}
+The directory used for temporary files and temporary tables.
+
+@item @code{version}
+The version number for the server.
+
+@item @code{wait_timeout}
+The number of seconds the server waits for activity on a connection before
+closing it. See also @code{interactive_timeout}.
+@end table
+
+The manual section that describes tuning MySQL contains some
+information of how to tune the above variables. @xref{Server parameters}.
+
+
+@node SHOW LOGS, SHOW PROCESSLIST, SHOW VARIABLES, SHOW
+@subsubsection @code{SHOW LOGS}
+
+@code{SHOW LOGS} shows you status information about existing log
+files. It currently only displays information about Berkeley DB log
+files.
+
+@itemize @bullet
+@item @code{File} shows the full path to the log file
+@item @code{Type} shows the type of the log file (@code{BDB} for Berkeley
+DB log files)
+@item @code{Status} shows the status of the log file (@code{FREE} if the
+file can be removed, or @code{IN USE} if the file is needed by the transaction
+subsystem)
+@end itemize
+
+
+@node SHOW PROCESSLIST, SHOW GRANTS, SHOW LOGS, SHOW
+@subsubsection @code{SHOW PROCESSLIST}
+
+@findex threads
+@findex PROCESSLIST
+
+@cindex threads, display
+@cindex processes, display
+
+@code{SHOW PROCESSLIST} shows you which threads are running. You can
+also get this information using the @code{mysqladmin processlist}
+command. If you have the @strong{process} privilege, you can see all
+threads. Otherwise, you can see only your own threads. @xref{KILL, ,
+@code{KILL}}. If you don't use the @code{FULL} option, then only
+the first 100 characters of each query will be shown.
+
+This command is very useful if you get the 'too many connections' error
+message and want to find out what's going on. MySQL reserves
+one extra connection for a client with the @code{Process_priv} privilege
+to ensure that you should always be able to login and check the system
+(assuming you are not giving this privilege to all your users).
+
+@node SHOW GRANTS, SHOW CREATE TABLE, SHOW PROCESSLIST, SHOW
+@subsubsection @code{SHOW GRANTS}
+
+@cindex privileges, display
+
+@code{SHOW GRANTS FOR user} lists the grant commands that must be issued to
+duplicate the grants for a user.
+
+@example
+mysql> SHOW GRANTS FOR root@@localhost;
++---------------------------------------------------------------------+
+| Grants for root@@localhost |
++---------------------------------------------------------------------+
+| GRANT ALL PRIVILEGES ON *.* TO 'root'@@'localhost' WITH GRANT OPTION |
++---------------------------------------------------------------------+
+@end example
+
+
+@node SHOW CREATE TABLE, , SHOW GRANTS, SHOW
+@subsubsection @code{SHOW CREATE TABLE}
+
+Shows a @code{CREATE TABLE} statement that will create the given table:
+
+@example
+mysql> show create table t\G
+*************************** 1. row ***************************
+ Table: t
+Create Table: CREATE TABLE t (
+ id int(11) default NULL auto_increment,
+ s char(60) default NULL,
+ PRIMARY KEY (id)
+) TYPE=MyISAM
+
+@end example
+
+@code{SHOW CREATE TABLE} will quote table and column names according to
+@code{SQL_QUOTE_SHOW_CREATE} option.
+@ref{SET OPTION, , @code{SET OPTION SQL_QUOTE_SHOW_CREATE}}.
+
+
+@node Localization, Server-Side Scripts, Database Administration, MySQL Database Administration
+@section MySQL Localization and International Usage
+
+@menu
+* Character sets:: The Character Set Used for Data and Sorting
+* Languages:: Non-English Error Messages
+* Adding character set:: Adding a New Character Set
+* Character arrays:: The character definition arrays
+* String collating:: String Collating Support
+* Multi-byte characters:: Multi-byte Character Support
+@end menu
+
+
+@node Character sets, Languages, Localization, Localization
+@subsection The Character Set Used for Data and Sorting
+
+@cindex character sets
+@cindex data, character sets
+@cindex sorting, character sets
+
+By default, MySQL uses the ISO-8859-1 (Latin1) character set
+with sorting according to Swedish/Finnish. This is the character set suitable
+in the USA and western Europe.
+
+All standard MySQL binaries are compiled with
+@code{--with-extra-charsets=complex}. This will add code to all
+standard programs to be able to handle @code{latin1} and all multi-byte
+character sets within the binary. Other character sets will be
+loaded from a character-set definition file when needed.
+
+The character set determines what characters are allowed in names and how
+things are sorted by the @code{ORDER BY} and @code{GROUP BY} clauses of
+the @code{SELECT} statement.
+
+You can change the character set with the @code{--default-character-set}
+option when you start the server. The character sets available depend
+on the @code{--with-charset=charset} and @code{--with-extra-charset=
+list-of-charset | complex | all} options to @code{configure}, and the
+character set configuration files listed in
+@file{SHAREDIR/charsets/Index}. @xref{configure options}.
+
+If you change the character set when running MySQL (which may
+also change the sort order), you must run myisamchk -r -q on all
+tables. Otherwise your indexes may not be ordered correctly.
+
+When a client connects to a MySQL server, the server sends the
+default character set in use to the client. The client will switch to
+use this character set for this connection.
+
+One should use @code{mysql_real_escape_string()} when escaping strings
+for a SQL query. @code{mysql_real_escape_string()} is identical to the
+old @code{mysql_escape_string()} function, except that it takes the MYSQL
+connection handle as the first parameter.
+
+If the client is compiled with different paths than where the server is
+installed and the user who configured MySQL didn't included all
+character sets in the MySQL binary, one must specify for
+the client where it can find the additional character sets it will need
+if the server runs with a different character set than the client.
+
+One can specify this by putting in a MySQL option file:
+
+@example
+[client]
+character-sets-dir=/usr/local/mysql/share/mysql/charsets
+@end example
+
+where the path points to where the dynamic MySQL character sets
+are stored.
+
+One can force the client to use specific character set by specifying:
+
+@example
+[client]
+default-character-set=character-set-name
+@end example
+
+but normally this is never needed.
+
+
+@node Languages, Adding character set, Character sets, Localization
+@subsection Non-English Error Messages
+
+@cindex error messages, languages
+@cindex messages, languages
+@cindex files, error messages
+@cindex language support
+
+@code{mysqld} can issue error messages in the following languages:
+Czech, Danish, Dutch, English (the default), Estonian, French, German, Greek,
+Hungarian, Italian, Japanese, Korean, Norwegian, Norwegian-ny, Polish,
+Portuguese, Romanian, Russian, Slovak, Spanish, and Swedish.
+
+To start @code{mysqld} with a particular language, use either the
+@code{--language=lang} or @code{-L lang} options. For example:
+
+@example
+shell> mysqld --language=swedish
+@end example
+
+or:
+
+@example
+shell> mysqld --language=/usr/local/share/swedish
+@end example
+
+Note that all language names are specified in lowercase.
+
+The language files are located (by default) in
+@file{@var{mysql_base_dir}/share/@var{LANGUAGE}/}.
+
+To update the error message file, you should edit the @file{errmsg.txt} file
+and execute the following command to generate the @file{errmsg.sys} file:
+
+@example
+shell> comp_err errmsg.txt errmsg.sys
+@end example
+
+If you upgrade to a newer version of MySQL, remember to repeat
+your changes with the new @file{errmsg.txt} file.
+
+
+@node Adding character set, Character arrays, Languages, Localization
+@subsection Adding a New Character Set
+
+@cindex character sets, adding
+@cindex adding, character sets
+
+To add another character set to MySQL, use the following procedure.
+
+Decide if the set is simple or complex. If the character set
+does not need to use special string collating routines for
+sorting and does not need multi-byte character support, it is
+simple. If it needs either of those features, it is complex.
+
+For example, @code{latin1} and @code{danish} are simple charactersets while
+@code{big5} or @code{czech} are complex character sets.
+
+In the following section, we have assumed that you name your character
+set @code{MYSET}.
+
+For a simple character set do the following:
+
+@enumerate
@item
-If @code{mysql -u user_name test} works but @code{mysql -u user_name
-other_db_name} doesn't work, you don't have an entry for @code{other_db_name}
-listed in the @code{db} table.
+Add MYSET to the end of the @file{sql/share/charsets/Index} file
+Assign an unique number to it.
@item
-If @code{mysql -u user_name db_name} works when executed on the server
-machine, but @code{mysql -u host_name -u user_name db_name} doesn't work when
-executed on another client machine, you don't have the client machine listed
-in the @code{user} table or the @code{db} table.
+Create the file @file{sql/share/charsets/MYSET.conf}.
+(You can use @file{sql/share/charsets/latin1.conf} as a base for this).
+
+The syntax for the file very simple:
+@itemize @bullet
@item
-If you can't figure out why you get @code{Access denied}, remove from the
-@code{user} table all entries that have @code{Host} values containing
-wild cards (entries that contain @samp{%} or @samp{_}). A very common error
-is to insert a new entry with @code{Host}=@code{'%'} and
-@code{User}=@code{'some user'}, thinking that this will allow you to specify
-@code{localhost} to connect from the same machine. The reason that this
-doesn't work is that the default privileges include an entry with
-@code{Host}=@code{'localhost'} and @code{User}=@code{''}. Because that entry
-has a @code{Host} value @code{'localhost'} that is more specific than
-@code{'%'}, it is used in preference to the new entry when connecting from
-@code{localhost}! The correct procedure is to insert a second entry with
-@code{Host}=@code{'localhost'} and @code{User}=@code{'some_user'}, or to
-remove the entry with @code{Host}=@code{'localhost'} and
-@code{User}=@code{''}.
+Comments start with a '#' character and proceed to the end of the line.
+@item
+Words are separated by arbitrary amounts of whitespace.
+@item
+When defining the character set, every word must be a number in hexadecimal
+format
+@item
+The @code{ctype} array takes up the first 257 words. The
+@code{to_lower}, @code{to_upper} and @code{sort_order} arrays take up
+256 words each after that.
+@end itemize
+
+@xref{Character arrays}.
@item
-If you get the following error, you may have a problem with the @code{db} or
-@code{host} table:
+Add the character set name to the @code{CHARSETS_AVAILABLE} and
+@code{COMPILED_CHARSETS} lists in @code{configure.in}.
+
+@item
+Reconfigure, recompile, and test.
+
+@end enumerate
+
+For a complex character set do the following:
+
+@enumerate
+@item
+Create the file @file{strings/ctype-MYSET.c} in the MySQL source
+distribution.
+
+@item
+Add MYSET to the end of the @file{sql/share/charsets/Index} file.
+Assign an unique number to it.
+
+@item
+Look at one of the existing @file{ctype-*.c} files to see what needs to
+be defined, for example @file{strings/ctype-big5.c}. Note that the
+arrays in your file must have names like @code{ctype_MYSET},
+@code{to_lower_MYSET}, and so on. This corresponds to the arrays
+in the simple character set. @xref{Character arrays}. For a complex
+character set
+
+@item
+Near the top of the file, place a special comment like this:
@example
-Access to database denied
+/*
+ * This comment is parsed by configure to create ctype.c,
+ * so don't change it unless you know what you are doing.
+ *
+ * .configure. number_MYSET=MYNUMBER
+ * .configure. strxfrm_multiply_MYSET=N
+ * .configure. mbmaxlen_MYSET=N
+ */
@end example
-If the entry selected from the @code{db} table has an empty value in the
-@code{Host} column, make sure there are one or more corresponding entries in
-the @code{host} table specifying which hosts the @code{db} table entry
-applies to.
+The @code{configure} program uses this comment to include
+the character set into the MySQL library automatically.
-If you get the error when using the SQL commands @code{SELECT ...
-INTO OUTFILE} or @code{LOAD DATA INFILE}, your entry in the @code{user} table
-probably doesn't have the @strong{file} privilege enabled.
+The strxfrm_multiply and mbmaxlen lines will be explained in
+the following sections. Only include them if you the string
+collating functions or the multi-byte character set functions,
+respectively.
@item
-@cindex configuration files
+You should then create some of the following functions:
+
+@itemize @bullet
+@item @code{my_strncoll_MYSET()}
+@item @code{my_strcoll_MYSET()}
+@item @code{my_strxfrm_MYSET()}
+@item @code{my_like_range_MYSET()}
+@end itemize
+
+@xref{String collating}.
+
+@item
+Add the character set name to the @code{CHARSETS_AVAILABLE} and
+@code{COMPILED_CHARSETS} lists in @code{configure.in}.
+
+@item
+Reconfigure, recompile, and test.
+@end enumerate
+
+The file @file{sql/share/charsets/README} includes some more instructions.
+
+If you want to have the character set included in the MySQL
+distribution, mail a patch to @email{internals@@lists.mysql.com}.
+
+
+@node Character arrays, String collating, Adding character set, Localization
+@subsection The character definition arrays
+
+@code{to_lower[]} and @code{to_upper[]} are simple arrays that hold the
+lowercase and uppercase characters corresponding to each member of the
+character set. For example:
+
+@example
+to_lower['A'] should contain 'a'
+to_upper['a'] should contain 'A'
+@end example
+
+@code{sort_order[]} is a map indicating how characters should be ordered for
+comparison and sorting purposes. For many character sets, this is the same as
+@code{to_upper[]} (which means sorting will be case insensitive).
+MySQL will sort characters based on the value of
+@code{sort_order[character]}. For more complicated sorting rules, see
+the discussion of string collating below. @xref{String collating}.
+
+@code{ctype[]} is an array of bit values, with one element for one character.
+(Note that @code{to_lower[]}, @code{to_upper[]}, and @code{sort_order[]}
+are indexed by character value, but @code{ctype[]} is indexed by character
+value + 1. This is an old legacy to be able to handle EOF.)
+
+You can find the following bitmask definitions in @file{m_ctype.h}:
+
+@example
+#define _U 01 /* Uppercase */
+#define _L 02 /* Lowercase */
+#define _N 04 /* Numeral (digit) */
+#define _S 010 /* Spacing character */
+#define _P 020 /* Punctuation */
+#define _C 040 /* Control character */
+#define _B 0100 /* Blank */
+#define _X 0200 /* heXadecimal digit */
+@end example
+
+The @code{ctype[]} entry for each character should be the union of the
+applicable bitmask values that describe the character. For example,
+@code{'A'} is an uppercase character (@code{_U}) as well as a
+hexadecimal digit (@code{_X}), so @code{ctype['A'+1]} should contain the
+value:
+
+@example
+_U + _X = 01 + 0200 = 0201
+@end example
+
+
+@node String collating, Multi-byte characters, Character arrays, Localization
+@subsection String Collating Support
+
+@cindex collating, strings
+@cindex string collating
+
+If the sorting rules for your language are too complex to be handled
+with the simple @code{sort_order[]} table, you need to use the string
+collating functions.
+
+Right now the best documentation on this is the character sets that are
+already implemented. Look at the big5, czech, gbk, sjis, and tis160
+character sets for examples.
+
+You must specify the @code{strxfrm_multiply_MYSET=N} value in the
+special comment at the top of the file. @code{N} should be set to
+the maximum ratio the strings may grow during @code{my_strxfrm_MYSET} (it
+must be a positive integer).
+
+
+@node Multi-byte characters, , String collating, Localization
+@subsection Multi-byte Character Support
+
+@cindex characters, multi-byte
+@cindex multi-byte characters
+
+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. 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 source file. @code{N} should be set to the
+size in bytes of the largest character in the set.
+
+
+@node Server-Side Scripts, Client-Side Scripts, Localization, MySQL Database Administration
+@section MySQL Server-Side Scripts and Utilities
+
+@menu
+* Server-Side Overview:: Overview of the Server-Side Scripts and Utilities
+* safe_mysqld:: safe_mysqld, the wrapper around mysqld
+* mysqld_multi:: mysqld_multi, program for managing multiple MySQL servers
+* myisampack:: myisampack, The MySQL Compressed Read-only Table Generator
+* mysqld-max:: mysqld-max, An extended mysqld server
+@end menu
+
+
+@node Server-Side Overview, safe_mysqld, Server-Side Scripts, Server-Side Scripts
+@subsection Overview of the Server-Side Scripts and Utilities
+
@cindex environment variables
-@tindex .my.cnf file
-Remember that client programs will use connection parameters specified
-in configuration files or environment variables. @xref{Environment
-variables}. If a client seems to be sending the wrong default
-connection parameters when you don't specify them on the command line,
-check your environment and the @file{.my.cnf} file in your home
-directory. You might also check the system-wide @strong{MySQL}
-configuration files, though it is far less likely that client connection
-parameters will be specified there. @xref{Option files}. If you get
-@code{Access denied} when you run a client without any options, make
-sure you haven't specified an old password in any of your option files!
+@cindex programs, list of
+
+All MySQL clients that communicate with the server using the
+@code{mysqlclient} library use the following environment variables:
+
+@tindex @code{MYSQL_UNIX_PORT} environment variable
+@tindex environment variable, @code{MYSQL_UNIX_PORT}
+@tindex @code{MYSQL_TCP_PORT} environment variable
+@tindex environment variable, @code{MYSQL_TCP_PORT}
+@tindex @code{MYSQL_PWD} environment variable
+@tindex environment variable, @code{MYSQL_PWD}
+@tindex @code{MYSQL_DEBUG} environment variable
+@tindex environment variable, @code{MYSQL_DEBUG}
+@multitable @columnfractions .25 .75
+@item @strong{Name} @tab @strong{Description}
+@item @code{MYSQL_UNIX_PORT} @tab The default socket; used for connections to @code{localhost}
+@item @code{MYSQL_TCP_PORT} @tab The default TCP/IP port
+@item @code{MYSQL_PWD} @tab The default password
+@item @code{MYSQL_DEBUG} @tab Debug-trace options when debugging
+@item @code{TMPDIR} @tab The directory where temporary tables/files are created
+@end multitable
+
+Use of @code{MYSQL_PWD} is insecure.
+@xref{Connecting}.
+
+@tindex @code{MYSQL_HISTFILE} environment variable
+@tindex environment variable, @code{MYSQL_HISTFILE}
+@tindex @code{HOME} environment variable
+@tindex environment variable, @code{HOME}
+@cindex history file
+@cindex command line history
+@tindex .mysql_history file
+The @file{mysql} client uses the file named in the @code{MYSQL_HISTFILE}
+environment variable to save the command-line history. The default value for
+the history file is @file{$HOME/.mysql_history}, where @code{$HOME} is the
+value of the @code{HOME} environment variable. @xref{Environment variables}.
+
+All MySQL programs take many different options. However, every
+MySQL program provides a @code{--help} option that you can use
+to get a full description of the program's different options. For example, try
+@code{mysql --help}.
+
+You can override default options for all standard client programs with an
+option file. @ref{Option files}.
+
+The list below briefly describes the MySQL programs:
+
+@table @code
+
+@cindex @code{myisamchk}
+@item myisamchk
+Utility to describe, check, optimize, and repair MySQL tables.
+Because @code{myisamchk} has many functions, it is described in its own
+chapter. @xref{MySQL Database Administration}.
+
+@cindex @code{make_binary_distribution}
+@item make_binary_distribution
+Makes a binary release of a compiled MySQL. This could be sent
+by FTP to @file{/pub/mysql/Incoming} on @code{support.mysql.com} for the
+convenience of other MySQL users.
+
+@cindex @code{msql2mysql}
+@item msql2mysql
+A shell script that converts @code{mSQL} programs to MySQL. It doesn't
+handle all cases, but it gives a good start when converting.
+
+@cindex @code{mysqlaccess}
+@item mysqlaccess
+A script that checks the access privileges for a host, user, and database
+combination.
+
+@cindex @code{mysqladmin}
+@item mysqladmin
+Utility for performing administrative operations, such as creating or
+dropping databases, reloading the grant tables, flushing tables to disk, and
+reopening log files. @code{mysqladmin} can also be used to retrieve version,
+process, and status information from the server.
+@xref{mysqladmin, , @code{mysqladmin}}.
+
+@cindex @code{mysqlbug}
+@item mysqlbug
+The MySQL bug report script. This script should always be used when
+filing a bug report to the MySQL list.
+
+@cindex @code{mysqld}
+@item mysqld
+The SQL daemon. This should always be running.
+
+@cindex @code{mysqldump}
+@item mysqldump
+Dumps a MySQL database into a file as SQL statements or
+as tab-separated text files. Enhanced freeware originally by Igor Romanenko.
+@xref{mysqldump, , @code{mysqldump}}.
+
+@cindex @code{mysqlimport}
+@item mysqlimport
+Imports text files into their respective tables using @code{LOAD DATA
+INFILE}. @xref{mysqlimport, , @code{mysqlimport}}.
+
+@cindex @code{mysqlshow}
+@item mysqlshow
+Displays information about databases, tables, columns, and indexes.
+
+@cindex @code{mysql_install_db}
+@item mysql_install_db
+Creates the MySQL grant tables with default privileges. This is
+usually executed only once, when first installing MySQL
+on a system.
+
+@cindex @code{replace}
+@item replace
+A utility program that is used by @code{msql2mysql}, but that has more
+general applicability as well. @code{replace} changes strings in place in
+files or on the standard input. Uses a finite state machine to match longer
+strings first. Can be used to swap strings. For example, this command
+swaps @code{a} and @code{b} in the given files:
+
+@example
+shell> replace a b b a -- file1 file2 ...
+@end example
+@end table
+
+
+@node safe_mysqld, mysqld_multi, Server-Side Overview, Server-Side Scripts
+@subsection safe_mysqld, the wrapper around mysqld
+
+@cindex tools, safe_mysqld
+@cindex scripts
+@cindex @code{safe_mysqld}
+
+@code{safe_mysqld} is the recommended way to start a @code{mysqld}
+daemon on Unix. @code{safe_mysqld} adds some safety features such as
+restarting the server when an error occurs and logging run-time
+information to a log file.
+
+If you don't use @code{--mysqld=#} or @code{--mysqld-version=#}
+@code{safe_mysqld} will use an executable named @code{mysqld-max} if it
+exists. If not, @code{safe_mysqld} will start @code{mysqld}.
+This makes it very easy to test to use @code{mysqld-max} instead of
+@code{mysqld}; Just copy @code{mysqld-max} to where you have
+@code{mysqld} and it will be used.
+
+Normally one should never edit the @code{safe_mysqld} script, but
+instead put the options to @code{safe_mysqld} in the
+@code{[safe_mysqld]} section in the @code{my.cnf}
+file. @code{safe_mysqld} will read all options from the @code{[mysqld]},
+@code{[server]} and @code{[safe_mysqld]} sections from the option files.
@xref{Option files}.
+Note that all options on the command line to @code{safe_mysqld} are passed
+to @code{mysqld}. If you wants to use any options in @code{safe_mysqld} that
+@code{mysqld} doesn't support, you must specify these in the option file.
+
+Most of the options to @code{safe_mysqld} are the same as the options to
+@code{mysqld}. @xref{Command-line options}.
+
+@code{safe_mysqld} supports the following options:
+
+@table @code
+@item --basedir=path
+@item --core-file-size=#
+Size of the core file @code{mysqld} should be able to create. Passed to @code{ulimit -c}.
+@item --datadir=path
+@item --defaults-extra-file=path
+@item --defaults-file=path
+@item --err-log=path
+@item --ledir=path
+Path to @code{mysqld}
+@item --log=path
+@item --mysqld=mysqld-version
+Name of the @code{mysqld} version in the @code{ledir} directory you want to start.
+@item --mysqld-version=version
+Similar to @code{--mysqld=} but here you only give the suffix for @code{mysqld}.
+For example if you use @code{--mysqld-version=max}, @code{safe_mysqld} will
+start the @code{ledir/mysqld-max} version. If the argument to
+@code{--mysqld-version} is empty, @code{ledir/mysqld} will be used.
+@item --no-defaults
+@item --open-files-limit=#
+Number of files @code{mysqld} should be able to open. Passed to @code{ulimit -n}. Note that you need to start @code{safe_mysqld} as root for this to work properly!
+@item --pid-file=path
+@item --port=#
+@item --socket=path
+@item --timezone=#
+Set the timezone (the @code{TZ}) variable to the value of this parameter.
+@item --user=#
+@end table
+
+The @code{safe_mysqld} script is written so that it normally is able to start
+a server that was installed from either a source or a binary version of
+MySQL, even if these install the server in slightly different
+locations. @code{safe_mysqld} expects one of these conditions to be true:
+
+@itemize @bullet
@item
-If you make changes to the grant tables directly (using an @code{INSERT} or
-@code{UPDATE} statement) and your changes seem to be ignored, remember
-that you must issue a @code{FLUSH PRIVILEGES} statement or execute a
-@code{mysqladmin flush-privileges} command to cause the server to re-read
-the privilege tables. Otherwise your changes have no effect until the
-next time the server is restarted. Remember that after you set the
-@code{root} password with an @code{UPDATE} command, you won't need to
-specify it until after you flush the privileges, because the server
-won't know you've changed the password yet!
+The server and databases can be found relative to the directory from which
+@code{safe_mysqld} is invoked. @code{safe_mysqld} looks under its working
+directory for @file{bin} and @file{data} directories (for binary
+distributions) or for @file{libexec} and @file{var} directories (for source
+distributions). This condition should be met if you execute
+@code{safe_mysqld} from your MySQL installation directory (for
+example, @file{/usr/local/mysql} for a binary distribution).
@item
-If you have access problems with a Perl, PHP, Python, or ODBC program, try to
-connect to the server with @code{mysql -u user_name db_name} or @code{mysql
--u user_name -pyour_pass db_name}. If you are able to connect using the
-@code{mysql} client, there is a problem with your program and not with the
-access privileges. (Note that there is no space between @code{-p} and the
-password; you can also use the @code{--password=your_pass} syntax to specify
-the password. If you use the @code{-p} option alone, @strong{MySQL} will
-prompt you for the password.)
+If the server and databases cannot be found relative to the working directory,
+@code{safe_mysqld} attempts to locate them by absolute pathnames. Typical
+locations are @file{/usr/local/libexec} and @file{/usr/local/var}.
+The actual locations are determined when the distribution was built from which
+@code{safe_mysqld} comes. They should be correct if
+MySQL was installed in a standard location.
+@end itemize
+
+Because @code{safe_mysqld} will try to find the server and databases relative
+to its own working directory, you can install a binary distribution of
+MySQL anywhere, as long as you start @code{safe_mysqld} from the
+MySQL installation directory:
+
+@example
+shell> cd mysql_installation_directory
+shell> bin/safe_mysqld &
+@end example
+
+If @code{safe_mysqld} fails, even when invoked from the MySQL
+installation directory, you can modify it to use the path to @code{mysqld}
+and the pathname options that are correct for your system. Note that if you
+upgrade MySQL in the future, your modified version of
+@code{safe_mysqld} will be overwritten, so you should make a copy of your
+edited version that you can reinstall.
+
+
+@node mysqld_multi, myisampack, safe_mysqld, Server-Side Scripts
+@subsection mysqld_multi, program for managing multiple MySQL servers
+
+@cindex tools, mysqld_multi
+@cindex scripts
+@cindex multi mysqld
+@cindex @code{mysqld_multi}
+
+@code{mysqld_multi} is meant for managing several @code{mysqld}
+processes running in different UNIX sockets and TCP/IP ports.
+
+The program will search for group(s) named [mysqld#] from my.cnf (or the
+given --config-file=...), where # can be any positive number starting
+from 1. These groups should be the same as the usual @code{[mysqld]}
+group (e.g. options to mysqld, see MySQL manual for detailed
+information about this group), but with those port, socket etc. options
+that are wanted for each separate @code{mysqld} processes. The number in
+the group name has another function; it can be used for starting,
+stopping, or reporting some specific @code{mysqld} servers with this
+program. See the usage and options below for more information.
+
+@example
+Usage: mysqld_multi [OPTIONS] @{start|stop|report@} [GNR,GNR,GNR...]
+or mysqld_multi [OPTIONS] @{start|stop|report@} [GNR-GNR,GNR,GNR-GNR,...]
+@end example
+The GNR above means the group number. You can start, stop or report
+any GNR, or several of them at the same time. (See --example) The GNRs
+list can be comma separated, or a dash combined, of which the latter
+means that all the GNRs between GNR1-GNR2 will be affected. Without
+GNR argument all the found groups will be either started, stopped, or
+reported. Note that you must not have any white spaces in the GNR
+list. Anything after a white space is ignored.
+
+@code{mysqld_multi} supports the following options:
+
+@table @code
+@cindex config-file option
+@item --config-file=...
+Alternative config file. NOTE: This will not affect this program's own
+options (group @code{[mysqld_multi]}), but only groups
+[mysqld#]. Without this option everything will be searched from the
+ordinary my.cnf file.
+@cindex example option
+@item --example
+Give an example of a config file.
+@cindex help option
+@item --help
+Print this help and exit.
+@cindex log option
+@item --log=...
+Log file. Full path to and the name for the log file. NOTE: If the file
+exists, everything will be appended.
+@cindex mysqladmin option
+@item --mysqladmin=...
+@code{mysqladmin} binary to be used for a server shutdown.
+@cindex mysqld option
+@item --mysqld=...
+@code{mysqld} binary to be used. Note that you can give
+@code{safe_mysqld} to this option also. The options are passed to
+@code{mysqld}. Just make sure you have @code{mysqld} in your environment
+variable @code{PATH} or fix @code{safe_mysqld}.
+@cindex no-log option
+@item --no-log
+Print to stdout instead of the log file. By default the log file is
+turned on.
+@cindex password option
+@item --password=...
+Password for user for @code{mysqladmin}.
+@cindex tcp-ip option
+@item --tcp-ip
+Connect to the MySQL server(s) via the TCP/IP port instead of
+the UNIX socket. This affects stopping and reporting. If a socket file
+is missing, the server may still be running, but can be accessed only
+via the TCP/IP port. By default connecting is done via the UNIX socket.
+@cindex user option
+@item --user=...
+MySQL user for @code{mysqladmin}.
+@cindex version option
+@item --version
+Print the version number and exit.
+@end table
+
+Some notes about @code{mysqld_multi}:
+
+@itemize @bullet
@item
-For testing, start the @code{mysqld} daemon with the
-@code{--skip-grant-tables} option. Then you can change the @strong{MySQL}
-grant tables and use the @code{mysqlaccess} script to check whether or not
-your modifications have the desired effect. When you are satisfied with your
-changes, execute @code{mysqladmin flush-privileges} to tell the @code{mysqld}
-server to start using the new grant tables. @strong{Note:} Reloading the
-grant tables overrides the @code{--skip-grant-tables} option. This allows
-you to tell the server to begin using the grant tables again without bringing
-it down and restarting it.
+Make sure that the MySQL user, who is stopping the
+@code{mysqld} services (e.g using the @code{mysqladmin}) have the same
+password and username for all the data directories accessed (to the
+'mysql' database) And make sure that the user has the 'Shutdown_priv'
+privilege! If you have many data- directories and many different 'mysql'
+databases with different passwords for the MySQL 'root' user,
+you may want to create a common 'multi_admin' user for each using the
+same password (see below). Example how to do it:
+@example
+shell> mysql -u root -S /tmp/mysql.sock -proot_password -e
+"GRANT SHUTDOWN ON *.* TO multi_admin@@localhost IDENTIFIED BY 'multipass'"
+@xref{Privileges}.
+@end example
+You will have to do the above for each @code{mysqld} running in each
+data directory, that you have (just change the socket, -S=...)
+@item
+@code{pid-file} is very important, if you are using @code{safe_mysqld}
+to start @code{mysqld} (e.g. --mysqld=safe_mysqld) Every @code{mysqld}
+should have its own @code{pid-file}. The advantage using
+@code{safe_mysqld} instead of @code{mysqld} directly here is, that
+@code{safe_mysqld} 'guards' every @code{mysqld} process and will restart
+it, if a @code{mysqld} process fails due to signal kill -9, or
+similar. (Like segmentation fault, which MySQL should never do,
+of course ;) Please note that @code{safe_mysqld} script may require that
+you start it from a certain place. This means that you may have to CD to
+a certain directory, before you start the @code{mysqld_multi}. If
+you have problems starting, please see the @code{safe_mysqld}
+script. Check especially the lines:
+@example
+--------------------------------------------------------------------------
+MY_PWD=`pwd` Check if we are starting this relative (for the binary
+release) if test -d /data/mysql -a -f ./share/mysql/english/errmsg.sys
+-a -x ./bin/mysqld
+--------------------------------------------------------------------------
+@xref{safe_mysqld, , @code{safe_mysqld}}.
+@end example
+The above test should be successful, or you may encounter problems.
+@item
+Beware of the dangers starting multiple @code{mysqlds} in the same data
+directory. Use separate data directories, unless you @strong{KNOW} what
+you are doing!
+@item
+The socket file and the TCP/IP port must be different for every @code{mysqld}.
+@item
+The first and fifth @code{mysqld} group were intentionally left out from
+the example. You may have 'gaps' in the config file. This gives you
+more flexibility. The order in which the @code{mysqlds} are started or
+stopped depends on the order in which they appear in the config file.
+@item
+When you want to refer to a certain group using GNR with this program,
+just use the number in the end of the group name ( [mysqld# <== ).
+@item
+You may want to use option '--user' for @code{mysqld}, but in order to
+do this you need to be root when you start the @code{mysqld_multi}
+script. Having the option in the config file doesn't matter; you will
+just get a warning, if you are not the superuser and the @code{mysqlds}
+are started under @strong{YOUR} UNIX account. @strong{IMPORTANT}: Make
+sure that the @code{pid-file} and the data directory are
+read+write(+execute for the latter one) accessible for @strong{THAT}
+UNIX user, who the specific @code{mysqld} process is started
+as. @strong{DON'T} use the UNIX root account for this, unless you
+@strong{KNOW} what you are doing!
+@item
+@strong{MOST IMPORTANT}: Make sure that you understand the meanings of
+the options that are passed to the @code{mysqlds} and why @strong{WOULD
+YOU WANT} to have separate @code{mysqld} processes. Starting multiple
+@code{mysqlds} in one data directory @strong{WILL NOT} give you extra
+performance in a threaded system!
+@end itemize
+
+@xref{Multiple servers}.
+
+This is an example of the config file on behalf of @code{mysqld_multi}.
+
+@example
+# This file should probably be in your home dir (~/.my.cnf) or /etc/my.cnf
+# Version 2.1 by Jani Tolonen
+
+[mysqld_multi]
+mysqld = /usr/local/bin/safe_mysqld
+mysqladmin = /usr/local/bin/mysqladmin
+user = multi_admin
+password = multipass
+[mysqld2]
+socket = /tmp/mysql.sock2
+port = 3307
+pid-file = /usr/local/mysql/var2/hostname.pid2
+datadir = /usr/local/mysql/var2
+language = /usr/local/share/mysql/english
+user = john
+
+[mysqld3]
+socket = /tmp/mysql.sock3
+port = 3308
+pid-file = /usr/local/mysql/var3/hostname.pid3
+datadir = /usr/local/mysql/var3
+language = /usr/local/share/mysql/swedish
+user = monty
+
+[mysqld4]
+socket = /tmp/mysql.sock4
+port = 3309
+pid-file = /usr/local/mysql/var4/hostname.pid4
+datadir = /usr/local/mysql/var4
+language = /usr/local/share/mysql/estonia
+user = tonu
+
+[mysqld6]
+socket = /tmp/mysql.sock6
+port = 3311
+pid-file = /usr/local/mysql/var6/hostname.pid6
+datadir = /usr/local/mysql/var6
+language = /usr/local/share/mysql/japanese
+user = jani
+@end example
+
+@xref{Option files}.
+
+
+@node myisampack, mysqld-max, mysqld_multi, Server-Side Scripts
+@subsection myisampack, The MySQL Compressed Read-only Table Generator
+
+@cindex compressed tables
+@cindex tables, compressed
+@cindex MyISAM, compressed tables
+@cindex @code{myisampack}
+@cindex @code{pack_isam}
+
+@code{myisampack} is used to compress MyISAM tables, and @code{pack_isam}
+is used to compress ISAM tables. Because ISAM tables are deprecated, we
+will only discuss @code{myisampack} here, but everything said about
+@code{myisampack} should also be true for @code{pack_isam}.
+
+@code{myisampack} works by compressing each column in the table separately.
+The information needed to decompress columns is read into memory when the
+table is opened. This results in much better performance when accessing
+individual records, because you only have to uncompress exactly one record, not
+a much larger disk block as when using Stacker on MS-DOS.
+Usually, @code{myisampack} packs the data file 40%-70%.
+
+MySQL uses memory mapping (@code{mmap()}) on compressed tables and
+falls back to normal read/write file usage if @code{mmap()} doesn't work.
+
+There are currently two limitations with @code{myisampack}:
+@itemize @bullet
@item
-If everything else fails, start the @code{mysqld} daemon with a debugging
-option (for example, @code{--debug=d,general,query}). This will print host and
-user information about attempted connections, as well as information about
-each command issued. @xref{Making trace files}.
+After packing, the table is read-only.
+@item
+@code{myisampack} can also pack @code{BLOB} or @code{TEXT} columns. The
+older @code{pack_isam} could not do this.
+@end itemize
+
+Fixing these limitations is on our TODO list but with low priority.
+
+@code{myisampack} is invoked like this:
+
+@example
+shell> myisampack [options] filename ...
+@end example
+
+Each filename should be the name of an index (@file{.MYI}) file. If you
+are not in the database directory, you should specify the pathname to the
+file. It is permissible to omit the @file{.MYI} extension.
+
+@code{myisampack} supports the following options:
+
+@table @code
+@item -b, --backup
+Make a backup of the table as @code{tbl_name.OLD}.
+
+@item -#, --debug=debug_options
+Output debug log. The @code{debug_options} string often is
+@code{'d:t:o,filename'}.
+
+@item -f, --force
+Force packing of the table even if it becomes bigger or if the temporary file
+exists. @code{myisampack} creates a temporary file named @file{tbl_name.TMD}
+while it compresses the table. If you kill @code{myisampack}, the @file{.TMD}
+file may not be deleted. Normally, @code{myisampack} exits with an error if
+it finds that @file{tbl_name.TMD} exists. With @code{--force},
+@code{myisampack} packs the table anyway.
+
+@item -?, --help
+Display a help message and exit.
+
+@item -j big_tbl_name, --join=big_tbl_name
+Join all tables named on the command line into a single table
+@code{big_tbl_name}. All tables that are to be combined
+MUST be identical (same column names and types, same indexes, etc.).
+
+@item -p #, --packlength=#
+Specify the record length storage size, in bytes. The value should be 1, 2,
+or 3. (@code{myisampack} stores all rows with length pointers of 1, 2, or 3
+bytes. In most normal cases, @code{myisampack} can determine the right length
+value before it begins packing the file, but it may notice during the packing
+process that it could have used a shorter length. In this case,
+@code{myisampack} will print a note that the next time you pack the same file,
+you could use a shorter record length.)
+
+@item -s, --silent
+Silent mode. Write output only when errors occur.
+
+@item -t, --test
+Don't actually pack table, just test packing it.
+
+@item -T dir_name, --tmp_dir=dir_name
+Use the named directory as the location in which to write the temporary table.
+
+@item -v, --verbose
+Verbose mode. Write information about progress and packing result.
+
+@item -V, --version
+Display version information and exit.
+
+@item -w, --wait
+
+Wait and retry if table is in use. If the @code{mysqld} server was
+invoked with the @code{--skip-locking} option, it is not a good idea to
+invoke @code{myisampack} if the table might be updated during the
+packing process.
+@end table
+
+@cindex examples, compressed tables
+The sequence of commands shown below illustrates a typical table compression
+session:
+
+@example
+shell> ls -l station.*
+-rw-rw-r-- 1 monty my 994128 Apr 17 19:00 station.MYD
+-rw-rw-r-- 1 monty my 53248 Apr 17 19:00 station.MYI
+-rw-rw-r-- 1 monty my 5767 Apr 17 19:00 station.frm
+
+shell> myisamchk -dvv station
+
+MyISAM file: station
+Isam-version: 2
+Creation time: 1996-03-13 10:08:58
+Recover time: 1997-02-02 3:06:43
+Data records: 1192 Deleted blocks: 0
+Datafile: Parts: 1192 Deleted data: 0
+Datafile pointer (bytes): 2 Keyfile pointer (bytes): 2
+Max datafile length: 54657023 Max keyfile length: 33554431
+Recordlength: 834
+Record format: Fixed length
+
+table description:
+Key Start Len Index Type Root Blocksize Rec/key
+1 2 4 unique unsigned long 1024 1024 1
+2 32 30 multip. text 10240 1024 1
+
+Field Start Length Type
+1 1 1
+2 2 4
+3 6 4
+4 10 1
+5 11 20
+6 31 1
+7 32 30
+8 62 35
+9 97 35
+10 132 35
+11 167 4
+12 171 16
+13 187 35
+14 222 4
+15 226 16
+16 242 20
+17 262 20
+18 282 20
+19 302 30
+20 332 4
+21 336 4
+22 340 1
+23 341 8
+24 349 8
+25 357 8
+26 365 2
+27 367 2
+28 369 4
+29 373 4
+30 377 1
+31 378 2
+32 380 8
+33 388 4
+34 392 4
+35 396 4
+36 400 4
+37 404 1
+38 405 4
+39 409 4
+40 413 4
+41 417 4
+42 421 4
+43 425 4
+44 429 20
+45 449 30
+46 479 1
+47 480 1
+48 481 79
+49 560 79
+50 639 79
+51 718 79
+52 797 8
+53 805 1
+54 806 1
+55 807 20
+56 827 4
+57 831 4
+
+shell> myisampack station.MYI
+Compressing station.MYI: (1192 records)
+- Calculating statistics
+
+normal: 20 empty-space: 16 empty-zero: 12 empty-fill: 11
+pre-space: 0 end-space: 12 table-lookups: 5 zero: 7
+Original trees: 57 After join: 17
+- Compressing file
+87.14%
+
+shell> ls -l station.*
+-rw-rw-r-- 1 monty my 127874 Apr 17 19:00 station.MYD
+-rw-rw-r-- 1 monty my 55296 Apr 17 19:04 station.MYI
+-rw-rw-r-- 1 monty my 5767 Apr 17 19:00 station.frm
+
+shell> myisamchk -dvv station
+
+MyISAM file: station
+Isam-version: 2
+Creation time: 1996-03-13 10:08:58
+Recover time: 1997-04-17 19:04:26
+Data records: 1192 Deleted blocks: 0
+Datafile: Parts: 1192 Deleted data: 0
+Datafilepointer (bytes): 3 Keyfile pointer (bytes): 1
+Max datafile length: 16777215 Max keyfile length: 131071
+Recordlength: 834
+Record format: Compressed
+
+table description:
+Key Start Len Index Type Root Blocksize Rec/key
+1 2 4 unique unsigned long 10240 1024 1
+2 32 30 multip. text 54272 1024 1
+
+Field Start Length Type Huff tree Bits
+1 1 1 constant 1 0
+2 2 4 zerofill(1) 2 9
+3 6 4 no zeros, zerofill(1) 2 9
+4 10 1 3 9
+5 11 20 table-lookup 4 0
+6 31 1 3 9
+7 32 30 no endspace, not_always 5 9
+8 62 35 no endspace, not_always, no empty 6 9
+9 97 35 no empty 7 9
+10 132 35 no endspace, not_always, no empty 6 9
+11 167 4 zerofill(1) 2 9
+12 171 16 no endspace, not_always, no empty 5 9
+13 187 35 no endspace, not_always, no empty 6 9
+14 222 4 zerofill(1) 2 9
+15 226 16 no endspace, not_always, no empty 5 9
+16 242 20 no endspace, not_always 8 9
+17 262 20 no endspace, no empty 8 9
+18 282 20 no endspace, no empty 5 9
+19 302 30 no endspace, no empty 6 9
+20 332 4 always zero 2 9
+21 336 4 always zero 2 9
+22 340 1 3 9
+23 341 8 table-lookup 9 0
+24 349 8 table-lookup 10 0
+25 357 8 always zero 2 9
+26 365 2 2 9
+27 367 2 no zeros, zerofill(1) 2 9
+28 369 4 no zeros, zerofill(1) 2 9
+29 373 4 table-lookup 11 0
+30 377 1 3 9
+31 378 2 no zeros, zerofill(1) 2 9
+32 380 8 no zeros 2 9
+33 388 4 always zero 2 9
+34 392 4 table-lookup 12 0
+35 396 4 no zeros, zerofill(1) 13 9
+36 400 4 no zeros, zerofill(1) 2 9
+37 404 1 2 9
+38 405 4 no zeros 2 9
+39 409 4 always zero 2 9
+40 413 4 no zeros 2 9
+41 417 4 always zero 2 9
+42 421 4 no zeros 2 9
+43 425 4 always zero 2 9
+44 429 20 no empty 3 9
+45 449 30 no empty 3 9
+46 479 1 14 4
+47 480 1 14 4
+48 481 79 no endspace, no empty 15 9
+49 560 79 no empty 2 9
+50 639 79 no empty 2 9
+51 718 79 no endspace 16 9
+52 797 8 no empty 2 9
+53 805 1 17 1
+54 806 1 3 9
+55 807 20 no empty 3 9
+56 827 4 no zeros, zerofill(2) 2 9
+57 831 4 no zeros, zerofill(1) 2 9
+@end example
+
+The information printed by @code{myisampack} is described below:
+
+@table @code
+@item normal
+The number of columns for which no extra packing is used.
+
+@item empty-space
+The number of columns containing
+values that are only spaces; these will occupy 1 bit.
+
+@item empty-zero
+The number of columns containing
+values that are only binary 0's; these will occupy 1 bit.
+
+@item empty-fill
+The number of integer columns that don't occupy the full byte range of their
+type; these are changed to a smaller type (for example, an @code{INTEGER}
+column may be changed to @code{MEDIUMINT}).
+
+@item pre-space
+The number of decimal columns that are stored with leading spaces. In this
+case, each value will contain a count for the number of leading spaces.
+
+@item end-space
+The number of columns that have a lot of trailing spaces. In this case, each
+value will contain a count for the number of trailing spaces.
+
+@item table-lookup
+The column had only a small number of different values, which were
+converted to an @code{ENUM} before Huffman compression.
+
+@item zero
+The number of columns for which all values are zero.
+
+@item Original trees
+The initial number of Huffman trees.
+
+@item After join
+The number of distinct Huffman trees left after joining
+trees to save some header space.
+@end table
+
+After a table has been compressed, @code{myisamchk -dvv} prints additional
+information about each field:
+
+@table @code
+@item Type
+The field type may contain the following descriptors:
+
+@table @code
+@item constant
+All rows have the same value.
+
+@item no endspace
+Don't store endspace.
+
+@item no endspace, not_always
+Don't store endspace and don't do end space compression for all values.
+
+@item no endspace, no empty
+Don't store endspace. Don't store empty values.
+
+@item table-lookup
+The column was converted to an @code{ENUM}.
+
+@item zerofill(n)
+The most significant @code{n} bytes in the value are always 0 and are not
+stored.
+
+@item no zeros
+Don't store zeros.
+
+@item always zero
+0 values are stored in 1 bit.
+@end table
+
+@item Huff tree
+The Huffman tree associated with the field.
+
+@item Bits
+The number of bits used in the Huffman tree.
+@end table
+
+After you have run @code{pack_isam}/@code{myisampack} you must run
+@code{isamchk}/@code{myisamchk} to re-create the index. At this time you
+can also sort the index blocks and create statistics needed for
+the MySQL optimizer to work more efficiently:
+
+@example
+myisamchk -rq --analyze --sort-index table_name.MYI
+isamchk -rq --analyze --sort-index table_name.ISM
+@end example
+
+After you have installed the packed table into the MySQL database
+directory you should do @code{mysqladmin flush-tables} to force @code{mysqld}
+to start using the new table.
+
+If you want to unpack a packed table, you can do this with the
+@code{--unpack} option to @code{isamchk} or @code{myisamchk}.
+
+
+@node mysqld-max, , myisampack, Server-Side Scripts
+@subsection mysqld-max, An extended mysqld server
+
+@cindex @code{mysqld-max}
+
+@code{mysqld-max} is the MySQL server (@code{mysqld}) configured with
+the following configure options:
+
+@multitable @columnfractions .3 .7
+@item @strong{Option} @tab @strong{Comment}
+@item --with-server-suffix=-max @tab Add a suffix to the @code{mysqld} version string.
+@item --with-bdb @tab Support for Berkeley DB (BDB) tables
+@item --with-innodb @tab Support for InnoDB tables.
+@item CFLAGS=-DUSE_SYMDIR @tab Symbolic links support for Windows.
+@end multitable
+
+You can find the MySQL-max binaries at
+@uref{http://www.mysql.com/downloads/mysql-max-3.23.html}.
+
+The Windows MySQL 3.23 binary distribution includes both the
+standard @code{mysqld.exe} binary and the @code{mysqld-max.exe} binary.
+@uref{http://www.mysql.com/downloads/mysql-3.23.html}.
+@xref{Windows installation}.
+
+Note that as Berkeley DB and InnoDB are not available for all platforms,
+some of the @code{Max} binaries may not have support for both of these.
+You can check which table types are supported by doing the following
+query:
+
+@example
+mysql> show variables like "have_%";
++---------------+-------+
+| Variable_name | Value |
++---------------+-------+
+| have_bdb | YES |
+| have_innodb | NO |
+| have_isam | YES |
+| have_raid | NO |
+| have_ssl | NO |
++---------------+-------+
+@end example
+
+The meaning of the values are:
+
+@multitable @columnfractions .3 .7
+@item @strong{Value} @tab @strong{Meaning}.
+@item YES @tab The option is activated and usable.
+@item NO @tab MySQL is not compiled with support for this option.
+@item DISABLED @tab The xxxx option is disabled because one started @code{mysqld} with @code{--skip-xxxx} or because one didn't start @code{mysqld} with all needed options to enable the option. In this case the @code{hostname.err} file should contain a reason for why the option is disabled.
+@end multitable
+
+@strong{NOTE}: To be able to create InnoDB tables you @strong{MUST} edit
+your startup options to include at least the @code{innodb_data_file_path}
+option. @xref{InnoDB start}.
+
+To get better performance for BDB tables, you should add some configuration
+options for these too. @xref{BDB start}.
+
+@code{safe_mysqld} will automatically try to start any @code{mysqld} binary
+with the @code{-max} prefix. This makes it very easy to test out a
+another @code{mysqld} binary in an existing installation. Just
+run @code{configure} with the options you want and then install the
+new @code{mysqld} binary as @code{mysqld-max} in the same directory
+where your old @code{mysqld} binary is. @xref{safe_mysqld, , @code{safe_mysqld}}.
+
+The @code{mysqld-max} RPM uses the above mentioned @code{safe_mysqld}
+feature. It just installs the @code{mysqld-max} executable and
+@code{safe_mysqld} will automatically use this executable when
+@code{safe_mysqld} is restarted.
+
+The following table shows which table types our standard @strong{MySQL-Max}
+binaries includes:
+
+@multitable @columnfractions .4 .3 .3
+@item @strong{System} @tab @strong{BDB} @tab @strong{InnoDB}
+@item AIX 4.3 @tab N @tab Y
+@item HP-UX 11.0 @tab N @tab Y
+@item Linux-Alpha @tab N @tab Y
+@item Linux-Intel @tab Y @tab Y
+@item Linux-Ia64 @tab N @tab Y
+@item Solaris-intel @tab N @tab Y
+@item Solaris-sparc @tab Y @tab Y
+@item SCO OSR5 @tab Y @tab Y
+@item UnixWare @tab Y @tab Y
+@item Windows/NT @tab Y @tab Y
+@end multitable
+
+
+@node Client-Side Scripts, Log Files, Server-Side Scripts, MySQL Database Administration
+@section MySQL Client-Side Scripts and Utilities
+
+@menu
+* Client-Side Overview:: Overview of the Client-Side Scripts and Utilities
+* mysql:: The Command-line Tool
+* mysqladmin:: mysqladmin, Administrating a MySQL Server
+* Using mysqlcheck:: Using @code{mysqlcheck} for Table Maintenance and Crash Recovery
+* mysqldump:: mysqldump, Dumping Table Structure and Data
+* mysqlhotcopy:: mysqlhotcopy, Copying MySQL Databases and Tables
+* mysqlimport:: mysqlimport, Importing Data from Text Files
+* mysqlshow:: Showing Databases, Tables, and Columns
+* perror:: perror, Explaining Error Codes
+* Batch Commands:: How to Run SQL Commands from a Text File
+@end menu
+
+
+@node Client-Side Overview, mysql, Client-Side Scripts, Client-Side Scripts
+@subsection Overview of the Client-Side Scripts and Utilities
+
+@cindex environment variables
+@cindex programs, list of
+
+All MySQL clients that communicate with the server using the
+@code{mysqlclient} library use the following environment variables:
+
+@tindex @code{MYSQL_UNIX_PORT} environment variable
+@tindex environment variable, @code{MYSQL_UNIX_PORT}
+@tindex @code{MYSQL_TCP_PORT} environment variable
+@tindex environment variable, @code{MYSQL_TCP_PORT}
+@tindex @code{MYSQL_PWD} environment variable
+@tindex environment variable, @code{MYSQL_PWD}
+@tindex @code{MYSQL_DEBUG} environment variable
+@tindex environment variable, @code{MYSQL_DEBUG}
+@multitable @columnfractions .25 .75
+@item @strong{Name} @tab @strong{Description}
+@item @code{MYSQL_UNIX_PORT} @tab The default socket; used for connections to @code{localhost}
+@item @code{MYSQL_TCP_PORT} @tab The default TCP/IP port
+@item @code{MYSQL_PWD} @tab The default password
+@item @code{MYSQL_DEBUG} @tab Debug-trace options when debugging
+@item @code{TMPDIR} @tab The directory where temporary tables/files are created
+@end multitable
+
+Use of @code{MYSQL_PWD} is insecure.
+@xref{Connecting}.
+
+@tindex @code{MYSQL_HISTFILE} environment variable
+@tindex environment variable, @code{MYSQL_HISTFILE}
+@tindex @code{HOME} environment variable
+@tindex environment variable, @code{HOME}
+@cindex history file
+@cindex command line history
+@tindex .mysql_history file
+The @file{mysql} client uses the file named in the @code{MYSQL_HISTFILE}
+environment variable to save the command-line history. The default value for
+the history file is @file{$HOME/.mysql_history}, where @code{$HOME} is the
+value of the @code{HOME} environment variable. @xref{Environment variables}.
+
+All MySQL programs take many different options. However, every
+MySQL program provides a @code{--help} option that you can use
+to get a full description of the program's different options. For example, try
+@code{mysql --help}.
+
+You can override default options for all standard client programs with an
+option file. @ref{Option files}.
+
+The list below briefly describes the MySQL programs:
+
+@table @code
+
+@cindex @code{myisamchk}
+@item myisamchk
+Utility to describe, check, optimize, and repair MySQL tables.
+Because @code{myisamchk} has many functions, it is described in its own
+chapter. @xref{MySQL Database Administration}.
+
+@cindex @code{make_binary_distribution}
+@item make_binary_distribution
+Makes a binary release of a compiled MySQL. This could be sent
+by FTP to @file{/pub/mysql/Incoming} on @code{support.mysql.com} for the
+convenience of other MySQL users.
+
+@cindex @code{msql2mysql}
+@item msql2mysql
+A shell script that converts @code{mSQL} programs to MySQL. It doesn't
+handle all cases, but it gives a good start when converting.
+
+@cindex @code{mysqlaccess}
+@item mysqlaccess
+A script that checks the access privileges for a host, user, and database
+combination.
+
+@cindex @code{mysqladmin}
+@item mysqladmin
+Utility for performing administrative operations, such as creating or
+dropping databases, reloading the grant tables, flushing tables to disk, and
+reopening log files. @code{mysqladmin} can also be used to retrieve version,
+process, and status information from the server.
+@xref{mysqladmin, , @code{mysqladmin}}.
+
+@cindex @code{mysqlbug}
+@item mysqlbug
+The MySQL bug report script. This script should always be used when
+filing a bug report to the MySQL list.
+
+@cindex @code{mysqld}
+@item mysqld
+The SQL daemon. This should always be running.
+
+@cindex @code{mysqldump}
+@item mysqldump
+Dumps a MySQL database into a file as SQL statements or
+as tab-separated text files. Enhanced freeware originally by Igor Romanenko.
+@xref{mysqldump, , @code{mysqldump}}.
+
+@cindex @code{mysqlimport}
+@item mysqlimport
+Imports text files into their respective tables using @code{LOAD DATA
+INFILE}. @xref{mysqlimport, , @code{mysqlimport}}.
+
+@cindex @code{mysqlshow}
+@item mysqlshow
+Displays information about databases, tables, columns, and indexes.
+
+@cindex @code{mysql_install_db}
+@item mysql_install_db
+Creates the MySQL grant tables with default privileges. This is
+usually executed only once, when first installing MySQL
+on a system.
+
+@cindex @code{replace}
+@item replace
+A utility program that is used by @code{msql2mysql}, but that has more
+general applicability as well. @code{replace} changes strings in place in
+files or on the standard input. Uses a finite state machine to match longer
+strings first. Can be used to swap strings. For example, this command
+swaps @code{a} and @code{b} in the given files:
+
+@example
+shell> replace a b b a -- file1 file2 ...
+@end example
+@end table
+
+
+@node mysql, mysqladmin, Client-Side Overview, Client-Side Scripts
+@subsection The Command-line Tool
+
+@cindex command line tool
+@cindex tools, command line
+@cindex scripts
+@cindex @code{mysql}
+
+@code{mysql} is a simple SQL shell (with GNU @code{readline} capabilities).
+It supports interactive and non-interactive use. When used interactively,
+query results are presented in an ASCII-table format. When used
+non-interactively (for example, as a filter), the result is presented in
+tab-separated format. (The output format can be changed using command-line
+options.) You can run scripts simply like this:
+
+@example
+shell> mysql database < script.sql > output.tab
+@end example
+
+If you have problems due to insufficient memory in the client, use the
+@code{--quick} option! This forces @code{mysql} to use
+@code{mysql_use_result()} rather than @code{mysql_store_result()} to
+retrieve the result set.
+
+Using @code{mysql} is very easy. Just start it as follows:
+@code{mysql database} or @code{mysql --user=user_name --password=your_password database}. Type a SQL statement, end it with @samp{;}, @samp{\g}, or @samp{\G}
+and press RETURN/ENTER.
+
+@cindex @code{mysql} command line options
+@cindex command line options, @code{mysql}
+@cindex options, command line, @code{mysql}
+@cindex startup parameters, @code{mysql}
+@code{mysql} supports the following options:
+
+@table @code
+@cindex @code{help}, @code{mysql} option
+@item -?, --help
+Display this help and exit.
+
+@cindex @code{no-auto-rehash}, @code{mysql} option
+@item -A, --no-auto-rehash
+No automatic rehashing. One has to use 'rehash' to get table and field
+completion. This gives a quicker start of mysql.
+
+@cindex @code{batch}, @code{mysql} option
+@item -B, --batch
+Print results with a tab as separator, each row on a new line. Doesn't use
+history file.
+
+@cindex @code{character-sets-dir}, @code{mysql} option
+@item --character-sets-dir=...
+Directory where character sets are located.
+
+@cindex @code{compress}, @code{mysql} option
+@item -C, --compress
+Use compression in server/client protocol.
+
+@cindex @code{debug}, @code{mysql} option
+@item -#, --debug[=...]
+Debug log. Default is 'd:t:o,/tmp/mysql.trace'.
+
+@cindex @code{database}, @code{mysql} option
+@item -D, --database=...
+Database to use. This is mainly useful in the @code{my.cnf} file.
+
+@cindex @code{default-character-set}, @code{mysql} option
+@item --default-character-set=...
+Set the default character set.
+@cindex @code{execute}, @code{mysql} option
+@item -e, --execute=...
+Execute command and quit. (Output like with --batch)
+
+@cindex @code{vertical}, @code{mysql} option
+@item -E, --vertical
+Print the output of a query (rows) vertically. Without this option you
+can also force this output by ending your statements with @code{\G}.
+
+@cindex @code{force}, @code{mysql} option
+@item -f, --force
+Continue even if we get a SQL error.
+
+@cindex @code{no-named-commands}, @code{mysql} option
+@item -g, --no-named-commands
+Named commands are disabled. Use \* form only, or use named commands
+only in the beginning of a line ending with a semicolon (;). Since
+Version 10.9, the client now starts with this option ENABLED by default!
+With the -g option, long format commands will still work from the first
+line, however.
+
+@cindex @code{enable-named-commands}, @code{mysql} option
+@item -G, --enable-named-commands
+Named commands are @strong{enabled}. Long format commands are allowed as
+well as shortened \* commands.
+
+@cindex @code{ignore-space}, @code{mysql} option
+@item -i, --ignore-space
+Ignore space after function names.
+
+@cindex @code{host}, @code{mysql} option
+@item -h, --host=...
+Connect to the given host.
+
+@cindex @code{html}, @code{mysql} option
+@item -H, --html
+Produce HTML output.
+
+@cindex @code{skip-line-numbers}, @code{mysql} option
+@item -L, --skip-line-numbers
+Don't write line number for errors. Useful when one wants to compare result
+files that includes error messages
+
+@cindex @code{no-pager}, @code{mysql} option
+@item --no-pager
+Disable pager and print to stdout. See interactive help (\h) also.
+
+@cindex @code{no-tee}, @code{mysql} option
+@item --no-tee
+Disable outfile. See interactive help (\h) also.
+
+@cindex @code{unbuffered}, @code{mysql} option
+@item -n, --unbuffered
+Flush buffer after each query.
+
+@cindex @code{skip-column-names}, @code{mysql} option
+@item -N, --skip-column-names
+Don't write column names in results.
+
+@cindex @code{set-variable}, @code{mysql} option
+@item -O, --set-variable var=option
+Give a variable a value. @code{--help} lists variables.
+
+@cindex @code{one-database}, @code{mysql} option
+@item -o, --one-database
+Only update the default database. This is useful for skipping updates to
+other database in the update log.
+
+@cindex @code{pager}, @code{mysql} option
+@item @code{--pager[=...]}
+Output type. Default is your @code{ENV} variable @code{PAGER}. Valid
+pagers are less, more, cat [> filename], etc. See interactive help (\h)
+also. This option does not work in batch mode. Pager works only in UNIX.
+
+@cindex @code{password}, @code{mysql} option
+@item -p[password], --password[=...]
+Password to use when connecting to server. If a password is not given on
+the command line, you will be prompted for it. Note that if you use the
+short form @code{-p} you can't have a space between the option and the
+password.
+
+@cindex @code{port}, @code{mysql} option
+@item -P --port=...
+TCP/IP port number to use for connection.
+
+@cindex @code{quick}, @code{mysql} option
+@item -q, --quick
+Don't cache result, print it row-by-row. This may slow down the server
+if the output is suspended. Doesn't use history file.
+
+@cindex @code{raw}, @code{mysql} option
+@item -r, --raw
+Write column values without escape conversion. Used with @code{--batch}
+
+@cindex @code{silent}, @code{mysql} option
+@item -s, --silent
+Be more silent.
+
+@cindex @code{socket}, @code{mysql} option
+@item -S --socket=...
+Socket file to use for connection.
+
+@cindex @code{table}, @code{mysql} option
+@item -t --table
+Output in table format. This is default in non-batch mode.
+
+@cindex @code{debug-info}, @code{mysql} option
+@item -T, --debug-info
+Print some debug information at exit.
+
+@cindex @code{tee}, @code{mysql} option
+@item --tee=...
+Append everything into outfile. See interactive help (\h) also. Does not
+work in batch mode.
+
+@cindex @code{user}, @code{mysql} option
+@item -u, --user=#
+User for login if not current user.
+
+@cindex @code{safe-updates}, @code{mysql} option
+@item -U, --safe-updates[=#], --i-am-a-dummy[=#]
+Only allow @code{UPDATE} and @code{DELETE} that uses keys. See below for
+more information about this option. You can reset this option if you have
+it in your @code{my.cnf} file by using @code{--safe-updates=0}.
+
+@cindex @code{verbose}, @code{mysql} option
+@item -v, --verbose
+More verbose output (-v -v -v gives the table output format).
+
+@cindex @code{version}, @code{mysql} option
+@item -V, --version
+Output version information and exit.
+
+@cindex @code{wait}, @code{mysql} option
+@item -w, --wait
+Wait and retry if connection is down instead of aborting.
+@end table
+
+You can also set the following variables with @code{-O} or
+@code{--set-variable}:
+
+@cindex timeout, @code{connect_timeout} variable
+@cindex @code{connect_timeout} variable
+@cindex @code{max_allowed_packet}
+@cindex @code{net_buffer_length}
+@cindex @code{select_limit}
+@cindex @code{max_join_size}
+@multitable @columnfractions .3 .2 .5
+@item Variable Name @tab Default @tab Description
+@item connect_timeout @tab 0 @tab Number of seconds before timeout connection.
+@item max_allowed_packet @tab 16777216 @tab Max packetlength to send/receive from to server
+@item net_buffer_length @tab 16384 @tab Buffer for TCP/IP and socket communication
+@item select_limit @tab 1000 @tab Automatic limit for SELECT when using --i-am-a-dummy
+@item max_join_size @tab 1000000 @tab Automatic limit for rows in a join when using --i-am-a-dummy.
+@end multitable
+
+If you type 'help' on the command line, @code{mysql} will print out the
+commands that it supports:
+
+@cindex commands, list of
+@example
+mysql> help
+
+MySQL commands:
+help (\h) Display this text.
+? (\h) Synonym for `help'.
+clear (\c) Clear command.
+connect (\r) Reconnect to the server. Optional arguments are db and host.
+edit (\e) Edit command with $EDITOR.
+ego (\G) Send command to mysql server, display result vertically.
+exit (\q) Exit mysql. Same as quit.
+go (\g) Send command to mysql server.
+nopager (\n) Disable pager, print to stdout.
+notee (\t) Don't write into outfile.
+pager (\P) Set PAGER [to_pager]. Print the query results via PAGER.
+print (\p) Print current command.
+quit (\q) Quit mysql.
+rehash (\#) Rebuild completion hash.
+source (\.) Execute a SQL script file. Takes a file name as an argument.
+status (\s) Get status information from the server.
+tee (\T) Set outfile [to_outfile]. Append everything into given outfile.
+use (\u) Use another database. Takes database name as argument.
+@end example
+
+From the above, pager only works in UNIX.
+
+@cindex status command
+The @code{status} command gives you some information about the
+connection and the server you are using. If you are running in the
+@code{--safe-updates} mode, @code{status} will also print the values for
+the @code{mysql} variables that affect your queries.
+
+@cindex @code{safe-mode} command
+A useful startup option for beginners (introduced in MySQL
+Version 3.23.11) is @code{--safe-updates} (or @code{--i-am-a-dummy} for
+users that has at some time done a @code{DELETE FROM table_name} but
+forgot the @code{WHERE} clause). When using this option, @code{mysql}
+sends the following command to the MySQL server when opening
+the connection:
+
+@example
+SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=#select_limit#,
+ SQL_MAX_JOIN_SIZE=#max_join_size#"
+@end example
+
+where @code{#select_limit#} and @code{#max_join_size#} are variables that
+can be set from the @code{mysql} command line. @xref{SET OPTION, @code{SET}}.
+
+The effect of the above is:
+
+@itemize @bullet
@item
-If you have any other problems with the @strong{MySQL} grant tables and
-feel you must post the problem to the mailing list, always provide a
-dump of the @strong{MySQL} grant tables. You can dump the tables with
-the @code{mysqldump mysql} command. As always, post your problem using
-the @code{mysqlbug} script. @xref{Bug reports}. In some cases you may need
-to restart @code{mysqld} with @code{--skip-grant-tables} to run
-@code{mysqldump}.
+You are not allowed to do an @code{UPDATE} or @code{DELETE} statement
+if you don't have a key constraint in the @code{WHERE} part. One can,
+however, force an @code{UPDATE/DELETE} by using @code{LIMIT}:
+@example
+UPDATE table_name SET not_key_column=# WHERE not_key_column=# LIMIT 1;
+@end example
+@item
+All big results are automatically limited to @code{#select_limit#} rows.
+@item
+@code{SELECT}'s that will probably need to examine more than
+@code{#max_join_size} row combinations will be aborted.
+@end itemize
+
+Some useful hints about the @code{mysql} client:
+
+Some data is much more readable when displayed vertically, instead of
+the usual horizontal box type output. For example longer text, which
+includes new lines, is often much easier to be read with vertical
+output.
+
+@example
+mysql> select * from mails where length(txt) < 300 limit 300,1\G
+*************************** 1. row ***************************
+ msg_nro: 3068
+ date: 2000-03-01 23:29:50
+time_zone: +0200
+mail_from: Monty
+ reply: monty@@no.spam.com
+ mail_to: "Thimble Smith" <tim@@no.spam.com>
+ sbj: UTF-8
+ txt: >>>>> "Thimble" == Thimble Smith writes:
+
+Thimble> Hi. I think this is a good idea. Is anyone familiar with UTF-8
+Thimble> or Unicode? Otherwise I'll put this on my TODO list and see what
+Thimble> happens.
+
+Yes, please do that.
+
+Regards,
+Monty
+ file: inbox-jani-1
+ hash: 190402944
+1 row in set (0.09 sec)
+@end example
+
+@itemize @bullet
+@item
+For logging, you can use the @code{tee} option. The @code{tee} can be
+started with option @code{--tee=...}, or from the command line
+interactively with command @code{tee}. All the data displayed on the
+screen will also be appended into a given file. This can be very useful
+for debugging purposes also. The @code{tee} can be disabled from the
+command line with command @code{notee}. Executing @code{tee} again
+starts logging again. Without a parameter the previous file will be
+used. Note that @code{tee} will flush the results into the file after
+each command, just before the command line appears again waiting for the
+next command.
+
+@item
+Browsing, or searching the results in the interactive mode in UNIX less,
+more, or any other similar program, is now possible with option
+@code{--pager[=...]}. Without argument, @code{mysql} client will look
+for environment variable PAGER and set @code{pager} to that.
+@code{pager} can be started from the interactive command line with
+command @code{pager} and disabled with command @code{nopager}. The
+command takes an argument optionally and the @code{pager} will be set to
+that. Command @code{pager} can be called without an argument, but this
+requires that the option @code{--pager} was used, or the @code{pager}
+will default to stdout. @code{pager} works only in UNIX, since it uses
+the popen() function, which doesn't exist in Windows. In Windows, the
+@code{tee} option can be used instead, although it may not be as handy
+as @code{pager} can be in some situations.
+
+@item
+A few tips about @code{pager}: You can use it to write to a file:
+@example
+mysql> pager cat > /tmp/log.txt
+@end example
+and the results will only go to a file. You can also pass any options
+for the programs that you want to use with the @code{pager}:
+@example
+mysql> pager less -n -i -S
+@end example
+From the above do note the option '-S'. You may find it very useful when
+browsing the results; try the option with horizontal output (end
+commands with '\g', or ';') and with vertical output (end commands with
+'\G'). Sometimes a very wide result set is hard to be read from the screen,
+with option -S to less you can browse the results within the interactive
+less from left to right, preventing lines longer than your screen from
+being continued to the next line. This can make the result set much more
+readable. You can swith the mode between on and off within the interactive
+less with '-S'. See the 'h' for more help about less.
+
+@item
+Last (unless you already understood this from the above examples ;) you
+can combine very complex ways to handle the results, for example the
+following would send the results to two files in two different
+directories, on two different hard-disks mounted on /dr1 and /dr2, yet
+let the results still be seen on the screen via less:
+@example
+mysql> pager cat | tee /dr1/tmp/res.txt | tee /dr2/tmp/res2.txt | less -n -i -S
+@end example
+
+@item
+You can also combine the two functions above; have the @code{tee}
+enabled, @code{pager} set to 'less' and you will be able to browse the
+results in unix 'less' and still have everything appended into a file
+the same time. The difference between @code{UNIX tee} used with the
+@code{pager} and the @code{mysql} client in-built @code{tee}, is that
+the in-built @code{tee} works even if you don't have the @code{UNIX tee}
+available. The in-built @code{tee} also logs everything that is printed
+on the screen, where the @code{UNIX tee} used with @code{pager} doesn't
+log quite that much. Last, but not least, the interactive @code{tee} is
+more handy to switch on and off, when you want to log something into a
+file, but want to be able to turn the feature off sometimes.
+@end itemize
+
+
+@node mysqladmin, Using mysqlcheck, mysql, Client-Side Scripts
+@subsection mysqladmin, Administrating a MySQL Server
+
+@cindex administration, server
+@cindex server administration
+@cindex @code{mysladmn}
+
+A utility for performing administrative operations. The syntax is:
+
+@example
+shell> mysqladmin [OPTIONS] command [command-option] command ...
+@end example
+
+You can get a list of the options your version of @code{mysqladmin} supports
+by executing @code{mysqladmin --help}.
+
+The current @code{mysqladmin} supports the following commands:
+
+@table @code
+@item create databasename
+Create a new database.
+
+@item drop databasename
+Delete a database and all its tables.
+
+@item extended-status
+Gives an extended status message from the server.
+
+@item flush-hosts
+Flush all cached hosts.
+
+@item flush-logs
+Flush all logs.
+
+@item flush-tables
+Flush all tables.
+
+@item flush-privileges
+Reload grant tables (same as reload).
+
+@item kill id,id,...
+Kill mysql threads.
+
+@item password
+Set a new password. Change old password to new-password.
+
+@item ping
+Check if mysqld is alive.
+
+@item processlist
+Show list of active threads in server.
+
+@item reload
+Reload grant tables.
+
+@item refresh
+Flush all tables and close and open logfiles.
+
+@item shutdown
+Take server down.
+
+@item slave-start
+Start slave replication thread.
+
+@item slave-stop
+Stop slave replication thread.
+
+@item status
+Gives a short status message from the server.
+
+@item variables
+Prints variables available.
+
+@item version
+Get version info from server.
+@end table
+
+All commands can be shortened to their unique prefix. For example:
+
+@example
+shell> mysqladmin proc stat
++----+-------+-----------+----+-------------+------+-------+------+
+| Id | User | Host | db | Command | Time | State | Info |
++----+-------+-----------+----+-------------+------+-------+------+
+| 6 | monty | localhost | | Processlist | 0 | | |
++----+-------+-----------+----+-------------+------+-------+------+
+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
+@end example
+
+@cindex status command, results
+The @code{mysqladmin status} command result has the following columns:
+
+@cindex uptime
+@multitable @columnfractions .3 .7
+@item Uptime @tab Number of seconds the MySQL server has been up.
+@cindex threads
+@item Threads @tab Number of active threads (clients).
+@cindex questions
+@item Questions @tab Number of questions from clients since @code{mysqld} was started.
+@cindex slow queries
+@item Slow queries @tab Queries that have taken more than @code{long_query_time} seconds. @xref{Slow query log}.
+@cindex opens
+@item Opens @tab How many tables @code{mysqld} has opened.
+@cindex flush tables
+@cindex tables, flush
+@item Flush tables @tab Number of @code{flush ...}, @code{refresh}, and @code{reload} commands.
+@cindex open tables
+@item Open tables @tab Number of tables that are open now.
+@cindex memory use
+@item Memory in use @tab Memory allocated directly by the @code{mysqld} code (only available when MySQL is compiled with --with-debug=full).
+@cindex max memory used
+@item Max memory used @tab Maximum memory allocated directly by the @code{mysqld} code (only available when MySQL is compiled with --with-debug=full).
+@end multitable
+
+If you do @code{myslqadmin shutdown} on a socket (in other words, on a
+the computer where @code{mysqld} is running), @code{mysqladmin} will
+wait until the MySQL @code{pid-file} is removed to ensure that
+the @code{mysqld} server has stopped properly.
+
+
+@node Using mysqlcheck, mysqldump, mysqladmin, Client-Side Scripts
+@subsection Using @code{mysqlcheck} for Table Maintenance and Crash Recovery
+
+Since MySQL version 3.23.38 you will be able to use a new
+checking and repairing tool for @code{MyISAM} tables. The difference to
+@code{myisamchk} is that @code{mysqlcheck} should be used when the
+@code{mysqld} server is running, where as @code{myisamchk} should be used
+when it is not. The benefit is that you no longer have to take the
+server down for checking or repairing your tables.
+
+@code{mysqlcheck} uses MySQL server commands @code{CHECK},
+@code{REPAIR}, @code{ANALYZE} and @code{OPTIMIZE} in a convenient way
+for the user.
+
+There are three alternative ways to invoke @code{mysqlcheck}:
+
+@example
+shell> mysqlcheck [OPTIONS] database [tables]
+shell> mysqlcheck [OPTIONS] --databases DB1 [DB2 DB3...]
+shell> mysqlcheck [OPTIONS] --all-databases
+@end example
+
+So it can be used in a similar way as @code{mysqldump} when it
+comes to what databases and tables you want to choose.
+
+@code{mysqlcheck} does have a special feature compared to the other
+clients; the default behavior, checking tables (-c), can be changed by
+renaming the binary. So if you want to have a tool that repairs tables
+by default, you should just copy @code{mysqlcheck} to your harddrive
+with a new name, @code{mysqlrepair}, or alternatively make a symbolic
+link to @code{mysqlrepair} and name the symbolic link as
+@code{mysqlrepair}. If you invoke @code{mysqlrepair} now, it will repair
+tables by default.
+
+The names that you can use to change @code{mysqlcheck} default behavior
+are here:
+
+@example
+mysqlrepair: The default option will be -r
+mysqlanalyze: The default option will be -a
+mysqloptimize: The default option will be -o
+@end example
+
+The options available for @code{mysqlcheck} are listed here, please
+check what your version supports with @code{mysqlcheck --help}.
+
+@table @code
+@item -A, --all-databases
+Check all the databases. This will be same as --databases with all
+databases selected
+@item -1, --all-in-1
+Instead of making one query for each table, execute all queries in 1
+query separately for each database. Table names will be in a comma
+separated list.
+@item -a, --analyze
+Analyze given tables.
+@item --auto-repair
+If a checked table is corrupted, automatically fix it. Repairing will be
+done after all tables have been checked, if corrupted ones were found.
+@item -#, --debug=...
+Output debug log. Often this is 'd:t:o,filename'
+@item --character-sets-dir=...
+Directory where character sets are
+@item -c, --check
+Check table for errors
+@item -C, --check-only-changed
+Check only tables that have changed since last check or haven't been
+closed properly.
+@item --compress
+Use compression in server/client protocol.
+@item -?, --help
+Display this help message and exit.
+@item -B, --databases
+To check several databases. Note the difference in usage; In this case
+no tables are given. All name arguments are regarded as database names.
+@item --default-character-set=...
+Set the default character set
+@item -F, --fast
+Check only tables that hasn't been closed properly
+@item -f, --force
+Continue even if we get an sql-error.
+@item -e, --extended
+If you are using this option with CHECK TABLE, it will ensure that the
+table is 100 percent consistent, but will take a long time.
+
+If you are using this option with REPAIR TABLE, it will run an extended
+repair on the table, which may not only take a long time to execute, but
+may produce a lot of garbage rows also!
+@item -h, --host=...
+Connect to host.
+@item -m, --medium-check
+Faster than extended-check, but only finds 99.99 percent of all
+errors. Should be good enough for most cases.
+@item -o, --optimize
+Optimize table
+@item -p, --password[=...]
+Password to use when connecting to server. If password is not given
+it's solicited on the tty.
+@item -P, --port=...
+Port number to use for connection.
+@item -q, --quick
+If you are using this option with CHECK TABLE, it prevents the check
+from scanning the rows to check for wrong links. This is the fastest
+check.
+
+If you are using this option with REPAIR TABLE, it will try to repair
+only the index tree. This is the fastest repair method for a table.
+@item -r, --repair
+Can fix almost anything except unique keys that aren't unique.
+@item -s, --silent
+Print only error messages.
+@item -S, --socket=...
+Socket file to use for connection.
+@item --tables
+Overrides option --databases (-B).
+@item -u, --user=#
+User for login if not current user.
+@item -v, --verbose
+Print info about the various stages.
+@item -V, --version
+Output version information and exit.
+@end table
+
+
+@node mysqldump, mysqlhotcopy, Using mysqlcheck, Client-Side Scripts
+@subsection mysqldump, Dumping Table Structure and Data
+
+@cindex dumping, databases
+@cindex databases, dumping
+@cindex tables, dumping
+@cindex backing up, databases
+
+@cindex @code{mysqldump}
+Utility to dump a database or a collection of database for backup or for
+transferring the data to another SQL server (not necessarily a MySQL
+server). The dump will contain SQL statements to create the table
+and/or populate the table.
+
+If you are doing a backup on the server, you should consider using
+the @code{mysqlhotcopy} instead. @xref{mysqlhotcopy, , @code{mysqlhotcopy}}.
+
+@example
+shell> mysqldump [OPTIONS] database [tables]
+OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
+OR mysqldump [OPTIONS] --all-databases [OPTIONS]
+@end example
+
+If you don't give any tables or use the @code{--databases} or
+@code{--all-databases}, the whole database(s) will be dumped.
+
+You can get a list of the options your version of @code{mysqldump} supports
+by executing @code{mysqldump --help}.
+
+Note that if you run @code{mysqldump} without @code{--quick} or
+@code{--opt}, @code{mysqldump} will load the whole result set into
+memory before dumping the result. This will probably be a problem if
+you are dumping a big database.
+
+Note that if you are using a new copy of the @code{mysqldump} program
+and you are going to do a dump that will be read into a very old MySQL
+server, you should not use the @code{--opt} or @code{-e} options.
+
+@code{mysqldump} supports the following options:
+
+@table @code
+@item --add-locks
+Add @code{LOCK TABLES} before and @code{UNLOCK TABLE} after each table dump.
+(To get faster inserts into MySQL.)
+@item --add-drop-table
+Add a @code{drop table} before each create statement.
+@item -A, --all-databases
+Dump all the databases. This will be same as @code{--databases} with all
+databases selected.
+@item -a, --all
+Include all MySQL-specific create options.
+@item --allow-keywords
+Allow creation of column names that are keywords. This works by
+prefixing each column name with the table name.
+@item -c, --complete-insert
+Use complete insert statements (with column names).
+@item -C, --compress
+Compress all information between the client and the server if both support
+compression.
+@item -B, --databases
+To dump several databases. Note the difference in usage. In this case
+no tables are given. All name arguments are regarded as database names.
+@code{USE db_name;} will be included in the output before each new database.
+@item --delayed
+Insert rows with the @code{INSERT DELAYED} command.
+@item -e, --extended-insert
+Use the new multiline @code{INSERT} syntax. (Gives more compact and
+faster inserts statements.)
+@item -#, --debug[=option_string]
+Trace usage of the program (for debugging).
+@item --help
+Display a help message and exit.
+@item --fields-terminated-by=...
+@itemx --fields-enclosed-by=...
+@itemx --fields-optionally-enclosed-by=...
+@itemx --fields-escaped-by=...
+@itemx --lines-terminated-by=...
+These options are used with the @code{-T} option and have the same
+meaning as the corresponding clauses for @code{LOAD DATA INFILE}.
+@xref{LOAD DATA, , @code{LOAD DATA}}.
+@item -F, --flush-logs
+Flush log file in the MySQL server before starting the dump.
+@item -f, --force,
+Continue even if we get a SQL error during a table dump.
+@item -h, --host=..
+Dump data from the MySQL server on the named host. The default host
+is @code{localhost}.
+@item -l, --lock-tables.
+Lock all tables before starting the dump. The tables are locked with
+@code{READ LOCAL} to allow concurrent inserts in the case of @code{MyISAM}
+tables.
+@item -n, --no-create-db
+'CREATE DATABASE /*!32312 IF NOT EXISTS*/ db_name;' will not be put in the
+output. The above line will be added otherwise, if --databases or
+--all-databases option was given.
+@item -t, --no-create-info
+Don't write table creation information (The @code{CREATE TABLE} statement.)
+@item -d, --no-data
+Don't write any row information for the table. This is very useful if you
+just want to get a dump of the structure for a table!
+@item --opt
+Same as @code{--quick --add-drop-table --add-locks --extended-insert
+--lock-tables}. Should give you the fastest possible dump for reading
+into a MySQL server.
+@item -pyour_pass, --password[=your_pass]
+The password to use when connecting to the server. If you specify
+no @samp{=your_pass} part,
+@code{mysqldump} you will be prompted for a password.
+@item -P port_num, --port=port_num
+The TCP/IP port number to use for connecting to a host. (This is used for
+connections to hosts other than @code{localhost}, for which Unix sockets are
+used.)
+@item -q, --quick
+Don't buffer query, dump directly to stdout. Uses @code{mysql_use_result()}
+to do this.
+@item -r, --result-file=...
+Direct output to a given file. This option should be used in MSDOS,
+because it prevents new line '\n' from being converted to '\n\r' (new
+line + carriage return).
+@item -S /path/to/socket, --socket=/path/to/socket
+The socket file to use when connecting to @code{localhost} (which is the
+default host).
+@item --tables
+Overrides option --databases (-B).
+@item -T, --tab=path-to-some-directory
+Creates a @code{table_name.sql} file, that contains the SQL CREATE commands,
+and a @code{table_name.txt} file, that contains the data, for each give table.
+@strong{NOTE}: This only works if @code{mysqldump} is run on the same
+machine as the @code{mysqld} daemon. The format of the @code{.txt} file
+is made according to the @code{--fields-xxx} and @code{--lines--xxx} options.
+@item -u user_name, --user=user_name
+The MySQL user name to use when connecting to the server. The
+default value is your Unix login name.
+@item -O var=option, --set-variable var=option
+Set the value of a variable. The possible variables are listed below.
+@item -v, --verbose
+Verbose mode. Print out more information on what the program does.
+@item -V, --version
+Print version information and exit.
+@item -w, --where='where-condition'
+Dump only selected records. Note that QUOTES are mandatory:
+
+@example
+"--where=user='jimf'" "-wuserid>1" "-wuserid<1"
+@end example
+@item -O net_buffer_length=#, where # < 16M
+When creating multi-row-insert statements (as with option
+@code{--extended-insert} or @code{--opt}), @code{mysqldump} will create
+rows up to @code{net_buffer_length} length. If you increase this
+variable, you should also ensure that the @code{max_allowed_packet}
+variable in the MySQL server is bigger than the
+@code{net_buffer_length}.
+@end table
+
+The most normal use of @code{mysqldump} is probably for making a backup of
+whole databases. @xref{Backup}.
+
+@example
+mysqldump --opt database > backup-file.sql
+@end example
+
+You can read this back into MySQL with:
+
+@example
+mysql database < backup-file.sql
+@end example
+
+or
+
+@example
+mysql -e "source /patch-to-backup/backup-file.sql" database
+@end example
+
+However, it's also very useful to populate another MySQL server with
+information from a database:
+
+@example
+mysqldump --opt database | mysql ---host=remote-host -C database
+@end example
+
+It is possible to dump several databases with one command:
+
+@example
+mysqldump --databases database1 [database2 database3...] > my_databases.sql
+@end example
+
+If all the databases are wanted, one can use:
+
+@example
+mysqldump --all-databases > all_databases.sql
+@end example
+
+
+@node mysqlhotcopy, mysqlimport, mysqldump, Client-Side Scripts
+@subsection mysqlhotcopy, Copying MySQL Databases and Tables
+
+@cindex dumping, databases
+@cindex databases, dumping
+@cindex tables, dumping
+@cindex backing up, databases
+
+@code{mysqlhotcopy} is a perl script that uses @code{LOCK TABLES},
+@code{FLUSH TABLES} and @code{cp} or @code{scp} to quickly make a backup
+of a database. It's the fastest way to make a backup of the database,
+of single tables but it can only be run on the same machine where the
+database directories are.
+
+@example
+mysqlhotcopy db_name [/path/to/new_directory]
+
+mysqlhotcopy db_name_1 ... db_name_n /path/to/new_directory
+
+mysqlhotcopy db_name./regex/
+@end example
+
+@code{mysqlhotcopy} supports the following options:
+
+@table @code
+@item -?, --help
+Display a help screen and exit
+@item -u, --user=#
+User for database login
+@item -p, --password=#
+Password to use when connecting to server
+@item -P, --port=#
+Port to use when connecting to local server
+@item -S, --socket=#
+Socket to use when connecting to local server
+@item --allowold
+Don't abort if target already exists (rename it _old)
+@item --keepold
+Don't delete previous (now renamed) target when done
+@item --noindices
+Don't include full index files in copy to make the backup smaller and faster
+The indexes can later be reconstructed with @code{myisamchk -rq.}.
+@item --method=#
+Method for copy (@code{cp} or @code{scp}).
+@item -q, --quiet
+Be silent except for errors
+@item --debug
+Enable debug
+@item -n, --dryrun
+Report actions without doing them
+@item --regexp=#
+Copy all databases with names matching regexp
+@item --suffix=#
+Suffix for names of copied databases
+@item --checkpoint=#
+Insert checkpoint entry into specified db.table
+@item --flushlog
+Flush logs once all tables are locked.
+@item --tmpdir=#
+Temporary directory (instead of /tmp).
+@end table
+
+You can use @code{perldoc mysqlhotcopy} to get a more complete
+documentation for @code{mysqlhotcopy}.
+
+@code{mysqlhotcopy} reads the groups @code{[client]} and @code{[mysqlhotcopy]}
+from the option files.
+
+To be able to execute @code{mysqlhotcopy} you need write access to the
+backup directory, @code{SELECT} privilege to the tables you are about to
+copy and the MySQL @code{Reload} privilege (to be able to
+execute @code{FLUSH TABLES}).
+
+
+@node mysqlimport, mysqlshow, mysqlhotcopy, Client-Side Scripts
+@subsection mysqlimport, Importing Data from Text Files
+
+@cindex importing, data
+@cindex data, importing
+@cindex files, text
+@cindex text files, importing
+@cindex @code{mysqlimport}
+
+@code{mysqlimport} provides a command-line interface to the @code{LOAD DATA
+INFILE} SQL statement. Most options to @code{mysqlimport} correspond
+directly to the same options to @code{LOAD DATA INFILE}.
+@xref{LOAD DATA, , @code{LOAD DATA}}.
+
+@code{mysqlimport} is invoked like this:
+
+@example
+shell> mysqlimport [options] database textfile1 [textfile2....]
+@end example
+
+For each text file named on the command line,
+@code{mysqlimport} strips any extension from the filename and uses the result
+to determine which table to import the file's contents into. For example,
+files named @file{patient.txt}, @file{patient.text}, and @file{patient} would
+all be imported into a table named @code{patient}.
+
+@code{mysqlimport} supports the following options:
+
+@table @code
+@item -c, --columns=...
+This option takes a comma-separated list of field names as an argument.
+The field list is used to create a proper @code{LOAD DATA INFILE} command,
+which is then passed to MySQL. @xref{LOAD DATA, , @code{LOAD DATA}}.
+
+@item -C, --compress
+Compress all information between the client and the server if both support
+compression.
+
+@item -#, --debug[=option_string]
+Trace usage of the program (for debugging).
+
+@item -d, --delete
+Empty the table before importing the text file.
+
+@item --fields-terminated-by=...
+@itemx --fields-enclosed-by=...
+@itemx --fields-optionally-enclosed-by=...
+@itemx --fields-escaped-by=...
+@itemx --lines-terminated-by=...
+These options have the same meaning as the corresponding clauses for
+@code{LOAD DATA INFILE}. @xref{LOAD DATA, , @code{LOAD DATA}}.
+
+@item -f, --force
+Ignore errors. For example, if a table for a text file doesn't exist,
+continue processing any remaining files. Without @code{--force},
+@code{mysqlimport} exits if a table doesn't exist.
+
+@item --help
+Display a help message and exit.
+
+@item -h host_name, --host=host_name
+Import data to the MySQL server on the named host. The default host
+is @code{localhost}.
+
+@item -i, --ignore
+See the description for the @code{--replace} option.
+
+@item -l, --lock-tables
+Lock @strong{ALL} tables for writing before processing any text files. This
+ensures that all tables are synchronized on the server.
+
+@item -L, --local
+Read input files from the client. By default, text files are assumed to be on
+the server if you connect to @code{localhost} (which is the default host).
+
+@item -pyour_pass, --password[=your_pass]
+The password to use when connecting to the server. If you specify
+no @samp{=your_pass} part,
+@code{mysqlimport} you will be prompted for a password.
+
+@item -P port_num, --port=port_num
+The TCP/IP port number to use for connecting to a host. (This is used for
+connections to hosts other than @code{localhost}, for which Unix sockets are
+used.)
+
+@item -r, --replace
+The @code{--replace} and @code{--ignore} options control handling of input
+records that duplicate existing records on unique key values. If you specify
+@code{--replace}, new rows replace existing rows that have the same unique key
+value. If you specify @code{--ignore}, input rows that duplicate an existing
+row on a unique key value are skipped. If you don't specify either option, an
+error occurs when a duplicate key value is found, and the rest of the text
+file is ignored.
+
+@item -s, --silent
+Silent mode. Write output only when errors occur.
+
+@item -S /path/to/socket, --socket=/path/to/socket
+The socket file to use when connecting to @code{localhost} (which is the
+default host).
+
+@item -u user_name, --user=user_name
+The MySQL user name to use when connecting to the server. The
+default value is your Unix login name.
+
+@item -v, --verbose
+Verbose mode. Print out more information what the program does.
+
+@item -V, --version
+Print version information and exit.
+@end table
+
+Here is a sample run using @code{mysqlimport}:
+
+@example
+$ mysql --version
+mysql Ver 9.33 Distrib 3.22.25, for pc-linux-gnu (i686)
+$ uname -a
+Linux xxx.com 2.2.5-15 #1 Mon Apr 19 22:21:09 EDT 1999 i586 unknown
+$ mysql -e 'CREATE TABLE imptest(id INT, n VARCHAR(30))' test
+$ ed
+a
+100 Max Sydow
+101 Count Dracula
+.
+w imptest.txt
+32
+q
+$ od -c imptest.txt
+0000000 1 0 0 \t M a x S y d o w \n 1 0
+0000020 1 \t C o u n t D r a c u l a \n
+0000040
+$ mysqlimport --local test imptest.txt
+test.imptest: Records: 2 Deleted: 0 Skipped: 0 Warnings: 0
+$ mysql -e 'SELECT * FROM imptest' test
++------+---------------+
+| id | n |
++------+---------------+
+| 100 | Max Sydow |
+| 101 | Count Dracula |
++------+---------------+
+@end example
+
+
+@node mysqlshow, perror, mysqlimport, Client-Side Scripts
+@subsection Showing Databases, Tables, and Columns
+
+@cindex databases, displaying
+@cindex displaying, database information
+@cindex tables, displaying
+@cindex columns, displaying
+@cindex showing, database information
+
+@code{mysqlshow} can be used to quickly look at which databases exist,
+their tables, and the table's columns.
+
+With the @code{mysql} program you can get the same information with the
+@code{SHOW} commands. @xref{SHOW}.
+
+@code{mysqlshow} is invoked like this:
+
+@example
+shell> mysqlshow [OPTIONS] [database [table [column]]]
+@end example
+
+@itemize @bullet
+@item
+If no database is given, all matching databases are shown.
+@item
+If no table is given, all matching tables in the database are shown.
+@item
+If no column is given, all matching columns and column types in the table
+are shown.
@end itemize
-@node Reference, Table types, Privilege system, Top
+Note that in newer MySQL versions, you only see those
+database/tables/columns for which you have some privileges.
+
+If the last argument contains a shell or SQL wild-card (@code{*}, @code{?},
+@code{%} or @code{_}) then only what's matched by the wild card is shown.
+This may cause some confusion when you try to display the columns for a
+table with a @code{_} as in this case @code{mysqlshow} only shows you
+the table names that match the pattern. This is easily fixed by
+adding an extra @code{%} last on the command line (as a separate
+argument).
+
+
+@node perror, Batch Commands, mysqlshow, Client-Side Scripts
+@subsection perror, Explaining Error Codes
+
+@cindex error messages, displaying
+@cindex perror
+
+@code{perror} can be used to print error message(s). @code{perror} can
+be invoked like this:
+
+@example
+shell> perror [OPTIONS] [ERRORCODE [ERRORCODE...]]
+
+For example:
+
+shell> perror 64 79
+Error code 64: Machine is not on the network
+Error code 79: Can not access a needed shared library
+@end example
+
+@code{perror} can be used to display a description for a system error
+code, or an MyISAM/ISAM table handler error code. The error messages
+are mostly system dependent.
+
+
+@node Batch Commands, , perror, Client-Side Scripts
+@subsection How to Run SQL Commands from a Text File
+
+@c FIX add the 'source' command
+
+The @code{mysql} client typically is used interactively, like this:
+
+@example
+shell> mysql database
+@end example
+
+However, it's also possible to put your SQL commands in a file and tell
+@code{mysql} to read its input from that file. To do so, create a text
+file @file{text_file} that contains the commands you wish to execute.
+Then invoke @code{mysql} as shown below:
+
+@example
+shell> mysql database < text_file
+@end example
+
+You can also start your text file with a @code{USE db_name} statement. In
+this case, it is unnecessary to specify the database name on the command
+line:
+
+@example
+shell> mysql < text_file
+@end example
+
+@xref{Client-Side Scripts}.
+
+
+@node Log Files, Replication, Client-Side Scripts, MySQL Database Administration
+@section The MySQL Log Files
+
+@cindex Log files
+
+MySQL has several different log files that 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 @code{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 Deprecated: 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} data directory. You can
+force @code{mysqld} to reopen the log files (or in some cases
+switch to a new log) by executing @code{FLUSH LOGS}. @xref{FLUSH}.
+
+@menu
+* Error log:: The Error Log
+* Query log:: The General Query Log
+* Update log:: The Update Log
+* Binary log:: The Binary Update Log
+* Slow query log:: The Slow Query Log
+* Log file maintenance:: Log File Maintenance
+@end menu
+
+
+@node Error log, Query log, Log Files, Log Files
+@subsection 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\data\mysql.err}).
+
+This contains information indicating when @code{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 automatically checked or repaired.
+
+On some operating systems, the error log will contain a stack trace
+for where @code{mysqld} died. This can be used to find out where
+@code{mysqld} died. @xref{Using stack trace}.
+
+
+@node Query log, Update log, Error log, Log Files
+@subsection The General Query Log
+
+@cindex query log
+@cindex files, 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 @file{'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 sent to it.
+
+By default, the @code{mysql.server} script starts the MySQL
+server with the @code{-l} option. If you need better performance when
+you start using MySQL in a production environment, you can
+remove the @code{-l} option from @code{mysql.server} or change it to
+@code{--log-binary}.
+
+The entries in this log are written as @code{mysqld} receives the questions.
+This may be different than the order in which the statements are executed.
+This is in contrast to the update log and the binary log which are written
+after the query is executed, but before any locks are released.
+
+
+@node Update log, Binary log, Query log, Log Files
+@subsection The Update Log
+
+@cindex update log
+@cindex files, update log
+
+@strong{NOTE}: The update log is replaced by the binary
+log. @xref{Binary log}. With this you can do anything that you can do
+with the update log.
+
+When started with the @code{--log-update[=file_name]} option,
+@code{mysqld} writes a log file containing all SQL commands that update
+data. If no filename is given, it defaults to the name of the host
+machine. If a filename is given, but it doesn't contain a path, the file
+is written in the data directory. If @file{file_name} doesn't have an
+extension, @code{mysqld} will create log file names like so:
+@file{file_name.###}, where @code{###} is a number that is incremented each
+time you execute @code{mysqladmin refresh}, execute @code{mysqladmin
+flush-logs}, execute the @code{FLUSH LOGS} statement, or restart the server.
+
+@strong{NOTE:} For the above scheme to work, you should NOT create
+your own files with the same filename as the update log + some extensions
+that may be regarded as a number, in the directory used by the update log!
+
+If you use the @code{--log} or @code{-l} options, @code{mysqld} writes a
+general log with a filename of @file{hostname.log}, and restarts and
+refreshes do not cause a new log file to be generated (although it is closed
+and reopened). In this case you can copy it (on Unix) by doing:
+
+@example
+mv hostname.log hostname-old.log
+mysqladmin flush-logs
+cp hostname-old.log to-backup-directory
+rm hostname-old.log
+@end example
+
+Update logging is smart because it logs only statements that really update
+data. So an @code{UPDATE} or a @code{DELETE} with a @code{WHERE} that finds no
+rows is not written to the log. It even skips @code{UPDATE} statements that
+set a column to the value it already has.
+
+The update logging is done immediately after a query completes but before
+any locks are released or any commit is done. This ensures that the log
+will be logged in the execution order.
+
+If you want to update a database from update log files, you could do the
+following (assuming your update logs have names of the form
+@file{file_name.###}):
+
+@example
+shell> ls -1 -t -r file_name.[0-9]* | xargs cat | mysql
+@end example
+
+@code{ls} is used to get all the log files in the right order.
+
+This can be useful if you have to revert to backup files after a crash
+and you want to redo the updates that occurred between the time of the backup
+and the crash.
+
+
+@node Binary log, Slow query log, Update log, Log Files
+@subsection The Binary Update Log
+
+@cindex binary log
+@cindex files, binary log
+
+In the future the binary log will replace the update log, so we
+recommend you to switch to this log format as soon as possible!
+
+The binary log contains all information that is available in the update
+log in a more efficient format. It also contains information about how long
+every query that updated the database took.
+
+The binary log is also used when you are replicating a slave from a master.
+@xref{Replication}.
+
+When started with the @code{--log-bin[=file_name]} option, @code{mysqld}
+writes a log file containing all SQL commands that update data. If no
+file name is given, it defaults to the name of the host machine followed
+by @code{-bin}. If file name is given, but it doesn't contain a path, the
+file is written in the data directory.
+
+You can use the following options to @code{mysqld} to affect what is logged
+to the binary log:
+
+@multitable @columnfractions .4 .6
+@item @code{binlog-do-db=database_name} @tab
+Tells the master it should log updates for the specified database, and
+exclude all others not explicitly mentioned.
+(Example: @code{binlog-do-db=some_database})
+
+@item @code{binlog-ignore-db=database_name} @tab
+Tells the master that updates to the given database should not be logged
+to the binary log (Example: @code{binlog-ignore-db=some_database})
+@end multitable
+
+To the binary log filename @code{mysqld} will append an extension that is a
+number that is incremented each time you execute @code{mysqladmin
+refresh}, execute @code{mysqladmin flush-logs}, execute the @code{FLUSH LOGS}
+statement or restart the server.
+
+To be able to know which different binary log files have been used,
+@code{mysqld} will also create a binary log index file that
+contains the name of all used binary log files. By default this has the
+same name as the binary log file, with the extension @code{'.index'}.
+You can change the name of the binary log index file with the
+@code{--log-bin-index=[filename]} option.
+
+If you are using replication, you should not delete old binary log
+files until you are sure that no slave will ever need to use them.
+One way to do this is to do @code{mysqladmin flush-logs} once a day and then
+remove any logs that are more than 3 days old.
+
+You can examine the binary log file with the @code{mysqlbinlog} command.
+For example, you can update a MySQL server from the binary log
+as follows:
+
+@example
+mysqlbinlog log-file | mysql -h server_name
+@end example
+
+You can also use the @code{mysqlbinlog} program to read the binary log
+directly from a remote MySQL server!
+
+@code{mysqlbinlog --help} will give you more information of how to use
+this program!
+
+If you are using @code{BEGIN [WORK]} or @code{SET AUTOCOMMIT=0}, you must
+use the MySQL binary log for backups instead of the old update log.
+
+The binary logging is done immediately after a query completes but before
+any locks are released or any commit is done. This ensures that the log
+will be logged in the execution order.
+
+All updates (@code{UPDATE}, @code{DELETE} or @code{INSERT}) that change
+a transactional table (like BDB tables) are cached until a @code{COMMIT}.
+Any updates to a non-transactional table are stored in the binary log at
+once. Every thread will, on start, allocate a buffer of
+@code{binlog_cache_size} to buffer queries. If a query is bigger than
+this, the thread will open a temporary file to handle the bigger cache.
+The temporary file will be deleted when the thread ends.
+
+The @code{max_binlog_cache_size} can be used to restrict the total size used
+to cache a multi-transaction query.
+
+If you are using the update or binary log, concurrent inserts will
+not work together with @code{CREATE ... INSERT} and @code{INSERT ... SELECT}.
+This is to ensure that you can recreate an exact copy of your tables by
+applying the log on a backup.
+
+
+@node Slow query log, Log file maintenance, Binary log, Log Files
+@subsection The Slow Query Log
+
+@cindex slow query log
+@cindex files, slow query log
+
+When started with the @code{--log-slow-queries[=file_name]} option,
+@code{mysqld} writes a log file containing all SQL commands that took
+more than @code{long_query_time} to execute. The time to get the initial
+table locks are not counted as execution time.
+
+The slow query log is logged after the query is executed and after all
+locks has been released. This may be different than the order in which
+the statements are executed.
+
+If no file name is given, it defaults to the name of the host machine
+suffixed with @code{-slow.log}. If a filename is given, but doesn't
+contain a path, the file is written in the data directory.
+
+The slow query log can be used to find queries that take a long time to
+execute and are thus candidates for optimization. With a large log, that
+can become a difficult task. You can pipe the slow query log through the
+@code{mysqldumpslow} command to get a summary of the queries which
+appear in the log.
+
+You are using @code{--log-long-format} then also queries that are not
+using indexes are printed. @xref{Command-line options}.
+
+
+@node Log file maintenance, , Slow query log, Log Files
+@subsection Log File Maintenance
+
+@cindex files, log
+@cindex maintaining, log files
+@cindex log files, maintaining
+
+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 don't take up too much disk
+space.
+
+When using MySQL with log files, you will, from time to time,
+want to remove/backup old log files and tell MySQL to start
+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 MySQL
+from an RPM distribution, the script should have been installed
+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.
+
+You can force MySQL to start using new log files by using
+@code{mysqladmin flush-logs} or by using the SQL command @code{FLUSH LOGS}.
+If you are using MySQL Version 3.21 you must use @code{mysqladmin refresh}.
+
+The above command does the following:
+
+@itemize @bullet
+@item
+If standard logging (@code{--log}) or slow query logging
+(@code{--log-slow-queries}) is used, closes and reopens the log file.
+(@file{mysql.log} and @file{`hostname`-slow.log} as default).
+@item
+If update logging (@code{--log-update}) is used, closes the update log and
+opens a new log file with a higher sequence number.
+@end itemize
+
+If you are using only an update log, you only have to flush the logs and then
+move away the old update log files to a backup.
+If you are using the normal logging, you can do something like:
+
+@example
+shell> cd mysql-data-directory
+shell> mv mysql.log mysql.old
+shell> mysqladmin flush-logs
+@end example
+
+and then take a backup and remove @file{mysql.old}.
+
+
+@node Replication, , Log Files, MySQL Database Administration
+@section Replication in MySQL
+
+@cindex replication
+@cindex increasing, speed
+@cindex speed, increasing
+@cindex databases, replicating
+
+@menu
+* Replication Intro:: Introduction
+* Replication Implementation:: Replication Implementation Overview
+* Replication HOWTO:: How To Set Up Replication
+* Replication Features:: Replication Features and Known Problems
+* Replication Options:: Replication Options in my.cnf
+* Replication SQL:: SQL Commands Related to Replication
+* Replication FAQ:: Replication FAQ
+* Replication Problems:: Troubleshooting Replication
+@end menu
+
+This chapter describes the various replication features in MySQL.
+It serves as a reference to the options available with replication.
+You will be introduced to replication and learn how to implement it.
+Towards the end, there are some frequently asked questions and descriptions
+of problems and how to solve them.
+
+
+@node Replication Intro, Replication Implementation, Replication, Replication
+@subsection Introduction
+
+One way replication can be used is to increase both robustness and
+speed. For robustness you can have two systems and can switch to the backup if
+you have problems with the master. The extra speed is achieved by
+sending a part of the non-updating queries to the replica server. Of
+course this only works if non-updating queries dominate, but that is the
+normal case.
+
+Starting in Version 3.23.15, MySQL supports one-way replication
+internally. One server acts as the master, while the other acts as the
+slave. Note that one server could play the roles of master in one pair
+and slave in the other. The master server keeps a binary log of updates
+(@xref{Binary log}.) and an index file to binary logs to keep track of
+log rotation. The slave, upon connecting, informs the master where it
+left off since the last successfully propagated update, catches up on
+the updates, and then blocks and waits for the master to notify it of
+the new updates.
+
+Note that if you are replicating a database, all updates to this
+database should be done through the master!
+
+Another benefit of using replication is that one can get live backups of
+the system by doing a backup on a slave instead of doing it on the
+master. @xref{Backup}.
+
+
+@node Replication Implementation, Replication HOWTO, Replication Intro, Replication
+@subsection Replication Implementation Overview
+
+@cindex master-slave setup
+
+MySQL replication is based on the server keeping track of all
+changes to your database (updates, deletes, etc) in the binary
+log. (@xref{Binary log}.) and the slave server(s) reading the saved
+queries from the master server's binary log so that the slave can
+execute the same queries on its copy of the data.
+
+It is @strong{very important} to realize that the binary log is simply a
+record starting from a fixed point in time (the moment you enable binary
+logging). Any slaves which you set up will need copies of all the data
+from your master as it existed the moment that you enabled binary
+logging on the master. If you start your slaves with data that doesn't
+agree with what was on the master @strong{when the binary log was
+started}, your slaves may fail.
+
+A future version (4.0) of MySQL will remove the need to keep a
+(possibly large) snapshot of data for new slaves that you might wish to
+set up through the live backup functionality with no locking required.
+However, at this time, it is necessary to block all writes either with a
+global read lock or by shutting down the master while taking a snapshot.
+
+Once a slave is properly configured and running, it will simply connect
+to the master and wait for updates to process. If the master goes away
+or the slave loses connectivity with your master, it will keep trying to
+connect every @code{master-connect-retry} seconds until it is able to
+reconnect and resume listening for updates.
+
+Each slave keeps track of where it left off. The master server has no
+knowledge of how many slaves there are or which ones are up-to-date at
+any given time.
+
+The next section explains the master/slave setup process in more detail.
+
+
+@node Replication HOWTO, Replication Features, Replication Implementation, Replication
+@subsection How To Set Up Replication
+
+Below is a quick description of how to set up complete replication on
+your current MySQL server. It assumes you want to replicate all
+your databases and have not configured replication before. You will need
+to shutdown your master server briefly to complete the steps outlined
+below.
+
+@enumerate
+@item
+Make sure you have a recent version of MySQL installed on the master
+and slave(s).
+
+Use Version 3.23.29 or higher. Previous releases used a different binary
+log format and had bugs which have been fixed in newer releases. Please,
+do not report bugs until you have verified that the problem is present
+in the latest release.
+
+@item
+Set up special a replication user on the master with the @code{FILE}
+privilege and permission to connect from all the slaves. If the user is
+only doing replication (which is recommended), you don't need to grant any
+additional privileges.
+
+For example, to create a user named @code{repl} which can access your
+master from any host, you might use this command:
+
+@example
+GRANT FILE ON *.* TO repl@@"%" IDENTIFIED BY '<password>';
+@end example
+
+@item
+Shut down MySQL on the master.
+
+@example
+mysqladmin -u root -p<password> shutdown
+@end example
+
+@item
+Snapshot all the data on your master server.
+
+The easiest way to do this (on Unix) is to simply use @strong{tar} to
+produce an archive of your entire data directory. The exact data
+directory location depends on your installation.
+
+@example
+tar -cvf /tmp/mysql-snapshot.tar /path/to/data-dir
+@end example
+
+Windows users can use WinZip or similar software to create an archive of
+the data directory.
+
+@item
+In @code{my.cnf} on the master add @code{log-bin} and
+@code{server-id=unique number} to the @code{[mysqld]} section and
+restart it. It is very important that the id of the slave is different from
+the id of the master. Think of @code{server-id} as something similar
+to the IP address - it uniquely identifies the server instance in the
+community of replication partners.
+
+@example
+[mysqld]
+log-bin
+server-id=1
+@end example
+
+@item
+Restart MySQL on the master.
+
+@item
+Add the following to @code{my.cnf} on the slave(s):
+
+@example
+master-host=<hostname of the master>
+master-user=<replication user name>
+master-password=<replication user password>
+master-port=<TCP/IP port for master>
+server-id=<some unique number between 2 and 2^32-1>
+@end example
+
+replacing the values in <> with what is relevant to your system.
+
+@code{server-id} must be different for each server participating in
+replication. If you don't specify a server-id, it will be set to 1 if
+you have not defined @code{master-host}, else it will be set to 2. Note
+that in the case of @code{server-id} omission the master will refuse
+connections from all slaves, and the slave will refuse to connect to a
+master. Thus, omitting @code{server-id} is only good for backup with a
+binary log.
+
+
+@item
+Copy the snapshot data into your data directory on your slave(s). Make
+sure that the privileges on the files and directories are correct. The
+user which MySQL runs as needs to be able to read and write to
+them, just as on the master.
+
+@item Restart the slave(s).
+
+@end enumerate
+
+After you have done the above, the slave(s) should connect to the master
+and catch up on any updates which happened since the snapshot was taken.
+
+If you have forgotten to set @code{server-id} for the slave you will get
+the following error in the error log file:
+
+@example
+Warning: one should set server_id to a non-0 value if master_host is set.
+The server will not act as a slave.
+@end example
+
+If you have forgot to do this for the master, the slaves will not be
+able to connect to the master.
+
+If a slave is not able to replicate for any reason, you will find error
+messages in the error log on the slave.
+
+Once a slave is replicating, you will find a file called
+@code{master.info} in the same directory as your error log. The
+@code{master.info} file is used by the slave to keep track of how much
+of the master's binary log is has processed. @strong{Do not} remove or
+edit the file, unless you really know what you are doing. Even in that case,
+it is preferred that you use @code{CHANGE MASTER TO} command.
+
+
+@menu
+* Replication Features:: Replication Features and Known Problems
+* Replication Options:: Replication Options in my.cnf
+* Replication SQL:: SQL Commands Related to Replication
+* Replication FAQ:: Replication FAQ
+* Replication Problems:: Troubleshooting Replication
+@end menu
+
+
+@node Replication Features, Replication Options, Replication HOWTO, Replication
+@subsection Replication Features and Known Problems
+
+@cindex options, replication
+@cindex @code{my.cnf} file
+@cindex files,@code{my.cnf}
+
+Below is an explanation of what is supported and what is not:
+
+@itemize @bullet
+@item
+Replication will be done correctly with @code{AUTO_INCREMENT},
+@code{LAST_INSERT_ID}, and @code{TIMESTAMP} values.
+@item
+@code{RAND()} in updates does not replicate properly. Use
+@code{RAND(some_non_rand_expr)} if you are replicating updates with
+@code{RAND()}. You can, for example, use @code{UNIX_TIMESTAMP()} for the
+argument to @code{RAND()}.
+@item
+You have to use the same character set (@code{--default-character-set})
+on the master and the slave. If not, you may get duplicate key errors on
+the slave, because a key that is regarded as unique on the master may
+not be that in the other character set.
+@item
+@code{LOAD DATA INFILE} will be handled properly as long as the file
+still resides on the master server at the time of update
+propagation. @code{LOAD LOCAL DATA INFILE} will be skipped.
+@item
+Update queries that use user variables are not replication-safe (yet).
+@item
+@code{FLUSH} commands are not stored in the binary log and are because
+of this not replicated to the slaves. This is not normally a problem as
+@code{FLUSH} doesn't change anything. This does however mean that if you
+update the @code{MySQL} privilege tables directly without using
+@code{GRANT} statement and you replicate the @code{MySQL} privilege
+database, you must do a @code{FLUSH PRIVILEGES} on your slaves to put
+the new privileges into effect.
+@item
+Temporary tables starting in 3.23.29 are replicated properly with the
+exception of the case when you shut down slave server ( not just slave thread),
+you have some temporary tables open, and the are used in subsequent updates.
+To deal with this problem, to shut down the slave, do @code{SLAVE STOP}, then
+check @code{Slave_open_temp_tables} variable to see if it is 0, then issue
+@code{mysqladmin shutdown}. If the number is not 0, restart the slave thread
+with @code{SLAVE START} and see
+if you have better luck next time. There will be a cleaner solution, but it
+has to wait until version 4.0.
+In earlier versions temporary tables are not being replicated properly - we
+recommend that you either upgrade, or execute @code{SET SQL_LOG_BIN=0} on
+your clients before all queries with temp tables.
+@item
+MySQL only supports one master and many slaves. We will in 4.x
+add a voting algorithm to automatically change master if something goes
+wrong with the current master. We will also introduce 'agent' processes
+to help doing load balancing by sending select queries to different
+slaves.
+@item
+Starting in Version 3.23.26, it is safe to connect servers in a circular
+master-slave relationship with @code{log-slave-updates} enabled.
+Note, however, that many queries will not work right in this kind of
+setup unless your client code is written to take care of the potential
+problems that can happen from updates that occur in different sequence
+on different servers.
+
+This means that you can do a setup like the following:
+
+@example
+A -> B -> C -> A
+@end example
+
+This setup will only works if you only do non conflicting updates
+between the tables. In other words, if you insert data in A and C, you
+should never insert a row in A that may have a conflicting key with a
+row insert in C. You should also not update the sam rows on two servers
+if the order in which the updates are applied matters.
+
+Note that the log format has changed in Version 3.23.26 so that
+pre-3.23.26 slaves will not be able to read it.
+@item
+If the query on the slave gets an error, the slave thread will
+terminate, and a message will appear in the @code{.err} file. You should
+then connect to the slave manually, fix the cause of the error (for
+example, non-existent table), and then run @code{SLAVE START} sql
+command (available starting in Version 3.23.16). In Version 3.23.15, you
+will have to restart the server.
+@item
+If connection to the master is lost, the slave will retry immediately,
+and then in case of failure every @code{master-connect-retry} (default
+60) seconds. Because of this, it is safe to shut down the master, and
+then restart it after a while. The slave will also be able to deal with
+network connectivity outages.
+@item
+Shutting down the slave (cleanly) is also safe, as it keeps track of
+where it left off. Unclean shutdowns might produce problems, especially
+if disk cache was not synced before the system died. Your system fault
+tolerance will be greatly increased if you have a good UPS.
+@item
+If the master is listening on a non-standard port, you will also need to
+specify this with @code{master-port} parameter in @code{my.cnf} .
+@item
+In Version 3.23.15, all of the tables and databases will be
+replicated. Starting in Version 3.23.16, you can restrict replication to
+a set of databases with @code{replicate-do-db} directives in
+@code{my.cnf} or just exclude a set of databases with
+@code{replicate-ignore-db}. Note that up until Version 3.23.23, there was a bug
+that did not properly deal with @code{LOAD DATA INFILE} if you did it in
+a database that was excluded from replication.
+@item
+Starting in Version 3.23.16, @code{SET SQL_LOG_BIN = 0} will turn off
+replication (binary) logging on the master, and @code{SET SQL_LOG_BIN =
+1} will turn in back on - you must have the process privilege to do
+this.
+@item
+Starting in Version 3.23.19, you can clean up stale replication leftovers when
+something goes wrong and you want a clean start with @code{FLUSH MASTER}
+and @code{FLUSH SLAVE} commands. In Version 3.23.26 we have renamed them to
+@code{RESET MASTER} and @code{RESET SLAVE} respectively to clarify
+what they do. The old @code{FLUSH} variants still work, though, for
+compatibility.
+
+@item
+Starting in Version 3.23.21, you can use @code{LOAD TABLE FROM MASTER} for
+network backup and to set up replication initially. We have recently
+received a number of bug reports concerning it that we are investigating, so
+we recommend that you use it only in testing until we make it more stable.
+@item
+Starting in Version 3.23.23, you can change masters and adjust log position
+with @code{CHANGE MASTER TO}.
+@item
+Starting in Version 3.23.23, you tell the master that updates in certain
+databases should not be logged to the binary log with @code{binlog-ignore-db}.
+@item
+Starting in Version 3.23.26, you can use @code{replicate-rewrite-db} to tell
+the slave to apply updates from one database on the master to the one
+with a different name on the slave.
+@item
+Starting in Version 3.23.28, you can use @code{PURGE MASTER LOGS TO 'log-name'}
+to get rid of old logs while the slave is running.
+@end itemize
+
+
+@node Replication Options, Replication SQL, Replication Features, Replication
+@subsection Replication Options in my.cnf
+
+If you are using replication, we recommend you to use MySQL Version
+3.23.30 or later. Older versions work, but they do have some bugs and are
+missing some features.
+
+On both master and slave you need to use the @code{server-id} option.
+This sets an unique replication id. You should pick a unique value in the
+range between 1 to 2^32-1 for each master and slave.
+Example: @code{server-id=3}
+
+The following table has the options you can use for the @strong{MASTER}:
+
+@multitable @columnfractions .3 .7
+
+@item @strong{Option} @tab @strong{Description}
+@item @code{log-bin=filename} @tab
+Write to a binary update log to the specified location. Note that if you
+give it a parameter with an extension (for example,
+@code{log-bin=/mysql/logs/replication.log} ) versions up to 3.23.24 will
+not work right during replication if you do @code{FLUSH LOGS} . The
+problem is fixed in Version 3.23.25. If you are using this kind of log
+name, @code{FLUSH LOGS} will be ignored on binlog. To clear the log, run
+@code{FLUSH MASTER}, and do not forget to run @code{FLUSH SLAVE} on all
+slaves. In Version 3.23.26 and in later versions you should use
+@code{RESET MASTER} and @code{RESET SLAVE}
+
+@item @code{log-bin-index=filename} @tab
+Because the user could issue the @code{FLUSH LOGS} command, we need to
+know which log is currently active and which ones have been rotated out
+and in what sequence. This information is stored in the binary log index file.
+The default is `hostname`.index. You can use this option if you want to
+be a rebel. (Example: @code{log-bin-index=db.index})
+
+@item @code{sql-bin-update-same} @tab
+If set, setting @code{SQL_LOG_BIN} to a value will automatically set
+@code{SQL_LOG_UPDATE} to the same value and vice versa.
+
+@item @code{binlog-do-db=database_name} @tab
+Tells the master it should log updates for the specified database, and
+exclude all others not explicitly mentioned.
+(Example: @code{binlog-do-db=some_database})
+
+@item @code{binlog-ignore-db=database_name} @tab
+Tells the master that updates to the given database should not be logged
+to the binary log (Example: @code{binlog-ignore-db=some_database})
+@end multitable
+
+The following table has the options you can use for the @strong{SLAVE}:
+
+@multitable @columnfractions .3 .7
+
+@item @strong{Option} @tab @strong{Description}
+@item @code{master-host=host} @tab
+Master hostname or IP address for replication. If not set, the slave
+thread will not be started.
+(Example: @code{master-host=db-master.mycompany.com})
+
+@item @code{master-user=username} @tab
+The user the slave thread will us for authentication when connecting to
+the master. The user must have @code{FILE} privilege. If the master user
+is not set, user @code{test} is assumed. (Example:
+@code{master-user=scott})
+
+@item @code{master-password=password} @tab
+The password the slave thread will authenticate with when connecting to
+the master. If not set, an empty password is assumed. (Example:
+@code{master-password=tiger})
+
+@item @code{master-port=portnumber} @tab
+The port the master is listening on. If not set, the compiled setting of
+@code{MYSQL_PORT} is assumed. If you have not tinkered with
+@code{configure} options, this should be 3306. (Example:
+@code{master-port=3306})
+
+@item @code{master-connect-retry=seconds} @tab
+The number of seconds the slave thread will sleep before retrying to
+connect to the master in case the master goes down or the connection is
+lost. Default is 60. (Example: @code{master-connect-retry=60})
+
+@item @code{master-info-file=filename} @tab
+The location of the file that remembers where we left off on the master
+during the replication process. The default is master.info in the data
+directory. Sasha: The only reason I see for ever changing the default
+is the desire to be rebelious. (Example:
+@code{master-info-file=master.info})
+
+@item @code{replicate-do-table=db_name.table_name} @tab
+Tells the slave thread to restrict replication to the specified database.
+To specify more than one table, use the directive multiple times,
+once for each table. .
+(Example: @code{replicate-do-table=some_db.some_table})
+
+@item @code{replicate-ignore-table=db_name.table_name} @tab
+Tells the slave thread to not replicate to the specified table. To
+specify more than one table to ignore, use the directive multiple
+times, once for each table.(Example:
+@code{replicate-ignore-table=db_name.some_table})
+
+@item @code{replicate-wild-do-table=db_name.table_name} @tab
+Tells the slave thread to restrict replication to the tables that match the
+specified wildcard pattern. .
+To specify more than one table, use the directive multiple times,
+once for each table. .
+(Example: @code{replicate-do-table=foo%.bar%} will replicate only updates
+to tables in all databases that start with foo and whose table names
+start with bar)
+
+@item @code{replicate-wild-ignore-table=db_name.table_name} @tab
+Tells the slave thread to not replicate to the tables that match the given
+wild card pattern. To
+specify more than one table to ignore, use the directive multiple
+times, once for each table.(Example:
+@code{replicate-ignore-table=foo%.bar%} - will not upates to tables in all databases that start with foo and whose table names
+start with bar)
+
+@item @code{replicate-ignore-db=database_name} @tab
+Tells the slave thread to not replicate to the specified database. To
+specify more than one database to ignore, use the directive multiple
+times, once for each database. This option will not work if you use cross
+database updates. If you need cross database updates to work, make sure
+you have 3.23.28 or later, and use
+@code{replicate-wild-ignore-table=db_name.%}(Example:
+@code{replicate-ignore-db=some_db})
+
+@item @code{replicate-do-db=database_name} @tab
+Tells the slave thread to restrict replication to the specified database.
+To specify more than one database, use the directive multiple times,
+once for each database. Note that this will only work if you do not use
+cross-database queries such as @code{UPDATE some_db.some_table SET
+foo='bar'} while having selected a different or no database. If you need
+cross database updates to work, make sure
+you have 3.23.28 or later, and use
+@code{replicate-wild-do-table=db_name.%}
+(Example: @code{replicate-do-db=some_db})
+
+@item @code{log-slave-updates} @tab
+Tells the slave to log the updates from the slave thread to the binary
+log. Off by default. You will need to turn it on if you plan to
+daisy-chain the slaves.
+
+@item @code{replicate-rewrite-db=from_name->to_name} @tab
+Updates to a database with a different name than the original (Example:
+@code{replicate-rewrite-db=master_db_name->slave_db_name}
+
+@item @code{skip-slave-start} @tab
+Tells the slave server not to start the slave on the startup. The user
+can start it later with @code{SLAVE START}.
+
+@item @code{slave_read_timeout=#} @tab
+Number of seconds to wait for more data from the master before aborting
+the read.
+@end multitable
+
+
+@node Replication SQL, Replication FAQ, Replication Options, Replication
+@subsection SQL Commands Related to Replication
+
+@cindex SQL commands, replication
+@cindex commands, replication
+@cindex replication, commands
+
+Replication can be controlled through the SQL interface. Below is the
+summary of commands:
+
+@multitable @columnfractions .30 .70
+@item @strong{Command} @tab @strong{Description}
+
+@item @code{SLAVE START}
+ @tab Starts the slave thread. (Slave)
+
+@item @code{SLAVE STOP}
+ @tab Stops the slave thread. (Slave)
+
+@item @code{SET SQL_LOG_BIN=0}
+ @tab Disables update logging if the user has process privilege.
+ Ignored otherwise. (Master)
+
+@item @code{SET SQL_LOG_BIN=1}
+ @tab Re-enables update logging if the user has process privilege.
+ Ignored otherwise. (Master)
+
+@item @code{SET SQL_SLAVE_SKIP_COUNTER=n}
+ @tab Skip the next @code{n} events from the master. Only valid when
+the slave thread is not running, otherwise, gives an error. Useful for
+recovering from replication glitches.
+
+@item @code{RESET MASTER}
+ @tab Deletes all binary logs listed in the index file, resetting the binlog
+index file to be empty. In pre-3.23.26 versions, @code{FLUSH MASTER} (Master)
+
+@item @code{RESET SLAVE}
+ @tab Makes the slave forget its replication position in the master
+logs. In pre 3.23.26 versions the command was called
+@code{FLUSH SLAVE}(Slave)
+
+@item @code{LOAD TABLE tblname FROM MASTER}
+ @tab Downloads a copy of the table from master to the slave. (Slave)
+
+@item @code{CHANGE MASTER TO master_def_list}
+ @tab Changes the master parameters to the values specified in
+@code{master_def_list} and restarts the slave thread. @code{master_def_list}
+is a comma-separated list of @code{master_def} where @code{master_def} is
+one of the following: @code{MASTER_HOST}, @code{MASTER_USER},
+@code{MASTER_PASSWORD}, @code{MASTER_PORT}, @code{MASTER_CONNECT_RETRY},
+@code{MASTER_LOG_FILE}, @code{MASTER_LOG_POS}. Example:
+
+@example
+
+CHANGE MASTER TO
+ MASTER_HOST='master2.mycompany.com',
+ MASTER_USER='replication',
+ MASTER_PASSWORD='bigs3cret',
+ MASTER_PORT=3306,
+ MASTER_LOG_FILE='master2-bin.001',
+ MASTER_LOG_POS=4;
+
+@end example
+
+You only need to specify the values that need to be changed. The values that
+you omit will stay the same with the exception of when you change the host or
+the port. In that case, the slave will assume that since you are connecting to
+a different host or a different port, the master is different. Therefore, the
+old values of log and position are not applicable anymore, and will
+automatically be reset to an empty string and 0, respectively (the start
+values). Note that if you restart the slave, it will remember its last master.
+If this is not desirable, you should delete the @file{master.info} file before
+restarting, and the slave will read its master from @code{my.cnf} or the
+command line. (Slave)
+
+@item @code{SHOW MASTER STATUS} @tab Provides status information on the binlog of the master. (Master)
+
+@item @code{SHOW SLAVE STATUS} @tab Provides status information on essential parameters of the slave thread. (Slave)
+@item @code{SHOW MASTER LOGS} @tab Only available starting in Version 3.23.28. Lists the binary logs on the master. You should use this command prior to @code{PURGE MASTER LOGS TO} to find out how far you should go.
+
+@item @code{PURGE MASTER LOGS TO 'logname'}
+ @tab Available starting in Version 3.23.28. Deletes all the
+replication logs that are listed in the log
+index as being prior to the specified log, and removed them from the
+log index, so that the given log now becomes first. Example:
+
+@example
+PURGE MASTER LOGS TO 'mysql-bin.010'
+@end example
+
+This command will do nothing and fail with an error if you have an
+active slave that is currently reading one of the logs you are trying to
+delete. However, if you have a dormant slave, and happen to purge one of
+the logs it wants to read, the slave will be unable to replicate once it
+comes up. The command is safe to run while slaves are replicating - you
+do not need to stop them.
+
+You must first check all the slaves with @code{SHOW SLAVE STATUS} to
+see which log they are on, then do a listing of the logs on the
+master with @code{SHOW MASTER LOGS}, find the earliest log among all
+the slaves (if all the slaves are up to date, this will be the
+last log on the list), backup all the logs you are about to delete
+(optional) and purge up to the target log.
+
+@end multitable
+
+
+@node Replication FAQ, Replication Problems, Replication SQL, Replication
+@subsection Replication FAQ
+
+@cindex @code{Binlog_Dump}
+@strong{Q}: Why do I sometimes see more than one @code{Binlog_Dump} thread on
+the master after I have restarted the slave?
+
+@strong{A}: @code{Binlog_Dump} is a continuous process that is handled by the
+server in the following way:
+
+@itemize @bullet
+@item
+Catch up on the updates.
+@item
+Once there are no more updates left, go into @code{pthread_cond_wait()},
+from which we can be awakened either by an update or a kill.
+@item
+On wake up, check the reason. If we are not supposed to die, continue
+the @code{Binlog_dump} loop.
+@item
+If there is some fatal error, such as detecting a dead client,
+terminate the loop.
+@end itemize
+
+So if the slave thread stops on the slave, the corresponding
+@code{Binlog_Dump} thread on the master will not notice it until after
+at least one update to the master (or a kill), which is needed to wake
+it up from @code{pthread_cond_wait()}. In the meantime, the slave
+could have opened another connection, which resulted in another
+@code{Binlog_Dump} thread.
+
+The above problem should not be present in Version 3.23.26 and later
+versions. In Version 3.23.26 we added @code{server-id} to each
+replication server, and now all the old zombie threads are killed on the
+master when a new replication thread connects from the same slave
+
+@strong{Q}: How do I rotate replication logs?
+
+@strong{A}: In Version 3.23.28 you should use @code{PURGE MASTER LOGS
+TO} command after determining which logs can be deleted, and optionally
+backing them up first. In earlier versions the process is much more
+painful, and cannot be safely done without stopping all the slaves in
+the case that you plan to re-use log names. You will need to stop the
+slave threads, edit the binary log index file, delete all the old logs,
+restart the master, start slave threads, and then remove the old log files.
+
+
+@strong{Q}: How do I upgrade on a hot replication setup?
+
+@strong{A}: If you are upgrading pre-3.23.26 versions, you should just
+lock the master tables, let the slave catch up, then run @code{FLUSH
+MASTER} on the master, and @code{FLUSH SLAVE} on the slave to reset the
+logs, then restart new versions of the master and the slave. Note that
+the slave can stay down for some time - since the master is logging
+all the updates, the slave will be able to catch up once it is up and
+can connect.
+
+After 3.23.26, we have locked the replication protocol for modifications, so
+you can upgrade masters and slave on the fly to a newer 3.23 version and you
+can have different versions of MySQL running on the slave and the
+master, as long as they are both newer than 3.23.26.
+
+@cindex replication, two-way
+@strong{Q}: What issues should I be aware of when setting up two-way
+replication?
+
+@strong{A}: MySQL replication currently does not support any
+locking protocol between master and slave to guarantee the atomicity of
+a distributed (cross-server) update. In in other words, it is possible
+for client A to make an update to co-master 1, and in the meantime,
+before it propagates to co-master 2, client B could make an update to
+co-master 2 that will make the update of client A work differently than
+it did on co-master 1. Thus when the update of client A will make it
+to co-master 2, it will produce tables that will be different than
+what you have on co-master 1, even after all the updates from co-master
+2 have also propagated. So you should not co-chain two servers in a
+two-way replication relationship, unless you are sure that you updates
+can safely happen in any order, or unless you take care of mis-ordered
+updates somehow in the client code.
+
+
+You must also realize that two-way replication actually does not improve
+performance very much, if at all, as far as updates are concerned. Both
+servers need to do the same amount of updates each, as you would have
+one server do. The only difference is that there will be a little less
+lock contention, because the updates originating on another server will
+be serialized in one slave thread. This benefit, though, might be
+offset by network delays.
+
+@cindex performance, improving
+@cindex increasing, performance
+@strong{Q}: How can I use replication to improve performance of my system?
+
+@strong{A}: You should set up one server as the master, and direct all
+writes to it, and configure as many slaves as you have the money and
+rackspace for, distributing the reads among the master and the slaves.
+You can also start the slaves with @code{--skip-bdb},
+@code{--low-priority-updates} and @code{--delay-key-write-for-all-tables}
+to get speed improvements for the slave. In this case the slave will
+use non-transactional @code{MyISAM} tables instead of @code{BDB} tables
+to get more speed.
+
+@strong{Q}: What should I do to prepare my client code to use
+performance-enhancing replication?
+
+@strong{A}:
+If the part of your code that is responsible for database access has
+been properly abstracted/modularized, converting it to run with the
+replicated setup should be very smooth and easy - just change the
+implementation of your database access to read from some slave or the
+master, and to always write to the master. If your code does not have
+this level of abstraction,
+setting up a replicated system will give you an opportunity/motivation
+to it clean up.
+ You should start by creating a wrapper library
+/module with the following functions:
+
+@itemize @bullet
+@item
+@code{safe_writer_connect()}
+@item
+@code{safe_reader_connect()}
+@item
+@code{safe_reader_query()}
+@item
+@code{safe_writer_query()}
+@end itemize
+
+@code{safe_} means that the function will take care of handling all
+the error conditions.
+
+You should then convert your client code to use the wrapper library.
+It may be a painful and scary process at first, but it will pay off in
+the long run. All applications that follow the above pattern will be
+able to take advantage of one-master/many slaves solution. The
+code will be a lot easier to maintain, and adding troubleshooting
+options will be trivial. You will just need to modify one or two
+functions, for example, to log how long each query took, or which
+query, among your many thousands, gave you an error. If you have written a lot of code already,
+you may want to automate the conversion task by using Monty's
+@code{replace} utility, which comes with the standard distribution of
+MySQL, or just write your own Perl script. Hopefully, your
+code follows some recognizable pattern. If not, then you are probably
+better off re-writing it anyway, or at least going through and manually
+beating it into a pattern.
+
+Note that, of course, you can use different names for the
+functions. What is important is having unified interface for connecting
+for reads, connecting for writes, doing a read, and doing a write.
+
+
+@strong{Q}: When and how much can MySQL replication improve the performance
+of my system?
+
+@strong{A}: MySQL replication is most beneficial for a system
+with frequent reads and not so frequent writes. In theory, by using a
+one master/many slaves setup you can scale by adding more slaves until
+you either run out of network bandwidth, or your update
+load grows to the point
+that the master cannot handle it.
+
+In order to determine how many slaves you can get before the added
+benefits begin to level out, and how much you can improve performance
+of your site, you need to know your query patterns, and empirically
+ (by benchmarking) determine the relationship between the throughput
+on reads (reads per second, or @code{max_reads}) and on writes
+@code{max_writes}) on a typical master and a typical slave. The
+example below will show you a rather simplified calculation of what you
+can get with replication for our imagined system.
+
+Let's say our system load consists of 10% writes and 90% reads, and we
+have determined that @code{max_reads} = 1200 - 2 * @code{max_writes},
+or in other words, our system can do 1200 reads per second with no
+writes, our average write is twice as slow as average read,
+and the relationship is
+linear. Let us suppose that our master and slave are of the same
+capacity, and we have N slaves and 1 master. Then we have for each
+server (master or slave):
+
+@code{reads = 1200 - 2 * writes} (from bencmarks)
+
+@code{reads = 9* writes / (N + 1) } (reads split, but writes go
+to all servers)
+
+@code{9*writes/(N+1) + 2 * writes = 1200}
+
+@code{writes = 1200/(2 + 9/(N+1)}
+
+So if N = 0, which means we have no replication, our system can handle
+1200/11, about 109 writes per second (which means we will have 9 times
+as many reads due to the nature of our application).
+
+If N = 1, we can get up to 184 writes per second.
+
+If N = 8, we get up to 400.
+
+If N = 17, 480 writes.
+
+Eventually as N approaches infinity (and our budget negative infinity),
+we can get very close to 600 writes per second, increasing system
+throughput about 5.5 times. However, with only 8 servers, we increased
+it almost 4 times already.
+
+Note that our computations assumed infinite network bandwidth, and
+neglected several other factors that could turn out to be significant on
+your system. In many cases, you may not be able to make a computation
+similar to the one above that will accurately predict what will happen
+on your system if you add N replication slaves. However, answering the
+following questions should help you decided whether and how much, if at
+all, the replication will improve the performance of your system:
+
+@itemize @bullet
+@item
+What is the read/write ratio on your system?
+@item
+How much more write load can one server handle if you reduce the reads?
+@item
+How many slaves do you have bandwidth for on your network?
+@end itemize
+
+@strong{Q}: How can I use replication to provide redundancy/high
+availability?
+
+@strong{A}: With the currently available features, you would have to
+set up a master and a slave (or several slaves), and write a script
+that will monitor the
+master to see if it is up, and instruct your applications and
+the slaves of the master change in case of failure. Some suggestions:
+
+@itemize @bullet
+@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 by
+having a dynamic DNS entry for the master. With @strong{bind} you can
+use @code{nsupdate} to dynamically update your DNS.
+@item
+You should run your slaves with the @code{log-bin} option and without
+@code{log-slave-updates}. This way the slave will be ready to become a
+master as soon as you issue @code{STOP SLAVE}; @code{RESET MASTER}, and
+@code{CHANGE MASTER TO} on the other slaves. It will also help you catch
+spurious updates that may happen because of misconfiguration of the
+slave (ideally, you want to configure access rights so that no client
+can update the slave, except for the slave thread) combined with the
+bugs in your client programs (they should never update the slave
+directly).
+
+@end itemize
+
+We are currently working on integrating an automatic master election
+system into MySQL, but until it is ready, you will have to
+create your own monitoring tools.
+
+
+@node Replication Problems, , Replication FAQ, Replication
+@subsection Troubleshooting Replication
+
+If you have followed the instructions, and your replication setup is not
+working, first eliminate the user error factor by checking the following:
+
+@itemize @bullet
+@item
+Is the master logging to the binary log? Check with @code{SHOW MASTER STATUS}.
+If it is, @code{Position} will be non-zero. If not, verify that you have
+given the master @code{log-bin} option and have set @code{server-id}.
+@item
+Is the slave running? Check with @code{SHOW SLAVE STATUS}. The answer is found
+in @code{Slave_running} column. If not, verify slave options and check the
+error log for messages.
+@item
+If the slave is running, did it establish connection with the master? Do
+@code{SHOW PROCESSLIST}, find the thread with @code{system user} value in
+@code{User} column and @code{none} in the @code{Host} column, and check the
+@code{State} column. If it says @code{connecting to master}, verify the
+privileges for the replication user on the master, master host name, your
+DNS setup, whether the master is actually running, whether it is reachable
+from the slave, and if all that seems ok, read the error logs.
+@item
+If the slave was running, but then stopped, look at SHOW SLAVE STATUS
+output and check the error logs. It usually
+happens when some query that succeeded on the master fails on the slave. This
+should never happen if you have taken a proper snapshot of the master, and
+never modify the data on the slave outside of the slave thread. If it does,
+it is a bug, read below on how to report it.
+@item
+If a query on that succeeded on the master refuses to run on the slave, and
+a full database resync ( the proper thing to do ) does not seem feasible,
+try the following:
+@itemize @minus
+@item
+First see if there is some stray record in the way. Understand how it got
+there, then delete it and run @code{SLAVE START}
+@item
+If the above does not work or does not apply, try to understand if it would
+be safe to make the update manually ( if needed) and then ignore the next
+query from the master.
+@item
+If you have decided you can skip the next query, do
+@code{SET SQL_SLAVE_SKIP_COUNTER=1; SLAVE START;} to skip a query that
+does not use auto_increment, or last_insert_id or
+@code{SET SQL_SLAVE_SKIP_COUNTER=2; SLAVE START;} otherwise. The reason
+auto_increment/last_insert_id queries are different is that they take
+two events in the binary log of the master.
+
+@item
+If you are sure the slave started out perfectly in sync with the master,
+and no one has updated the tables involved outside of slave thread,
+report the bug, so
+you will not have to do the above tricks again.
+@end itemize
+@item
+Make sure you are not running into an old bug by upgrading to the most recent
+version.
+@item
+If all else fails, read the error logs. If they are big,
+@code{grep -i slave /path/to/your-log.err} on the slave. There is no
+generic pattern to search for on the master, as the only errors it logs
+are general system errors - if it can, it will send the error to the slave
+when things go wrong.
+@end itemize
+
+When you have determined that there is no user error involved, and replication
+still either does not work at all or is unstable, it is time to start working
+on a bug report. We need to get as much info as possible from you to be able
+to track down the bug. Please do spend some time and effort preparing a good
+bug report. Ideally, we would like to have a test case in the format found in
+@code{mysql-test/t/rpl*} directory of the source tree. If you submit a test
+case like that, you can expect a patch within a day or two in most cases,
+although, of course, you mileage may vary depending on a number of factors.
+
+Second best option is a just program with easily configurable connection
+arguments for the master and the slave that will demonstrate the problem on our
+systems. You can write one in Perl or in C, depending on which language you
+know better.
+
+If you have one of the above ways to demonstrate the bug, use
+@code{mysqlbug} to prepare a bug report and send it to
+@email{bugs@@lists.mysql.com}. If you have a phantom - a problem that
+does occur but you cannot duplicate "at will":
+
+@itemize @bullet
+@item
+Verify that there is no user error involved. For example, if you update the
+slave outside of the slave thread, the data will be out of sync, and you can
+have unique key violations on updates, in which case the slave thread will
+stop and wait for you to clean up the tables manually to bring them in sync.
+@item
+Run slave with @code{log-slave-updates} and @code{log-bin} - this will keep
+a log of all updates on the slave.
+@item
+Save all evidence before resetting the replication. If we have no or only
+sketchy information, it would take us a while to track down the problem. The
+evidence you should collect is:
+@itemize @minus
+@item
+All binary logs on the master
+@item
+All binary log on the slave
+@item
+The output of @code{SHOW MASTER STATUS} on the master at the time
+you have discovered the problem
+@item
+The output of @code{SHOW SLAVE STATUS} on the master at the time
+you have discovered the problem
+@item
+Error logs on the master and on the slave
+@end itemize
+@item
+Use @code{mysqlbinlog} to examine the binary logs. The following should
+be helpful
+to find the trouble query, for example:
+@example
+mysqlbinlog -j pos_from_slave_status /path/to/log_from_slave_status | head
+@end example
+@end itemize
+
+Once you have collected the evidence on the phantom problem, try hard to
+isolate it into a separate test case first. Then report the problem to
+@email{bugs@@lists.mysql.com} with as much info as possible.
+
+
+
+
+@node MySQL Optimization, Reference, MySQL Database Administration, Top
+@chapter MySQL Optimization
+
+@menu
+* Optimize Overview:: Optimization Overview
+* Query Speed:: Optimizing @code{SELECT}s and Other Queries
+* Locking Issues:: Locking Issues
+* Optimizing Database Structure:: Optimizing Database Structure
+* Optimizing the Server:: Optimizing the MySQL Server
+* Disk issues:: Disk Issues
+@end menu
+
+
+Optimization is a complicated task because it ultimately requires
+understanding of the whole system. While it may be possible to do some
+local optimizations with small knowledge of your system or application,
+the more optimal you want your system to become the more you will have
+to know about it.
+
+This chapter will try to explain and give some examples of different
+ways to optimize MySQL. Remember, however, that there are
+always some (increasingly harder) additional ways to make the system
+even faster.
+
+
+@node Optimize Overview, Query Speed, MySQL Optimization, MySQL Optimization
+@section Optimization Overview
+
+The most important part for getting a system fast is of course the basic
+design. You also need to know what kinds of things your system will be
+doing, and what your bottlenecks are.
+
+The most common bottlenecks are:
+@itemize @bullet
+@item Disk seeks.
+It takes time for the disk to find a piece of data. With modern disks in
+1999, the mean time for this is usually lower than 10ms, so we can in
+theory do about 1000 seeks a second. This time improves slowly with new
+disks and is very hard to optimize for a single table. The way to
+optimize this is to spread the data on more than one disk.
+
+@item Disk reading/writing.
+When the disk is at the correct position we need to read the data. With
+modern disks in 1999, one disk delivers something like 10-20Mb/s. This
+is easier to optimize than seeks because you can read in parallel from
+multiple disks.
+
+@item CPU cycles.
+When we have the data in main memory (or if it already were
+there) we need to process it to get to our result. Having small
+tables compared to the memory is the most common limiting
+factor. But then, with small tables speed is usually not the problem.
+
+@item Memory bandwidth.
+When the CPU needs more data than can fit in the CPU cache the main
+memory bandwidth becomes a bottleneck. This is an uncommon bottleneck
+for most systems, but one should be aware of it.
+@end itemize
+
+
+@menu
+* Design Limitations:: MySQL Design Limitations/Tradeoffs
+* Portability:: Portability
+* Internal use:: What Have We Used MySQL For?
+* MySQL Benchmarks:: The MySQL Benchmark Suite
+* Custom Benchmarks:: Using Your Own Benchmarks
+@end menu
+
+
+@node Design Limitations, Portability, Optimize Overview, Optimize Overview
+@subsection MySQL Design Limitations/Tradeoffs
+
+@cindex design, limitations
+@cindex limitations, design
+
+Because MySQL uses extremely fast table locking (multiple readers /
+single writers) the biggest remaining problem is a mix of a steady stream of
+inserts and slow selects on the same table.
+
+We believe that for a huge number of systems the extremely fast
+performance in other cases make this choice a win. This case is usually
+also possible to solve by having multiple copies of the table, but it
+takes more effort and hardware.
+
+We are also working on some extensions to solve this problem for some
+common application niches.
+
+
+@node Portability, Internal use, Design Limitations, Optimize Overview
+@subsection Portability
+
+@cindex portability
+@cindex crash-me program
+@cindex programs, crash-me
+
+Because all SQL servers implement different parts of SQL, it takes work to
+write portable SQL applications. For very simple selects/inserts it is
+very easy, but the more you need the harder it gets. If you want an
+application that is fast with many databases it becomes even harder!
+
+To make a complex application portable you need to choose a number of
+SQL servers that it should work with.
+
+You can use the MySQL crash-me program/web-page
+@uref{http://www.mysql.com/information/crash-me.php} to find functions,
+types, and limits you can use with a selection of database
+servers. Crash-me now tests far from everything possible, but it
+is still comprehensive with about 450 things tested.
+
+For example, you shouldn't have column names longer than 18 characters
+if you want to be able to use Informix or DB2.
+
+Both the MySQL benchmarks and crash-me programs are very
+database-independent. By taking a look at how we have handled this, you
+can get a feeling for what you have to do to write your application
+database-independent. The benchmarks themselves can be found in the
+@file{sql-bench} directory in the MySQL source
+distribution. They are written in Perl with DBI database interface
+(which solves the access part of the problem).
+
+See @uref{http://www.mysql.com/information/benchmarks.html} for the results
+from this benchmark.
+
+As you can see in these results, all databases have some weak points. That
+is, they have different design compromises that lead to different
+behavior.
+
+If you strive for database independence, you need to get a good feeling
+for each SQL server's bottlenecks. MySQL is VERY fast in
+retrieving and updating things, but will have a problem in mixing slow
+readers/writers on the same table. Oracle, on the other hand, has a big
+problem when you try to access rows that you have recently updated
+(until they are flushed to disk). Transaction databases in general are
+not very good at generating summary tables from log tables, as in this
+case row locking is almost useless.
+
+To get your application @emph{really} database-independent, you need to define
+an easy extendable interface through which you manipulate your data. As
+C++ is available on most systems, it makes sense to use a C++ classes
+interface to the databases.
+
+If you use some specific feature for some database (like the
+@code{REPLACE} command in MySQL), you should code a method for
+the other SQL servers to implement the same feature (but slower). With
+MySQL you can use the @code{/*! */} syntax to add
+MySQL-specific keywords to a query. The code inside
+@code{/**/} will be treated as a comment (ignored) by most other SQL
+servers.
+
+If REAL high performance is more important than exactness, as in some
+Web applications, a possibility is to create an application layer that
+caches all results to give you even higher performance. By letting
+old results 'expire' after a while, you can keep the cache reasonably
+fresh. This is quite nice in case of extremely high load, in which case
+you can dynamically increase the cache and set the expire timeout higher
+until things get back to normal.
+
+In this case the table creation information should contain information
+of the initial size of the cache and how often the table should normally
+be refreshed.
+
+
+@node Internal use, MySQL Benchmarks, Portability, Optimize Overview
+@subsection What Have We Used MySQL For?
+
+@cindex uses, of MySQL
+@cindex customers, of MySQL
+
+During MySQL initial development, the features of MySQL
+were made to fit our largest customer. They handle data warehousing for a
+couple of the biggest retailers in Sweden.
+
+From all stores, we get weekly summaries of all bonus card transactions,
+and we are expected to provide useful information for the store owners
+to help them find how their advertisement campaigns are affecting their
+customers.
+
+The data is quite huge (about 7 million summary transactions per month),
+and we have data for 4-10 years that we need to present to the users.
+We got weekly requests from the customers that they want to get
+'instant' access to new reports from this data.
+
+We solved this by storing all information per month in compressed
+'transaction' tables. We have a set of simple macros (script) that
+generates summary tables grouped by different criteria (product group,
+customer id, store ...) from the transaction tables. The reports are
+Web pages that are dynamically generated by a small Perl script that
+parses a Web page, executes the SQL statements in it, and inserts the
+results. We would have used PHP or mod_perl instead but they were
+not available at that time.
+
+For graphical data we wrote a simple tool in @code{C} that can produce
+GIFs based on the result of a SQL query (with some processing of the
+result). This is also dynamically executed from the Perl script that
+parses the @code{HTML} files.
+
+In most cases a new report can simply be done by copying an existing
+script and modifying the SQL query in it. In some cases, we will need to
+add more fields to an existing summary table or generate a new one, but
+this is also quite simple, as we keep all transactions tables on disk.
+(Currently we have at least 50G of transactions tables and 200G of other
+customer data.)
+
+We also let our customers access the summary tables directly with ODBC
+so that the advanced users can themselves experiment with the data.
+
+We haven't had any problems handling this with quite modest Sun Ultra
+SPARCstation (2x200 Mhz). We recently upgraded one of our servers to a 2
+CPU 400 Mhz UltraSPARC, and we are now planning to start handling
+transactions on the product level, which would mean a ten-fold increase
+of data. We think we can keep up with this by just adding more disk to
+our systems.
+
+We are also experimenting with Intel-Linux to be able to get more CPU
+power cheaper. Now that we have the binary portable database format (new
+in Version 3.23), we will start to use this for some parts of the application.
+
+Our initial feelings are that Linux will perform much better on
+low-to-medium load and Solaris will perform better when you start to get a
+high load because of extreme disk IO, but we don't yet have anything
+conclusive about this. After some discussion with a Linux Kernel
+developer, this might be a side effect of Linux giving so much resources
+to the batch job that the interactive performance gets very low. This
+makes the machine feel very slow and unresponsive while big batches are
+going. Hopefully this will be better handled in future Linux Kernels.
+
+
+@node MySQL Benchmarks, Custom Benchmarks, Internal use, Optimize Overview
+@subsection The MySQL Benchmark Suite
+
+@cindex benchmark suite
+@cindex crash-me program
+
+This should contain a technical description of the MySQL
+benchmark suite (and @code{crash-me}), but that description is not
+written yet. Currently, you can get a good idea of the benchmark by
+looking at the code and results in the @file{sql-bench} directory in any
+MySQL source distributions.
+
+This benchmark suite is meant to be a benchmark that will tell any user
+what things a given SQL implementation performs well or poorly at.
+
+Note that this benchmark is single threaded, so it measures the minimum
+time for the operations. We plan to in the future add a lot of
+multi-threaded tests to the benchmark suite.
+
+For example, (run on the same NT 4.0 machine):
+
+@multitable @columnfractions .6 .2 .2
+@strong{Reading 2000000 rows by index} @tab @strong{Seconds} @tab @strong{Seconds}
+@item mysql @tab 367 @tab 249
+@item mysql_odbc @tab 464
+@item db2_odbc @tab 1206
+@item informix_odbc @tab 121126
+@item ms-sql_odbc @tab 1634
+@item oracle_odbc @tab 20800
+@item solid_odbc @tab 877
+@item sybase_odbc @tab 17614
+@end multitable
+
+@multitable @columnfractions .6 .2 .2
+@strong{Inserting (350768) rows} @tab @strong{Seconds} @tab @strong{Seconds}
+@item mysql @tab 381 @tab 206
+@item mysql_odbc @tab 619
+@item db2_odbc @tab 3460
+@item informix_odbc @tab 2692
+@item ms-sql_odbc @tab 4012
+@item oracle_odbc @tab 11291
+@item solid_odbc @tab 1801
+@item sybase_odbc @tab 4802
+@end multitable
+
+In the above test MySQL was run with a 8M index cache.
+
+We have gather some more benchmark results at
+@uref{http://www.mysql.com/information/benchmarks.html}.
+
+Note that Oracle is not included because they asked to be removed. All
+Oracle benchmarks have to be passed by Oracle! We believe that makes
+Oracle benchmarks @strong{VERY} biased because the above benchmarks are
+supposed to show what a standard installation can do for a single
+client.
+
+To run the benchmark suite, you have to download a MySQL source
+distribution, install the perl DBI driver, the perl DBD driver for the
+database you want to test and then do:
+
+@example
+cd sql-bench
+perl run-all-tests --server=#
+@end example
+
+where # is one of supported servers. You can get a list of all options
+and supported servers by doing @code{run-all-tests --help}.
+
+@cindex crash-me
+@code{crash-me} tries to determine what features a database supports and
+what its capabilities and limitations are by actually running
+queries. For example, it determines:
+
+@itemize @bullet
+@item
+What column types are supported
+@item
+How many indexes are supported
+@item
+What functions are supported
+@item
+How big a query can be
+@item
+How big a @code{VARCHAR} column can be
+@end itemize
+
+We can find the result from crash-me on a lot of different databases at
+@uref{http://www.mysql.com/information/crash-me.php}.
+
+
+@node Custom Benchmarks, , MySQL Benchmarks, Optimize Overview
+@subsection Using Your Own Benchmarks
+
+@cindex benchmarks
+@cindex performance, benchmarks
+
+You should definitely benchmark your application and database to find
+out where the bottlenecks are. By fixing it (or by replacing the
+bottleneck with a 'dummy module') you can then easily identify the next
+bottleneck (and so on). Even if the overall performance for your
+application is sufficient, you should at least make a plan for each
+bottleneck, and decide how to solve it if someday you really need the
+extra performance.
+
+For an example of portable benchmark programs, look at the MySQL
+benchmark suite. @xref{MySQL Benchmarks, , MySQL Benchmarks}. You
+can take any program from this suite and modify it for your needs. By doing
+this, you can try different solutions to your problem and test which is really
+the fastest solution for you.
+
+It is very common that some problems only occur when the system is very
+heavily loaded. We have had many customers who contact us when they
+have a (tested) system in production and have encountered load problems. In
+every one of these cases so far, it has been problems with basic design
+(table scans are NOT good at high load) or OS/Library issues. Most of
+this would be a @strong{LOT} easier to fix if the systems were not
+already in production.
+
+To avoid problems like this, you should put some effort into benchmarking
+your whole application under the worst possible load! You can use
+Super Smack for this, and it is available at:
+@uref{http://www.mysql.com/Downloads/super-smack/super-smack-1.0.tar.gz}.
+As the name suggests, it can bring your system down to its knees if you ask it,
+so make sure to use it only on your development systems.
+
+
+@node Query Speed, Locking Issues, Optimize Overview, MySQL Optimization
+@section Optimizing @code{SELECT}s and Other Queries
+
+@cindex queries, speed of
+@cindex permission checks, effect on speed
+@cindex speed, of queries
+
+First, one thing that affects all queries: The more complex permission
+system setup you have, the more overhead you get.
+
+If you do not have any @code{GRANT} statements done, MySQL will
+optimize the permission checking somewhat. So if you have a very high
+volume it may be worth the time to avoid grants. Otherwise more
+permission check results in a larger overhead.
+
+If your problem is with some explicit MySQL function, you can
+always time this in the MySQL client:
+
+@example
+mysql> select benchmark(1000000,1+1);
++------------------------+
+| benchmark(1000000,1+1) |
++------------------------+
+| 0 |
++------------------------+
+1 row in set (0.32 sec)
+@end example
+
+The above shows that MySQL can execute 1,000,000 @code{+}
+expressions in 0.32 seconds on a @code{PentiumII 400MHz}.
+
+All MySQL functions should be very optimized, but there may be
+some exceptions, and the @code{benchmark(loop_count,expression)} is a
+great tool to find out if this is a problem with your query.
+
+@menu
+* EXPLAIN:: @code{EXPLAIN} Syntax (Get Information About a @code{SELECT})
+* Estimating performance:: Estimating query performance
+* SELECT speed:: Speed of @code{SELECT} queries
+* Where optimizations:: How MySQL optimizes @code{WHERE} clauses
+* DISTINCT optimization:: How MySQL Optimizes @code{DISTINCT}
+* LEFT JOIN optimization:: How MySQL optimizes @code{LEFT JOIN}
+* LIMIT optimization:: How MySQL optimizes @code{LIMIT}
+* Insert speed:: Speed of @code{INSERT} queries
+* Update speed:: Speed of @code{UPDATE} queries
+* Delete speed:: Speed of @code{DELETE} queries
+* Tips:: Other Optimization Tips
+@end menu
+
+
+@node EXPLAIN, Estimating performance, Query Speed, Query Speed
+@subsection @code{EXPLAIN} Syntax (Get Information About a @code{SELECT})
+
+@findex EXPLAIN
+@findex SELECT, optimizing
+
+@example
+ EXPLAIN tbl_name
+or EXPLAIN SELECT select_options
+@end example
+
+@code{EXPLAIN tbl_name} is a synonym for @code{DESCRIBE tbl_name} or
+@code{SHOW COLUMNS FROM tbl_name}.
+
+When you precede a @code{SELECT} statement with the keyword @code{EXPLAIN},
+MySQL explains how it would process the @code{SELECT}, providing
+information about how tables are joined and in which order.
+
+With the help of @code{EXPLAIN}, you can see when you must add indexes
+to tables to get a faster @code{SELECT} that uses indexes to find the
+records. You can also see if the optimizer joins the tables in an optimal
+order. To force the optimizer to use a specific join order for a
+@code{SELECT} statement, add a @code{STRAIGHT_JOIN} clause.
+
+For non-simple joins, @code{EXPLAIN} returns a row of information for each
+table used in the @code{SELECT} statement. The tables are listed in the order
+they would be read. MySQL resolves all joins using a single-sweep
+multi-join method. This means that MySQL reads a row from the first
+table, then finds a matching row in the second table, then in the third table
+and so on. When all tables are processed, it outputs the selected columns and
+backtracks through the table list until a table is found for which there are
+more matching rows. The next row is read from this table and the process
+continues with the next table.
+
+Output from @code{EXPLAIN} includes the following columns:
+
+@table @code
+@item table
+The table to which the row of output refers.
+
+@item type
+The join type. Information about the various types is given below.
+
+@item possible_keys
+The @code{possible_keys} column indicates which indexes MySQL
+could use to find the rows in this table. Note that this column is
+totally independent of the order of the tables. That means that some of
+the keys in possible_keys may not be usable in practice with the
+generated table order.
+
+If this column is empty, there are no relevant indexes. In this case,
+you may be able to improve the performance of your query by examining
+the @code{WHERE} clause to see if it refers to some column or columns
+that would be suitable for indexing. If so, create an appropriate index
+and check the query with @code{EXPLAIN} again. @xref{ALTER TABLE}.
+
+To see what indexes a table has, use @code{SHOW INDEX FROM tbl_name}.
+
+@item key
+The @code{key} column indicates the key that MySQL actually
+decided to use. The key is @code{NULL} if no index was chosen. If
+MySQL chooses the wrong index, you can probably force
+MySQL to use another index by using @code{myisamchk --analyze},
+@xref{myisamchk syntax}, or by using @code{USE INDEX/IGNORE INDEX}.
+@xref{JOIN}.
+
+@item key_len
+The @code{key_len} column indicates the length of the key that
+MySQL decided to use. The length is @code{NULL} if the
+@code{key} is @code{NULL}. Note that this tells us how many parts of a
+multi-part key MySQL will actually use.
+
+@item ref
+The @code{ref} column shows which columns or constants are used with the
+@code{key} to select rows from the table.
+
+@item rows
+The @code{rows} column indicates the number of rows MySQL
+believes it must examine to execute the query.
+
+@item Extra
+This column contains additional information of how MySQL will
+resolve the query. Here is an explanation of the different text
+strings that can be found in this column:
+
+@table @code
+@item Distinct
+MySQL will not continue searching for more rows for the current row
+combination after it has found the first matching row.
+
+@item Not exists
+MySQL was able to do a @code{LEFT JOIN} optimization on the
+query and will not examine more rows in this table for the previous row
+combination after it finds one row that matches the @code{LEFT JOIN} criteria.
+
+Here is an example for this:
+
+@example
+SELECT * FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.id IS NULL;
+@end example
+
+Assume that @code{t2.id} is defined with @code{NOT NULL}. In this case
+MySQL will scan @code{t1} and look up the rows in @code{t2}
+through @code{t1.id}. If MySQL finds a matching row in
+@code{t2}, it knows that @code{t2.id} can never be @code{NULL}, and will
+not scan through the rest of the rows in @code{t2} that has the same
+@code{id}. In other words, for each row in @code{t1}, MySQL
+only needs to do a single lookup in @code{t2}, independent of how many
+matching rows there are in @code{t2}.
+
+@item @code{range checked for each record (index map: #)}
+MySQL didn't find a real good index to use. It will, instead, for
+each row combination in the preceding tables, do a check on which index to
+use (if any), and use this index to retrieve the rows from the table. This
+isn't very fast but is faster than having to do a join without
+an index.
+
+@item Using filesort
+MySQL will need to do an extra pass to find out how to retrieve
+the rows in sorted order. The sort is done by going through all rows
+according to the @code{join type} and storing the sort key + pointer to
+the row for all rows that match the @code{WHERE}. Then the keys are
+sorted. Finally the rows are retrieved in sorted order.
+
+@item Using index
+The column information is retrieved from the table using only
+information in the index tree without having to do an additional seek to
+read the actual row. This can be done when all the used columns for
+the table are part of the same index.
+
+@item Using temporary
+To resolve the query MySQL will need to create a
+temporary table to hold the result. This typically happens if you do an
+@code{ORDER BY} on a different column set than you did a @code{GROUP
+BY} on.
+
+@item Where used
+A @code{WHERE} clause will be used to restrict which rows will be
+matched against the next table or sent to the client. If you don't have
+this information and the table is of type @code{ALL} or @code{index},
+you may have something wrong in your query (if you don't intend to
+fetch/examine all rows from the table).
+@end table
+
+If you want to get your queries as fast as possible, you should look out for
+@code{Using filesort} and @code{Using temporary}.
+@end table
+
+The different join types are listed below, ordered from best to worst type:
+
+@cindex system table
+@cindex tables, system
+@table @code
+@item system
+The table has only one row (= system table). This is a special case of
+the @code{const} join type.
+
+@cindex constant table
+@cindex tables, constant
+@item const
+The table has at most one matching row, which will be read at the start
+of the query. Because there is only one row, values from the column in
+this row can be regarded as constants by the rest of the
+optimizer. @code{const} tables are very fast as they are read only once!
+
+@item eq_ref
+One row will be read from this table for each combination of rows from
+the previous tables. This is the best possible join type, other than the
+@code{const} types. It is used when all parts of an index are used by
+the join and the index is @code{UNIQUE} or a @code{PRIMARY KEY}.
+
+@item ref
+All rows with matching index values will be read from this table for each
+combination of rows from the previous tables. @code{ref} is used if the join
+uses only a leftmost prefix of the key, or if the key is not @code{UNIQUE}
+or a @code{PRIMARY KEY} (in other words, if the join cannot select a single
+row based on the key value). If the key that is used matches only a few rows,
+this join type is good.
+
+@item range
+Only rows that are in a given range will be retrieved, using an index to
+select the rows. The @code{key} column indicates which index is used.
+The @code{key_len} contains the longest key part that was used.
+The @code{ref} column will be NULL for this type.
+
+@item index
+This is the same as @code{ALL}, except that only the index tree is
+scanned. This is usually faster than @code{ALL}, as the index file is usually
+smaller than the data file.
+
+@item ALL
+A full table scan will be done for each combination of rows from the
+previous tables. This is normally not good if the table is the first
+table not marked @code{const}, and usually @strong{very} bad in all other
+cases. You normally can avoid @code{ALL} by adding more indexes, so that
+the row can be retrieved based on constant values or column values from
+earlier tables.
+@end table
+
+You can get a good indication of how good a join is by multiplying all values
+in the @code{rows} column of the @code{EXPLAIN} output. This should tell you
+roughly how many rows MySQL must examine to execute the query. This
+number is also used when you restrict queries with the @code{max_join_size}
+variable.
+@xref{Server parameters}.
+
+The following example shows how a @code{JOIN} can be optimized progressively
+using the information provided by @code{EXPLAIN}.
+
+Suppose you have the @code{SELECT} statement shown below, that you examine
+using @code{EXPLAIN}:
+
+@example
+EXPLAIN SELECT tt.TicketNumber, tt.TimeIn,
+ tt.ProjectReference, tt.EstimatedShipDate,
+ tt.ActualShipDate, tt.ClientID,
+ tt.ServiceCodes, tt.RepetitiveID,
+ tt.CurrentProcess, tt.CurrentDPPerson,
+ tt.RecordVolume, tt.DPPrinted, et.COUNTRY,
+ et_1.COUNTRY, do.CUSTNAME
+ FROM tt, et, et AS et_1, do
+ WHERE tt.SubmitTime IS NULL
+ AND tt.ActualPC = et.EMPLOYID
+ AND tt.AssignedPC = et_1.EMPLOYID
+ AND tt.ClientID = do.CUSTNMBR;
+@end example
+
+For this example, assume that:
+
+@itemize @bullet
+@item
+The columns being compared have been declared as follows:
+
+@multitable @columnfractions .1 .2 .7
+@item @strong{Table} @tab @strong{Column} @tab @strong{Column type}
+@item @code{tt} @tab @code{ActualPC} @tab @code{CHAR(10)}
+@item @code{tt} @tab @code{AssignedPC} @tab @code{CHAR(10)}
+@item @code{tt} @tab @code{ClientID} @tab @code{CHAR(10)}
+@item @code{et} @tab @code{EMPLOYID} @tab @code{CHAR(15)}
+@item @code{do} @tab @code{CUSTNMBR} @tab @code{CHAR(15)}
+@end multitable
+
+@item
+The tables have the indexes shown below:
+
+@multitable @columnfractions .1 .9
+@item @strong{Table} @tab @strong{Index}
+@item @code{tt} @tab @code{ActualPC}
+@item @code{tt} @tab @code{AssignedPC}
+@item @code{tt} @tab @code{ClientID}
+@item @code{et} @tab @code{EMPLOYID} (primary key)
+@item @code{do} @tab @code{CUSTNMBR} (primary key)
+@end multitable
+
+@item
+The @code{tt.ActualPC} values aren't evenly distributed.
+@end itemize
+
+Initially, before any optimizations have been performed, the @code{EXPLAIN}
+statement produces the following information:
+
+@example
+table type possible_keys key key_len ref rows Extra
+et ALL PRIMARY NULL NULL NULL 74
+do ALL PRIMARY NULL NULL NULL 2135
+et_1 ALL PRIMARY NULL NULL NULL 74
+tt ALL AssignedPC,ClientID,ActualPC NULL NULL NULL 3872
+ range checked for each record (key map: 35)
+@end example
+
+Because @code{type} is @code{ALL} for each table, this output indicates that
+MySQL is doing a full join for all tables! This will take quite a
+long time, as the product of the number of rows in each table must be
+examined! For the case at hand, this is @code{74 * 2135 * 74 * 3872 =
+45,268,558,720} rows. If the tables were bigger, you can only imagine how
+long it would take.
+
+One problem here is that MySQL can't (yet) use indexes on columns
+efficiently if they are declared differently. In this context,
+@code{VARCHAR} and @code{CHAR} are the same unless they are declared as
+different lengths. Because @code{tt.ActualPC} is declared as @code{CHAR(10)}
+and @code{et.EMPLOYID} is declared as @code{CHAR(15)}, there is a length
+mismatch.
+
+To fix this disparity between column lengths, use @code{ALTER TABLE} to
+lengthen @code{ActualPC} from 10 characters to 15 characters:
+
+@example
+mysql> ALTER TABLE tt MODIFY ActualPC VARCHAR(15);
+@end example
+
+Now @code{tt.ActualPC} and @code{et.EMPLOYID} are both @code{VARCHAR(15)}.
+Executing the @code{EXPLAIN} statement again produces this result:
+
+@example
+table type possible_keys key key_len ref rows Extra
+tt ALL AssignedPC,ClientID,ActualPC NULL NULL NULL 3872 where used
+do ALL PRIMARY NULL NULL NULL 2135
+ range checked for each record (key map: 1)
+et_1 ALL PRIMARY NULL NULL NULL 74
+ range checked for each record (key map: 1)
+et eq_ref PRIMARY PRIMARY 15 tt.ActualPC 1
+@end example
+
+This is not perfect, but is much better (the product of the @code{rows}
+values is now less by a factor of 74). This version is executed in a couple
+of seconds.
+
+A second alteration can be made to eliminate the column length mismatches
+for the @code{tt.AssignedPC = et_1.EMPLOYID} and @code{tt.ClientID =
+do.CUSTNMBR} comparisons:
+
+@example
+mysql> ALTER TABLE tt MODIFY AssignedPC VARCHAR(15),
+ MODIFY ClientID VARCHAR(15);
+@end example
+
+Now @code{EXPLAIN} produces the output shown below:
+
+@example
+table type possible_keys key key_len ref rows Extra
+et ALL PRIMARY NULL NULL NULL 74
+tt ref AssignedPC,ClientID,ActualPC ActualPC 15 et.EMPLOYID 52 where used
+et_1 eq_ref PRIMARY PRIMARY 15 tt.AssignedPC 1
+do eq_ref PRIMARY PRIMARY 15 tt.ClientID 1
+@end example
+
+This is almost as good as it can get.
+
+The remaining problem is that, by default, MySQL assumes that values
+in the @code{tt.ActualPC} column are evenly distributed, and that isn't the
+case for the @code{tt} table. Fortunately, it is easy to tell MySQL
+about this:
+
+@example
+shell> myisamchk --analyze PATH_TO_MYSQL_DATABASE/tt
+shell> mysqladmin refresh
+@end example
+
+Now the join is perfect, and @code{EXPLAIN} produces this result:
+
+@example
+table type possible_keys key key_len ref rows Extra
+tt ALL AssignedPC,ClientID,ActualPC NULL NULL NULL 3872 where used
+et eq_ref PRIMARY PRIMARY 15 tt.ActualPC 1
+et_1 eq_ref PRIMARY PRIMARY 15 tt.AssignedPC 1
+do eq_ref PRIMARY PRIMARY 15 tt.ClientID 1
+@end example
+
+Note that the @code{rows} column in the output from @code{EXPLAIN} is an
+educated guess from the MySQL join optimizer. To optimize a
+query, you should check if the numbers are even close to the truth. If not,
+you may get better performance by using @code{STRAIGHT_JOIN} in your
+@code{SELECT} statement and trying to list the tables in a different order in
+the @code{FROM} clause.
+
+
+@node Estimating performance, SELECT speed, EXPLAIN, Query Speed
+@subsection Estimating Query Performance
+
+@cindex estimating, query performance
+@cindex queries, estimating performance
+@cindex performance, estimating
+
+In most cases you can estimate the performance by counting disk seeks.
+For small tables, you can usually find the row in 1 disk seek (as the
+index is probably cached). For bigger tables, you can estimate that
+(using B++ tree indexes) you will need: @code{log(row_count) /
+log(index_block_length / 3 * 2 / (index_length + data_pointer_length)) +
+1} seeks to find a row.
+
+In MySQL an index block is usually 1024 bytes and the data
+pointer is usually 4 bytes. A 500,000 row table with an
+index length of 3 (medium integer) gives you:
+@code{log(500,000)/log(1024/3*2/(3+4)) + 1} = 4 seeks.
+
+As the above index would require about 500,000 * 7 * 3/2 = 5.2M,
+(assuming that the index buffers are filled to 2/3, which is typical)
+you will probably have much of the index in memory and you will probably
+only need 1-2 calls to read data from the OS to find the row.
+
+For writes, however, you will need 4 seek requests (as above) to find
+where to place the new index and normally 2 seeks to update the index
+and write the row.
+
+Note that the above doesn't mean that your application will slowly
+degenerate by N log N! As long as everything is cached by the OS or SQL
+server things will only go marginally slower while the table gets
+bigger. After the data gets too big to be cached, things will start to
+go much slower until your applications is only bound by disk-seeks
+(which increase by N log N). To avoid this, increase the index cache as
+the data grows. @xref{Server parameters}.
+
+
+@node SELECT speed, Where optimizations, Estimating performance, Query Speed
+@subsection Speed of @code{SELECT} Queries
+
+@findex SELECT speed
+
+@cindex speed, of queries
+
+In general, when you want to make a slow @code{SELECT ... WHERE} faster, the
+first thing to check is whether or not you can add an index. @xref{MySQL
+indexes, , MySQL indexes}. All references between different tables
+should usually be done with indexes. You can use the @code{EXPLAIN} command
+to determine which indexes are used for a @code{SELECT}.
+@xref{EXPLAIN, , @code{EXPLAIN}}.
+
+Some general tips:
+
+@itemize @bullet
+@item
+To help MySQL optimize queries better, run @code{myisamchk
+--analyze} on a table after it has been loaded with relevant data. This
+updates a value for each index part that indicates the average number of
+rows that have the same value. (For unique indexes, this is always 1,
+of course.). MySQL will use this to decide which index to
+choose when you connect two tables with 'a non-constant expression'.
+You can check the result from the @code{analyze} run by doing @code{SHOW
+INDEX FROM table_name} and examining the @code{Cardinality} column.
+
+@item
+To sort an index and data according to an index, use @code{myisamchk
+--sort-index --sort-records=1} (if you want to sort on index 1). If you
+have a unique index from which you want to read all records in order
+according to that index, this is a good way to make that faster. Note,
+however, that this sorting isn't written optimally and will take a long
+time for a large table!
+@end itemize
+
+
+@node Where optimizations, DISTINCT optimization, SELECT speed, Query Speed
+@subsection How MySQL Optimizes @code{WHERE} Clauses
+
+@findex WHERE
+
+@cindex optimizations
+
+The @code{WHERE} optimizations are put in the @code{SELECT} part here because
+they are mostly used with @code{SELECT}, but the same optimizations apply for
+@code{WHERE} in @code{DELETE} and @code{UPDATE} statements.
+
+Also note that this section is incomplete. MySQL does many
+optimizations, and we have not had time to document them all.
+
+Some of the optimizations performed by MySQL are listed below:
+
+@itemize @bullet
+@item
+Removal of unnecessary parentheses:
+@example
+ ((a AND b) AND c OR (((a AND b) AND (c AND d))))
+-> (a AND b AND c) OR (a AND b AND c AND d)
+@end example
+@item
+Constant folding:
+@example
+ (a<b AND b=c) AND a=5
+-> b>5 AND b=c AND a=5
+@end example
+@item
+Constant condition removal (needed because of constant folding):
+@example
+ (B>=5 AND B=5) OR (B=6 AND 5=5) OR (B=7 AND 5=6)
+-> B=5 OR B=6
+@end example
+@item
+Constant expressions used by indexes are evaluated only once.
+@item
+@code{COUNT(*)} on a single table without a @code{WHERE} is retrieved
+directly from the table information. This is also done for any @code{NOT NULL}
+expression when used with only one table.
+@item
+Early detection of invalid constant expressions. MySQL quickly
+detects that some @code{SELECT} statements are impossible and returns no rows.
+@item
+@code{HAVING} is merged with @code{WHERE} if you don't use @code{GROUP BY}
+or group functions (@code{COUNT()}, @code{MIN()}...).
+@item
+For each sub-join, a simpler @code{WHERE} is constructed to get a fast
+@code{WHERE} evaluation for each sub-join and also to skip records as
+soon as possible.
+@cindex constant table
+@cindex tables, constant
+@item
+All constant tables are read first, before any other tables in the query.
+A constant table is:
+@itemize @minus
+@item
+An empty table or a table with 1 row.
+@item
+A table that is used with a @code{WHERE} clause on a @code{UNIQUE}
+index, or a @code{PRIMARY KEY}, where all index parts are used with constant
+expressions and the index parts are defined as @code{NOT NULL}.
+@end itemize
+All the following tables are used as constant tables:
+@example
+mysql> SELECT * FROM t WHERE primary_key=1;
+mysql> SELECT * FROM t1,t2
+ WHERE t1.primary_key=1 AND t2.primary_key=t1.id;
+@end example
+
+@item
+The best join combination to join the tables is found by trying all
+possibilities. If all columns in @code{ORDER BY} and in @code{GROUP
+BY} come from the same table, then this table is preferred first when
+joining.
+@item
+If there is an @code{ORDER BY} clause and a different @code{GROUP BY}
+clause, or if the @code{ORDER BY} or @code{GROUP BY} contains columns
+from tables other than the first table in the join queue, a temporary
+table is created.
+@item
+If you use @code{SQL_SMALL_RESULT}, MySQL will use an in-memory
+temporary table.
+@item
+Each table index is queried, and the best index that spans fewer than 30% of
+the rows is used. If no such index can be found, a quick table scan is used.
+@item
+In some cases, MySQL can read rows from the index without even
+consulting the data file. If all columns used from the index are numeric,
+then only the index tree is used to resolve the query.
+@item
+Before each record is output, those that do not match the @code{HAVING} clause
+are skipped.
+@end itemize
+
+Some examples of queries that are very fast:
+
+@example
+mysql> SELECT COUNT(*) FROM tbl_name;
+mysql> SELECT MIN(key_part1),MAX(key_part1) FROM tbl_name;
+mysql> SELECT MAX(key_part2) FROM tbl_name
+ WHERE key_part_1=constant;
+mysql> SELECT ... FROM tbl_name
+ ORDER BY key_part1,key_part2,... LIMIT 10;
+mysql> SELECT ... FROM tbl_name
+ ORDER BY key_part1 DESC,key_part2 DESC,... LIMIT 10;
+@end example
+
+The following queries are resolved using only the index tree (assuming
+the indexed columns are numeric):
+
+@example
+mysql> SELECT key_part1,key_part2 FROM tbl_name WHERE key_part1=val;
+mysql> SELECT COUNT(*) FROM tbl_name
+ WHERE key_part1=val1 AND key_part2=val2;
+mysql> SELECT key_part2 FROM tbl_name GROUP BY key_part1;
+@end example
+
+The following queries use indexing to retrieve the rows in sorted
+order without a separate sorting pass:
+
+@example
+mysql> SELECT ... FROM tbl_name ORDER BY key_part1,key_part2,... ;
+mysql> SELECT ... FROM tbl_name ORDER BY key_part1 DESC,key_part2 DESC,... ;
+@end example
+
+
+@node DISTINCT optimization, LEFT JOIN optimization, Where optimizations, Query Speed
+@subsection How MySQL Optimizes @code{DISTINCT}
+
+@findex DISTINCT
+
+@cindex optimizing, DISTINCT
+
+@code{DISTINCT} is converted to a @code{GROUP BY} on all columns,
+@code{DISTINCT} combined with @code{ORDER BY} will in many cases also
+need a temporary table.
+
+When combining @code{LIMIT #} with @code{DISTINCT}, MySQL will stop
+as soon as it finds @code{#} unique rows.
+
+If you don't use columns from all used tables, MySQL will stop
+the scanning of the not used tables as soon as it has found the first match.
+
+@example
+SELECT DISTINCT t1.a FROM t1,t2 where t1.a=t2.a;
+@end example
+
+In the case, assuming t1 is used before t2 (check with @code{EXPLAIN}), then
+MySQL will stop reading from t2 (for that particular row in t1)
+when the first row in t2 is found.
+
+
+@node LEFT JOIN optimization, LIMIT optimization, DISTINCT optimization, Query Speed
+@subsection How MySQL Optimizes @code{LEFT JOIN} and @code{RIGHT JOIN}
+
+@findex LEFT JOIN
+
+@cindex optimizing, LEFT JOIN
+
+@code{A LEFT JOIN B} in MySQL is implemented as follows:
+
+@itemize @bullet
+@item
+The table @code{B} is set to be dependent on table @code{A} and all tables
+that @code{A} is dependent on.
+
+@item
+The table @code{A} is set to be dependent on all tables (except @code{B})
+that are used in the @code{LEFT JOIN} condition.
+
+@item
+All @code{LEFT JOIN} conditions are moved to the @code{WHERE} clause.
+
+@item
+All standard join optimizations are done, with the exception that a table is
+always read after all tables it is dependent on. If there is a circular
+dependence then MySQL will issue an error.
+
+@item
+All standard @code{WHERE} optimizations are done.
+
+@item
+If there is a row in @code{A} that matches the @code{WHERE} clause, but there
+wasn't any row in @code{B} that matched the @code{LEFT JOIN} condition,
+then an extra @code{B} row is generated with all columns set to @code{NULL}.
+
+@item
+If you use @code{LEFT JOIN} to find rows that don't exist in some
+table and you have the following test: @code{column_name IS NULL} in the
+@code{WHERE} part, where column_name is a column that is declared as
+@code{NOT NULL}, then MySQL will stop searching after more rows
+(for a particular key combination) after it has found one row that
+matches the @code{LEFT JOIN} condition.
+@end itemize
+
+@code{RIGHT JOIN} is implemented analogously as @code{LEFT JOIN}.
+
+The table read order forced by @code{LEFT JOIN} and @code{STRAIGHT JOIN}
+will help the join optimizer (which calculates in which order tables
+should be joined) to do its work much more quickly, as there are fewer
+table permutations to check.
+
+Note that the above means that if you do a query of type:
+
+@example
+SELECT * FROM a,b LEFT JOIN c ON (c.key=a.key) LEFT JOIN d (d.key=a.key) WHERE b.key=d.key
+@end example
+
+MySQL will do a full scan on @code{b} as the @code{LEFT JOIN} will force
+it to be read before @code{d}.
+
+The fix in this case is to change the query to:
+
+@example
+SELECT * FROM b,a LEFT JOIN c ON (c.key=a.key) LEFT JOIN d (d.key=a.key) WHERE b.key=d.key
+@end example
+
+
+@node LIMIT optimization, Insert speed, LEFT JOIN optimization, Query Speed
+@subsection How MySQL Optimizes @code{LIMIT}
+
+@findex LIMIT
+
+@cindex optimizing, LIMIT
+
+In some cases MySQL will handle the query differently when you are
+using @code{LIMIT #} and not using @code{HAVING}:
+
+@itemize @bullet
+@item
+If you are selecting only a few rows with @code{LIMIT}, MySQL
+will use indexes in some cases when it normally would prefer to do a
+full table scan.
+@item
+If you use @code{LIMIT #} with @code{ORDER BY}, MySQL will end the
+sorting as soon as it has found the first @code{#} lines instead of sorting
+the whole table.
+@item
+When combining @code{LIMIT #} with @code{DISTINCT}, MySQL will stop
+as soon as it finds @code{#} unique rows.
+@item
+In some cases a @code{GROUP BY} can be resolved by reading the key in order
+(or do a sort on the key) and then calculate summaries until the
+key value changes. In this case @code{LIMIT #} will not calculate any
+unnecessary @code{GROUP BY}'s.
+@item
+As soon as MySQL has sent the first @code{#} rows to the client, it
+will abort the query.
+@item
+@code{LIMIT 0} will always quickly return an empty set. This is useful
+to check the query and to get the column types of the result columns.
+@item
+The size of temporary tables uses the @code{LIMIT #} to calculate how much
+space is needed to resolve the query.
+@end itemize
+
+
+@node Insert speed, Update speed, LIMIT optimization, Query Speed
+@subsection Speed of @code{INSERT} Queries
+
+@findex INSERT
+
+@cindex speed, inserting
+@cindex inserting, speed of
+
+The time to insert a record consists approximately of:
+
+@itemize @bullet
+@item
+Connect: (3)
+@item
+Sending query to server: (2)
+@item
+Parsing query: (2)
+@item
+Inserting record: (1 x size of record)
+@item
+Inserting indexes: (1 x number of indexes)
+@item
+Close: (1)
+@end itemize
+
+where the numbers are somewhat proportional to the overall time. This
+does not take into consideration the initial overhead to open tables
+(which is done once for each concurrently running query).
+
+The size of the table slows down the insertion of indexes by N log N
+(B-trees).
+
+Some ways to speed up inserts:
+
+@itemize @bullet
+@item
+If you are inserting many rows from the same client at the same time, use
+multiple value lists @code{INSERT} statements. This is much faster (many
+times in some cases) than using separate @code{INSERT} statements.
+@item
+If you are inserting a lot of rows from different clients, you can get
+higher speed by using the @code{INSERT DELAYED} statement. @xref{INSERT,
+, @code{INSERT}}.
+@item
+Note that with @code{MyISAM} you can insert rows at the same time
+@code{SELECT}s are running if there are no deleted rows in the tables.
+@item
+When loading a table from a text file, use @code{LOAD DATA INFILE}. This
+is usually 20 times faster than using a lot of @code{INSERT} statements.
+@xref{LOAD DATA, , @code{LOAD DATA}}.
+@item
+It is possible with some extra work to make @code{LOAD DATA INFILE} run even
+faster when the table has many indexes. Use the following procedure:
+
+@enumerate
+@item
+Optionally create the table with @code{CREATE TABLE}. For example, using
+@code{mysql} or Perl-DBI.
+
+@item
+Execute a @code{FLUSH TABLES} statement or the shell command @code{mysqladmin
+flush-tables}.
+
+@item
+Use @code{myisamchk --keys-used=0 -rq /path/to/db/tbl_name}. This will
+remove all usage of all indexes from the table.
+
+@item
+Insert data into the table with @code{LOAD DATA INFILE}. This will not
+update any indexes and will therefore be very fast.
+
+@item
+If you are going to only read the table in the future, run @code{myisampack}
+on it to make it smaller. @xref{Compressed format}.
+
+@item
+Re-create the indexes with @code{myisamchk -r -q
+/path/to/db/tbl_name}. This will create the index tree in memory before
+writing it to disk, which is much faster because it avoids lots of disk
+seeks. The resulting index tree is also perfectly balanced.
+
+@item
+Execute a @code{FLUSH TABLES} statement or the shell command @code{mysqladmin
+flush-tables}.
+@end enumerate
+
+This procedure will be built into @code{LOAD DATA INFILE} in some future
+version of MySQL.
+@item
+You can speed up insertions by locking your tables:
+
+@example
+mysql> LOCK TABLES a WRITE;
+mysql> INSERT INTO a VALUES (1,23),(2,34),(4,33);
+mysql> INSERT INTO a VALUES (8,26),(6,29);
+mysql> UNLOCK TABLES;
+@end example
+
+The main speed difference is that the index buffer is flushed to disk only
+once, after all @code{INSERT} statements have completed. Normally there would
+be as many index buffer flushes as there are different @code{INSERT}
+statements. Locking is not needed if you can insert all rows with a single
+statement.
+
+Locking will also lower the total time of multi-connection tests, but the
+maximum wait time for some threads will go up (because they wait for
+locks). For example:
+
+@example
+thread 1 does 1000 inserts
+thread 2, 3, and 4 does 1 insert
+thread 5 does 1000 inserts
+@end example
+
+If you don't use locking, 2, 3, and 4 will finish before 1 and 5. If you
+use locking, 2, 3, and 4 probably will not finish before 1 or 5, but the
+total time should be about 40% faster.
+
+As @code{INSERT}, @code{UPDATE}, and @code{DELETE} operations are very
+fast in MySQL, you will obtain better overall performance by
+adding locks around everything that does more than about 5 inserts or
+updates in a row. If you do very many inserts in a row, you could do a
+@code{LOCK TABLES} followed by an @code{UNLOCK TABLES} once in a while
+(about each 1000 rows) to allow other threads access to the table. This
+would still result in a nice performance gain.
+
+Of course, @code{LOAD DATA INFILE} is much faster for loading data.
+@end itemize
+
+To get some more speed for both @code{LOAD DATA INFILE} and
+@code{INSERT}, enlarge the key buffer. @xref{Server parameters}.
+
+
+@node Update speed, Delete speed, Insert speed, Query Speed
+@subsection Speed of @code{UPDATE} Queries
+
+Update queries are optimized as a @code{SELECT} query with the additional
+overhead of a write. The speed of the write is dependent on the size of
+the data that is being updated and the number of indexes that are
+updated. Indexes that are not changed will not be updated.
+
+Also, another way to get fast updates is to delay updates and then do
+many updates in a row later. Doing many updates in a row is much quicker
+than doing one at a time if you lock the table.
+
+Note that, with dynamic record format, updating a record to
+a longer total length may split the record. So if you do this often,
+it is very important to @code{OPTIMIZE TABLE} sometimes.
+@xref{OPTIMIZE TABLE, , @code{OPTIMIZE TABLE}}.
+
+
+@node Delete speed, Tips, Update speed, Query Speed
+@subsection Speed of @code{DELETE} Queries
+
+If you want to delete all rows in the table, you should use
+@code{TRUNCATE TABLE table_name}. @xref{TRUNCATE}.
+
+The time to delete a record is exactly proportional to the number of
+indexes. To delete records more quickly, you can increase the size of
+the index cache. @xref{Server parameters}.
+
+
+@node Tips, , Delete speed, Query Speed
+@subsection Other Optimization Tips
+
+@cindex optimization, tips
+@cindex tips, optimization
+
+Unsorted tips for faster systems:
+
+@itemize @bullet
+@item
+Use persistent connections to the database to avoid the connection
+overhead. If you can't use persistent connections and you are doing a
+lot of new connections to the database, you may want to change the value
+of the @code{thread_cache_size} variable. @xref{Server parameters}.
+@item
+Always check that all your queries really use the indexes you have created
+in the tables. In MySQL you can do this with the @code{EXPLAIN}
+command. @xref{EXPLAIN, Explain, Explain, manual}.
+@item
+Try to avoid complex @code{SELECT} queries on tables that are updated a
+lot. This is to avoid problems with table locking.
+@item
+The new @code{MyISAM} tables can insert rows in a table without deleted
+rows at the same time another table is reading from it. If this is important
+for you, you should consider methods where you don't have to delete rows
+or run @code{OPTIMIZE TABLE} after you have deleted a lot of rows.
+@item
+Use @code{ALTER TABLE ... ORDER BY expr1,expr2...} if you mostly
+retrieve rows in expr1,expr2.. order. By using this option after big
+changes to the table, you may be able to get higher performance.
+@item
+In some cases it may make sense to introduce a column that is 'hashed'
+based on information from other columns. If this column is short and
+reasonably unique it may be much faster than a big index on many
+columns. In MySQL it's very easy to use this extra column:
+@code{SELECT * FROM table_name WHERE hash=MD5(concat(col1,col2))
+AND col_1='constant' AND col_2='constant'}
+@item
+For tables that change a lot you should try to avoid all @code{VARCHAR}
+or @code{BLOB} columns. You will get dynamic row length as soon as you
+are using a single @code{VARCHAR} or @code{BLOB} column. @xref{Table
+types}.
+@item
+It's not normally useful to split a table into different tables just
+because the rows gets 'big'. To access a row, the biggest performance
+hit is the disk seek to find the first byte of the row. After finding
+the data most new disks can read the whole row fast enough for most
+applications. The only cases where it really matters to split up a table is if
+it's a dynamic row size table (see above) that you can change to a fixed
+row size, or if you very often need to scan the table and don't need
+most of the columns. @xref{Table types}.
+@item
+If you very often need to calculate things based on information from a
+lot of rows (like counts of things), it's probably much better to
+introduce a new table and update the counter in real time. An update of
+type @code{UPDATE table set count=count+1 where index_column=constant}
+is very fast!
+
+This is really important when you use databases like MySQL that
+only have table locking (multiple readers / single writers). This will
+also give better performance with most databases, as the row locking
+manager in this case will have less to do.
+@item
+If you need to collect statistics from big log tables, use summary tables
+instead of scanning the whole table. Maintaining the summaries should be
+much faster than trying to do statistics 'live'. It's much faster to
+regenerate new summary tables from the logs when things change
+(depending on business decisions) than to have to change the running
+application!
+@item
+If possible, one should classify reports as 'live' or 'statistical',
+where data needed for statistical reports are only generated based on
+summary tables that are generated from the actual data.
+@item
+Take advantage of the fact that columns have default values. Insert
+values explicitly only when the value to be inserted differs from the
+default. This reduces the parsing that MySQL need to do and
+improves the insert speed.
+@item
+In some cases it's convenient to pack and store data into a blob. In this
+case you have to add some extra code in your application to pack/unpack
+things in the blob, but this may save a lot of accesses at some stage.
+This is practical when you have data that doesn't conform to a static
+table structure.
+@item
+Normally you should try to keep all data non-redundant (what
+is called 3rd normal form in database theory), but you should not be
+afraid of duplicating things or creating summary tables if you need these
+to gain more speed.
+@item
+Stored procedures or UDF (user-defined functions) may be a good way to
+get more performance. In this case you should, however, always have a way
+to do this some other (slower) way if you use some database that doesn't
+support this.
+@item
+You can always gain something by caching queries/answers in your
+application and trying to do many inserts/updates at the same time. If
+your database supports lock tables (like MySQL and Oracle),
+this should help to ensure that the index cache is only flushed once
+after all updates.
+@item
+Use @code{INSERT /*! DELAYED */} when you do not need to know when your
+data is written. This speeds things up because many records can be written
+with a single disk write.
+@item
+Use @code{INSERT /*! LOW_PRIORITY */} when you want your selects to be
+more important.
+@item
+Use @code{SELECT /*! HIGH_PRIORITY */} to get selects that jump the
+queue. That is, the select is done even if there is somebody waiting to
+do a write.
+@item
+Use the multi-line @code{INSERT} statement to store many rows with one
+SQL command (many SQL servers supports this).
+@item
+Use @code{LOAD DATA INFILE} to load bigger amounts of data. This is
+faster than normal inserts and will be even faster when @code{myisamchk}
+is integrated in @code{mysqld}.
+@item
+Use @code{AUTO_INCREMENT} columns to make unique values.
+@item
+Use @code{OPTIMIZE TABLE} once in a while to avoid fragmentation when
+using dynamic table format. @xref{OPTIMIZE TABLE, , @code{OPTIMIZE TABLE}}.
+
+@item
+Use @code{HEAP} tables to get more speed when possible. @xref{Table
+types}.
+@item
+When using a normal Web server setup, images should be stored as
+files. That is, store only a file reference in the database. The main
+reason for this is that a normal Web server is much better at caching
+files than database contents. So it it's much easier to get a fast
+system if you are using files.
+@item
+Use in memory tables for non-critical data that are accessed often (like
+information about the last shown banner for users that don't have
+cookies).
+@item
+Columns with identical information in different tables should be
+declared identical and have identical names. Before Version 3.23 you
+got slow joins otherwise.
+
+Try to keep the names simple (use @code{name} instead of
+@code{customer_name} in the customer table). To make your names portable
+to other SQL servers you should keep them shorter than 18 characters.
+@item
+If you need REALLY high speed, you should take a look at the low-level
+interfaces for data storage that the different SQL servers support! For
+example, by accessing the MySQL @code{MyISAM} directly, you could
+get a speed increase of 2-5 times compared to using the SQL interface.
+To be able to do this the data must be on the same server as
+the application, and usually it should only be accessed by one process
+(because external file locking is really slow). One could eliminate the
+above problems by introducing low-level @code{MyISAM} commands in the
+MySQL server (this could be one easy way to get more
+performance if needed). By carefully designing the database interface,
+it should be quite easy to support this types of optimization.
+@item
+In many cases it's faster to access data from a database (using a live
+connection) than accessing a text file, just because the database is
+likely to be more compact than the text file (if you are using numerical
+data), and this will involve fewer disk accesses. You will also save
+code because you don't have to parse your text files to find line and
+column boundaries.
+@item
+You can also use replication to speed things up. @xref{Replication}.
+@item
+Declaring a table with @code{DELAY_KEY_WRITE=1} will make the updating of
+indexes faster, as these are not logged to disk until the file is closed.
+The downside is that you should run @code{myisamchk} on these tables before
+you start @code{mysqld} to ensure that they are okay if something killed
+@code{mysqld} in the middle. As the key information can always be generated
+from the data, you should not lose anything by using @code{DELAY_KEY_WRITE}.
+@end itemize
+
+
+@node Locking Issues, Optimizing Database Structure, Query Speed, MySQL Optimization
+@section Locking Issues
+
+
+@menu
+* Internal locking:: How MySQL Locks Tables
+* Table locking:: Table Locking Issues
+@end menu
+
+
+@node Internal locking, Table locking, Locking Issues, Locking Issues
+@subsection How MySQL Locks Tables
+
+@cindex internal locking
+@cindex locking, tables
+@cindex tables, locking
+
+You can find a discussion about different locking methods in the appendix.
+@xref{Locking methods}.
+
+All locking in MySQL is deadlock-free. This is managed by always
+requesting all needed locks at once at the beginning of a query and always
+locking the tables in the same order.
+
+The locking method MySQL uses for @code{WRITE} locks works as follows:
+
+@itemize @bullet
+@item
+If there are no locks on the table, put a write lock on it.
+@item
+Otherwise, put the lock request in the write lock queue.
+@end itemize
+
+The locking method MySQL uses for @code{READ} locks works as follows:
+
+@itemize @bullet
+@item
+If there are no write locks on the table, put a read lock on it.
+@item
+Otherwise, put the lock request in the read lock queue.
+@end itemize
+
+When a lock is released, the lock is made available to the threads
+in the write lock queue, then to the threads in the read lock queue.
+
+This means that if you have many updates on a table, @code{SELECT}
+statements will wait until there are no more updates.
+
+To work around this for the case where you want to do many @code{INSERT} and
+@code{SELECT} operations on a table, you can insert rows in a temporary
+table and update the real table with the records from the temporary table
+once in a while.
+
+This can be done with the following code:
+@example
+mysql> LOCK TABLES real_table WRITE, insert_table WRITE;
+mysql> insert into real_table select * from insert_table;
+mysql> TRUNCATE TABLE insert_table;
+mysql> UNLOCK TABLES;
+@end example
+
+You can use the @code{LOW_PRIORITY} options with @code{INSERT},
+@code{UPDATE} or @code{DELETE} or @code{HIGH_PRIORITY} with
+@code{SELECT} if you want to prioritize retrieval in some specific
+cases. You can also start @code{mysqld} with @code{--low-priority-updates}
+to get the same behaveour.
+
+Using @code{SQL_BUFFER_RESULT} can also help making table locks shorter.
+@xref{SELECT}.
+
+You could also change the locking code in @file{mysys/thr_lock.c} to use a
+single queue. In this case, write locks and read locks would have the same
+priority, which might help some applications.
+
+
+@node Table locking, , Internal locking, Locking Issues
+@subsection Table Locking Issues
+
+@cindex problems, table locking
+
+The table locking code in MySQL is deadlock free.
+
+MySQL uses table locking (instead of row locking or column
+locking) on all table types, except @code{BDB} tables, to achieve a very
+high lock speed. For large tables, table locking is MUCH better than
+row locking for most applications, but there are, of course, some
+pitfalls.
+
+For @code{BDB} and @code{InnoDB} tables, MySQL only uses table
+locking if you explicitely lock the table with @code{LOCK TABLES} or
+execute a command that will modify every row in the table, like
+@code{ALTER TABLE}. For these table types we recommend you to not use
+@code{LOCK TABLES} at all.
+
+In MySQL Version 3.23.7 and above, you can insert rows into
+@code{MyISAM} tables at the same time other threads are reading from the
+table. Note that currently this only works if there are no holes after
+deleted rows in the table at the time the insert is made. When all holes
+has been filled with new data, concurrent inserts will automatically be
+enabled again.
+
+Table locking enables many threads to read from a table at the same
+time, but if a thread wants to write to a table, it must first get
+exclusive access. During the update, all other threads that want to
+access this particular table will wait until the update is ready.
+
+As updates on tables normally are considered to be more important than
+@code{SELECT}, all statements that update a table have higher priority
+than statements that retrieve information from a table. This should
+ensure that updates are not 'starved' because one issues a lot of heavy
+queries against a specific table. (You can change this by using
+LOW_PRIORITY with the statement that does the update or
+@code{HIGH_PRIORITY} with the @code{SELECT} statement.)
+
+Starting from MySQL Version 3.23.7 one can use the
+@code{max_write_lock_count} variable to force MySQL to
+temporary give all @code{SELECT} statements, that wait for a table, a
+higher priority after a specific number of inserts on a table.
+
+Table locking is, however, not very good under the following senario:
+
+@itemize @bullet
+@item
+A client issues a @code{SELECT} that takes a long time to run.
+@item
+Another client then issues an @code{UPDATE} on a used table. This client
+will wait until the @code{SELECT} is finished.
+@item
+Another client issues another @code{SELECT} statement on the same table. As
+@code{UPDATE} has higher priority than @code{SELECT}, this @code{SELECT}
+will wait for the @code{UPDATE} to finish. It will also wait for the first
+@code{SELECT} to finish!
+@item
+A thread is waiting for something like @code{full disk}, in which case all
+threads that wants to access the problem table will also be put in a waiting
+state until more disk space is made available.
+@end itemize
+
+Some possible solutions to this problem are:
+
+@itemize @bullet
+@item
+Try to get the @code{SELECT} statements to run faster. You may have to create
+some summary tables to do this.
+
+@item
+Start @code{mysqld} with @code{--low-priority-updates}. This will give
+all statements that update (modify) a table lower priority than a @code{SELECT}
+statement. In this case the last @code{SELECT} statement in the previous
+scenario would execute before the @code{INSERT} statement.
+
+@item
+You can give a specific @code{INSERT}, @code{UPDATE}, or @code{DELETE}
+statement lower priority with the @code{LOW_PRIORITY} attribute.
+
+@item
+Start @code{mysqld} with a low value for @strong{max_write_lock_count} to give
+@code{READ} locks after a certain number of @code{WRITE} locks.
+
+@item
+You can specify that all updates from a specific thread should be done with
+low priority by using the SQL command: @code{SET SQL_LOW_PRIORITY_UPDATES=1}.
+@xref{SET OPTION, , @code{SET OPTION}}.
+
+@item
+You can specify that a specific @code{SELECT} is very important with the
+@code{HIGH_PRIORITY} attribute. @xref{SELECT, , @code{SELECT}}.
+
+@item
+If you have problems with @code{INSERT} combined with @code{SELECT},
+switch to use the new @code{MyISAM} tables as these support concurrent
+@code{SELECT}s and @code{INSERT}s.
+
+@item
+If you mainly mix @code{INSERT} and @code{SELECT} statements, the
+@code{DELAYED} attribute to @code{INSERT} will probably solve your problems.
+@xref{INSERT, , @code{INSERT}}.
+
+@item
+If you have problems with @code{SELECT} and @code{DELETE}, the @code{LIMIT}
+option to @code{DELETE} may help. @xref{DELETE, , @code{DELETE}}.
+@end itemize
+
+
+@node Optimizing Database Structure, Optimizing the Server, Locking Issues, MySQL Optimization
+@section Optimizing Database Structure
+
+
+@menu
+* Design:: Design Choices
+* Data size:: Get Your Data as Small as Possible
+* MySQL indexes:: How MySQL Uses Indexes
+* Indexes:: Column Indexes
+* Multiple-column indexes:: Multiple-Column Indexes
+* Table cache:: How MySQL Opens and Closes Tables
+* Creating many tables:: Drawbacks to Creating Large Numbers of Tables in the Same Database
+* Open tables:: Why So Many Open tables?
+@end menu
+
+
+@node Design, Data size, Optimizing Database Structure, Optimizing Database Structure
+@subsection Design Choices
+
+@cindex design, choices
+@cindex database design
+@cindex storage of data
+
+MySQL keeps row data and index data in separate files. Many (almost
+all) other databases mix row and index data in the same file. We believe that
+the MySQL choice is better for a very wide range of modern systems.
+
+Another way to store the row data is to keep the information for each
+column in a separate area (examples are SDBM and Focus). This will cause a
+performance hit for every query that accesses more than one column. Because
+this degenerates so quickly when more than one column is accessed,
+we believe that this model is not good for general purpose databases.
+
+The more common case is that the index and data are stored together
+(like in Oracle/Sybase et al). In this case you will find the row
+information at the leaf page of the index. The good thing with this
+layout is that it, in many cases, depending on how well the index is
+cached, saves a disk read. The bad things with this layout are:
+
+@itemize @bullet
+@item
+Table scanning is much slower because you have to read through the indexes
+to get at the data.
+@item
+You can't use only the index table to retrieve data for a query.
+@item
+You lose a lot of space, as you must duplicate indexes from the nodes
+(as you can't store the row in the nodes).
+@item
+Deletes will degenerate the table over time (as indexes in nodes are
+usually not updated on delete).
+@item
+It's harder to cache ONLY the index data.
+@end itemize
+
+
+@node Data size, MySQL indexes, Design, Optimizing Database Structure
+@subsection Get Your Data as Small as Possible
+
+@cindex data, size
+@cindex reducing, data size
+@cindex storage space, minimizing
+@cindex tables, improving performance
+@cindex performance, improving
+
+One of the most basic optimization is to get your data (and indexes) to
+take as little space on the disk (and in memory) as possible. This can
+give huge improvements because disk reads are faster and normally less
+main memory will be used. Indexing also takes less resources if
+done on smaller columns.
+
+MySQL supports a lot of different table types and row formats.
+Choosing the right table format may give you a big performance gain.
+@xref{Table types}.
+
+You can get better performance on a table and minimize storage space
+using the techniques listed below:
+
+@itemize @bullet
+@item
+Use the most efficient (smallest) types possible. MySQL has
+many specialized types that save disk space and memory.
+
+@item
+Use the smaller integer types if possible to get smaller tables. For
+example, @code{MEDIUMINT} is often better than @code{INT}.
+
+@item
+Declare columns to be @code{NOT NULL} if possible. It makes everything
+faster and you save one bit per column. Note that if you really need
+@code{NULL} in your application you should definitely use it. Just avoid
+having it on all columns by default.
+
+@item
+If you don't have any variable-length columns (@code{VARCHAR},
+@code{TEXT}, or @code{BLOB} columns), a fixed-size record format is
+used. This is faster but unfortunately may waste some space.
+@xref{MyISAM table formats}.
+
+@item
+The primary index of a table should be as short as possible. This makes
+identification of one row easy and efficient.
+
+@item
+For each table, you have to decide which storage/index method to
+use. @xref{Table types}.
+
+@item
+Only create the indexes that you really need. Indexes are good for
+retrieval but bad when you need to store things fast. If you mostly
+access a table by searching on a combination of columns, make an index
+on them. The first index part should be the most used column. If you are
+ALWAYS using many columns, you should use the column with more duplicates
+first to get better compression of the index.
+
+@item
+If it's very likely that a column has a unique prefix on the first number
+of characters, it's better to only index this prefix. MySQL
+supports an index on a part of a character column. Shorter indexes are
+faster not only because they take less disk space but also because they
+will give you more hits in the index cache and thus fewer disk
+seeks. @xref{Server parameters}.
+
+@item
+In some circumstances it can be beneficial to split into two a table that is
+scanned very often. This is especially true if it is a dynamic
+format table and it is possible to use a smaller static format table that
+can be used to find the relevant rows when scanning the table.
+@end itemize
+
+
+@node MySQL indexes, Indexes, Data size, Optimizing Database Structure
+@subsection How MySQL Uses Indexes
+
+@cindex indexes, use of
+
+Indexes are used to find rows with a specific value of one column
+fast. Without an index MySQL has to start with the first record
+and then read through the whole table until it finds the relevant
+rows. The bigger the table, the more this costs. If the table has an index
+for the columns in question, MySQL can quickly get a position to
+seek to in the middle of the data file without having to look at all the
+data. If a table has 1000 rows, this is at least 100 times faster than
+reading sequentially. Note that if you need to access almost all 1000
+rows it is faster to read sequentially because we then avoid disk seeks.
+
+All MySQL indexes (@code{PRIMARY}, @code{UNIQUE}, and
+@code{INDEX}) are stored in B-trees. Strings are automatically prefix-
+and end-space compressed. @xref{CREATE INDEX, , @code{CREATE INDEX}}.
+
+Indexes are used to:
+@itemize @bullet
+@item
+Quickly find the rows that match a @code{WHERE} clause.
+
+@item
+Retrieve rows from other tables when performing joins.
+
+@item
+Find the @code{MAX()} or @code{MIN()} value for a specific indexed
+column. This is optimized by a preprocessor that checks if you are
+using @code{WHERE} key_part_# = constant on all key parts < N. In this case
+MySQL will do a single key lookup and replace the @code{MIN()}
+expression with a constant. If all expressions are replaced with
+constants, the query will return at once:
+
+@example
+SELECT MIN(key_part2),MAX(key_part2) FROM table_name where key_part1=10
+@end example
+
+@item
+Sort or group a table if the sorting or grouping is done on a leftmost
+prefix of a usable key (for example, @code{ORDER BY key_part_1,key_part_2 }). The
+key is read in reverse order if all key parts are followed by @code{DESC}.
+
+The index can also be used even if the @code{ORDER BY} doesn't match the index
+exactly, as long as all the unused index parts and all the extra
+are @code{ORDER BY} columns are constants in the @code{WHERE} clause. The
+following queries will use the index to resolve the @code{ORDER BY} part:
+
+@example
+SELECT * FROM foo ORDER BY key_part1,key_part2,key_part3;
+SELECT * FROM foo WHERE column=constant ORDER BY column, key_part1;
+SELECT * FROM foo WHERE key_part1=const GROUP BY key_part2;
+@end example
+
+@item
+In some cases a query can be optimized to retrieve values without
+consulting the data file. If all used columns for some table are numeric
+and form a leftmost prefix for some key, the values may be retrieved
+from the index tree for greater speed:
+
+@example
+SELECT key_part3 FROM table_name WHERE key_part1=1
+@end example
+
+@end itemize
+
+Suppose you issue the following @code{SELECT} statement:
+
+@example
+mysql> SELECT * FROM tbl_name WHERE col1=val1 AND col2=val2;
+@end example
+
+If a multiple-column index exists on @code{col1} and @code{col2}, the
+appropriate rows can be fetched directly. If separate single-column
+indexes exist on @code{col1} and @code{col2}, the optimizer tries to
+find the most restrictive index by deciding which index will find fewer
+rows and using that index to fetch the rows.
+
+@cindex indexes, leftmost prefix of
+@cindex leftmost prefix of indexes
+If the table has a multiple-column index, any leftmost prefix of the
+index can be used by the optimizer to find rows. For example, if you
+have a three-column index on @code{(col1,col2,col3)}, you have indexed
+search capabilities on @code{(col1)}, @code{(col1,col2)}, and
+@code{(col1,col2,col3)}.
+
+MySQL can't use a partial index if the columns don't form a
+leftmost prefix of the index. Suppose you have the @code{SELECT}
+statements shown below:
+
+@example
+mysql> SELECT * FROM tbl_name WHERE col1=val1;
+mysql> SELECT * FROM tbl_name WHERE col2=val2;
+mysql> SELECT * FROM tbl_name WHERE col2=val2 AND col3=val3;
+@end example
+
+If an index exists on @code{(col1,col2,col3)}, only the first query
+shown above uses the index. The second and third queries do involve
+indexed columns, but @code{(col2)} and @code{(col2,col3)} are not
+leftmost prefixes of @code{(col1,col2,col3)}.
+
+@findex LIKE, and indexes
+@findex LIKE, and wildcards
+@cindex indexes, and @code{LIKE}
+@cindex wildcards, and @code{LIKE}
+MySQL also uses indexes for @code{LIKE} comparisons if the argument
+to @code{LIKE} is a constant string that doesn't start with a wild-card
+character. For example, the following @code{SELECT} statements use indexes:
+
+@example
+mysql> select * from tbl_name where key_col LIKE "Patrick%";
+mysql> select * from tbl_name where key_col LIKE "Pat%_ck%";
+@end example
+
+In the first statement, only rows with @code{"Patrick" <= key_col <
+"Patricl"} are considered. In the second statement, only rows with
+@code{"Pat" <= key_col < "Pau"} are considered.
+
+The following @code{SELECT} statements will not use indexes:
+@example
+mysql> select * from tbl_name where key_col LIKE "%Patrick%";
+mysql> select * from tbl_name where key_col LIKE other_col;
+@end example
+
+In the first statement, the @code{LIKE} value begins with a wild-card
+character. In the second statement, the @code{LIKE} value is not a
+constant.
+
+@findex IS NULL, and indexes
+@cindex indexes, and @code{IS NULL}
+Searching using @code{column_name IS NULL} will use indexes if column_name
+is an index.
+
+MySQL normally uses the index that finds the least number of rows. An
+index is used for columns that you compare with the following operators:
+@code{=}, @code{>}, @code{>=}, @code{<}, @code{<=}, @code{BETWEEN}, and a
+@code{LIKE} with a non-wild-card prefix like @code{'something%'}.
+
+Any index that doesn't span all @code{AND} levels in the @code{WHERE} clause
+is not used to optimize the query. In other words: To be able to use an
+index, a prefix of the index must be used in every @code{AND} group.
+
+The following @code{WHERE} clauses use indexes:
+@example
+... WHERE index_part1=1 AND index_part2=2 AND other_column=3
+... WHERE index=1 OR A=10 AND index=2 /* index = 1 OR index = 2 */
+... WHERE index_part1='hello' AND index_part_3=5
+ /* optimized like "index_part1='hello'" */
+... WHERE index1=1 and index2=2 or index1=3 and index3=3;
+ /* Can use index on index1 but not on index2 or index 3 */
+@end example
+
+These @code{WHERE} clauses do @strong{NOT} use indexes:
+@example
+... WHERE index_part2=1 AND index_part3=2 /* index_part_1 is not used */
+... WHERE index=1 OR A=10 /* Index is not used in both AND parts */
+... WHERE index_part1=1 OR index_part2=10 /* No index spans all rows */
+@end example
+
+Note that in some cases MySQL will not use an index, even if one
+would be available. Some of the cases where this happens are:
+
+@itemize @bullet
+@item
+If the use of the index would require MySQL to access more
+than 30 % of the rows in the table. (In this case a table scan is
+probably much faster, as this will require us to do much fewer seeks).
+Note that if such a query uses @code{LIMIT} to only retrieve
+part of the rows, MySQL will use an index anyway, as it can
+much more quickly find the few rows to return in the result.
+@end itemize
+
+
+@menu
+* Indexes:: Column Indexes
+* Multiple-column indexes:: Multiple-Column Indexes
+* Table cache:: How MySQL Opens and Closes Tables
+* Creating many tables:: Drawbacks to Creating Large Numbers of Tables in the Same Database
+* Open tables:: Why So Many Open tables?
+@end menu
+
+
+@node Indexes, Multiple-column indexes, MySQL indexes, Optimizing Database Structure
+@subsection Column Indexes
+
+@cindex indexes, columns
+@cindex columns, indexes
+@cindex keys
+
+All MySQL column types can be indexed. Use of indexes on the
+relevant columns is the best way to improve the performance of @code{SELECT}
+operations.
+
+The maximum number of keys and the maximum index length is defined per
+table handler. @xref{Table types}. You can with all table handlers have
+at least 16 keys and a total index length of at least 256 bytes.
+
+For @code{CHAR} and @code{VARCHAR} columns, you can index a prefix of a
+column. This is much faster and requires less disk space than indexing the
+whole column. The syntax to use in the @code{CREATE TABLE} statement to
+index a column prefix looks like this:
+
+@example
+KEY index_name (col_name(length))
+@end example
+
+The example below creates an index for the first 10 characters of the
+@code{name} column:
+
+@example
+mysql> CREATE TABLE test (
+ name CHAR(200) NOT NULL,
+ KEY index_name (name(10)));
+@end example
+
+For @code{BLOB} and @code{TEXT} columns, you must index a prefix of the
+column. You cannot index the entire column.
+
+In MySQL Version 3.23.23 or later, you can also create special
+@strong{FULLTEXT} indexes. They are used for full-text search. Only the
+@code{MyISAM} table type supports @code{FULLTEXT} indexes. They can be
+created only from @code{VARCHAR} and @code{TEXT} columns.
+Indexing always happens over the entire column and partial indexing is not
+supported. See @ref{Fulltext Search} for details.
+
+@node Multiple-column indexes, Table cache, Indexes, Optimizing Database Structure
+@subsection Multiple-Column Indexes
+
+@cindex multi-column indexes
+@cindex indexes, multi-column
+@cindex keys, multi-column
+
+MySQL can create indexes on multiple columns. An index may
+consist of up to 15 columns. (On @code{CHAR} and @code{VARCHAR} columns you
+can also use a prefix of the column as a part of an index).
+
+A multiple-column index can be considered a sorted array containing values
+that are created by concatenating the values of the indexed columns.
+
+MySQL uses multiple-column indexes in such a way that queries are
+fast when you specify a known quantity for the first column of the index in a
+@code{WHERE} clause, even if you don't specify values for the other columns.
+
+Suppose a table is created using the following specification:
+
+@example
+mysql> CREATE TABLE test (
+ id INT NOT NULL,
+ last_name CHAR(30) NOT NULL,
+ first_name CHAR(30) NOT NULL,
+ PRIMARY KEY (id),
+ INDEX name (last_name,first_name));
+@end example
+
+Then the index @code{name} is an index over @code{last_name} and
+@code{first_name}. The index will be used for queries that specify
+values in a known range for @code{last_name}, or for both @code{last_name}
+and @code{first_name}.
+Therefore, the @code{name} index will be used in the following queries:
+
+@example
+mysql> SELECT * FROM test WHERE last_name="Widenius";
+
+mysql> SELECT * FROM test WHERE last_name="Widenius"
+ AND first_name="Michael";
+
+mysql> SELECT * FROM test WHERE last_name="Widenius"
+ AND (first_name="Michael" OR first_name="Monty");
+
+mysql> SELECT * FROM test WHERE last_name="Widenius"
+ AND first_name >="M" AND first_name < "N";
+@end example
+
+However, the @code{name} index will NOT be used in the following queries:
+
+@example
+mysql> SELECT * FROM test WHERE first_name="Michael";
+
+mysql> SELECT * FROM test WHERE last_name="Widenius"
+ OR first_name="Michael";
+@end example
+
+For more information on the manner in which MySQL uses indexes to
+improve query performance, see @ref{MySQL indexes, , MySQL
+indexes}.
+
+
+@node Table cache, Creating many tables, Multiple-column indexes, Optimizing Database Structure
+@subsection How MySQL Opens and Closes Tables
+
+@findex table_cache
+
+@cindex tables, opening
+@cindex tables, closing
+@cindex opening, tables
+@cindex closing, tables
+@cindex table cache
+
+@code{table_cache}, @code{max_connections}, and @code{max_tmp_tables}
+affect the maximum number of files the server keeps open. If you
+increase one or both of these values, you may run up against a limit
+imposed by your operating system on the per-process number of open file
+descriptors. However, you can increase the limit on many systems.
+Consult your OS documentation to find out how to do this, because the
+method for changing the limit varies widely from system to system.
+
+@code{table_cache} is related to @code{max_connections}. For example,
+for 200 concurrent running connections, you should have a table cache of
+at least @code{200 * n}, where @code{n} is the maximum number of tables
+in a join. You also need to reserve some extra file descriptors for
+temporary tables and files.
+
+The cache of open tables can grow to a maximum of @code{table_cache}
+(default 64; this can be changed with the @code{-O table_cache=#}
+option to @code{mysqld}). A table is never closed, except when the
+cache is full and another thread tries to open a table or if you use
+@code{mysqladmin refresh} or @code{mysqladmin flush-tables}.
+
+When the table cache fills up, the server uses the following procedure
+to locate a cache entry to use:
+
+@itemize @bullet
+@item
+Tables that are not currently in use are released, in least-recently-used
+order.
+
+@item
+If the cache is full and no tables can be released, but a new table needs to
+be opened, the cache is temporarily extended as necessary.
+
+@item
+If the cache is in a temporarily-extended state and a table goes from in-use
+to not-in-use state, the table is closed and released from the cache.
+@end itemize
+
+A table is opened for each concurrent access. This means that
+if you have two threads accessing the same table or access the table
+twice in the same query (with @code{AS}) the table needs to be opened twice.
+The first open of any table takes two file descriptors; each additional
+use of the table takes only one file descriptor. The extra descriptor
+for the first open is used for the index file; this descriptor is shared
+among all threads.
+
+You can check if your table cache is too small by checking the mysqld
+variable @code{opened_tables}. If this is quite big, even if you
+haven't done a lot of @code{FLUSH TABLES}, you should increase your table
+cache. @xref{SHOW STATUS}.
+
+
+@node Creating many tables, Open tables, Table cache, Optimizing Database Structure
+@subsection Drawbacks to Creating Large Numbers of Tables in the Same Database
+
+@cindex tables, too many
+
+If you have many files in a directory, open, close, and create operations will
+be slow. If you execute @code{SELECT} statements on many different tables,
+there will be a little overhead when the table cache is full, because for
+every table that has to be opened, another must be closed. You can reduce
+this overhead by making the table cache larger.
+
+
+@node Open tables, , Creating many tables, Optimizing Database Structure
+@subsection Why So Many Open tables?
+
+@cindex tables, open
+@cindex open tables
+
+When you run @code{mysqladmin status}, you'll see something like this:
+
+@example
+Uptime: 426 Running threads: 1 Questions: 11082 Reloads: 1 Open tables: 12
+@end example
+
+This can be somewhat perplexing if you only have 6 tables.
+
+MySQL is multithreaded, so it may have many queries on the same
+table simultaneously. To minimize the problem with two threads having
+different states on the same file, the table is opened independently by
+each concurrent thread. This takes some memory and one extra file
+descriptor for the data file. The index file descriptor is shared
+between all threads.
+
+
+@node Optimizing the Server, Disk issues, Optimizing Database Structure, MySQL Optimization
+@section Optimizing the MySQL Server
+
+
+@menu
+* System:: System/Compile Time and Startup Parameter Tuning
+* Server parameters:: Tuning Server Parameters
+* Compile and link options:: How Compiling and Linking Affects the Speed of MySQL
+* Memory use:: How MySQL Uses Memory
+* DNS:: How MySQL uses DNS
+* SET OPTION:: @code{SET} Syntax
+@end menu
+
+
+@node System, Server parameters, Optimizing the Server, Optimizing the Server
+@subsection System/Compile Time and Startup Parameter Tuning
+
+@cindex compiling, optimizing
+@cindex system optimization
+@cindex startup parameters, tuning
+
+We start with the system level things since some of these decisions have
+to be made very early. In other cases a fast look at this part may
+suffice because it not that important for the big gains. However, it is always
+nice to have a feeling about how much one could gain by changing things
+at this level.
+
+The default OS to use is really important! To get the most use of
+multiple CPU machines one should use Solaris (because the threads works
+really nice) or Linux (because the 2.2 kernel has really good SMP
+support). Also on 32-bit machines Linux has a 2G file size limit by
+default. Hopefully this will be fixed soon when new filesystems are
+released (XFS/Reiserfs). If you have a desperate need for files bigger
+than 2G on Linux-intel 32 bit, you should get the LFS patch for the ext2
+file system.
+
+Because we have not run MySQL in production on that many platforms, we
+advice you to test your intended platform before choosing it, if possible.
+
+@cindex locking
+Other tips:
+@itemize @bullet
+@item
+If you have enough RAM, you could remove all swap devices. Some
+operating systems will use a swap device in some contexts even if you
+have free memory.
+@item
+Use the @code{--skip-locking} MySQL option to avoid external
+locking. Note that this will not impact MySQL's functionality as
+long as you only run one server. Just remember to take down the server (or
+lock relevant parts) before you run @code{myisamchk}. On some system
+this switch is mandatory because the external locking does not work in any
+case.
+
+The @code{--skip-locking} option is on by default when compiling with
+MIT-pthreads, because @code{flock()} isn't fully supported by
+MIT-pthreads on all platforms. It's also on default for Linux
+as Linux file locking are not yet safe.
+
+The only case when you can't use @code{--skip-locking} is if you run
+multiple MySQL @emph{servers} (not clients) on the same data,
+or run @code{myisamchk} on the table without first flushing and locking
+the @code{mysqld} server tables first.
+
+You can still use @code{LOCK TABLES}/@code{UNLOCK TABLES} even if you
+are using @code{--skip-locking}
+@end itemize
+
+
+@node Server parameters, Compile and link options, System, Optimizing the Server
+@subsection Tuning Server Parameters
+
+@cindex parameters, server
+@cindex @code{mysqld} server, buffer sizes
+@cindex buffer sizes, @code{mysqld} server
+@cindex startup parameters
+
+You can get the default buffer sizes used by the @code{mysqld} server
+with this command:
+
+@example
+shell> mysqld --help
+@end example
+
+@cindex @code{mysqld} options
+@cindex variables, @code{mysqld}
+This command produces a list of all @code{mysqld} options and configurable
+variables. The output includes the default values and looks something
+like this:
+
+@example
+Possible variables for option --set-variable (-O) are:
+back_log current value: 5
+bdb_cache_size current value: 1048540
+binlog_cache_size current_value: 32768
+connect_timeout current value: 5
+delayed_insert_timeout current value: 300
+delayed_insert_limit current value: 100
+delayed_queue_size current value: 1000
+flush_time current value: 0
+interactive_timeout current value: 28800
+join_buffer_size current value: 131072
+key_buffer_size current value: 1048540
+lower_case_table_names current value: 0
+long_query_time current value: 10
+max_allowed_packet current value: 1048576
+max_binlog_cache_size current_value: 4294967295
+max_connections current value: 100
+max_connect_errors current value: 10
+max_delayed_threads current value: 20
+max_heap_table_size current value: 16777216
+max_join_size current value: 4294967295
+max_sort_length current value: 1024
+max_tmp_tables current value: 32
+max_write_lock_count current value: 4294967295
+myisam_sort_buffer_size current value: 8388608
+net_buffer_length current value: 16384
+net_retry_count current value: 10
+net_read_timeout current value: 30
+net_write_timeout current value: 60
+query_buffer_size current value: 0
+record_buffer current value: 131072
+record_rnd_buffer current value: 131072
+slow_launch_time current value: 2
+sort_buffer current value: 2097116
+table_cache current value: 64
+thread_concurrency current value: 10
+tmp_table_size current value: 1048576
+thread_stack current value: 131072
+wait_timeout current value: 28800
+@end example
+
+If there is a @code{mysqld} server currently running, you can see what
+values it actually is using for the variables by executing this command:
+
+@example
+shell> mysqladmin variables
+@end example
+
+You can find a full description for all variables in the @code{SHOW VARIABLES}
+section in this manual. @xref{SHOW VARIABLES}.
+
+You can also see some statistics from a running server by issuing the command
+@code{SHOW STATUS}. @xref{SHOW STATUS}.
+
+MySQL uses algorithms that are very scalable, so you can usually
+run with very little memory. If you, however, give MySQL more
+memory, you will normally also get better performance.
+
+When tuning a MySQL server, the two most important variables to use
+are @code{key_buffer_size} and @code{table_cache}. You should first feel
+confident that you have these right before trying to change any of the
+other variables.
+
+If you have much memory (>=256M) and many tables and want maximum performance
+with a moderate number of clients, you should use something like this:
+
+@example
+shell> safe_mysqld -O key_buffer=64M -O table_cache=256 \
+ -O sort_buffer=4M -O record_buffer=1M &
+@end example
+
+If you have only 128M and only a few tables, but you still do a lot of
+sorting, you can use something like:
+
+@example
+shell> safe_mysqld -O key_buffer=16M -O sort_buffer=1M
+@end example
+
+If you have little memory and lots of connections, use something like this:
+
+@example
+shell> safe_mysqld -O key_buffer=512k -O sort_buffer=100k \
+ -O record_buffer=100k &
+@end example
+
+or even:
+
+@example
+shell> safe_mysqld -O key_buffer=512k -O sort_buffer=16k \
+ -O table_cache=32 -O record_buffer=8k -O net_buffer=1K &
+@end example
+
+If you are doing a @code{GROUP BY} or @code{ORDER BY} on files that are
+much bigger than your available memory you should increase the value of
+@code{record_rnd_buffer} to speed up the reading of rows after the sorting
+is done.
+
+When you have installed MySQL, the @file{support-files} directory will
+contain some different @code{my.cnf} example files, @file{my-huge.cnf},
+@file{my-large.cnf}, @file{my-medium.cnf}, and @file{my-small.cnf}, you can
+use as a base to optimize your system.
+
+If there are very many connections, ``swapping problems'' may occur unless
+@code{mysqld} has been configured to use very little memory for each
+connection. @code{mysqld} performs better if you have enough memory for all
+connections, of course.
+
+Note that if you change an option to @code{mysqld}, it remains in effect only
+for that instance of the server.
+
+To see the effects of a parameter change, do something like this:
+
+@example
+shell> mysqld -O key_buffer=32m --help
+@end example
+
+Make sure that the @code{--help} option is last; otherwise, the effect of any
+options listed after it on the command line will not be reflected in the
+output.
+
+
+@node Compile and link options, Memory use, Server parameters, Optimizing the Server
+@subsection How Compiling and Linking Affects the Speed of MySQL
+
+@cindex linking, speed
+@cindex compiling, speed
+@cindex speed, compiling
+@cindex speed, linking
+
+Most of the following tests are done on Linux with the
+MySQL benchmarks, but they should give some indication for
+other operating systems and workloads.
+
+You get the fastest executable when you link with @code{-static}.
+
+On Linux, you will get the fastest code when compiling with @code{pgcc}
+and @code{-O3}. To compile @file{sql_yacc.cc} with these options, you
+need about 200M memory because @code{gcc/pgcc} needs a lot of memory to
+make all functions inline. You should also set @code{CXX=gcc} when
+configuring MySQL to avoid inclusion of the @code{libstdc++}
+library (it is not needed). Note that with some versions of @code{pgcc},
+the resulting code will only run on true Pentium processors, even if you
+use the compiler option that you want the resulting code to be working on
+all x586 type processors (like AMD).
+
+By just using a better compiler and/or better compiler options you can
+get a 10-30 % speed increase in your application. This is particularly
+important if you compile the SQL server yourself!
+
+We have tested both the Cygnus CodeFusion and Fujitsu compilers, but
+when we tested them, neither was sufficiently bug free to allow
+MySQL to be compiled with optimizations on.
+
+When you compile MySQL you should only include support for the
+character sets that you are going to use. (Option @code{--with-charset=xxx}).
+The standard MySQL binary distributions are compiled with support
+for all character sets.
+
+Here is a list of some measurements that we have done:
+@itemize @bullet
+@item
+If you use @code{pgcc} and compile everything with @code{-O6}, the
+@code{mysqld} server is 1% faster than with @code{gcc} 2.95.2.
+
+@item
+If you link dynamically (without @code{-static}), the result is 13%
+slower on Linux. Note that you still can use a dynamic linked
+MySQL library. It is only the server that is critical for
+performance.
+
+@item
+If you strip your @code{mysqld} binary with @code{strip libexec/mysqld},
+the resulting binary can be up to 4 % faster.
+
+@item
+If you connect using TCP/IP rather than Unix sockets, the result is 7.5%
+slower on the same computer. (If you are connection to @code{localhost},
+MySQL will, by default, use sockets).
+
+@item
+If you connect using TCP/IP from another computer over a 100M Ethernet,
+things will be 8-11 % slower.
+
+@item
+If you compile with @code{--with-debug=full}, then you will loose 20 %
+for most queries, but some queries may take substantially longer (The
+MySQL benchmarks ran 35 % slower)
+If you use @code{--with-debug}, then you will only loose 15 %.
+By starting a @code{mysqld} version compiled with @code{--with-debug=full}
+with @code{--skip-safemalloc} the end result should be close to when
+configuring with @code{--with-debug}.
+
+@item
+On a Sun SPARCstation 20, SunPro C++ 4.2 is 5 % faster than @code{gcc} 2.95.2.
+
+@item
+Compiling with @code{gcc} 2.95.2 for ultrasparc with the option
+@code{-mcpu=v8 -Wa,-xarch=v8plusa} gives 4 % more performance.
+
+@item
+On Solaris 2.5.1, MIT-pthreads is 8-12% slower than Solaris native
+threads on a single processor. With more load/CPUs the difference should
+get bigger.
+
+@item
+Running with @code{--log-bin} makes @strong{[MySQL} 1 % slower.
+
+@item
+Compiling on Linux-x86 using gcc without frame pointers
+@code{-fomit-frame-pointer} or @code{-fomit-frame-pointer -ffixed-ebp}
+@code{mysqld} 1-4% faster.
+@end itemize
+
+The MySQL-Linux distribution provided by MySQL AB used
+to be compiled with @code{pgcc}, but we had to go back to regular gcc
+because of a bug in @code{pgcc} that would generate the code that does
+not run on AMD. We will continue using gcc until that bug is resolved.
+In the meantime, if you have a non-AMD machine, you can get a faster
+binary by compiling with @code{pgcc}. The standard MySQL
+Linux binary is linked statically to get it faster and more portable.
+
+
+@node Memory use, DNS, Compile and link options, Optimizing the Server
+@subsection How MySQL Uses Memory
+
+@cindex memory use
+
+The list below indicates some of the ways that the @code{mysqld} server
+uses memory. Where applicable, the name of the server variable relevant
+to the memory use is given:
+
+@itemize @bullet
+@item
+The key buffer (variable @code{key_buffer_size}) is shared by all
+threads; Other buffers used by the server are allocated as
+needed. @xref{Server parameters}.
+
+@item
+Each connection uses some thread-specific space: A stack (default 64K,
+variable @code{thread_stack}), a connection buffer (variable
+@code{net_buffer_length}), and a result buffer (variable
+@code{net_buffer_length}). The connection buffer and result buffer are
+dynamically enlarged up to @code{max_allowed_packet} when needed. When
+a query is running, a copy of the current query string is also allocated.
+
+@item
+All threads share the same base memory.
+
+@item
+Only the compressed ISAM / MyISAM tables are memory mapped. This is
+because the 32-bit memory space of 4GB is not large enough for most
+big tables. When systems with a 64-bit address space become more
+common we may add general support for memory mapping.
+
+@item
+Each request doing a sequential scan over a table allocates a read buffer
+(variable @code{record_buffer}).
+
+@item
+When reading rows in 'random' order (for example after a sort) a
+random-read buffer is allocated to avoid disk seeks.
+(variable @code{record_rnd_buffer}).
+
+@item
+All joins are done in one pass, and most joins can be done without even
+using a temporary table. Most temporary tables are memory-based (HEAP)
+tables. Temporary tables with a big record length (calculated as the
+sum of all column lengths) or that contain @code{BLOB} columns are
+stored on disk.
+
+One problem in MySQL versions before Version 3.23.2 is that if a HEAP table
+exceeds the size of @code{tmp_table_size}, you get the error @code{The
+table tbl_name is full}. In newer versions this is handled by
+automatically changing the in-memory (HEAP) table to a disk-based
+(MyISAM) table as necessary. To work around this problem, you can
+increase the temporary table size by setting the @code{tmp_table_size}
+option to @code{mysqld}, or by setting the SQL option
+@code{SQL_BIG_TABLES} in the client program. @xref{SET OPTION, ,
+@code{SET OPTION}}. In MySQL Version 3.20, the maximum size of the
+temporary table was @code{record_buffer*16}, so if you are using this
+version, you have to increase the value of @code{record_buffer}. You can
+also start @code{mysqld} with the @code{--big-tables} option to always
+store temporary tables on disk. However, this will affect the speed of
+many complicated queries.
+
+@item
+Most requests doing a sort allocates a sort buffer and 0-2 temporary
+files depending on the result set size. @xref{Temporary files}.
+
+@item
+Almost all parsing and calculating is done in a local memory store. No
+memory overhead is needed for small items and the normal slow memory
+allocation and freeing is avoided. Memory is allocated only for
+unexpectedly large strings (this is done with @code{malloc()} and
+@code{free()}).
+
+@item
+Each index file is opened once and the data file is opened once for each
+concurrently running thread. For each concurrent thread, a table structure,
+column structures for each column, and a buffer of size @code{3 * n} is
+allocated (where @code{n} is the maximum row length, not counting @code{BLOB}
+columns). A @code{BLOB} uses 5 to 8 bytes plus the length of the @code{BLOB}
+data. The @code{ISAM}/@code{MyISAM} table handlers will use one extra row
+buffer for internal usage.
+
+@item
+For each table having @code{BLOB} columns, a buffer is enlarged dynamically
+to read in larger @code{BLOB} values. If you scan a table, a buffer as large
+as the largest @code{BLOB} value is allocated.
+
+@item
+Table handlers for all in-use tables are saved in a cache and managed as a
+FIFO. Normally the cache has 64 entries. If a table has been used by two
+running threads at the same time, the cache contains two entries for the
+table. @xref{Table cache}.
+
+@item
+A @code{mysqladmin flush-tables} command closes all tables that are not in
+use and marks all in-use tables to be closed when the currently executing
+thread finishes. This will effectively free most in-use memory.
+@end itemize
+
+@code{ps} and other system status programs may report that @code{mysqld}
+uses a lot of memory. This may be caused by thread-stacks on different
+memory addresses. For example, the Solaris version of @code{ps} counts
+the unused memory between stacks as used memory. You can verify this by
+checking available swap with @code{swap -s}. We have tested
+@code{mysqld} with commercial memory-leakage detectors, so there should
+be no memory leaks.
+
+
+@node DNS, SET OPTION, Memory use, Optimizing the Server
+@subsection How MySQL uses DNS
+
+@cindex DNS
+@cindex hostname caching
+
+When a new thread connects to @code{mysqld}, @code{mysqld} will span a
+new thread to handle the request. This thread will first check if the
+hostname is in the hostname cache. If not the thread will call
+@code{gethostbyaddr_r()} and @code{gethostbyname_r()} to resolve the
+hostname.
+
+If the operating system doesn't support the above thread-safe calls, the
+thread will lock a mutex and call @code{gethostbyaddr()} and
+@code{gethostbyname()} instead. Note that in this case no other thread
+can resolve other hostnames that is not in the hostname cache until the
+first thread is ready.
+
+You can disable DNS host lookup by starting @code{mysqld} with
+@code{--skip-name-resolve}. In this case you can however only use IP
+names in the MySQL privilege tables.
+
+If you have a very slow DNS and many hosts, you can get more performance by
+either disabling DNS lookop with @code{--skip-name-resolve} or by
+increasing the @code{HOST_CACHE_SIZE} define (default: 128) and recompile
+@code{mysqld}.
+
+You can disable the hostname cache with @code{--skip-host-cache}. You
+can clear the hostname cache with @code{FLUSH HOSTS} or @code{mysqladmin
+flush-hosts}.
+
+If you don't want to allow connections over @code{TCP/IP}, you can do this
+by starting @code{mysqld} with @code{--skip-networking}.
+
+
+@node SET OPTION, , DNS, Optimizing the Server
+@subsection @code{SET} Syntax
+
+@findex SET OPTION
+
+@example
+SET [OPTION] SQL_VALUE_OPTION= value, ...
+@end example
+
+@code{SET OPTION} sets various options that affect the operation of the
+server or your client. Any option you set remains in effect until the
+current session ends, or until you set the option to a different value.
+
+@table @code
+@item CHARACTER SET character_set_name | DEFAULT
+This maps all strings from and to the client with the given mapping.
+Currently the only option for @code{character_set_name} is
+@code{cp1251_koi8}, but you can easily add new mappings by editing the
+@file{sql/convert.cc} file in the MySQL source distribution. The
+default mapping can be restored by using a @code{character_set_name} value of
+@code{DEFAULT}.
+
+Note that the syntax for setting the @code{CHARACTER SET} option differs
+from the syntax for setting the other options.
+
+@item PASSWORD = PASSWORD('some password')
+@cindex passwords, setting
+Set the password for the current user. Any non-anonymous user can change his
+own password!
+
+@item PASSWORD FOR user = PASSWORD('some password')
+Set the password for a specific user on the current server host. Only a user
+with access to the @code{mysql} database can do this. The user should be
+given in @code{user@@hostname} format, where @code{user} and @code{hostname}
+are exactly as they are listed in the @code{User} and @code{Host} columns of
+the @code{mysql.user} table entry. For example, if you had an entry with
+@code{User} and @code{Host} fields of @code{'bob'} and @code{'%.loc.gov'},
+you would write:
+
+@example
+mysql> SET PASSWORD FOR bob@@"%.loc.gov" = PASSWORD("newpass");
+
+or
+
+mysql> UPDATE mysql.user SET password=PASSWORD("newpass") where user="bob' and host="%.loc.gov";
+@end example
+
+@item SQL_AUTO_IS_NULL = 0 | 1
+If set to @code{1} (default) then one can find the last inserted row
+for a table with an auto_increment row with the following construct:
+@code{WHERE auto_increment_column IS NULL}. This is used by some
+ODBC programs like Access.
+
+@item AUTOCOMMIT= 0 | 1
+If set to @code{1} all changes to a table will be done at once. To start
+a multi-command transaction, you have to use the @code{BEGIN}
+statement. @xref{COMMIT}. If set to @code{0} you have to use @code{COMMIT} /
+@code{ROLLBACK} to accept/revoke that transaction. @xref{COMMIT}. Note
+that when you change from not @code{AUTOCOMMIT} mode to
+@code{AUTOCOMMIT} mode, MySQL will do an automatic
+@code{COMMIT} on any open transactions.
+
+@item SQL_BIG_TABLES = 0 | 1
+@cindex table is full
+If set to @code{1}, all temporary tables are stored on disk rather than in
+memory. This will be a little slower, but you will not get the error
+@code{The table tbl_name is full} for big @code{SELECT} operations that
+require a large temporary table. The default value for a new connection is
+@code{0} (that is, use in-memory temporary tables).
+
+@item SQL_BIG_SELECTS = 0 | 1
+If set to @code{0}, MySQL will abort if a @code{SELECT} is attempted
+that probably will take a very long time. This is useful when an inadvisable
+@code{WHERE} statement has been issued. A big query is defined as a
+@code{SELECT} that probably will have to examine more than
+@code{max_join_size} rows. The default value for a new connection is
+@code{1} (which will allow all @code{SELECT} statements).
+
+@item SQL_BUFFER_RESULT = 0 | 1
+@code{SQL_BUFFER_RESULT} will force the result from @code{SELECT}'s
+to be put into a temporary table. This will help MySQL free the
+table locks early and will help in cases where it takes a long time to
+send the result set to the client.
+
+@item SQL_LOW_PRIORITY_UPDATES = 0 | 1
+If set to @code{1}, all @code{INSERT}, @code{UPDATE}, @code{DELETE}, and
+and @code{LOCK TABLE WRITE} statements wait until there is no pending
+@code{SELECT} or @code{LOCK TABLE READ} on the affected table.
+
+@item SQL_MAX_JOIN_SIZE = value | DEFAULT
+Don't allow @code{SELECT}s that will probably need to examine more than
+@code{value} row combinations. By setting this value, you can catch
+@code{SELECT}s where keys are not used properly and that would probably
+take a long time. Setting this to a value other than @code{DEFAULT} will reset
+the @code{SQL_BIG_SELECTS} flag. If you set the @code{SQL_BIG_SELECTS}
+flag again, the @code{SQL_MAX_JOIN_SIZE} variable will be ignored.
+You can set a default value for this variable by starting @code{mysqld} with
+@code{-O max_join_size=#}.
+
+@item SQL_SAFE_UPDATES = 0 | 1
+If set to @code{1}, MySQL will abort if an @code{UPDATE} or
+@code{DELETE} is attempted that doesn't use a key or @code{LIMIT} in the
+@code{WHERE} clause. This makes it possible to catch wrong updates
+when creating SQL commands by hand.
+
+@item SQL_SELECT_LIMIT = value | DEFAULT
+The maximum number of records to return from @code{SELECT} statements. If
+a @code{SELECT} has a @code{LIMIT} clause, the @code{LIMIT} takes precedence
+over the value of @code{SQL_SELECT_LIMIT}. The default value for a new
+connection is ``unlimited.'' If you have changed the limit, the default value
+can be restored by using a @code{SQL_SELECT_LIMIT} value of @code{DEFAULT}.
+
+@item SQL_LOG_OFF = 0 | 1
+If set to @code{1}, no logging will be done to the standard log for this
+client, if the client has the @strong{process} privilege. This does not
+affect the update log!
+
+@item SQL_LOG_UPDATE = 0 | 1
+If set to @code{0}, no logging will be done to the update log for the client,
+if the client has the @strong{process} privilege. This does not affect the
+standard log!
+
+@item SQL_QUOTE_SHOW_CREATE = 0 | 1
+If set to @code{1}, @code{SHOW CREATE TABLE} will quote
+table and column names. This is @strong{on} by default,
+for replication of tables with fancy column names to work.
+@ref{SHOW CREATE TABLE, , @code{SHOW CREATE TABLE}}.
+
+@item TIMESTAMP = timestamp_value | DEFAULT
+Set the time for this client. This is used to get the original timestamp if
+you use the update log to restore rows. @code{timestamp_value} should be a
+UNIX Epoch timestamp, not a MySQL timestamp.
+
+@item LAST_INSERT_ID = #
+Set the value to be returned from @code{LAST_INSERT_ID()}. This is stored in
+the update log when you use @code{LAST_INSERT_ID()} in a command that updates
+a table.
+
+@item INSERT_ID = #
+Set the value to be used by the following @code{INSERT} or @code{ALTER TABLE}
+command when inserting an @code{AUTO_INCREMENT} value. This is mainly used
+with the update log.
+@end table
+
+
+@menu
+* SET TRANSACTION:: @code{SET TRANSACTION} Syntax
+@end menu
+
+
+
+
+@node Disk issues, , Optimizing the Server, MySQL Optimization
+@section Disk Issues
+
+@cindex disk issues
+@cindex performance, disk issues
+
+@itemize @bullet
+@item
+As mentioned before, disks seeks are a big performance bottleneck. This
+problems gets more and more apparent when the data starts to grow so
+large that effective caching becomes impossible. For large databases,
+where you access data more or less randomly, you can be sure that you
+will need at least one disk seek to read and a couple of disk seeks to
+write things. To minimize this problem, use disks with low seek times.
+
+@item
+Increase the number of available disk spindles (and thereby reduce
+the seek overhead) by either symlink files to different disks or striping
+the disks.
+
+@table @strong
+@item Using symbolic links
+This means that you symlink the index and/or data file(s) from the
+normal data directory to another disk (that may also be striped). This
+makes both the seek and read times better (if the disks are not used for
+other things). @xref{Symbolic links}.
+
+@cindex striping, defined
+@item Striping
+Striping means that you have many disks and put the first block on the
+first disk, the second block on the second disk, and the Nth on the
+(N mod number_of_disks) disk, and so on. This means if your normal data
+size is less than the stripe size (or perfectly aligned) you will get
+much better performance. Note that striping is very dependent on the OS
+and stripe-size. So benchmark your application with different
+stripe-sizes. @xref{Custom Benchmarks}.
+
+Note that the speed difference for striping is @strong{very} dependent
+on the parameters. Depending on how you set the striping parameters and
+number of disks you may get a difference in orders of magnitude. Note that
+you have to choose to optimize for random or sequential access.
+@end table
+
+@item
+For reliability you may want to use RAID 0+1 (striping + mirroring), but
+in this case you will need 2*N drives to hold N drives of data. This is
+probably the best option if you have the money for it! You may, however,
+also have to invest in some volume-management software to handle it
+efficiently.
+
+@item
+A good option is to have semi-important data (that can be regenerated)
+on RAID 0 disk while storing really important data (like host information
+and logs) on a RAID 0+1 or RAID N disk. RAID N can be a problem if you
+have many writes because of the time to update the parity bits.
+
+@item
+You may also set the parameters for the file system that the database
+uses. One easy change is to mount the file system with the noatime
+option. That makes it skip the updating of the last access time in the
+inode and by this will avoid some disk seeks.
+
+@item
+On Linux, you can get much more performance (up to 100 % under load is
+not uncommon) by using hdpram to configure your disk's interface! The
+following should be quite good hdparm options for MySQL (and
+probably many other applications):
+
+@example
+hdparm -m 16 -d 1
+@end example
+
+Note that the performance/reliability when using the above depends on
+your hardware, so we strongly suggest that you test your system
+thoroughly after using @code{hdparm}! Please consult the @code{hdparm}
+man page for more information! If @code{hdparm} is not used wisely,
+filesystem corruption may result. Backup everything before experimenting!
+
+@item
+On many operating systems you can mount the disks with the 'async' flag to
+set the file system to be updated asynchronously. If your computer is
+reasonable stable, this should give you more performance without sacrificing
+too much reliability. (This flag is on by default on Linux.)
+
+@item
+If you don't need to know when a file was last accessed (which is not
+really useful on a database server), you can mount your file systems
+with the noatime flag.
+@end itemize
+
+@menu
+* Symbolic links:: Using Symbolic Links
+@end menu
+
+
+@node Symbolic links, , Disk issues, Disk issues
+@subsection Using Symbolic Links
+
+@cindex symbolic links
+@cindex links, symbolic
+
+You can move tables and databases from the database directory to other
+locations and replace them with symbolic links to the new locations.
+You might want to do this, for example, to move a database to a file
+system with more free space or increase the speed of your system by
+spreading your tables to different disk.
+
+The recommended may to do this, is to just symlink databases to different
+disk and only symlink tables as a last resort.
+
+@cindex databases, symbolic links
+@menu
+* Symbolic links to databases:: Using Symbolic Links for Databases
+* Symbolic links to tables:: Using Symbolic Links for Tables
+@end menu
+
+
+@node Symbolic links to databases, Symbolic links to tables, Symbolic links, Symbolic links
+@subsubsection Using Symbolic Links for Databases
+
+The way to symlink a database is to first create a directory on some
+disk where you have free space and then create a symlink to it from
+the MySQL database directory.
+
+@example
+shell> mkdir /dr1/databases/test
+shell> ln -s /dr1/databases/test mysqld-datadir
+@end example
+
+MySQL doesn't support that you link one directory to multiple
+databases. Replacing a database directory with a symbolic link will
+work fine as long as you don't make a symbolic link between databases.
+Suppose you have a database @code{db1} under the MySQL data
+directory, and then make a symlink @code{db2} that points to @code{db1}:
+
+@example
+shell> cd /path/to/datadir
+shell> ln -s db1 db2
+@end example
+
+Now, for any table @code{tbl_a} in @code{db1}, there also appears to be
+a table @code{tbl_a} in @code{db2}. If one thread updates @code{db1.tbl_a}
+and another thread updates @code{db2.tbl_a}, there will be problems.
+
+If you really need this, you must change the following code in
+@file{mysys/mf_format.c}:
+
+@example
+if (flag & 32 || (!lstat(to,&stat_buff) && S_ISLNK(stat_buff.st_mode)))
+@end example
+
+to
+
+@example
+if (1)
+@end example
+
+On Windows you can use internal symbolic links to directories by compiling
+MySQL with @code{-DUSE_SYMDIR}. This allows you to put different
+databases on different disks. @xref{Windows symbolic links}.
+
+
+@node Symbolic links to tables, , Symbolic links to databases, Symbolic links
+@subsubsection Using Symbolic Links for Tables
+
+@cindex databases, symbolic links
+
+Before MySQL 4.0 you should not symlink tables, if you are not
+very carefully with them. The problem is that if you run @code{ALTER
+TABLE}, @code{REPAIR TABLE} or @code{OPTIMIZE TABLE} on a symlinked
+table, the symlinks will be removed and replaced by the original
+files. This happens because the above command works by creating a
+temporary file in the database directory and when the command is
+complete, replace the original file with the temporary file.
+
+You should not symlink tables on system that doesn't have a fully
+working @code{realpath()} call. (At least Linux and Solaris support
+@code{realpath()})
+
+In MySQL 4.0 symlinks is only fully supported for @code{MyISAM}
+tables. For other table types you will probably get strange problems
+when doing any of the above mentioned commands.
+
+The handling of symbolic links in MySQL 4.0 works the following
+way (this is mostly relevant only for @code{MyISAM} tables).
+
+@itemize @bullet
+@item
+In the data directory you will always have the table definition file
+and the data/index files.
+
+@item
+You can symlink the index file and the data file to different directories
+independent of the other.
+
+@item
+The symlinking can be done from the operating system (if @code{mysqld} is
+not running) or with the @code{INDEX/DATA DIRECTORY="path-to-dir"} command
+in @code{CREATE TABLE}. @xref{CREATE TABLE}.
+
+@item
+@code{myisamchk} will not replace a symlink with the index/file but
+work directly on the files the symlinks points to. Any temporary files
+will be created in the same directory where the data/index file is.
+
+@item
+When you drop a table that is using symlinks, both the symlink and the
+file the symlink points to is dropped. This is a good reason to why you
+should NOT run @code{mysqld} as root and not allow persons to have write
+access to the MySQL database directories.
+
+@item
+If you rename a table with @code{ALTER TABLE RENAME} and you don't change
+database, the symlink in the database directory will be renamed to the new
+name and the data/index file will be renamed accordingly.
+
+@item
+If you use @code{ALTER TABLE RENAME} to move a table to another database,
+then the table will be moved to the other database directory and the old
+symlinks and the files they pointed to will be deleted.
+
+@item
+If you are not using symlinks you should use the @code{--skip-symlink}
+option to @code{mysqld} to ensure that no one can drop or rename a file
+outside of the @code{mysqld} data directory.
+@end itemize
+
+Things that are not yet supported:
+
+@cindex TODO, symlinks
+@itemize @bullet
+@item
+@code{ALTER TABLE} ignores all @code{INDEX/DATA DIRECTORY="path"} options.
+@item
+@code{CREATE TABLE} doesn't report if the table has symbolic links.
+@item
+@code{mysqldump} doesn't include the symbolic links information in the output.
+@item
+@code{BACKUP TABLE} and @code{RESTORE TABLE} don't respect symbolic links.
+@end itemize
+
+
+
+
+@node Reference, Table types, MySQL Optimization, Top
@chapter MySQL Language Reference
@menu
-* Literals:: Literals: How to write strings and numbers
-* Variables:: User variables
+* Language Structure:: Language Structure
* Column types:: Column types
* Functions:: Functions
-* CREATE DATABASE:: @code{CREATE DATABASE} syntax
-* DROP DATABASE:: @code{DROP DATABASE} syntax
-* CREATE TABLE:: @code{CREATE TABLE} syntax
-* ALTER TABLE:: @code{ALTER TABLE} syntax
-* RENAME TABLE:: @code{RENAME TABLE} syntax
-* DROP TABLE:: @code{DROP TABLE} syntax
-* OPTIMIZE TABLE:: @code{OPTIMIZE TABLE} syntax
-* CHECK TABLE:: @code{CHECK TABLE} syntax
-* BACKUP TABLE:: @code{BACKUP TABLE} syntax
-* RESTORE TABLE:: @code{RESTORE TABLE} syntax
-* ANALYZE TABLE:: @code{ANALYZE TABLE} syntax
-* REPAIR TABLE:: @code{REPAIR TABLE} syntax
-* DELETE:: @code{DELETE} syntax
-* TRUNCATE:: @code{TRUNCATE} syntax
-* SELECT:: @code{SELECT} syntax
-* JOIN:: @code{JOIN} syntax
-* INSERT:: @code{INSERT} syntax
-* REPLACE:: @code{REPLACE} syntax
-* LOAD DATA:: @code{LOAD DATA INFILE} syntax
-* UPDATE:: @code{UPDATE} syntax
-* USE:: @code{USE} syntax
-* FLUSH:: @code{FLUSH} syntax (clearing caches)
-* KILL:: @code{KILL} syntax
-* SHOW:: @code{SHOW} syntax (Get information about tables, columns, ...)
-* EXPLAIN:: @code{EXPLAIN} syntax (Get information about a @code{SELECT})
-* DESCRIBE:: @code{DESCRIBE} syntax (Get information about names of columns)
-* COMMIT:: @code{BEGIN/COMMIT/ROLLBACK} syntax
-* LOCK TABLES:: @code{LOCK TABLES/UNLOCK TABLES} syntax
-* SET OPTION:: @code{SET OPTION} syntax
-* SET TRANSACTION:: @code{SET TRANSACTION} syntax
-* GRANT:: @code{GRANT} and @code{REVOKE} syntax
-* HANDLER:: @code{HANDLER} syntax
-* CREATE INDEX:: @code{CREATE INDEX} syntax
-* DROP INDEX:: @code{DROP INDEX} syntax
-* Comments:: Comment syntax
-* CREATE FUNCTION:: @code{CREATE FUNCTION} syntax
-* Reserved words:: Is @strong{MySQL} picky about reserved words?
+* Data Manipulation:: Data Manipulation: @code{SELECT}, @code{INSERT}, @code{UPDATE}, @code{DELETE}
+* Data Definition:: Data Definition: @code{CREATE}, @code{DROP}, @code{ALTER}
+* Basic User Commands:: Basic MySQL User Utility Commands
+* Transactional Commands:: MySQL Transactional and Locking Commands
+* Fulltext Search:: MySQL Full-text Search
@end menu
-@strong{MySQL} has a very complex, but intuitive and easy to learn SQL
+MySQL has a very complex, but intuitive and easy to learn SQL
interface. This chapter describes the various commands, types, and functions
-you will need to know in order to use @strong{MySQL} efficiently and
+you will need to know in order to use MySQL efficiently and
effectively. This chapter also serves as a reference to all functionality
-included in @strong{MySQL}. In order to use this chapter effectively, you
+included in MySQL. In order to use this chapter effectively, you
may find it useful to refer to the various indexes.
+
+@node Language Structure, Column types, Reference, Reference
+@section Language Structure
+
+@menu
+* Literals:: Literals: How to Write Strings and Numbers
+* Legal names:: Database, Table, Index, Column, and Alias Names
+* Name case sensitivity:: Case Sensitivity in Names
+* Variables:: User Variables
+* Comments:: Comment Syntax
+* Reserved words:: Is MySQL Picky About Reserved Words?
+@end menu
+
+
+@node Literals, Legal names, Language Structure, Language Structure
+@subsection Literals: How to Write Strings and Numbers
+
@cindex strings, defined
@cindex strings, escaping characters
@cindex literals
@cindex escape characters
@cindex backslash, escape character
-@node Literals, Variables, Reference, Reference
-@section Literals: How to Write Strings and Numbers
@menu
* String syntax:: Strings
* Number syntax:: Numbers
* Hexadecimal values:: Hexadecimal values
* NULL values:: @code{NULL} values
-* Legal names:: Database, Table, Index, Column, and Alias Names
@end menu
+
This section describes the various ways to write strings and numbers in
-@strong{MySQL}. It also covers the various nuances and ``gotchas'' that
-you may run into when dealing with these basic types in @strong{MySQL}.
+MySQL. It also covers the various nuances and ``gotchas'' that
+you may run into when dealing with these basic types in MySQL.
+
@node String syntax, Number syntax, Literals, Literals
-@subsection Strings
+@subsubsection Strings
A string is a sequence of characters, surrounded by either single quote
(@samp{'}) or double quote (@samp{"}) characters (only the single quote
@@ -14202,7 +27270,7 @@ if you run in ANSI mode). Examples:
Within a string, certain sequences have special meaning. Each of these
sequences begins with a backslash (@samp{\}), known as the @emph{escape
-character}. @strong{MySQL} recognizes the following escape sequences:
+character}. MySQL recognizes the following escape sequences:
@c these aren't really functions, but that's probably the most reasonable index
@table @code
@@ -14346,13 +27414,15 @@ characters to the proper escape sequences. @xref{Perl DBI Class, , Perl
You should use an escape function on any string that might contain any of the
special characters listed above!
+
+@node Number syntax, Hexadecimal values, String syntax, Literals
+@subsubsection Numbers
+
@cindex numbers
@cindex valid numbers, examples
@cindex integers
@cindex floats
@cindex negative values
-@node Number syntax, Hexadecimal values, String syntax, Literals
-@subsection Numbers
Integers are represented as a sequence of digits. Floats use @samp{.} as a
decimal separator. Either type of number may be preceded by @samp{-} to
@@ -14377,30 +27447,30 @@ Examples of valid floating-point numbers:
An integer may be used in a floating-point context; it is interpreted
as the equivalent floating-point number.
-@tindex hexadecimal values
+
@node Hexadecimal values, NULL values, Number syntax, Literals
-@subsection Hexadecimal Values
+@subsubsection Hexadecimal Values
+
+@tindex hexadecimal values
-@strong{MySQL} supports hexadecimal values. In number context these act
+MySQL supports hexadecimal values. In number context these act
like an integer (64-bit precision). In string context these act like a binary
string where each pair of hex digits is converted to a character:
@example
-mysql> SELECT x'FF'
- -> 255
mysql> SELECT 0xa+0;
-> 10
mysql> select 0x5061756c;
-> Paul
@end example
-The x'hexstring' syntax (new in 4.0) is based on ANSI SQL and the 0x
-syntax is based on ODBC.
Hexadecimal strings are often used by ODBC to give values for BLOB columns.
+
+@node NULL values, , Hexadecimal values, Literals
+@subsubsection @code{NULL} Values
+
@tindex NULL value
-@node NULL values, Legal names, Hexadecimal values, Literals
-@subsection @code{NULL} Values
The @code{NULL} value means ``no data'' and is different from values such
as @code{0} for numeric types or the empty string for string types.
@@ -14410,6 +27480,10 @@ as @code{0} for numeric types or the empty string for string types.
or export formats (@code{LOAD DATA INFILE}, @code{SELECT ... INTO OUTFILE}).
@xref{LOAD DATA, , @code{LOAD DATA}}.
+
+@node Legal names, Name case sensitivity, Literals, Language Structure
+@subsection Database, Table, Index, Column, and Alias Names
+
@cindex names
@cindex legal names
@cindex databases, names
@@ -14417,21 +27491,20 @@ or export formats (@code{LOAD DATA INFILE}, @code{SELECT ... INTO OUTFILE}).
@cindex indexes, names
@cindex columns, names
@cindex aliases, names
-@node Legal names, , NULL values, Literals
-@subsection Database, Table, Index, Column, and Alias Names
@menu
* Name case sensitivity:: Case sensitivity in names
@end menu
+
Database, table, index, column, and alias names all follow the same rules in
-@strong{MySQL}.
+MySQL.
@tindex identifiers, quoting
@tindex quoting of identifiers
@tindex `
@tindex "
-Note that the rules changed starting with @strong{MySQL} Version 3.23.6 when we
+Note that the rules changed starting with MySQL Version 3.23.6 when we
introduced quoting of identifiers (database, table, and column names)
with @samp{`}. @samp{"} will also work to quote identifiers if you run
in ANSI mode. @xref{ANSI mode}.
@@ -14454,7 +27527,7 @@ you must always quote it with @code{`} when you use it:
SELECT * from `select` where `select`.id > 100;
@end example
-In previous versions of @strong{MySQL}, the name rules are as follows:
+In previous versions of MySQL, the name rules are as follows:
@itemize @bullet
@item
@@ -14478,7 +27551,7 @@ It is recommended that you do not use names like @code{1e}, because
an expression like @code{1e+1} is ambiguous. It may be interpreted as the
expression @code{1e + 1} or as the number @code{1e+1}.
-In @strong{MySQL} you can refer to a column using any of the following forms:
+In MySQL you can refer to a column using any of the following forms:
@multitable @columnfractions .35 .65
@item @strong{Column reference} @tab @strong{Meaning}
@@ -14488,7 +27561,7 @@ from whichever table used in the query contains a column of that name.
@code{tbl_name} of the current database.
@item @code{db_name.tbl_name.col_name} @tab Column @code{col_name} from table
@code{tbl_name} of the database @code{db_name}. This form is available in
-@strong{MySQL} Version 3.22 or later.
+MySQL Version 3.22 or later.
@item
@code{`column_name`} @tab A column that is a keyword or contains special characters.
@end multitable
@@ -14510,16 +27583,18 @@ The syntax @code{.tbl_name} means the table @code{tbl_name} in the current
database. This syntax is accepted for ODBC compatibility, because some ODBC
programs prefix table names with a @samp{.} character.
+
+@node Name case sensitivity, Variables, Legal names, Language Structure
+@subsection Case Sensitivity in Names
+
@cindex names, case-sensitivity
@cindex case-sensitivity, in names
-@node Name case sensitivity, , Legal names, Legal names
-@subsubsection Case Sensitivity in Names
@cindex database names, case sensitivity
@cindex table names, case sensitivity
@cindex column names, case sensitivity
@cindex alias names, case sensitivity
-In @strong{MySQL}, databases and tables correspond to directories and files
+In 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
@@ -14554,18 +27629,20 @@ One way to avoid this problem is to start @code{mysqld} with @code{-O
lower_case_table_names=1}. By default this option is 1 on Windows and 0 on
Unix.
-If @code{lower_case_table_names} is 1 @strong{MySQL} will convert all
+If @code{lower_case_table_names} is 1 MySQL will convert all
table names to lower case on storage and lookup. Note that if you
change this option, you need to first convert your old table names to
lower case before starting @code{mysqld}.
+
+@node Variables, Comments, Name case sensitivity, Language Structure
+@subsection User Variables
+
@cindex variables, user
@cindex user variables
@cindex names, variables
-@node Variables, Column types, Literals, Reference
-@section User Variables
-@strong{MySQL} supports thread-specific variables with the
+MySQL supports thread-specific variables with the
@code{@@variablename} syntax. A variable name may consist of
alphanumeric characters from the current character set and also
@samp{_}, @samp{$}, and @samp{.} . The default character set is
@@ -14617,12 +27694,185 @@ SELECT (@@aa:=id) AS a, (@@aa+3) AS b FROM table_name HAVING b=5;
The reason is that @code{@@aa} will not contain the value of the current
row, but the value of @code{id} for the previous accepted row.
+
+@menu
+* Comments:: Comment Syntax
+* Reserved words:: Is MySQL Picky About Reserved Words?
+@end menu
+
+@node Comments, Reserved words, Variables, Language Structure
+@subsection Comment Syntax
+
+@findex Comment syntax
+
+@cindex comments, adding
+
+The MySQL server supports the @code{# to end of line}, @code{--
+to end of line} and @code{/* in-line or multiple-line */} comment
+styles:
+
+@example
+mysql> select 1+1; # This comment continues to the end of line
+mysql> select 1+1; -- This comment continues to the end of line
+mysql> select 1 /* this is an in-line comment */ + 1;
+mysql> select 1+
+/*
+this is a
+multiple-line comment
+*/
+1;
+@end example
+
+Note that the @code{--} comment style requires you to have at least one space
+after the @code{--}!
+
+Although the server understands the comment syntax just described,
+there are some limitations on the way that the @code{mysql} client
+parses @code{/* ... */} comments:
+
+@itemize @bullet
+@item
+Single-quote and double-quote characters are taken to indicate the beginning
+of a quoted string, even within a comment. If the quote is not matched by a
+second quote within the comment, the parser doesn't realize the comment has
+ended. If you are running @code{mysql} interactively, you can tell that it
+has gotten confused like this because the prompt changes from @code{mysql>}
+to @code{'>} or @code{">}.
+
+@item
+A semicolon is taken to indicate the end of the current SQL statement
+and anything following it to indicate the beginning of the next statement.
+@end itemize
+
+These limitations apply both when you run @code{mysql} interactively
+and when you put commands in a file and tell @code{mysql} to read its
+input from that file with @code{mysql < some-file}.
+
+MySQL doesn't support the @samp{--} ANSI SQL comment style.
+@xref{Missing comments}.
+
+
+@node Reserved words, , Comments, Language Structure
+@subsection Is MySQL Picky About Reserved Words?
+
+@cindex keywords
+@cindex reserved words, exceptions
+
+A common problem stems from trying to create a table with column names that
+use the names of datatypes or functions built into MySQL, such as
+@code{TIMESTAMP} or @code{GROUP}. You're allowed to do it (for example,
+@code{ABS} is an allowed column name), but whitespace is not allowed between
+a function name and the @samp{(} when using functions whose names are also
+column names.
+
+The following words are explicitly reserved in MySQL. Most of
+them are forbidden by ANSI SQL92 as column and/or table names
+(for example, @code{group}).
+A few are reserved because MySQL needs them and is
+(currently) using a @code{yacc} parser:
+
+@c This is fixed by including the symbols table from lex.h here and then running
+@c fix-mysql-reserved-words in emacs (or let David do it):
+@c (defun fix-mysql-reserved-words ()
+@c (interactive)
+@c (let ((cnt 0))
+@c (insert "\n@item ")
+@c (while (looking-at "[ \t]*{ +\"\\([^\"]+\\)\"[ \t]*,.*\n")
+@c (replace-match "@code{\\1}")
+@c (incf cnt)
+@c (if (> cnt 3)
+@c (progn
+@c (setf cnt 0)
+@c (insert "\n@item "))
+@c (insert " @tab ")))))
+@c But remove the non alphanumeric entries by hand first.
+@c Updated after 3.23.4 990928 by David
+
+@multitable @columnfractions .25 .25 .25 .25
+@item @code{action} @tab @code{add} @tab @code{aggregate} @tab @code{all}
+@item @code{alter} @tab @code{after} @tab @code{and} @tab @code{as}
+@item @code{asc} @tab @code{avg} @tab @code{avg_row_length} @tab @code{auto_increment}
+@item @code{between} @tab @code{bigint} @tab @code{bit} @tab @code{binary}
+@item @code{blob} @tab @code{bool} @tab @code{both} @tab @code{by}
+@item @code{cascade} @tab @code{case} @tab @code{char} @tab @code{character}
+@item @code{change} @tab @code{check} @tab @code{checksum} @tab @code{column}
+@item @code{columns} @tab @code{comment} @tab @code{constraint} @tab @code{create}
+@item @code{cross} @tab @code{current_date} @tab @code{current_time} @tab @code{current_timestamp}
+@item @code{data} @tab @code{database} @tab @code{databases} @tab @code{date}
+@item @code{datetime} @tab @code{day} @tab @code{day_hour} @tab @code{day_minute}
+@item @code{day_second} @tab @code{dayofmonth} @tab @code{dayofweek} @tab @code{dayofyear}
+@item @code{dec} @tab @code{decimal} @tab @code{default} @tab @code{delayed}
+@item @code{delay_key_write} @tab @code{delete} @tab @code{desc} @tab @code{describe}
+@item @code{distinct} @tab @code{distinctrow} @tab @code{double} @tab @code{drop}
+@item @code{end} @tab @code{else} @tab @code{escape} @tab @code{escaped}
+@item @code{enclosed} @tab @code{enum} @tab @code{explain} @tab @code{exists}
+@item @code{fields} @tab @code{file} @tab @code{first} @tab @code{float}
+@item @code{float4} @tab @code{float8} @tab @code{flush} @tab @code{foreign}
+@item @code{from} @tab @code{for} @tab @code{full} @tab @code{function}
+@item @code{global} @tab @code{grant} @tab @code{grants} @tab @code{group}
+@item @code{having} @tab @code{heap} @tab @code{high_priority} @tab @code{hour}
+@item @code{hour_minute} @tab @code{hour_second} @tab @code{hosts} @tab @code{identified}
+@item @code{ignore} @tab @code{in} @tab @code{index} @tab @code{infile}
+@item @code{inner} @tab @code{insert} @tab @code{insert_id} @tab @code{int}
+@item @code{integer} @tab @code{interval} @tab @code{int1} @tab @code{int2}
+@item @code{int3} @tab @code{int4} @tab @code{int8} @tab @code{into}
+@item @code{if} @tab @code{is} @tab @code{isam} @tab @code{join}
+@item @code{key} @tab @code{keys} @tab @code{kill} @tab @code{last_insert_id}
+@item @code{leading} @tab @code{left} @tab @code{length} @tab @code{like}
+@item @code{lines} @tab @code{limit} @tab @code{load} @tab @code{local}
+@item @code{lock} @tab @code{logs} @tab @code{long} @tab @code{longblob}
+@item @code{longtext} @tab @code{low_priority} @tab @code{max} @tab @code{max_rows}
+@item @code{match} @tab @code{mediumblob} @tab @code{mediumtext} @tab @code{mediumint}
+@item @code{middleint} @tab @code{min_rows} @tab @code{minute} @tab @code{minute_second}
+@item @code{modify} @tab @code{month} @tab @code{monthname} @tab @code{myisam}
+@item @code{natural} @tab @code{numeric} @tab @code{no} @tab @code{not}
+@item @code{null} @tab @code{on} @tab @code{optimize} @tab @code{option}
+@item @code{optionally} @tab @code{or} @tab @code{order} @tab @code{outer}
+@item @code{outfile} @tab @code{pack_keys} @tab @code{partial} @tab @code{password}
+@item @code{precision} @tab @code{primary} @tab @code{procedure} @tab @code{process}
+@item @code{processlist} @tab @code{privileges} @tab @code{read} @tab @code{real}
+@item @code{references} @tab @code{reload} @tab @code{regexp} @tab @code{rename}
+@item @code{replace} @tab @code{restrict} @tab @code{returns} @tab @code{revoke}
+@item @code{rlike} @tab @code{row} @tab @code{rows} @tab @code{second}
+@item @code{select} @tab @code{set} @tab @code{show} @tab @code{shutdown}
+@item @code{smallint} @tab @code{soname} @tab @code{sql_big_tables} @tab @code{sql_big_selects}
+@item @code{sql_low_priority_updates} @tab @code{sql_log_off} @tab @code{sql_log_update} @tab @code{sql_select_limit}
+@item @code{sql_small_result} @tab @code{sql_big_result} @tab @code{sql_warnings} @tab @code{straight_join}
+@item @code{starting} @tab @code{status} @tab @code{string} @tab @code{table}
+@item @code{tables} @tab @code{temporary} @tab @code{terminated} @tab @code{text}
+@item @code{then} @tab @code{time} @tab @code{timestamp} @tab @code{tinyblob}
+@item @code{tinytext} @tab @code{tinyint} @tab @code{trailing} @tab @code{to}
+@item @code{type} @tab @code{use} @tab @code{using} @tab @code{unique}
+@item @code{unlock} @tab @code{unsigned} @tab @code{update} @tab @code{usage}
+@item @code{values} @tab @code{varchar} @tab @code{variables} @tab @code{varying}
+@item @code{varbinary} @tab @code{with} @tab @code{write} @tab @code{when}
+@item @code{where} @tab @code{year} @tab @code{year_month} @tab @code{zerofill}
+@end multitable
+
+The following symbols (from the table above) are disallowed by ANSI SQL
+but allowed by MySQL as column/table names. This is because some
+of these names are very natural names and a lot of people have already
+used them.
+
+@itemize @bullet
+@item @code{ACTION}
+@item @code{BIT}
+@item @code{DATE}
+@item @code{ENUM}
+@item @code{NO}
+@item @code{TEXT}
+@item @code{TIME}
+@item @code{TIMESTAMP}
+@end itemize
+
+
+@node Column types, Functions, Language Structure, Reference
+@section Column Types
+
@cindex columns, types
@cindex types, columns
-@node Column types, Functions, Variables, Reference
-@section Column Types
-@strong{MySQL} supports a number of column types, which may be grouped into
+MySQL supports a number of column types, which may be grouped into
three categories: numeric types, date and time types, and string (character)
types. This section first gives an overview of the types available and
summarizes the storage requirements for each column type, then provides a
@@ -14631,7 +27881,7 @@ The overview is intentionally brief. The more detailed descriptions should
be consulted for additional information about particular column types, such
as the allowable formats in which you can specify values.
-The column types supported by @strong{MySQL} are listed below.
+The column types supported by MySQL are listed below.
The following code letters are used in the descriptions:
@cindex display size
@@ -14658,7 +27908,7 @@ that are optional.
@c The @w{-number} stuff keeps a linebreak from occurring between
@c the - and number.
-Note that if you specify @code{ZEROFILL} for a column, @strong{MySQL} will
+Note that if you specify @code{ZEROFILL} for a column, MySQL will
automatically add the @code{UNSIGNED} attribute to the column.
@table @code
@@ -14732,11 +27982,11 @@ the @code{FLOAT} and @code{DOUBLE} types described immediately below.
@code{FLOAT(X)} has the same range as the corresponding @code{FLOAT} and
@code{DOUBLE} types, but the display size and number of decimals is undefined.
-In @strong{MySQL} Version 3.23, this is a true floating-point value. In
-earlier @strong{MySQL} versions, @code{FLOAT(precision)} always has 2 decimals.
+In MySQL Version 3.23, this is a true floating-point value. In
+earlier MySQL versions, @code{FLOAT(precision)} always has 2 decimals.
Note that using @code{FLOAT} may give you some unexpected problems as
-all calculation in @strong{MySQL} is done with double precision.
+all calculation in MySQL is done with double precision.
@xref{No matching rows}.
@cindex ODBC compatibility
@@ -14788,7 +28038,7 @@ the same as for @code{DOUBLE}, but the actual range for a given
If @code{D} is left out it's set to 0. If @code{M} is left out it's set to 10.
-Note that in @strong{MySQL} Version 3.22 the @code{M} argument had to
+Note that in MySQL Version 3.22 the @code{M} argument had to
includes the space needed for the sign and the decimal point.
@tindex NUMERIC
@@ -14800,7 +28050,7 @@ This is a synonym for @code{DECIMAL}.
@item DATE
A date. The supported range is @code{'1000-01-01'} to @code{'9999-12-31'}.
-@strong{MySQL} displays @code{DATE} values in @code{'YYYY-MM-DD'} format, but
+MySQL displays @code{DATE} values in @code{'YYYY-MM-DD'} format, but
allows you to assign values to @code{DATE} columns using either strings or
numbers. @xref{DATETIME}.
@@ -14808,7 +28058,7 @@ numbers. @xref{DATETIME}.
@item DATETIME
A date and time combination. The supported range is @code{'1000-01-01
-00:00:00'} to @code{'9999-12-31 23:59:59'}. @strong{MySQL} displays
+00:00:00'} to @code{'9999-12-31 23:59:59'}. MySQL displays
@code{DATETIME} values in @code{'YYYY-MM-DD HH:MM:SS'} format, but allows you
to assign values to @code{DATETIME} columns using either strings or numbers.
@xref{DATETIME}.
@@ -14817,7 +28067,7 @@ to assign values to @code{DATETIME} columns using either strings or numbers.
@item TIMESTAMP[(M)]
A timestamp. The range is @code{'1970-01-01 00:00:00'} to sometime in the
-year @code{2037}. @strong{MySQL} displays @code{TIMESTAMP} values in
+year @code{2037}. MySQL displays @code{TIMESTAMP} values in
@code{YYYYMMDDHHMMSS}, @code{YYMMDDHHMMSS}, @code{YYYYMMDD}, or @code{YYMMDD}
format, depending on whether @code{M} is @code{14} (or missing), @code{12},
@code{8}, or @code{6}, but allows you to assign values to @code{TIMESTAMP}
@@ -14841,7 +28091,7 @@ the table with these types!
@item TIME
A time. The range is @code{'-838:59:59'} to @code{'838:59:59'}.
-@strong{MySQL} displays @code{TIME} values in @code{'HH:MM:SS'} format, but
+MySQL displays @code{TIME} values in @code{'HH:MM:SS'} format, but
allows you to assign values to @code{TIME} columns using either strings or
numbers. @xref{TIME}.
@@ -14850,10 +28100,10 @@ numbers. @xref{TIME}.
A year in 2- or 4-digit format (default is 4-digit). The allowable values
are @code{1901} to @code{2155}, @code{0000} in the 4-digit year format,
-and 1970-2069 if you use the 2-digit format (70-69). @strong{MySQL} displays
+and 1970-2069 if you use the 2-digit format (70-69). MySQL displays
@code{YEAR} values in @code{YYYY} format, but allows you to assign values to
@code{YEAR} columns using either strings or numbers. (The @code{YEAR} type is
-new in @strong{MySQL} Version 3.22.). @xref{YEAR}.
+new in MySQL Version 3.22.). @xref{YEAR}.
@tindex NATIONAL CHAR
@tindex NCHAR
@@ -14869,11 +28119,11 @@ default character set unless the @code{BINARY} keyword is given.
@code{NATIONAL CHAR} (short form @code{NCHAR}) is the ANSI SQL way to
define that a CHAR column should use the default CHARACTER set. This is
-the default in @strong{MySQL}.
+the default in MySQL.
@code{CHAR} is a shorthand for @code{CHARACTER}.
-@strong{MySQL} allows you to create a column of type
+MySQL allows you to create a column of type
@code{CHAR(0)}. This is mainly useful when you have to be compliant with
some old applications that depend on the existence of a column but that do not
actually use the value. This is also quite nice when you need a
@@ -14947,121 +28197,19 @@ be chosen from the list of values @code{'value1'}, @code{'value2'},
@end table
@menu
-* Storage requirements:: Column type storage requirements
* Numeric types:: Numeric types
* Date and time types:: Date and time types
* String types:: String types
* Choosing types:: Choosing the right type for a column
-* Indexes:: Column indexes
-* Multiple-column indexes:: Multiple-column indexes
* Other-vendor column types:: Using column types from other database engines
+* Storage requirements:: Column type storage requirements
@end menu
-@cindex storage requirements, column type
-@cindex columns, storage requirements
-
-@node Storage requirements, Numeric types, Column types, Column types
-@subsection Column Type Storage Requirements
-
-The storage requirements for each of the column types supported by
-@strong{MySQL} are listed below by category.
-
-@cindex numeric types
-@cindex types, numeric
-
-@subsubheading Storage requirements for numeric types
-
-@multitable @columnfractions .5 .5
-@item @strong{Column type} @tab @strong{Storage required}
-@item @code{TINYINT} @tab 1 byte
-@item @code{SMALLINT} @tab 2 bytes
-@item @code{MEDIUMINT} @tab 3 bytes
-@item @code{INT} @tab 4 bytes
-@item @code{INTEGER} @tab 4 bytes
-@item @code{BIGINT} @tab 8 bytes
-@item @code{FLOAT(X)} @tab 4 if X <= 24 or 8 if 25 <= X <= 53
-@item @code{FLOAT} @tab 4 bytes
-@item @code{DOUBLE} @tab 8 bytes
-@item @code{DOUBLE PRECISION} @tab 8 bytes
-@item @code{REAL} @tab 8 bytes
-@item @code{DECIMAL(M,D)} @tab @code{M+2} bytes if D > 0, @code{M+1} bytes if D = 0 (@code{D}+2, if @code{M < D})
-@item @code{NUMERIC(M,D)} @tab @code{M+2} bytes if D > 0, @code{M+1} bytes if D = 0 (@code{D}+2, if @code{M < D})
-@end multitable
-
-@cindex date types
-@cindex time types
-@cindex types, date
-@cindex types, time
-
-@subsubheading Storage requirements for date and time types
-
-@multitable @columnfractions .5 .5
-@item @strong{Column type} @tab @strong{Storage required}
-@item @code{DATE} @tab 3 bytes
-@item @code{DATETIME} @tab 8 bytes
-@item @code{TIMESTAMP} @tab 4 bytes
-@item @code{TIME} @tab 3 bytes
-@item @code{YEAR} @tab 1 byte
-@end multitable
-
-@subsubheading Storage requirements for string types
-
-@multitable @columnfractions .5 .5
-@item @strong{Column type} @tab @strong{Storage required}
-@item @code{CHAR(M)} @tab @code{M} bytes, @code{1 <= M <= 255}
-@item @code{VARCHAR(M)} @tab @code{L}+1 bytes, where @code{L <= M} and
-@code{1 <= M <= 255}
-@item @code{TINYBLOB}, @code{TINYTEXT} @tab @code{L}+1 bytes,
-where @code{L} < 2^8
-@item @code{BLOB}, @code{TEXT} @tab @code{L}+2 bytes,
-where @code{L} < 2^16
-@item @code{MEDIUMBLOB}, @code{MEDIUMTEXT} @tab @code{L}+3 bytes,
-where @code{L} < 2^24
-@item @code{LONGBLOB}, @code{LONGTEXT} @tab @code{L}+4 bytes,
-where @code{L} < 2^32
-@item @code{ENUM('value1','value2',...)} @tab 1 or 2 bytes, depending on
-the number of enumeration values (65535 values maximum)
-@item @code{SET('value1','value2',...)} @tab 1, 2, 3, 4 or 8 bytes, depending
-on the number of set members (64 members maximum)
-@end multitable
-
-@cindex BLOB, size
-@cindex TEXT, size
-@cindex VARCHAR, size
-@code{VARCHAR} and the @code{BLOB} and @code{TEXT} types are variable-length
-types, for which the storage requirements depend on the actual length of
-column values (represented by @code{L} in the preceding table), rather than
-on the type's maximum possible size. For example, a @code{VARCHAR(10)}
-column can hold a string with a maximum length of 10 characters. The actual
-storage required is the length of the string (@code{L}), plus 1 byte to
-record the length of the string. For the string @code{'abcd'}, @code{L} is 4
-and the storage requirement is 5 bytes.
-
-The @code{BLOB} and @code{TEXT} types require 1, 2, 3, or 4 bytes to record
-the length of the column value, depending on the maximum possible length of
-the type. @xref{BLOB}.
-
-If a table includes any variable-length column types, the record format will
-also be variable-length. Note that when a table is created, @strong{MySQL}
-may, under certain conditions, change a column from a variable-length type to a
-fixed-length type, or vice-versa. @xref{Silent column changes}.
-
-@cindex ENUM, size
-The size of an @code{ENUM} object is determined by the number of
-different enumeration values. One byte is used for enumerations with up
-to 255 possible values. Two bytes are used for enumerations with up to
-65535 values. @xref{ENUM}.
-
-@cindex SET, size
-The size of a @code{SET} object is determined by the number of different
-set members. If the set size is @code{N}, the object occupies @code{(N+7)/8}
-bytes, rounded up to 1, 2, 3, 4, or 8 bytes. A @code{SET} can have a maximum
-of 64 members. @xref{SET}.
-@node Numeric types, Date and time types, Storage requirements, Column types
+@node Numeric types, Date and time types, Column types, Column types
@subsection Numeric Types
-@strong{MySQL} supports all of the ANSI/ISO SQL92 numeric types. These
+MySQL supports all of the ANSI/ISO SQL92 numeric types. These
types include the exact numeric data types (@code{NUMERIC},
@code{DECIMAL}, @code{INTEGER}, and @code{SMALLINT}), as well as the
approximate numeric data types (@code{FLOAT}, @code{REAL}, and
@@ -15070,7 +28218,7 @@ approximate numeric data types (@code{FLOAT}, @code{REAL}, and
@code{DECIMAL}.
The @code{NUMERIC} and @code{DECIMAL} types are implemented as the same
-type by @strong{MySQL}, as permitted by the SQL92 standard. They are
+type by MySQL, as permitted by the SQL92 standard. They are
used for values for which it is important to preserve exact precision,
for example with monetary data. When declaring a column of one of these
types the precision and scale can be (and usually is) specified; for
@@ -15085,11 +28233,11 @@ significant decimal digits that will be stored for values, and
@code{2} (@code{scale}) represents the number of digits that will be
stored following the decimal point. In this case, therefore, the range
of values that can be stored in the @code{salary} column is from
-@code{-9999999.99} to @code{9999999.99}. In ANSI/ISO SQL92, the syntax
+@code{-999999.99} to @code{9999999.99}. In ANSI/ISO SQL92, the syntax
@code{DECIMAL(p)} is equivalent to @code{DECIMAL(p,0)}. Similarly, the
syntax @code{DECIMAL} is equivalent to @code{DECIMAL(p,0)}, where the
implementation is allowed to decide the value of @code{p}.
-@strong{MySQL} does not currently support either of these variant forms
+MySQL does not currently support either of these variant forms
of the @code{DECIMAL}/@code{NUMERIC} data types. This is not generally
a serious problem, as the principal benefits of these types derive from
the ability to control both precision and scale explicitly.
@@ -15110,13 +28258,13 @@ are allowed by the specified @code{scale}, the value is rounded to that
@code{scale}. When a @code{DECIMAL} or @code{NUMERIC} column is
assigned a value whose magnitude exceeds the range implied by the
specified (or defaulted) @code{precision} and @code{scale},
-@strong{MySQL} stores the value representing the corresponding end
+MySQL stores the value representing the corresponding end
point of that range.
-As an extension to the ANSI/ISO SQL92 standard, @strong{MySQL} also
+As an extension to the ANSI/ISO SQL92 standard, MySQL also
supports the integral types @code{TINYINT}, @code{MEDIUMINT}, and
@code{BIGINT} as listed in the tables above. Another extension is
-supported by @strong{MySQL} for optionally specifying the display width
+supported by MySQL for optionally specifying the display width
of an integral value in parentheses following the base keyword for the
type (for example, @code{INT(4)}). This optional width specification is
used to left-pad the display of values whose width is less than the
@@ -15128,8 +28276,8 @@ column. When used in conjunction with the optional extension attribute
For example, for a column declared as @code{INT(5) ZEROFILL}, a value
of @code{4} is retrieved as @code{00004}. Note that if you store larger
values than the display width in an integer column, you may experience
-problems when @strong{MySQL} generates temporary tables for some
-complicated joins, as in these cases @strong{MySQL} trusts that the
+problems when MySQL generates temporary tables for some
+complicated joins, as in these cases MySQL trusts that the
data did fit into the original column width.
All integral types can have an optional (non-standard) attribute
@@ -15140,33 +28288,33 @@ range for the column.
The @code{FLOAT} type is used to represent approximate numeric data
types. The ANSI/ISO SQL92 standard allows an optional specification of
the precision (but not the range of the exponent) in bits following the
-keyword @code{FLOAT} in parentheses. The @strong{MySQL} implementation
+keyword @code{FLOAT} in parentheses. The MySQL implementation
also supports this optional precision specification. When the keyword
@code{FLOAT} is used for a column type without a precision
-specification, @strong{MySQL} uses four bytes to store the values. A
+specification, MySQL uses four bytes to store the values. A
variant syntax is also supported, with two numbers given in parentheses
following the @code{FLOAT} keyword. With this option, the first number
continues to represent the storage requirements for the value in bytes,
and the second number specifies the number of digits to be stored and
displayed following the decimal point (as with @code{DECIMAL} and
-@code{NUMERIC}). When @strong{MySQL} is asked to store a number for
+@code{NUMERIC}). When MySQL is asked to store a number for
such a column with more decimal digits following the decimal point than
specified for the column, the value is rounded to eliminate the extra
digits when the value is stored.
The @code{REAL} and @code{DOUBLE PRECISION} types do not accept
precision specifications. As an extension to the ANSI/ISO SQL92
-standard, @strong{MySQL} recognizes @code{DOUBLE} as a synonym for the
+standard, MySQL recognizes @code{DOUBLE} as a synonym for the
@code{DOUBLE PRECISION} type. In contrast with the standard's
requirement that the precision for @code{REAL} be smaller than that used
-for @code{DOUBLE PRECISION}, @strong{MySQL} implements both as 8-byte
+for @code{DOUBLE PRECISION}, MySQL implements both as 8-byte
double-precision floating-point values (when not running in ``ANSI mode'').
For maximum portability, code requiring storage of approximate numeric
data values should use @code{FLOAT} or @code{DOUBLE PRECISION} with no
specification of precision or number of decimal points.
When asked to store a value in a numeric column that is outside the column
-type's allowable range, @strong{MySQL} clips the value to the appropriate
+type's allowable range, MySQL clips the value to the appropriate
endpoint of the range and stores the resulting value instead.
For example, the range of an @code{INT} column is @code{-2147483648} to
@@ -15184,11 +28332,13 @@ Conversions that occur due to clipping are reported as ``warnings'' for
@code{ALTER TABLE}, @code{LOAD DATA INFILE}, @code{UPDATE}, and
multi-row @code{INSERT} statements.
-@cindex types, Date and Time
-@cindex Date and Time types
+
@node Date and time types, String types, Numeric types, Column types
@subsection Date and Time Types
+@cindex types, Date and Time
+@cindex Date and Time types
+
@menu
* Y2K issues:: Y2K issues and date types
* DATETIME:: The @code{DATETIME}, @code{DATE} and @code{TIMESTAMP} types
@@ -15196,16 +28346,17 @@ multi-row @code{INSERT} statements.
* YEAR:: The @code{YEAR} type
@end menu
+
The date and time types are @code{DATETIME}, @code{DATE},
@code{TIMESTAMP}, @code{TIME}, and @code{YEAR}. Each of these has a
range of legal values, as well as a ``zero'' value that is used when you
-specify a really illegal value. Note that @strong{MySQL} allows you to store
+specify a really illegal value. Note that MySQL allows you to store
certain 'not strictly' legal date values, for example @code{1999-11-31}.
The reason for this is that we think it's the responsibility of the
application to handle date checking, not the SQL servers. To make the
-date checking 'fast', @strong{MySQL} only checks that the month is in
+date checking 'fast', MySQL only checks that the month is in
the range of 0-12 and the day is in the range of 0-31. The above ranges
-are defined this way because @strong{MySQL} allows you to store, in a
+are defined this way because MySQL allows you to store, in a
@code{DATE} or @code{DATETIME} column, dates where the day or month-day
is zero. This is extremely useful for applications that need to store
a birth-date for which you don't know the exact date. In this case you
@@ -15218,7 +28369,7 @@ with date and time types:
@itemize @bullet
@item
-@strong{MySQL} retrieves values for a given date or time type in a standard
+MySQL retrieves values for a given date or time type in a standard
format, but it attempts to interpret a variety of formats for values that
you supply (for example, when you specify a value to be assigned to or
compared to a date or time type). Nevertheless, only the formats described
@@ -15227,18 +28378,18 @@ legal values, and unpredictable results may occur if you use values in other
formats.
@item
-Although @strong{MySQL} tries to interpret values in several formats, it
+Although MySQL tries to interpret values in several formats, it
always expects the year part of date values to be leftmost. Dates must be
given in year-month-day order (for example, @code{'98-09-04'}), rather than
in the month-day-year or day-month-year orders commonly used elsewhere (for
example, @code{'09-04-98'}, @code{'04-09-98'}).
@item
-@strong{MySQL} automatically converts a date or time type value to a number
+MySQL automatically converts a date or time type value to a number
if the value is used in a numeric context, and vice versa.
@item
-When @strong{MySQL} encounters a value for a date or time type that is
+When MySQL encounters a value for a date or time type that is
out of range or otherwise illegal for the type (see the start of this
section), it converts the value to the ``zero'' value for that type.
(The exception is that out-of-range @code{TIME} values are clipped to
@@ -15265,19 +28416,21 @@ automatically to @code{NULL} in @strong{MyODBC} Version 2.50.12 and above,
because ODBC can't handle such values.
@end itemize
-@cindex Year 2000 issues
-@cindex date types, Y2K issues
+
@node Y2K issues, DATETIME, Date and time types, Date and time types
@subsubsection Y2K Issues and Date Types
-@strong{MySQL} itself is Y2K-safe (@pxref{Year 2000 compliance}),
-but input values presented to @strong{MySQL} may not be. Any input
+@cindex Year 2000 issues
+@cindex date types, Y2K issues
+
+MySQL itself is Y2K-safe (@pxref{Year 2000 compliance}),
+but input values presented to MySQL may not be. Any input
containing 2-digit year values is ambiguous, because the century is unknown.
-Such values must be interpreted into 4-digit form because @strong{MySQL} stores
+Such values must be interpreted into 4-digit form because MySQL stores
years internally using four digits.
For @code{DATETIME}, @code{DATE}, @code{TIMESTAMP}, and @code{YEAR} types,
-@strong{MySQL} interprets dates with ambiguous year values using the
+MySQL interprets dates with ambiguous year values using the
following rules:
@itemize @bullet
@@ -15289,7 +28442,7 @@ Year values in the range @code{70-99} are converted to @code{1970-1999}.
@end itemize
Remember that these rules provide only reasonable guesses as to what your
-data mean. If the heuristics used by @strong{MySQL} don't produce the
+data mean. If the heuristics used by MySQL don't produce the
correct values, you should provide unambiguous input containing 4-digit
year values.
@@ -15301,25 +28454,27 @@ Note also that some functions like @code{MIN()} and @code{MAX()} will convert a
case is to convert the @code{TIMESTAMP/DATE} to 4-digit year format or
use something like @code{MIN(DATE_ADD(timestamp,INTERVAL 0 DAYS))}.
+
+@node DATETIME, TIME, Y2K issues, Date and time types
+@subsubsection The @code{DATETIME}, @code{DATE}, and @code{TIMESTAMP} Types
+
@tindex DATETIME
@tindex DATE
@tindex TIMESTAMP
-@node DATETIME, TIME, Y2K issues, Date and time types
-@subsubsection The @code{DATETIME}, @code{DATE}, and @code{TIMESTAMP} Types
The @code{DATETIME}, @code{DATE}, and @code{TIMESTAMP} types are related.
This section describes their characteristics, how they are similar, and how
they differ.
The @code{DATETIME} type is used when you need values that contain both date
-and time information. @strong{MySQL} retrieves and displays @code{DATETIME}
+and time information. MySQL retrieves and displays @code{DATETIME}
values in @code{'YYYY-MM-DD HH:MM:SS'} format. The supported range is
@code{'1000-01-01 00:00:00'} to @code{'9999-12-31 23:59:59'}. (``Supported''
means that although earlier values might work, there is no guarantee that
they will.)
The @code{DATE} type is used when you need only a date value, without a time
-part. @strong{MySQL} retrieves and displays @code{DATE} values in
+part. MySQL retrieves and displays @code{DATE} values in
@code{'YYYY-MM-DD'} format. The supported range is @code{'1000-01-01'} to
@code{'9999-12-31'}.
@@ -15339,7 +28494,7 @@ The column is not specified explicitly in an @code{INSERT} or
The column is not specified explicitly in an @code{UPDATE} statement and some
other column changes value. (Note that an @code{UPDATE} that sets a column
to the value it already has will not cause the @code{TIMESTAMP} column to be
-updated, because if you set a column to its current value, @strong{MySQL}
+updated, because if you set a column to its current value, MySQL
ignores the update for efficiency.)
@item
You explicitly set the @code{TIMESTAMP} column to @code{NULL}.
@@ -15357,7 +28512,7 @@ later:
@itemize @bullet
@item
-Let @strong{MySQL} set the column when the row is created.
+Let MySQL set the column when the row is created.
This will initialize it to the current date and time.
@item
@@ -15373,7 +28528,7 @@ leave alone for subsequent updates.
the year 2037, with a resolution of one second. Values are displayed as
numbers.
-The format in which @strong{MySQL} retrieves and displays @code{TIMESTAMP}
+The format in which MySQL retrieves and displays @code{TIMESTAMP}
values depends on the display size, as illustrated by the table below. The
`full' @code{TIMESTAMP} format is 14 digits, but @code{TIMESTAMP} columns may
be created with shorter display sizes:
@@ -15474,7 +28629,7 @@ given by the first 2 characters. The string is interpreted from left to
right to find year, month, day, hour, minute, and second values, for as many
parts as are present in the string. This means you should not use strings
that have fewer than 6 characters. For example, if you specify @code{'9903'},
-thinking that will represent March, 1999, you will find that @strong{MySQL}
+thinking that will represent March, 1999, you will find that MySQL
inserts a ``zero'' date into your table. This is because the year and month
values are @code{99} and @code{03}, but the day part is missing (zero), so
the value is not a legal date.
@@ -15550,7 +28705,7 @@ month.
@item
Year values specified as two digits are ambiguous, because the century is
-unknown. @strong{MySQL} interprets 2-digit year values using the following
+unknown. MySQL interprets 2-digit year values using the following
rules:
@itemize @minus
@@ -15562,11 +28717,13 @@ Year values in the range @code{70-99} are converted to @code{1970-1999}.
@end itemize
@end itemize
-@tindex TIME
+
@node TIME, YEAR, DATETIME, Date and time types
@subsubsection The @code{TIME} Type
-@strong{MySQL} retrieves and displays @code{TIME} values in @code{'HH:MM:SS'}
+@tindex TIME
+
+MySQL retrieves and displays @code{TIME} values in @code{'HH:MM:SS'}
format (or @code{'HHH:MM:SS'} format for large hours values). @code{TIME}
values may range from @code{'-838:59:59'} to @code{'838:59:59'}. The reason
the hours part may be so large is that the @code{TIME} type may be used not
@@ -15579,7 +28736,7 @@ You can specify @code{TIME} values in a variety of formats:
@itemize @bullet
@item
As a string in @code{'D HH:MM:SS.fraction'} format. (Note that
-@strong{MySQL} doesn't yet store the fraction for the time column). One
+MySQL doesn't yet store the fraction for the time column). One
can also use one of the following ``relaxed'' syntax:
@code{HH:MM:SS.fraction}, @code{HH:MM:SS}, @code{HH:MM}, @code{D HH:MM:SS},
@@ -15595,7 +28752,7 @@ minute part) and becomes @code{'00:00:00'}.
As a number in @code{HHMMSS} format, provided that it makes sense as a time.
For example, @code{101112} is understood as @code{'10:11:12'}. The following
alternative formats are also understood: @code{SS}, @code{MMSS},@code{HHMMSS},
-@code{HHMMSS.fraction}. Note that @strong{MySQL} doesn't yet store the
+@code{HHMMSS.fraction}. Note that MySQL doesn't yet store the
fraction part.
@item
@@ -15609,12 +28766,12 @@ seconds values that are less than @code{10}. @code{'8:3:2'} is the same as
@code{'08:03:02'}.
Be careful about assigning ``short'' @code{TIME} values to a @code{TIME}
-column. Without semicolon, @strong{MySQL} interprets values using the
-assumption that the rightmost digits represent seconds. (@strong{MySQL}
+column. Without semicolon, MySQL interprets values using the
+assumption that the rightmost digits represent seconds. (MySQL
interprets @code{TIME} values as elapsed time rather than as time of
day.) For example, you might think of @code{'1112'} and @code{1112} as
meaning @code{'11:12:00'} (12 minutes after 11 o'clock), but
-@strong{MySQL} interprets them as @code{'00:11:12'} (11 minutes, 12 seconds).
+MySQL interprets them as @code{'00:11:12'} (11 minutes, 12 seconds).
Similarly, @code{'12'} and @code{12} are interpreted as @code{'00:00:12'}.
@code{TIME} values with semicolon, instead, are always treated as
time of the day. That is @code{'11:12'} will mean @code{'11:12:00'},
@@ -15631,13 +28788,15 @@ because @code{'00:00:00'} is itself a legal @code{TIME} value, there is no way
to tell, from a value of @code{'00:00:00'} stored in a table, whether the
original value was specified as @code{'00:00:00'} or whether it was illegal.
-@tindex YEAR
+
@node YEAR, , TIME, Date and time types
@subsubsection The @code{YEAR} Type
+@tindex YEAR
+
The @code{YEAR} type is a 1-byte type used for representing years.
-@strong{MySQL} retrieves and displays @code{YEAR} values in @code{YYYY}
+MySQL retrieves and displays @code{YEAR} values in @code{YYYY}
format. The range is @code{1901} to @code{2155}.
You can specify @code{YEAR} values in a variety of formats:
@@ -15672,13 +28831,16 @@ in a @code{YEAR} context, such as @code{NOW()}.
Illegal @code{YEAR} values are converted to @code{0000}.
-@cindex types, strings
-@cindex string types
+
@node String types, Choosing types, Date and time types, Column types
@subsection String Types
+@cindex types, strings
+@cindex string types
+
@tindex CHAR
@tindex VARCHAR
+
@menu
* CHAR:: The @code{CHAR} and @code{VARCHAR} types
* BLOB:: The @code{BLOB} and @code{TEXT} types
@@ -15686,10 +28848,12 @@ Illegal @code{YEAR} values are converted to @code{0000}.
* SET:: The @code{SET} type
@end menu
+
The string types are @code{CHAR}, @code{VARCHAR}, @code{BLOB}, @code{TEXT},
@code{ENUM}, and @code{SET}. This section describes how these types work,
their storage requirements, and how to use them in your queries.
+
@node CHAR, BLOB, String types, String types
@subsubsection The @code{CHAR} and @code{VARCHAR} Types
@@ -15698,7 +28862,7 @@ way they are stored and retrieved.
The length of a @code{CHAR} column is fixed to the length that you declare
when you create the table. The length can be any value between 1 and 255.
-(As of @strong{MySQL} Version 3.23, the length of @code{CHAR} may be 0 to 255.)
+(As of MySQL Version 3.23, the length of @code{CHAR} may be 0 to 255.)
When @code{CHAR} values are stored, they are right-padded with spaces to the
specified length. When @code{CHAR} values are retrieved, trailing spaces are
removed.
@@ -15737,7 +28901,7 @@ Values in @code{CHAR} and @code{VARCHAR} columns are sorted and compared
in case-insensitive fashion, unless the @code{BINARY} attribute was
specified when the table was created. The @code{BINARY} attribute means
that column values are sorted and compared in case-sensitive fashion
-according to the ASCII order of the machine where the @strong{MySQL}
+according to the ASCII order of the machine where the MySQL
server is running. @code{BINARY} doesn't affect how the column is stored
or retrieved.
@@ -15745,15 +28909,17 @@ The @code{BINARY} attribute is sticky. This means that if a column marked
@code{BINARY} is used in an expression, the whole expression is compared as a
@code{BINARY} value.
-@strong{MySQL} may silently change the type of a @code{CHAR} or @code{VARCHAR}
+MySQL may silently change the type of a @code{CHAR} or @code{VARCHAR}
column at table creation time.
@xref{Silent column changes}.
-@tindex BLOB
-@tindex TEXT
+
@node BLOB, ENUM, CHAR, String types
@subsubsection The @code{BLOB} and @code{TEXT} Types
+@tindex BLOB
+@tindex TEXT
+
A @code{BLOB} is a binary large object that can hold a variable amount of
data. The four @code{BLOB} types @code{TINYBLOB}, @code{BLOB},
@code{MEDIUMBLOB}, and @code{LONGBLOB} differ only in the maximum length of
@@ -15778,8 +28944,8 @@ column that can be as big as you like. Similarly, you can regard a
@itemize @bullet
@item
You can have indexes on @code{BLOB} and @code{TEXT} columns with
-@strong{MySQL} Version 3.23.2 and newer. Older versions of
-@strong{MySQL} did not support this.
+MySQL Version 3.23.2 and newer. Older versions of
+MySQL did not support this.
@item
There is no trailing-space removal for @code{BLOB} and @code{TEXT} columns
@@ -15836,10 +29002,12 @@ internally by a separately allocated object. This is in contrast to all
other column types, for which storage is allocated once per column when
the table is opened.
-@tindex ENUM
+
@node ENUM, SET, BLOB, String types
@subsubsection The @code{ENUM} Type
+@tindex ENUM
+
An @code{ENUM} is a string object whose value normally is chosen from a list
of allowed values that are enumerated explicitly in the column specification
at table creation time.
@@ -15923,10 +29091,12 @@ If you want to get all possible values for an @code{ENUM} column, you should
use: @code{SHOW COLUMNS FROM table_name LIKE enum_column_name} and parse
the @code{ENUM} definition in the second column.
-@tindex SET
+
@node SET, , ENUM, String types
@subsubsection The @code{SET} Type
+@tindex SET
+
A @code{SET} is a string object that can have zero or more values, each of
which must be chosen from a list of allowed values specified when the table
is created. @code{SET} column values that consist of multiple set members
@@ -15946,7 +29116,7 @@ any of these values:
A @code{SET} can have a maximum of 64 different members.
-@strong{MySQL} stores @code{SET} values numerically, with the low-order bit
+MySQL stores @code{SET} values numerically, with the low-order bit
of the stored value corresponding to the first set member. If you retrieve a
@code{SET} value in a numeric context, the value retrieved has bits set
corresponding to the set members that make up the column value. For example,
@@ -16008,10 +29178,12 @@ If you want to get all possible values for a @code{SET} column, you should
use: @code{SHOW COLUMNS FROM table_name LIKE set_column_name} and parse
the @code{SET} definition in the second column.
+
+@node Choosing types, Other-vendor column types, String types, Column types
+@subsection Choosing the Right Type for a Column
+
@cindex types, columns
@cindex choosing types
-@node Choosing types, Indexes, String types, Column types
-@subsection Choosing the Right Type for a Column
For the most efficient use of storage, try to use the most precise type in
all cases. For example, if an integer column will be used for values in the
@@ -16019,7 +29191,7 @@ range between @code{1} and @code{99999}, @code{MEDIUMINT UNSIGNED} is the
best type.
Accurate representation of monetary values is a common problem. In
-@strong{MySQL}, you should use the @code{DECIMAL} type. This is stored as
+MySQL, you should use the @code{DECIMAL} type. This is stored as
a string, so no loss of accuracy should occur. If accuracy is not
too important, the @code{DOUBLE} type may also be good enough.
@@ -16027,118 +29199,18 @@ For high precision, you can always convert to a fixed-point type stored
in a @code{BIGINT}. This allows you to do all calculations with integers
and convert results back to floating-point values only when necessary.
-@cindex indexes, columns
-@cindex columns, indexes
-@cindex keys
-@node Indexes, Multiple-column indexes, Choosing types, Column types
-@subsection Column Indexes
-
-All @strong{MySQL} column types can be indexed. Use of indexes on the
-relevant columns is the best way to improve the performance of @code{SELECT}
-operations.
-
-The maximum number of keys and the maximum index length is defined per
-table handler. @xref{Table types}. You can with all table handlers have
-at least 16 keys and a total index length of at least 256 bytes.
-
-For @code{CHAR} and @code{VARCHAR} columns, you can index a prefix of a
-column. This is much faster and requires less disk space than indexing the
-whole column. The syntax to use in the @code{CREATE TABLE} statement to
-index a column prefix looks like this:
-
-@example
-KEY index_name (col_name(length))
-@end example
-
-The example below creates an index for the first 10 characters of the
-@code{name} column:
-
-@example
-mysql> CREATE TABLE test (
- name CHAR(200) NOT NULL,
- KEY index_name (name(10)));
-@end example
-
-For @code{BLOB} and @code{TEXT} columns, you must index a prefix of the
-column. You cannot index the entire column.
-
-In @strong{MySQL} Version 3.23.23 or later, you can also create special
-@strong{FULLTEXT} indexes. They are used for full-text search. Only the
-@code{MyISAM} table type supports @code{FULLTEXT} indexes. They can be
-created only from @code{VARCHAR} and @code{TEXT} columns.
-Indexing always happens over the entire column and partial indexing is not
-supported. See @ref{Fulltext Search} for details.
-
-@cindex multi-column indexes
-@cindex indexes, multi-column
-@cindex keys, multi-column
-@node Multiple-column indexes, Other-vendor column types, Indexes, Column types
-@subsection Multiple-column Indexes
-@strong{MySQL} can create indexes on multiple columns. An index may
-consist of up to 15 columns. (On @code{CHAR} and @code{VARCHAR} columns you
-can also use a prefix of the column as a part of an index).
-
-A multiple-column index can be considered a sorted array containing values
-that are created by concatenating the values of the indexed columns.
-
-@strong{MySQL} uses multiple-column indexes in such a way that queries are
-fast when you specify a known quantity for the first column of the index in a
-@code{WHERE} clause, even if you don't specify values for the other columns.
-
-Suppose a table is created using the following specification:
-
-@example
-mysql> CREATE TABLE test (
- id INT NOT NULL,
- last_name CHAR(30) NOT NULL,
- first_name CHAR(30) NOT NULL,
- PRIMARY KEY (id),
- INDEX name (last_name,first_name));
-@end example
-
-Then the index @code{name} is an index over @code{last_name} and
-@code{first_name}. The index will be used for queries that specify
-values in a known range for @code{last_name}, or for both @code{last_name}
-and @code{first_name}.
-Therefore, the @code{name} index will be used in the following queries:
-
-@example
-mysql> SELECT * FROM test WHERE last_name="Widenius";
-
-mysql> SELECT * FROM test WHERE last_name="Widenius"
- AND first_name="Michael";
-
-mysql> SELECT * FROM test WHERE last_name="Widenius"
- AND (first_name="Michael" OR first_name="Monty");
-
-mysql> SELECT * FROM test WHERE last_name="Widenius"
- AND first_name >="M" AND first_name < "N";
-@end example
-
-However, the @code{name} index will NOT be used in the following queries:
-
-@example
-mysql> SELECT * FROM test WHERE first_name="Michael";
-
-mysql> SELECT * FROM test WHERE last_name="Widenius"
- OR first_name="Michael";
-@end example
-
-For more information on the manner in which @strong{MySQL} uses indexes to
-improve query performance, see @ref{MySQL indexes, , @strong{MySQL}
-indexes}.
+@node Other-vendor column types, Storage requirements, Choosing types, Column types
+@subsection Using Column Types from Other Database Engines
@cindex types, portability
@cindex portability, types
@cindex columns, other types
-@node Other-vendor column types, , Multiple-column indexes, Column types
-@subsection Using Column Types from Other Database Engines
To make it easier to use code written for SQL implementations from other
-vendors, @strong{MySQL} maps column types as shown in the table below. These
+vendors, MySQL maps column types as shown in the table below. These
mappings make it easier to move table definitions from other database engines
-to @strong{MySQL}:
+to MySQL:
@multitable @columnfractions .4 .6
@item @strong{Other vendor type} @tab @strong{MySQL type}
@@ -16159,13 +29231,117 @@ to @strong{MySQL}:
Column type mapping occurs at table creation time. If you create a table
with types used by other vendors and then issue a @code{DESCRIBE tbl_name}
-statement, @strong{MySQL} reports the table structure using the equivalent
-@strong{MySQL} types.
+statement, MySQL reports the table structure using the equivalent
+MySQL types.
-@cindex functions for @code{SELECT} and @code{WHERE} clauses
-@node Functions, CREATE DATABASE, Column types, Reference
+
+@node Storage requirements, , Other-vendor column types, Column types
+@subsection Column Type Storage Requirements
+
+@cindex storage requirements, column type
+@cindex columns, storage requirements
+
+The storage requirements for each of the column types supported by
+MySQL are listed below by category.
+
+@cindex numeric types
+@cindex types, numeric
+
+@subsubheading Storage requirements for numeric types
+
+@multitable @columnfractions .5 .5
+@item @strong{Column type} @tab @strong{Storage required}
+@item @code{TINYINT} @tab 1 byte
+@item @code{SMALLINT} @tab 2 bytes
+@item @code{MEDIUMINT} @tab 3 bytes
+@item @code{INT} @tab 4 bytes
+@item @code{INTEGER} @tab 4 bytes
+@item @code{BIGINT} @tab 8 bytes
+@item @code{FLOAT(X)} @tab 4 if X <= 24 or 8 if 25 <= X <= 53
+@item @code{FLOAT} @tab 4 bytes
+@item @code{DOUBLE} @tab 8 bytes
+@item @code{DOUBLE PRECISION} @tab 8 bytes
+@item @code{REAL} @tab 8 bytes
+@item @code{DECIMAL(M,D)} @tab @code{M+2} bytes if D > 0, @code{M+1} bytes if D = 0 (@code{D}+2, if @code{M < D})
+@item @code{NUMERIC(M,D)} @tab @code{M+2} bytes if D > 0, @code{M+1} bytes if D = 0 (@code{D}+2, if @code{M < D})
+@end multitable
+
+@cindex date types
+@cindex time types
+@cindex types, date
+@cindex types, time
+
+@subsubheading Storage requirements for date and time types
+
+@multitable @columnfractions .5 .5
+@item @strong{Column type} @tab @strong{Storage required}
+@item @code{DATE} @tab 3 bytes
+@item @code{DATETIME} @tab 8 bytes
+@item @code{TIMESTAMP} @tab 4 bytes
+@item @code{TIME} @tab 3 bytes
+@item @code{YEAR} @tab 1 byte
+@end multitable
+
+@subsubheading Storage requirements for string types
+
+@multitable @columnfractions .5 .5
+@item @strong{Column type} @tab @strong{Storage required}
+@item @code{CHAR(M)} @tab @code{M} bytes, @code{1 <= M <= 255}
+@item @code{VARCHAR(M)} @tab @code{L}+1 bytes, where @code{L <= M} and
+@code{1 <= M <= 255}
+@item @code{TINYBLOB}, @code{TINYTEXT} @tab @code{L}+1 bytes,
+where @code{L} < 2^8
+@item @code{BLOB}, @code{TEXT} @tab @code{L}+2 bytes,
+where @code{L} < 2^16
+@item @code{MEDIUMBLOB}, @code{MEDIUMTEXT} @tab @code{L}+3 bytes,
+where @code{L} < 2^24
+@item @code{LONGBLOB}, @code{LONGTEXT} @tab @code{L}+4 bytes,
+where @code{L} < 2^32
+@item @code{ENUM('value1','value2',...)} @tab 1 or 2 bytes, depending on
+the number of enumeration values (65535 values maximum)
+@item @code{SET('value1','value2',...)} @tab 1, 2, 3, 4 or 8 bytes, depending
+on the number of set members (64 members maximum)
+@end multitable
+
+@cindex @code{BLOB}, size
+@cindex @code{TEXT}, size
+@cindex @code{VARCHAR}, size
+@code{VARCHAR} and the @code{BLOB} and @code{TEXT} types are variable-length
+types, for which the storage requirements depend on the actual length of
+column values (represented by @code{L} in the preceding table), rather than
+on the type's maximum possible size. For example, a @code{VARCHAR(10)}
+column can hold a string with a maximum length of 10 characters. The actual
+storage required is the length of the string (@code{L}), plus 1 byte to
+record the length of the string. For the string @code{'abcd'}, @code{L} is 4
+and the storage requirement is 5 bytes.
+
+The @code{BLOB} and @code{TEXT} types require 1, 2, 3, or 4 bytes to record
+the length of the column value, depending on the maximum possible length of
+the type. @xref{BLOB}.
+
+If a table includes any variable-length column types, the record format will
+also be variable-length. Note that when a table is created, MySQL
+may, under certain conditions, change a column from a variable-length type to a
+fixed-length type, or vice-versa. @xref{Silent column changes}.
+
+@cindex ENUM, size
+The size of an @code{ENUM} object is determined by the number of
+different enumeration values. One byte is used for enumerations with up
+to 255 possible values. Two bytes are used for enumerations with up to
+65535 values. @xref{ENUM}.
+
+@cindex SET, size
+The size of a @code{SET} object is determined by the number of different
+set members. If the set size is @code{N}, the object occupies @code{(N+7)/8}
+bytes, rounded up to 1, 2, 3, 4, or 8 bytes. A @code{SET} can have a maximum
+of 64 members. @xref{SET}.
+
+
+@node Functions, Data Manipulation, Column types, Reference
@section Functions for Use in @code{SELECT} and @code{WHERE} Clauses
+@cindex functions for @code{SELECT} and @code{WHERE} clauses
+
A @code{select_expression} or @code{where_definition} in a SQL statement
can consist of any expression using the functions described below.
@@ -16174,12 +29350,12 @@ unless otherwise indicated in the documentation for the operators and
functions involved in the expression.
@strong{NOTE:} There must be no whitespace between a function name and the
-parenthesis following it. This helps the @strong{MySQL} parser distinguish
+parenthesis following it. This helps the MySQL parser distinguish
between function calls and references to tables or columns that happen to
have the same name as a function. Spaces around arguments are permitted,
though.
-You can force @strong{MySQL} to accept spaces after the function name by
+You can force MySQL to accept spaces after the function name by
starting @code{mysqld} with @code{--ansi} or using the
@code{CLIENT_IGNORE_SPACE} to @code{mysql_connect()}, but in this case all
function names will become reserved words. @xref{ANSI mode}.
@@ -16207,236 +29383,64 @@ mysql> select MOD(29,9);
@end example
@menu
-* Grouping functions:: Grouping functions
-* Arithmetic functions:: Normal arithmetic operations
-* Bit functions:: Bit functions
-* Logical functions:: Logical operations
-* Comparison functions:: Comparison operators
-* String comparison functions:: String comparison functions
-* Casts:: Cast operators
-* Control flow functions:: Control flow functions
-* Mathematical functions:: Mathematical functions
+* Non-typed Operators:: Non-Type-Specific Operators and Functions
* String functions:: String functions
+* Numeric Functions:: Numeric Functions
* Date and time functions:: Date and time functions
-* Miscellaneous functions:: Miscellaneous functions
-* Group by functions:: Functions for @code{GROUP BY} clause
+* Other Functions:: Other Functions
@end menu
-@cindex functions, grouping
-@cindex grouping, expressions
-@node Grouping functions, Arithmetic functions, Functions, Functions
-@subsection Grouping Functions
-@table @code
-
-@findex () (parentheses)
-@findex parentheses ( and )
-@item ( ... )
-Parentheses. Use these to force the order of evaluation in an expression:
-@example
-mysql> select 1+2*3;
- -> 7
-mysql> select (1+2)*3;
- -> 9
-@end example
-@end table
-
-@node Arithmetic functions, Bit functions, Grouping functions, Functions
-@subsection Normal Arithmetic Operations
-
-The usual arithmetic operators are available. Note that in the case of
-@samp{-}, @samp{+}, and @samp{*}, the result is calculated with
-@code{BIGINT} (64-bit) precision if both arguments are integers!
-
-@cindex operations, arithmetic
-@cindex arithmetic expressions
-@table @code
-@findex + (addition)
-@findex addition (+)
-@item +
-Addition:
-@example
-mysql> select 3+5;
- -> 8
-@end example
-
-@findex - (subtraction)
-@findex subtraction (-)
-@item -
-Subtraction:
-@example
-mysql> select 3-5;
- -> -2
-@end example
-
-@findex * (multiplication)
-@findex multiplication (*)
-@item *
-Multiplication:
-@example
-mysql> select 3*5;
- -> 15
-mysql> select 18014398509481984*18014398509481984.0;
- -> 324518553658426726783156020576256.0
-mysql> select 18014398509481984*18014398509481984;
- -> 0
-@end example
-
-The result of the last expression is incorrect because the result of the integer
-multiplication exceeds the 64-bit range of @code{BIGINT} calculations.
-
-@findex / (division)
-@findex division (/)
-@item /
-Division:
-@example
-mysql> select 3/5;
- -> 0.60
-@end example
-
-Division by zero produces a @code{NULL} result:
-@example
-mysql> select 102/(1-1);
- -> NULL
-@end example
+@node Non-typed Operators, String functions, Functions, Functions
+@subsection Non-Type-Specific Operators and Functions
-A division will be calculated with @code{BIGINT} arithmetic only if performed
-in a context where its result is converted to an integer!
-@end table
+@menu
+* Parenthesis:: Parenthesis
+* Comparison Operators:: Comparison Operators
+* Logical Operators:: Logical Operators
+* Control flow functions:: Control Flow Functions
+@end menu
-@findex arithmetic functions
-@findex bit functions
-@findex functions, arithmetic
-@findex functions, bit
-@node Bit functions, Logical functions, Arithmetic functions, Functions
-@subsection Bit Functions
-@strong{MySQL} uses @code{BIGINT} (64-bit) arithmetic for bit operations, so
-these operators have a maximum range of 64 bits.
+@node Parenthesis, Comparison Operators, Non-typed Operators, Non-typed Operators
+@subsubsection Parenthesis
-@table @code
-@findex | (bitwise OR)
-@findex OR, bitwise
-@item |
-Bitwise OR:
-@example
-mysql> select 29 | 15;
- -> 31
-@end example
+@findex () (parentheses)
+@findex parentheses ( and )
-@findex & (bitwise AND)
-@findex AND, bitwise
-@item &
-Bitwise AND:
-@example
-mysql> select 29 & 15;
- -> 13
-@end example
+@cindex functions, grouping
+@cindex grouping, expressions
-@findex << (left shift)
-@item <<
-Shifts a longlong (@code{BIGINT}) number to the left:
@example
-mysql> select 1 << 2;
- -> 4
+( ... )
@end example
-@findex >> (right shift)
-@item >>
-Shifts a longlong (@code{BIGINT}) number to the right:
-@example
-mysql> select 4 >> 2;
- -> 1
-@end example
+Use parenthesis to force the order of evaluation in an expression. For
+example:
-@findex ~
-@item ~
-Invert all bits:
@example
-mysql> select 5 & ~1;
- -> 4
+mysql> select 1+2*3;
+ -> 7
+mysql> select (1+2)*3;
+ -> 9
@end example
-@findex BIT_COUNT()
-@item BIT_COUNT(N)
-Returns the number of bits that are set in the argument @code{N}:
-@example
-mysql> select BIT_COUNT(29);
- -> 4
-@end example
-@end table
-@findex Logical functions
-@findex Functions, logical
-@node Logical functions, Comparison functions, Bit functions, Functions
-@subsection Logical Operations
-All logical functions return @code{1} (TRUE), @code{0} (FALSE) or
-@code{NULL} (unknown, which is in most cases the same as FALSE):
+@node Comparison Operators, Logical Operators, Parenthesis, Non-typed Operators
+@subsubsection Comparison Operators
-@table @code
-@findex NOT, logical
-@findex ! (logical NOT)
-@item NOT
-@itemx !
-Logical NOT. Returns @code{1} if the argument is @code{0}, otherwise returns
-@code{0}.
-Exception: @code{NOT NULL} returns @code{NULL}:
-@example
-mysql> select NOT 1;
- -> 0
-mysql> select NOT NULL;
- -> NULL
-mysql> select ! (1+1);
- -> 0
-mysql> select ! 1+1;
- -> 1
-@end example
-The last example returns @code{1} because the expression evaluates
-the same way as @code{(!1)+1}.
-
-@findex OR, logical
-@findex || (logical OR)
-@item OR
-@itemx ||
-Logical OR. Returns @code{1} if either argument is not @code{0} and not
-@code{NULL}:
-@example
-mysql> select 1 || 0;
- -> 1
-mysql> select 0 || 0;
- -> 0
-mysql> select 1 || NULL;
- -> 1
-
-@end example
-
-@findex AND, logical
-@findex && (logical AND)
-@item AND
-@itemx &&
-Logical AND. Returns @code{0} if either argument is @code{0} or @code{NULL},
-otherwise returns @code{1}:
-@example
-mysql> select 1 && NULL;
- -> 0
-mysql> select 1 && 0;
- -> 0
-@end example
-@end table
+@findex comparison operators
@cindex casts
@cindex type conversions
-@findex comparison operators
-@node Comparison functions, String comparison functions, Logical functions, Functions
-@subsection Comparison Operators
Comparison operations result in a value of @code{1} (TRUE), @code{0} (FALSE),
or @code{NULL}. These functions work for both numbers and strings. Strings
are automatically converted to numbers and numbers to strings as needed (as
in Perl).
-@strong{MySQL} performs comparisons using the following
+MySQL performs comparisons using the following
rules:
@itemize @bullet
@@ -16533,8 +29537,8 @@ mysql> select 0.1 <= 2;
@item <
Less than:
@example
-mysql> select 2 <= 2;
- -> 1
+mysql> select 2 < 2;
+ -> 0
@end example
@findex >= (greater than or equal)
@@ -16678,193 +29682,82 @@ mysql> select INTERVAL(22, 23, 30, 44, 200);
@end example
@end table
-@findex string comparison functions
-@findex functions, string comparison
-@node String comparison functions, Casts, Comparison functions, Functions
-@subsection String Comparison Functions
-
-@cindex case sensitivity, in string comparisons
-@cindex string comparisons, case sensitivity
-Normally, if any expression in a string comparison is case sensitive, the
-comparison is performed in case-sensitive fashion.
-
-@table @code
-@findex LIKE
-@item expr LIKE pat [ESCAPE 'escape-char']
-Pattern matching using
-SQL simple regular expression comparison. Returns @code{1} (TRUE) or @code{0}
-(FALSE). With @code{LIKE} you can use the following two wild-card characters
-in the pattern:
-
-@multitable @columnfractions .1 .9
-@item @code{%} @tab Matches any number of characters, even zero characters
-@item @code{_} @tab Matches exactly one character
-@end multitable
+If you are comparing case sensitive string with any of the standard
+operators (@code{=}, @code{<>}..., but not @code{LIKE}) end space will
+be ignored.
@example
-mysql> select 'David!' LIKE 'David_';
- -> 1
-mysql> select 'David!' LIKE '%D%v%';
+mysql> select "a" ="A ";
-> 1
@end example
-To test for literal instances of a wild-card character, precede the character
-with the escape character. If you don't specify the @code{ESCAPE} character,
-@samp{\} is assumed:
-@multitable @columnfractions .1 .9
-@item @code{\%} @tab Matches one @code{%} character
-@item @code{\_} @tab Matches one @code{_} character
-@end multitable
+@node Logical Operators, Control flow functions, Comparison Operators, Non-typed Operators
+@subsubsection Logical Operators
-@example
-mysql> select 'David!' LIKE 'David\_';
- -> 0
-mysql> select 'David_' LIKE 'David\_';
- -> 1
-@end example
+@findex Logical functions
+@findex Functions, logical
-To specify a different escape character, use the @code{ESCAPE} clause:
+All logical functions return @code{1} (TRUE), @code{0} (FALSE) or
+@code{NULL} (unknown, which is in most cases the same as FALSE):
+@table @code
+@findex NOT, logical
+@findex ! (logical NOT)
+@item NOT
+@itemx !
+Logical NOT. Returns @code{1} if the argument is @code{0}, otherwise returns
+@code{0}.
+Exception: @code{NOT NULL} returns @code{NULL}:
@example
-mysql> select 'David_' LIKE 'David|_' ESCAPE '|';
+mysql> select NOT 1;
+ -> 0
+mysql> select NOT NULL;
+ -> NULL
+mysql> select ! (1+1);
+ -> 0
+mysql> select ! 1+1;
-> 1
@end example
+The last example returns @code{1} because the expression evaluates
+the same way as @code{(!1)+1}.
-The following two statements illustrate that string comparisons are
-case insensitive unless one of the operands is a binary string:
-
+@findex OR, logical
+@findex || (logical OR)
+@item OR
+@itemx ||
+Logical OR. Returns @code{1} if either argument is not @code{0} and not
+@code{NULL}:
@example
-mysql> select 'abc' LIKE 'ABC';
+mysql> select 1 || 0;
-> 1
-mysql> SELECT 'abc' LIKE BINARY 'ABC';
+mysql> select 0 || 0;
-> 0
-@end example
-
-@code{LIKE} is allowed on numeric expressions! (This is a @strong{MySQL}
-extension to the ANSI SQL @code{LIKE}.)
-
-@example
-mysql> select 10 LIKE '1%';
+mysql> select 1 || NULL;
-> 1
-@end example
-
-Note: Because @strong{MySQL} uses the C escape syntax in strings (for example,
-@samp{\n}), you must double any @samp{\} that you use in your @code{LIKE}
-strings. For example, to search for @samp{\n}, specify it as @samp{\\n}. To
-search for @samp{\}, specify it as @samp{\\\\} (the backslashes are stripped
-once by the parser and another time when the pattern match is done, leaving
-a single backslash to be matched).
-
-@findex NOT LIKE
-@item expr NOT LIKE pat [ESCAPE 'escape-char']
-Same as @code{NOT (expr LIKE pat [ESCAPE 'escape-char'])}.
-
-@cindex mSQL compatibility
-@cindex compatibility, with mSQL
-@findex REGEXP
-@findex RLIKE
-@item expr REGEXP pat
-@itemx expr RLIKE pat
-Performs a pattern match of a string expression @code{expr} against a pattern
-@code{pat}. The pattern can be an extended regular expression.
-@xref{Regexp}. Returns @code{1} if @code{expr} matches @code{pat}, otherwise
-returns @code{0}. @code{RLIKE} is a synonym for @code{REGEXP}, provided for
-@code{mSQL} compatibility. Note: Because @strong{MySQL} uses the C escape
-syntax in strings (for example, @samp{\n}), you must double any @samp{\} that
-you use in your @code{REGEXP} strings. As of @strong{MySQL} Version 3.23.4,
-@code{REGEXP} is case insensitive for normal (not binary) strings:
-@example
-mysql> select 'Monty!' REGEXP 'm%y%%';
- -> 0
-mysql> select 'Monty!' REGEXP '.*';
- -> 1
-mysql> select 'new*\n*line' REGEXP 'new\\*.\\*line';
- -> 1
-mysql> select "a" REGEXP "A", "a" REGEXP BINARY "A";
- -> 1 0
-mysql> select "a" REGEXP "^[a-d]";
- -> 1
@end example
-@item
-@code{REGEXP} and @code{RLIKE} use the current character set (ISO-8859-1
-Latin1 by default) when deciding the type of a character.
-
-@findex NOT REGEXP
-@item expr NOT REGEXP pat
-@itemx expr NOT RLIKE pat
-Same as @code{NOT (expr REGEXP pat)}.
-
-@findex STRCMP()
-@item STRCMP(expr1,expr2)
-@code{STRCMP()}
-returns @code{0} if the strings are the same, @code{-1} if the first
-argument is smaller than the second according to the current sort order,
-and @code{1} otherwise:
-
+@findex AND, logical
+@findex && (logical AND)
+@item AND
+@itemx &&
+Logical AND. Returns @code{0} if either argument is @code{0} or @code{NULL},
+otherwise returns @code{1}:
@example
-mysql> select STRCMP('text', 'text2');
- -> -1
-mysql> select STRCMP('text2', 'text');
- -> 1
-mysql> select STRCMP('text', 'text');
+mysql> select 1 && NULL;
-> 0
-@end example
-
-@findex MATCH ... AGAINST()
-@item MATCH (col1,col2,...) AGAINST (expr)
-@code{MATCH ... AGAINST()} is used for full-text search and returns
-relevance - similarity measure between the text in columns
-@code{(col1,col2,...)} and the query @code{expr}. Relevance is a
-positive floating-point number. Zero relevance means no similarity.
-For @code{MATCH ... AGAINST()} to work, a @strong{FULLTEXT} index
-must be created first. @xref{CREATE TABLE, , @code{CREATE TABLE}}.
-@code{MATCH ... AGAINST()} is available in @strong{MySQL} Version
-3.23.23 or later. For details and usage examples
-@pxref{Fulltext Search}.
-@end table
-
-@findex casts
-@cindex cast operators
-@cindex operators, cast
-@node Casts, Control flow functions, String comparison functions, Functions
-@subsection Cast Operators
-
-@table @code
-@findex BINARY
-@item @code{BINARY}
-The @code{BINARY} operator casts the string following it to a binary string.
-This is an easy way to force a column comparison to be case sensitive even
-if the column isn't defined as @code{BINARY} or @code{BLOB}:
-@example
-mysql> select "a" = "A";
- -> 1
-mysql> select BINARY "a" = "A";
+mysql> select 1 && 0;
-> 0
@end example
-
-@code{BINARY} was introduced in @strong{MySQL} Version 3.23.0.
-
-Note that in some context @strong{MySQL} will not be able to use the
-index efficiently when you cast an indexed column to @code{BINARY}.
@end table
-If you want to compare a blob case-insensitively you can always convert
-the blob to upper case before doing the comparison:
-@example
-SELECT 'A' LIKE UPPER(blob_col) FROM table_name;
-@end example
-
-We plan to soon introduce casting between different character sets to
-make string comparison even more flexible.
+@node Control flow functions, , Logical Operators, Non-typed Operators
+@subsubsection Control Flow Functions
@findex control flow functions
@findex functions, control flow
-@node Control flow functions, Mathematical functions, Casts, Functions
-@subsection Control Flow Functions
@table @code
@cindex @code{NULL}, testing for null
@@ -16895,7 +29788,7 @@ mysql> select NULLIF(1,2);
-> 1
@end example
-Note that @code{expr1} is evaluated twice in @strong{MySQL} if the arguments
+Note that @code{expr1} is evaluated twice in MySQL if the arguments
are equal.
@findex IF()
@@ -16932,7 +29825,7 @@ original floating-point value to see whether it is non-zero. The result
of the comparison is used as an integer.
The default return type of @code{IF()} (which may matter when it is
-stored into a temporary table) is calculated in @strong{MySQL} Version
+stored into a temporary table) is calculated in MySQL Version
3.23 as follows:
@multitable @columnfractions .55 .45
@@ -16966,400 +29859,12 @@ The type of the return value (@code{INTEGER}, @code{DOUBLE} or
@code{STRING}) is the same as the type of the first returned value (the
expression after the first @code{THEN}).
-@findex mathematical functions
-@findex functions, mathematical
-@node Mathematical functions, String functions, Control flow functions, Functions
-@subsection Mathematical Functions
-All mathematical functions return @code{NULL} in case of an error.
-
-@table @code
-@findex - (unary minus)
-@findex minus, unary (-)
-@findex unary minus (-)
-@item -
-Unary minus. Changes the sign of the argument:
-@example
-mysql> select - 2;
- -> -2
-@end example
-
-Note that if this operator is used with a @code{BIGINT}, the return value is a
-@code{BIGINT}! This means that you should avoid using @code{-} on integers that
-may have the value of @code{-2^63}!
-
-@findex ABS()
-@item ABS(X)
-Returns the absolute value of @code{X}:
-@example
-mysql> select ABS(2);
- -> 2
-mysql> select ABS(-32);
- -> 32
-@end example
-
-This function is safe to use with @code{BIGINT} values.
-
-@findex SIGN()
-@item SIGN(X)
-Returns the sign of the argument as @code{-1}, @code{0}, or @code{1}, depending
-on whether @code{X} is negative, zero, or positive:
-@example
-mysql> select SIGN(-32);
- -> -1
-mysql> select SIGN(0);
- -> 0
-mysql> select SIGN(234);
- -> 1
-@end example
-
-@findex MOD()
-@findex % (modulo)
-@findex modulo (%)
-@item MOD(N,M)
-@itemx %
-Modulo (like the @code{%} operator in C).
-Returns the remainder of @code{N} divided by @code{M}:
-@example
-mysql> select MOD(234, 10);
- -> 4
-mysql> select 253 % 7;
- -> 1
-mysql> select MOD(29,9);
- -> 2
-@end example
-
-This function is safe to use with @code{BIGINT} values.
-
-@findex FLOOR()
-@item FLOOR(X)
-Returns the largest integer value not greater than @code{X}:
-@example
-mysql> select FLOOR(1.23);
- -> 1
-mysql> select FLOOR(-1.23);
- -> -2
-@end example
-
-Note that the return value is converted to a @code{BIGINT}!
-
-@findex CEILING()
-@item CEILING(X)
-Returns the smallest integer value not less than @code{X}:
-@example
-mysql> select CEILING(1.23);
- -> 2
-mysql> select CEILING(-1.23);
- -> -1
-@end example
-
-Note that the return value is converted to a @code{BIGINT}!
-
-@findex ROUND()
-@item ROUND(X)
-Returns the argument @code{X}, rounded to the nearest integer:
-@example
-mysql> select ROUND(-1.23);
- -> -1
-mysql> select ROUND(-1.58);
- -> -2
-mysql> select ROUND(1.58);
- -> 2
-@end example
-
-Note that the behavior of @code{ROUND()} when the argument
-is half way between two integers depends on the C library
-implementation. Some round to the nearest even number,
-always up, always down, or always towards zero. If you need
-one kind of rounding, you should use a well-defined function
-like @code{TRUNCATE()} or @code{FLOOR()} instead.
-
-@findex ROUND()
-@item ROUND(X,D)
-Returns the argument @code{X}, rounded to a number with @code{D} decimals.
-If @code{D} is @code{0}, the result will have no decimal point or fractional
-part:
-
-@example
-mysql> select ROUND(1.298, 1);
- -> 1.3
-mysql> select ROUND(1.298, 0);
- -> 1
-@end example
-
-@findex EXP()
-@item EXP(X)
-Returns the value of @code{e} (the base of natural logarithms) raised to
-the power of @code{X}:
-@example
-mysql> select EXP(2);
- -> 7.389056
-mysql> select EXP(-2);
- -> 0.135335
-@end example
-@findex LOG()
-@item LOG(X)
-Returns the natural logarithm of @code{X}:
-@example
-mysql> select LOG(2);
- -> 0.693147
-mysql> select LOG(-2);
- -> NULL
-@end example
-If you want the log of a number @code{X} to some arbitary base @code{B}, use
-the formula @code{LOG(X)/LOG(B)}.
-
-@findex LOG10()
-@item LOG10(X)
-Returns the base-10 logarithm of @code{X}:
-@example
-mysql> select LOG10(2);
- -> 0.301030
-mysql> select LOG10(100);
- -> 2.000000
-mysql> select LOG10(-100);
- -> NULL
-@end example
-
-@findex POW()
-@findex POWER()
-@item POW(X,Y)
-@itemx POWER(X,Y)
-Returns the value of @code{X} raised to the power of @code{Y}:
-@example
-mysql> select POW(2,2);
- -> 4.000000
-mysql> select POW(2,-2);
- -> 0.250000
-@end example
-
-@findex SQRT()
-@item SQRT(X)
-Returns the non-negative square root of @code{X}:
-@example
-mysql> select SQRT(4);
- -> 2.000000
-mysql> select SQRT(20);
- -> 4.472136
-@end example
-
-@findex PI()
-@item PI()
-Returns the value of PI. The default shown number of decimals is 5, but
-@strong{MySQL} internally uses the full double precession for PI.
-@example
-mysql> select PI();
- -> 3.141593
-mysql> SELECT PI()+0.000000000000000000;
- -> 3.141592653589793116
-@end example
-
-@findex COS()
-@item COS(X)
-Returns the cosine of @code{X}, where @code{X} is given in radians:
-@example
-mysql> select COS(PI());
- -> -1.000000
-@end example
-
-@findex SIN()
-@item SIN(X)
-Returns the sine of @code{X}, where @code{X} is given in radians:
-@example
-mysql> select SIN(PI());
- -> 0.000000
-@end example
-
-@findex TAN()
-@item TAN(X)
-Returns the tangent of @code{X}, where @code{X} is given in radians:
-@example
-mysql> select TAN(PI()+1);
- -> 1.557408
-@end example
-
-@findex ACOS()
-@item ACOS(X)
-Returns the arc cosine of @code{X}, that is, the value whose cosine is
-@code{X}. Returns @code{NULL} if @code{X} is not in the range @code{-1} to
-@code{1}:
-@example
-mysql> select ACOS(1);
- -> 0.000000
-mysql> select ACOS(1.0001);
- -> NULL
-mysql> select ACOS(0);
- -> 1.570796
-@end example
-
-@findex ASIN()
-@item ASIN(X)
-Returns the arc sine of @code{X}, that is, the value whose sine is
-@code{X}. Returns @code{NULL} if @code{X} is not in the range @code{-1} to
-@code{1}:
-@example
-mysql> select ASIN(0.2);
- -> 0.201358
-mysql> select ASIN('foo');
- -> 0.000000
-@end example
-
-@findex ATAN()
-@item ATAN(X)
-Returns the arc tangent of @code{X}, that is, the value whose tangent is
-@code{X}:
-@example
-mysql> select ATAN(2);
- -> 1.107149
-mysql> select ATAN(-2);
- -> -1.107149
-@end example
-
-@findex ATAN2()
-@item ATAN2(Y,X)
-Returns the arc tangent of the two variables @code{X} and @code{Y}. It is
-similar to calculating the arc tangent of @code{Y / X}, except that the
-signs of both arguments are used to determine the quadrant of the
-result:
-@example
-mysql> select ATAN(-2,2);
- -> -0.785398
-mysql> select ATAN(PI(),0);
- -> 1.570796
-@end example
-
-@findex COT()
-@item COT(X)
-Returns the cotangent of @code{X}:
-@example
-mysql> select COT(12);
- -> -1.57267341
-mysql> select COT(0);
- -> NULL
-@end example
-
-@findex RAND()
-@item RAND()
-@itemx RAND(N)
-Returns a random floating-point value in the range @code{0} to @code{1.0}.
-If an integer argument @code{N} is specified, it is used as the seed value:
-@example
-mysql> select RAND();
- -> 0.5925
-mysql> select RAND(20);
- -> 0.1811
-mysql> select RAND(20);
- -> 0.1811
-mysql> select RAND();
- -> 0.2079
-mysql> select RAND();
- -> 0.7888
-@end example
-You can't use a column with @code{RAND()} values in an @code{ORDER BY}
-clause, because @code{ORDER BY} would evaluate the column multiple times.
-In @strong{MySQL} Version 3.23, you can, however, do:
-@code{SELECT * FROM table_name ORDER BY RAND()}
-
-This is useful to get a random sample of a set @code{SELECT * FROM
-table1,table2 WHERE a=b AND c<d ORDER BY RAND() LIMIT 1000}.
-
-Note that a @code{RAND()} in a @code{WHERE} clause will be re-evaluated
-every time the @code{WHERE} is executed.
-
-@findex LEAST()
-@item LEAST(X,Y,...)
-With two or more arguments, returns the smallest (minimum-valued) argument.
-The arguments are compared using the following rules:
-
-@itemize @bullet
-@item
-If the return value is used in an @code{INTEGER} context, or all arguments
-are integer-valued, they are compared as integers.
-
-@item
-If the return value is used in a @code{REAL} context, or all arguments are
-real-valued, they are compared as reals.
-
-@item
-If any argument is a case-sensitive string, the arguments are compared
-as case-sensitive strings.
-
-@item
-In other cases, the arguments are compared as case-insensitive strings:
-@end itemize
-
-@example
-mysql> select LEAST(2,0);
- -> 0
-mysql> select LEAST(34.0,3.0,5.0,767.0);
- -> 3.0
-mysql> select LEAST("B","A","C");
- -> "A"
-@end example
-In @strong{MySQL} versions prior to Version 3.22.5, you can use @code{MIN()}
-instead of @code{LEAST}.
-
-@findex GREATEST()
-@item GREATEST(X,Y,...)
-Returns the largest (maximum-valued) argument.
-The arguments are compared using the same rules as for @code{LEAST}:
-@example
-mysql> select GREATEST(2,0);
- -> 2
-mysql> select GREATEST(34.0,3.0,5.0,767.0);
- -> 767.0
-mysql> select GREATEST("B","A","C");
- -> "C"
-@end example
-In @strong{MySQL} versions prior to Version 3.22.5, you can use @code{MAX()}
-instead of @code{GREATEST}.
-@findex DEGREES()
-@item DEGREES(X)
-Returns the argument @code{X}, converted from radians to degrees:
-@example
-mysql> select DEGREES(PI());
- -> 180.000000
-@end example
-
-@findex RADIANS()
-@item RADIANS(X)
-Returns the argument @code{X}, converted from degrees to radians:
-@example
-mysql> select RADIANS(90);
- -> 1.570796
-@end example
-
-@findex TRUNCATE()
-@item TRUNCATE(X,D)
-Returns the number @code{X}, truncated to @code{D} decimals. If @code{D}
-is @code{0}, the result will have no decimal point or fractional part:
-@example
-mysql> select TRUNCATE(1.223,1);
- -> 1.2
-mysql> select TRUNCATE(1.999,1);
- -> 1.9
-mysql> select TRUNCATE(1.999,0);
- -> 1
-@end example
-
-Note that as decimal numbers are normally not stored as exact numbers in
-computers, but as double values, you may be fooled by the following
-result:
-
-@cindex rounding errors
-@example
-mysql> select TRUNCATE(10.28*100,0);
- -> 1027
-@end example
-
-The above happens because 10.28 is actually stored as something like
-10.2799999999999999.
-@end table
+@node String functions, Numeric Functions, Non-typed Operators, Functions
+@subsection String Functions
@findex string functions
@findex functions, string
-@node String functions, Date and time functions, Mathematical functions, Functions
-@subsection String Functions
String-valued functions return @code{NULL} if the length of the result would
be greater than the @code{max_allowed_packet} server parameter. @xref{Server
@@ -17893,13 +30398,13 @@ mysql> UPDATE table_name
@end example
@end table
-If you are not using @strong{MySQL} Version 3.23, you have to do the reading
+If you are not using MySQL Version 3.23, you have to do the reading
of the file inside your application and create an @code{INSERT} statement
to update the database with the file information. One way to do this, if
-you are using the @strong{MySQL}++ library, can be found at
+you are using the MySQL++ library, can be found at
@uref{http://www.mysql.com/documentation/mysql++/mysql++-examples.html}.
-@strong{MySQL} automatically converts numbers to strings as necessary, and
+MySQL automatically converts numbers to strings as necessary, and
vice-versa:
@example
@@ -17916,10 +30421,672 @@ If a string function is given a binary string as an argument, the resulting
string is also a binary string. A number converted to a string is treated as
a binary string. This only affects comparisons.
+
+@menu
+* String comparison functions:: String Comparison Functions
+* Case Sensitivity Operators:: Case Sensitivity
+@end menu
+
+@node String comparison functions, Case Sensitivity Operators, String functions, String functions
+@subsubsection String Comparison Functions
+
+@findex string comparison functions
+@findex functions, string comparison
+
+@cindex case sensitivity, in string comparisons
+@cindex string comparisons, case sensitivity
+
+Normally, if any expression in a string comparison is case sensitive, the
+comparison is performed in case-sensitive fashion.
+
+@table @code
+@findex LIKE
+@item expr LIKE pat [ESCAPE 'escape-char']
+Pattern matching using
+SQL simple regular expression comparison. Returns @code{1} (TRUE) or @code{0}
+(FALSE). With @code{LIKE} you can use the following two wild-card characters
+in the pattern:
+
+@multitable @columnfractions .1 .9
+@item @code{%} @tab Matches any number of characters, even zero characters
+@item @code{_} @tab Matches exactly one character
+@end multitable
+
+@example
+mysql> select 'David!' LIKE 'David_';
+ -> 1
+mysql> select 'David!' LIKE '%D%v%';
+ -> 1
+@end example
+
+To test for literal instances of a wild-card character, precede the character
+with the escape character. If you don't specify the @code{ESCAPE} character,
+@samp{\} is assumed:
+
+@multitable @columnfractions .1 .9
+@item @code{\%} @tab Matches one @code{%} character
+@item @code{\_} @tab Matches one @code{_} character
+@end multitable
+
+@example
+mysql> select 'David!' LIKE 'David\_';
+ -> 0
+mysql> select 'David_' LIKE 'David\_';
+ -> 1
+@end example
+
+To specify a different escape character, use the @code{ESCAPE} clause:
+
+@example
+mysql> select 'David_' LIKE 'David|_' ESCAPE '|';
+ -> 1
+@end example
+
+The following two statements illustrate that string comparisons are
+case insensitive unless one of the operands is a binary string:
+
+@example
+mysql> select 'abc' LIKE 'ABC';
+ -> 1
+mysql> SELECT 'abc' LIKE BINARY 'ABC';
+ -> 0
+@end example
+
+@code{LIKE} is allowed on numeric expressions! (This is a MySQL
+extension to the ANSI SQL @code{LIKE}.)
+
+@example
+mysql> select 10 LIKE '1%';
+ -> 1
+@end example
+
+Note: Because MySQL uses the C escape syntax in strings (for example,
+@samp{\n}), you must double any @samp{\} that you use in your @code{LIKE}
+strings. For example, to search for @samp{\n}, specify it as @samp{\\n}. To
+search for @samp{\}, specify it as @samp{\\\\} (the backslashes are stripped
+once by the parser and another time when the pattern match is done, leaving
+a single backslash to be matched).
+
+@findex NOT LIKE
+@item expr NOT LIKE pat [ESCAPE 'escape-char']
+Same as @code{NOT (expr LIKE pat [ESCAPE 'escape-char'])}.
+
+@cindex mSQL compatibility
+@cindex compatibility, with mSQL
+@findex REGEXP
+@findex RLIKE
+@item expr REGEXP pat
+@itemx expr RLIKE pat
+Performs a pattern match of a string expression @code{expr} against a pattern
+@code{pat}. The pattern can be an extended regular expression.
+@xref{Regexp}. Returns @code{1} if @code{expr} matches @code{pat}, otherwise
+returns @code{0}. @code{RLIKE} is a synonym for @code{REGEXP}, provided for
+@code{mSQL} compatibility. Note: Because MySQL uses the C escape
+syntax in strings (for example, @samp{\n}), you must double any @samp{\} that
+you use in your @code{REGEXP} strings. As of MySQL Version 3.23.4,
+@code{REGEXP} is case insensitive for normal (not binary) strings:
+
+@example
+mysql> select 'Monty!' REGEXP 'm%y%%';
+ -> 0
+mysql> select 'Monty!' REGEXP '.*';
+ -> 1
+mysql> select 'new*\n*line' REGEXP 'new\\*.\\*line';
+ -> 1
+mysql> select "a" REGEXP "A", "a" REGEXP BINARY "A";
+ -> 1 0
+mysql> select "a" REGEXP "^[a-d]";
+ -> 1
+@end example
+
+@item
+@code{REGEXP} and @code{RLIKE} use the current character set (ISO-8859-1
+Latin1 by default) when deciding the type of a character.
+
+@findex NOT REGEXP
+@item expr NOT REGEXP pat
+@itemx expr NOT RLIKE pat
+Same as @code{NOT (expr REGEXP pat)}.
+
+@findex STRCMP()
+@item STRCMP(expr1,expr2)
+@code{STRCMP()}
+returns @code{0} if the strings are the same, @code{-1} if the first
+argument is smaller than the second according to the current sort order,
+and @code{1} otherwise:
+
+@example
+mysql> select STRCMP('text', 'text2');
+ -> -1
+mysql> select STRCMP('text2', 'text');
+ -> 1
+mysql> select STRCMP('text', 'text');
+ -> 0
+@end example
+
+@findex MATCH ... AGAINST()
+@item MATCH (col1,col2,...) AGAINST (expr)
+@code{MATCH ... AGAINST()} is used for full-text search and returns
+relevance - similarity measure between the text in columns
+@code{(col1,col2,...)} and the query @code{expr}. Relevance is a
+positive floating-point number. Zero relevance means no similarity.
+For @code{MATCH ... AGAINST()} to work, a @strong{FULLTEXT} index
+must be created first. @xref{CREATE TABLE, , @code{CREATE TABLE}}.
+@code{MATCH ... AGAINST()} is available in MySQL Version
+3.23.23 or later. For details and usage examples
+@pxref{Fulltext Search}.
+@end table
+
+
+@node Case Sensitivity Operators, , String comparison functions, String functions
+@subsubsection Case Sensitivity
+
+@findex casts
+
+@cindex cast operators
+@cindex operators, cast
+
+@table @code
+@findex BINARY
+@item @code{BINARY}
+The @code{BINARY} operator casts the string following it to a binary string.
+This is an easy way to force a column comparison to be case sensitive even
+if the column isn't defined as @code{BINARY} or @code{BLOB}:
+@example
+mysql> select "a" = "A";
+ -> 1
+mysql> select BINARY "a" = "A";
+ -> 0
+@end example
+
+@code{BINARY} was introduced in MySQL Version 3.23.0.
+
+Note that in some context MySQL will not be able to use the
+index efficiently when you cast an indexed column to @code{BINARY}.
+@end table
+
+If you want to compare a blob case-insensitively you can always convert
+the blob to upper case before doing the comparison:
+
+@example
+SELECT 'A' LIKE UPPER(blob_col) FROM table_name;
+@end example
+
+We plan to soon introduce casting between different character sets to
+make string comparison even more flexible.
+
+
+@node Numeric Functions, Date and time functions, String functions, Functions
+@subsection Numeric Functions
+
+@menu
+* Arithmetic functions:: Arithmetic Operations
+* Mathematical functions:: Mathematical Functions
+@end menu
+
+
+@node Arithmetic functions, Mathematical functions, Numeric Functions, Numeric Functions
+@subsubsection Arithmetic Operations
+
+The usual arithmetic operators are available. Note that in the case of
+@samp{-}, @samp{+}, and @samp{*}, the result is calculated with
+@code{BIGINT} (64-bit) precision if both arguments are integers!
+
+@cindex operations, arithmetic
+@cindex arithmetic expressions
+@table @code
+@findex + (addition)
+@findex addition (+)
+@item +
+Addition:
+@example
+mysql> select 3+5;
+ -> 8
+@end example
+
+@findex - (subtraction)
+@findex subtraction (-)
+@item -
+Subtraction:
+@example
+mysql> select 3-5;
+ -> -2
+@end example
+
+@findex * (multiplication)
+@findex multiplication (*)
+@item *
+Multiplication:
+@example
+mysql> select 3*5;
+ -> 15
+mysql> select 18014398509481984*18014398509481984.0;
+ -> 324518553658426726783156020576256.0
+mysql> select 18014398509481984*18014398509481984;
+ -> 0
+@end example
+
+The result of the last expression is incorrect because the result of the integer
+multiplication exceeds the 64-bit range of @code{BIGINT} calculations.
+
+@findex / (division)
+@findex division (/)
+@item /
+Division:
+@example
+mysql> select 3/5;
+ -> 0.60
+@end example
+
+Division by zero produces a @code{NULL} result:
+
+@example
+mysql> select 102/(1-1);
+ -> NULL
+@end example
+
+A division will be calculated with @code{BIGINT} arithmetic only if performed
+in a context where its result is converted to an integer!
+@end table
+
+
+@node Mathematical functions, , Arithmetic functions, Numeric Functions
+@subsubsection Mathematical Functions
+All mathematical functions return @code{NULL} in case of an error.
+
+@findex mathematical functions
+@findex functions, mathematical
+
+@table @code
+@findex - (unary minus)
+@findex minus, unary (-)
+@findex unary minus (-)
+@item -
+Unary minus. Changes the sign of the argument:
+@example
+mysql> select - 2;
+ -> -2
+@end example
+
+Note that if this operator is used with a @code{BIGINT}, the return value is a
+@code{BIGINT}! This means that you should avoid using @code{-} on integers that
+may have the value of @code{-2^63}!
+
+@findex ABS()
+@item ABS(X)
+Returns the absolute value of @code{X}:
+@example
+mysql> select ABS(2);
+ -> 2
+mysql> select ABS(-32);
+ -> 32
+@end example
+
+This function is safe to use with @code{BIGINT} values.
+
+@findex SIGN()
+@item SIGN(X)
+Returns the sign of the argument as @code{-1}, @code{0}, or @code{1}, depending
+on whether @code{X} is negative, zero, or positive:
+@example
+mysql> select SIGN(-32);
+ -> -1
+mysql> select SIGN(0);
+ -> 0
+mysql> select SIGN(234);
+ -> 1
+@end example
+
+@findex MOD()
+@findex % (modulo)
+@findex modulo (%)
+@item MOD(N,M)
+@itemx %
+Modulo (like the @code{%} operator in C).
+Returns the remainder of @code{N} divided by @code{M}:
+@example
+mysql> select MOD(234, 10);
+ -> 4
+mysql> select 253 % 7;
+ -> 1
+mysql> select MOD(29,9);
+ -> 2
+@end example
+
+This function is safe to use with @code{BIGINT} values.
+
+@findex FLOOR()
+@item FLOOR(X)
+Returns the largest integer value not greater than @code{X}:
+@example
+mysql> select FLOOR(1.23);
+ -> 1
+mysql> select FLOOR(-1.23);
+ -> -2
+@end example
+
+Note that the return value is converted to a @code{BIGINT}!
+
+@findex CEILING()
+@item CEILING(X)
+Returns the smallest integer value not less than @code{X}:
+@example
+mysql> select CEILING(1.23);
+ -> 2
+mysql> select CEILING(-1.23);
+ -> -1
+@end example
+
+Note that the return value is converted to a @code{BIGINT}!
+
+@findex ROUND()
+@item ROUND(X)
+Returns the argument @code{X}, rounded to the nearest integer:
+@example
+mysql> select ROUND(-1.23);
+ -> -1
+mysql> select ROUND(-1.58);
+ -> -2
+mysql> select ROUND(1.58);
+ -> 2
+@end example
+
+Note that the behavior of @code{ROUND()} when the argument
+is half way between two integers depends on the C library
+implementation. Some round to the nearest even number,
+always up, always down, or always towards zero. If you need
+one kind of rounding, you should use a well-defined function
+like @code{TRUNCATE()} or @code{FLOOR()} instead.
+
+@findex ROUND()
+@item ROUND(X,D)
+Returns the argument @code{X}, rounded to a number with @code{D} decimals.
+If @code{D} is @code{0}, the result will have no decimal point or fractional
+part:
+
+@example
+mysql> select ROUND(1.298, 1);
+ -> 1.3
+mysql> select ROUND(1.298, 0);
+ -> 1
+@end example
+
+@findex EXP()
+@item EXP(X)
+Returns the value of @code{e} (the base of natural logarithms) raised to
+the power of @code{X}:
+@example
+mysql> select EXP(2);
+ -> 7.389056
+mysql> select EXP(-2);
+ -> 0.135335
+@end example
+@findex LOG()
+@item LOG(X)
+Returns the natural logarithm of @code{X}:
+@example
+mysql> select LOG(2);
+ -> 0.693147
+mysql> select LOG(-2);
+ -> NULL
+@end example
+If you want the log of a number @code{X} to some arbitary base @code{B}, use
+the formula @code{LOG(X)/LOG(B)}.
+
+@findex LOG10()
+@item LOG10(X)
+Returns the base-10 logarithm of @code{X}:
+@example
+mysql> select LOG10(2);
+ -> 0.301030
+mysql> select LOG10(100);
+ -> 2.000000
+mysql> select LOG10(-100);
+ -> NULL
+@end example
+
+@findex POW()
+@findex POWER()
+@item POW(X,Y)
+@itemx POWER(X,Y)
+Returns the value of @code{X} raised to the power of @code{Y}:
+@example
+mysql> select POW(2,2);
+ -> 4.000000
+mysql> select POW(2,-2);
+ -> 0.250000
+@end example
+
+@findex SQRT()
+@item SQRT(X)
+Returns the non-negative square root of @code{X}:
+@example
+mysql> select SQRT(4);
+ -> 2.000000
+mysql> select SQRT(20);
+ -> 4.472136
+@end example
+
+@findex PI()
+@item PI()
+Returns the value of PI. The default shown number of decimals is 5, but
+MySQL internally uses the full double precession for PI.
+@example
+mysql> select PI();
+ -> 3.141593
+mysql> SELECT PI()+0.000000000000000000;
+ -> 3.141592653589793116
+@end example
+
+@findex COS()
+@item COS(X)
+Returns the cosine of @code{X}, where @code{X} is given in radians:
+@example
+mysql> select COS(PI());
+ -> -1.000000
+@end example
+
+@findex SIN()
+@item SIN(X)
+Returns the sine of @code{X}, where @code{X} is given in radians:
+@example
+mysql> select SIN(PI());
+ -> 0.000000
+@end example
+
+@findex TAN()
+@item TAN(X)
+Returns the tangent of @code{X}, where @code{X} is given in radians:
+@example
+mysql> select TAN(PI()+1);
+ -> 1.557408
+@end example
+
+@findex ACOS()
+@item ACOS(X)
+Returns the arc cosine of @code{X}, that is, the value whose cosine is
+@code{X}. Returns @code{NULL} if @code{X} is not in the range @code{-1} to
+@code{1}:
+@example
+mysql> select ACOS(1);
+ -> 0.000000
+mysql> select ACOS(1.0001);
+ -> NULL
+mysql> select ACOS(0);
+ -> 1.570796
+@end example
+
+@findex ASIN()
+@item ASIN(X)
+Returns the arc sine of @code{X}, that is, the value whose sine is
+@code{X}. Returns @code{NULL} if @code{X} is not in the range @code{-1} to
+@code{1}:
+@example
+mysql> select ASIN(0.2);
+ -> 0.201358
+mysql> select ASIN('foo');
+ -> 0.000000
+@end example
+
+@findex ATAN()
+@item ATAN(X)
+Returns the arc tangent of @code{X}, that is, the value whose tangent is
+@code{X}:
+@example
+mysql> select ATAN(2);
+ -> 1.107149
+mysql> select ATAN(-2);
+ -> -1.107149
+@end example
+
+@findex ATAN2()
+@item ATAN2(Y,X)
+Returns the arc tangent of the two variables @code{X} and @code{Y}. It is
+similar to calculating the arc tangent of @code{Y / X}, except that the
+signs of both arguments are used to determine the quadrant of the
+result:
+@example
+mysql> select ATAN(-2,2);
+ -> -0.785398
+mysql> select ATAN(PI(),0);
+ -> 1.570796
+@end example
+
+@findex COT()
+@item COT(X)
+Returns the cotangent of @code{X}:
+@example
+mysql> select COT(12);
+ -> -1.57267341
+mysql> select COT(0);
+ -> NULL
+@end example
+
+@findex RAND()
+@item RAND()
+@itemx RAND(N)
+Returns a random floating-point value in the range @code{0} to @code{1.0}.
+If an integer argument @code{N} is specified, it is used as the seed value:
+@example
+mysql> select RAND();
+ -> 0.5925
+mysql> select RAND(20);
+ -> 0.1811
+mysql> select RAND(20);
+ -> 0.1811
+mysql> select RAND();
+ -> 0.2079
+mysql> select RAND();
+ -> 0.7888
+@end example
+You can't use a column with @code{RAND()} values in an @code{ORDER BY}
+clause, because @code{ORDER BY} would evaluate the column multiple times.
+In MySQL Version 3.23, you can, however, do:
+@code{SELECT * FROM table_name ORDER BY RAND()}
+
+This is useful to get a random sample of a set @code{SELECT * FROM
+table1,table2 WHERE a=b AND c<d ORDER BY RAND() LIMIT 1000}.
+
+Note that a @code{RAND()} in a @code{WHERE} clause will be re-evaluated
+every time the @code{WHERE} is executed.
+
+@findex LEAST()
+@item LEAST(X,Y,...)
+With two or more arguments, returns the smallest (minimum-valued) argument.
+The arguments are compared using the following rules:
+
+@itemize @bullet
+@item
+If the return value is used in an @code{INTEGER} context, or all arguments
+are integer-valued, they are compared as integers.
+
+@item
+If the return value is used in a @code{REAL} context, or all arguments are
+real-valued, they are compared as reals.
+
+@item
+If any argument is a case-sensitive string, the arguments are compared
+as case-sensitive strings.
+
+@item
+In other cases, the arguments are compared as case-insensitive strings:
+@end itemize
+
+@example
+mysql> select LEAST(2,0);
+ -> 0
+mysql> select LEAST(34.0,3.0,5.0,767.0);
+ -> 3.0
+mysql> select LEAST("B","A","C");
+ -> "A"
+@end example
+In MySQL versions prior to Version 3.22.5, you can use @code{MIN()}
+instead of @code{LEAST}.
+
+@findex GREATEST()
+@item GREATEST(X,Y,...)
+Returns the largest (maximum-valued) argument.
+The arguments are compared using the same rules as for @code{LEAST}:
+@example
+mysql> select GREATEST(2,0);
+ -> 2
+mysql> select GREATEST(34.0,3.0,5.0,767.0);
+ -> 767.0
+mysql> select GREATEST("B","A","C");
+ -> "C"
+@end example
+In MySQL versions prior to Version 3.22.5, you can use @code{MAX()}
+instead of @code{GREATEST}.
+
+@findex DEGREES()
+@item DEGREES(X)
+Returns the argument @code{X}, converted from radians to degrees:
+@example
+mysql> select DEGREES(PI());
+ -> 180.000000
+@end example
+
+@findex RADIANS()
+@item RADIANS(X)
+Returns the argument @code{X}, converted from degrees to radians:
+@example
+mysql> select RADIANS(90);
+ -> 1.570796
+@end example
+
+@findex TRUNCATE()
+@item TRUNCATE(X,D)
+Returns the number @code{X}, truncated to @code{D} decimals. If @code{D}
+is @code{0}, the result will have no decimal point or fractional part:
+@example
+mysql> select TRUNCATE(1.223,1);
+ -> 1.2
+mysql> select TRUNCATE(1.999,1);
+ -> 1.9
+mysql> select TRUNCATE(1.999,0);
+ -> 1
+@end example
+
+Note that as decimal numbers are normally not stored as exact numbers in
+computers, but as double values, you may be fooled by the following
+result:
+
+@cindex rounding errors
+@example
+mysql> select TRUNCATE(10.28*100,0);
+ -> 1027
+@end example
+
+The above happens because 10.28 is actually stored as something like
+10.2799999999999999.
+@end table
+
+
+@node Date and time functions, Other Functions, Numeric Functions, Functions
+@subsection Date and Time Functions
+
@findex date and time functions
@findex functions, date and time
-@node Date and time functions, Miscellaneous functions, String functions, Functions
-@subsection Date and Time Functions
See @ref{Date and time types} for a description of the range of values
each type has and the valid formats in which date and time values may be
@@ -18114,17 +31281,17 @@ mysql> select PERIOD_DIFF(9802,199703);
@findex DATE_SUB()
@findex ADDDATE()
@findex SUBDATE()
-@findex EXTRACT(type FROM date)
+@findex EXTRACT()
@item DATE_ADD(date,INTERVAL expr type)
@itemx DATE_SUB(date,INTERVAL expr type)
@itemx ADDDATE(date,INTERVAL expr type)
@itemx SUBDATE(date,INTERVAL expr type)
-These functions perform date arithmetic. They are new for @strong{MySQL}
+These functions perform date arithmetic. They are new for MySQL
Version 3.22. @code{ADDDATE()} and @code{SUBDATE()} are synonyms for
@code{DATE_ADD()} and @code{DATE_SUB()}.
-In @strong{MySQL} Version 3.23, you can use @code{+} and @code{-} instead of
+In MySQL Version 3.23, you can use @code{+} and @code{-} instead of
@code{DATE_ADD()} and @code{DATE_SUB()} if the expression on the right side is
a date or datetime column. (See example)
@@ -18134,7 +31301,7 @@ or subtracted from the starting date. @code{expr} is a string; it may start
with a @samp{-} for negative intervals. @code{type} is a keyword indicating
how the expression should be interpreted.
-The @code{EXTRACT(type FROM date)} function returns the 'type'
+The related function @code{EXTRACT(type FROM date)} returns the 'type'
interval from the date.
The following table shows how the @code{type} and @code{expr} arguments
@@ -18157,7 +31324,7 @@ are related:
@item @code{DAY_SECOND} @tab @code{"DAYS HOURS:MINUTES:SECONDS"}
@end multitable
-@strong{MySQL} allows any punctuation delimiter in the @code{expr} format.
+MySQL allows any punctuation delimiter in the @code{expr} format.
Those shown in the table are the suggested delimiters. If the @code{date}
argument is a @code{DATE} value and your calculations involve only
@code{YEAR}, @code{MONTH}, and @code{DAY} parts (that is, no time parts), the
@@ -18188,24 +31355,18 @@ mysql> SELECT DATE_ADD("1998-01-01 00:00:00",
-> 1997-12-30 14:00:00
mysql> SELECT DATE_SUB("1998-01-02", INTERVAL 31 DAY);
-> 1997-12-02
-mysql> SELECT EXTRACT(YEAR FROM "1999-07-02");
- -> 1999
-mysql> SELECT EXTRACT(YEAR_MONTH FROM "1999-07-02 01:02:03");
- -> 199907
-mysql> SELECT EXTRACT(DAY_MINUTE FROM "1999-07-02 01:02:03");
- -> 20102
@end example
If you specify an interval value that is too short (does not include all the
interval parts that would be expected from the @code{type} keyword),
-@strong{MySQL} assumes you have left out the leftmost parts of the interval
+MySQL assumes you have left out the leftmost parts of the interval
value. For example, if you specify a @code{type} of @code{DAY_SECOND}, the
value of @code{expr} is expected to have days, hours, minutes, and seconds
-parts. If you specify a value like @code{"1:10"}, @strong{MySQL} assumes
+parts. If you specify a value like @code{"1:10"}, MySQL assumes
that the days and hours parts are missing and the value represents minutes
and seconds. In other words, @code{"1:10" DAY_SECOND} is interpreted in such
a way that it is equivalent to @code{"1:10" MINUTE_SECOND}. This is
-analogous to the way that @strong{MySQL} interprets @code{TIME} values
+analogous to the way that MySQL interprets @code{TIME} values
as representing elapsed time rather than as time of day.
Note that if you add or subtract a date value against something that
@@ -18232,6 +31393,22 @@ mysql> select DATE_ADD('1998-01-30', Interval 1 month);
Note from the preceding example that the word @code{INTERVAL} and the
@code{type} keyword are not case sensitive.
+@findex EXTRACT()
+@item EXTRACT(type FROM date)
+
+The @code{EXTRACT()} function uses the same kinds of interval type
+specifiers as @code{DATE_ADD()} or @code{DATE_SUB()}, but extracts parts
+from the date rather than performing date arithmetic.
+
+@example
+mysql> SELECT EXTRACT(YEAR FROM "1999-07-02");
+ -> 1999
+mysql> SELECT EXTRACT(YEAR_MONTH FROM "1999-07-02 01:02:03");
+ -> 199907
+mysql> SELECT EXTRACT(DAY_MINUTE FROM "1999-07-02 01:02:03");
+ -> 20102
+@end example
+
@findex TO_DAYS()
@item TO_DAYS(date)
Given a date @code{date}, returns a daynumber (the number of days since year
@@ -18316,8 +31493,8 @@ mysql> select DATE_FORMAT('1999-01-01', '%X %V');
-> '1998 52'
@end example
-As of @strong{MySQL} Version 3.23, the @samp{%} character is required before
-format specifier characters. In earlier versions of @strong{MySQL},
+As of MySQL Version 3.23, the @samp{%} character is required before
+format specifier characters. In earlier versions of MySQL,
@samp{%} was optional.
@findex TIME_FORMAT()
@@ -18447,10 +31624,85 @@ mysql> select TIME_TO_SEC('00:39:38');
@end example
@end table
+
+@node Other Functions, , Date and time functions, Functions
+@subsection Other Functions
+
+@menu
+* Bit functions:: Bit Functions
+* Miscellaneous functions:: Miscellaneous Functions
+@end menu
+
+
+@node Bit functions, Miscellaneous functions, Other Functions, Other Functions
+@subsubsection Bit Functions
+
+@findex arithmetic functions
+@findex bit functions
+@findex functions, arithmetic
+@findex functions, bit
+
+MySQL uses @code{BIGINT} (64-bit) arithmetic for bit operations, so
+these operators have a maximum range of 64 bits.
+
+@table @code
+@findex | (bitwise OR)
+@findex OR, bitwise
+@item |
+Bitwise OR:
+@example
+mysql> select 29 | 15;
+ -> 31
+@end example
+
+@findex & (bitwise AND)
+@findex AND, bitwise
+@item &
+Bitwise AND:
+@example
+mysql> select 29 & 15;
+ -> 13
+@end example
+
+@findex << (left shift)
+@item <<
+Shifts a longlong (@code{BIGINT}) number to the left:
+@example
+mysql> select 1 << 2;
+ -> 4
+@end example
+
+@findex >> (right shift)
+@item >>
+Shifts a longlong (@code{BIGINT}) number to the right:
+@example
+mysql> select 4 >> 2;
+ -> 1
+@end example
+
+@findex ~
+@item ~
+Invert all bits:
+@example
+mysql> select 5 & ~1;
+ -> 4
+@end example
+
+@findex BIT_COUNT()
+@item BIT_COUNT(N)
+Returns the number of bits that are set in the argument @code{N}:
+@example
+mysql> select BIT_COUNT(29);
+ -> 4
+@end example
+@end table
+
+
+@node Miscellaneous functions, , Bit functions, Other Functions
+@subsubsection Miscellaneous Functions
+
@findex miscellaneous functions
@findex functions, miscellaneous
-@node Miscellaneous functions, Group by functions, Date and time functions, Functions
-@subsection Miscellaneous Functions
@table @code
@findex DATABASE()
@@ -18470,14 +31722,14 @@ If there is no current database, @code{DATABASE()} returns the empty string.
@item USER()
@itemx SYSTEM_USER()
@itemx SESSION_USER()
-Returns the current @strong{MySQL} user name:
+Returns the current MySQL user name:
@example
mysql> select USER();
-> 'davida@@localhost'
@end example
-In @strong{MySQL} Version 3.22.11 or later, this includes the client hostname
+In MySQL Version 3.22.11 or later, this includes the client hostname
as well as the user name. You can extract just the user name part like this
(which works whether or not the value includes a hostname part):
@@ -18489,7 +31741,7 @@ mysql> select substring_index(USER(),"@@",1);
@findex PASSWORD()
@item PASSWORD(str)
Calculates a password string from the plaintext password @code{str}. This is
-the function that is used for encrypting @strong{MySQL} passwords for storage
+the function that is used for encrypting MySQL passwords for storage
in the @code{Password} column of the @code{user} grant table:
@example
@@ -18502,7 +31754,7 @@ mysql> select PASSWORD('badpwd');
@code{PASSWORD()} does not perform password encryption in the same way that
Unix passwords are encrypted. You should not assume that if your Unix
-password and your @strong{MySQL} password are the same, @code{PASSWORD()}
+password and your MySQL password are the same, @code{PASSWORD()}
will result in the same encrypted value as is stored in the Unix password
file. See @code{ENCRYPT()}.
@@ -18510,7 +31762,7 @@ file. See @code{ENCRYPT()}.
@item ENCRYPT(str[,salt])
Encrypt @code{str} using the Unix @code{crypt()} system call. The
@code{salt} argument should be a string with two characters.
-(As of @strong{MySQL} Version 3.22.16, @code{salt} may be longer than two characters.):
+(As of MySQL Version 3.22.16, @code{salt} may be longer than two characters.):
@example
mysql> select ENCRYPT("hello");
@@ -18593,7 +31845,7 @@ You can generate sequences without calling @code{LAST_INSERT_ID()}, but the
utility of using the function this way is that the ID value is maintained in
the server as the last automatically generated value. You can retrieve the
new ID as you would read any normal @code{AUTO_INCREMENT} value in
-@strong{MySQL}. For example, @code{LAST_INSERT_ID()} (without an argument)
+MySQL. For example, @code{LAST_INSERT_ID()} (without an argument)
will return the new ID. The C API function @code{mysql_insert_id()}
can also be used to get the value.
@@ -18614,7 +31866,7 @@ mysql> select FORMAT(12332.2,0);
@findex VERSION()
@item VERSION()
-Returns a string indicating the @strong{MySQL} server version:
+Returns a string indicating the MySQL server version:
@example
mysql> select VERSION();
@@ -18675,7 +31927,7 @@ been released.
@findex BENCHMARK()
@item BENCHMARK(count,expr)
The @code{BENCHMARK()} function executes the expression @code{expr}
-repeatedly @code{count} times. It may be used to time how fast @strong{MySQL}
+repeatedly @code{count} times. It may be used to time how fast MySQL
processes the expression. The result value is always @code{0}. The intended
use is in the @code{mysql} client, which reports query execution times:
@@ -18729,1435 +31981,26 @@ control of master-slave synchronization, but was originally written to
facilitate replication testing.
@end table
-@findex GROUP BY functions
-@findex functions, GROUP BY
-@node Group by functions, , Miscellaneous functions, Functions
-@subsection Functions for Use with @code{GROUP BY} Clauses
-
-If you use a group function in a statement containing no @code{GROUP BY}
-clause, it is equivalent to grouping on all rows.
-
-@table @code
-@findex COUNT()
-@item COUNT(expr)
-Returns a count of the number of non-@code{NULL} values in the rows
-retrieved by a @code{SELECT} statement:
-@example
-mysql> select student.student_name,COUNT(*)
- from student,course
- where student.student_id=course.student_id
- GROUP BY student_name;
+@node Data Manipulation, Data Definition, Functions, Reference
+@section Data Manipulation: @code{SELECT}, @code{INSERT}, @code{UPDATE}, @code{DELETE}
-@end example
-
-@code{COUNT(*)} is somewhat different in that it returns a count of
-the number of rows retrieved, whether or not they contain @code{NULL}
-values.
-
-@code{COUNT(*)} is optimized to
-return very quickly if the @code{SELECT} retrieves from one table, no
-other columns are retrieved, and there is no @code{WHERE} clause.
-For example:
-
-@example
-mysql> select COUNT(*) from student;
-@end example
-
-@findex COUNT(DISTINCT)
-@findex DISTINCT
-@item COUNT(DISTINCT expr,[expr...])
-Returns a count of the number of different non-@code{NULL} values:
-
-@example
-mysql> select COUNT(DISTINCT results) from student;
-@end example
-
-In @strong{MySQL} you can get the number of distinct expression
-combinations that don't contain NULL by giving a list of expressions.
-In ANSI SQL you would have to do a concatenation of all expressions
-inside @code{CODE(DISTINCT ..)}.
-
-@findex AVG()
-@item AVG(expr)
-Returns the average value of @code{expr}:
-
-@example
-mysql> select student_name, AVG(test_score)
- from student
- GROUP BY student_name;
-@end example
-
-@findex MIN()
-@findex MAX()
-@item MIN(expr)
-@itemx MAX(expr)
-Returns the minimum or maximum value of @code{expr}. @code{MIN()} and
-@code{MAX()} may take a string argument; in such cases they return the
-minimum or maximum string value. @xref{MySQL indexes}.
-
-@example
-mysql> select student_name, MIN(test_score), MAX(test_score)
- from student
- GROUP BY student_name;
-@end example
-
-@findex SUM()
-@item SUM(expr)
-Returns the sum of @code{expr}. Note that if the return set has no rows,
-it returns NULL!
-
-@findex STD()
-@findex STDDEV()
-@cindex Oracle compatibility
-@cindex compatibility, with Oracle
-@item STD(expr)
-@itemx STDDEV(expr)
-Returns the standard deviation of @code{expr}. This is an extension to
-ANSI SQL. The @code{STDDEV()} form of this function is provided for Oracle
-compatibility.
-
-@findex BIT_OR()
-@item BIT_OR(expr)
-Returns the bitwise @code{OR} of all bits in @code{expr}. The calculation is
-performed with 64-bit (@code{BIGINT}) precision.
-
-@findex BIT_AND()
-@item BIT_AND(expr)
-Returns the bitwise @code{AND} of all bits in @code{expr}. The calculation is
-performed with 64-bit (@code{BIGINT}) precision.
-@end table
-
-@cindex @code{GROUP BY}, extensions to ANSI SQL
-@strong{MySQL} has extended the use of @code{GROUP BY}. You can use columns or
-calculations in the @code{SELECT} expressions that don't appear in
-the @code{GROUP BY} part. This stands for @emph{any possible value for this
-group}. You can use this to get better performance by avoiding sorting and
-grouping on unnecessary items. For example, you don't need to group on
-@code{customer.name} in the following query:
-
-@example
-mysql> select order.custid,customer.name,max(payments)
- from order,customer
- where order.custid = customer.custid
- GROUP BY order.custid;
-@end example
-
-In ANSI SQL, you would have to add @code{customer.name} to the @code{GROUP
-BY} clause. In @strong{MySQL}, the name is redundant if you don't run in
-ANSI mode.
-
-@strong{Don't use this feature} if the columns you omit from the
-@code{GROUP BY} part aren't unique in the group! You will get
-unpredictable results.
-
-In some cases, you can use @code{MIN()} and @code{MAX()} to obtain a specific
-column value even if it isn't unique. The following gives the value of
-@code{column} from the row containing the smallest value in the @code{sort}
-column:
-
-@example
-substr(MIN(concat(rpad(sort,6,' '),column)),7)
-@end example
-
-@xref{example-Maximum-column-group-row}.
-
-@cindex @code{ORDER BY}, aliases in
-@cindex aliases, in @code{ORDER BY} clauses
-@cindex @code{GROUP BY}, aliases in
-@cindex aliases, in @code{GROUP BY} clauses
-@cindex expression aliases
-@cindex aliases, for expressions
-Note that if you are using @strong{MySQL} Version 3.22 (or earlier) or if
-you are trying to follow ANSI SQL, you can't use expressions in @code{GROUP
-BY} or @code{ORDER BY} clauses. You can work around this limitation by
-using an alias for the expression:
-
-@example
-mysql> SELECT id,FLOOR(value/100) AS val FROM tbl_name
- GROUP BY id,val ORDER BY val;
-@end example
-
-In @strong{MySQL} Version 3.23 you can do:
-
-@example
-mysql> SELECT id,FLOOR(value/100) FROM tbl_name ORDER BY RAND();
-@end example
-
-@findex CREATE DATABASE
-@node CREATE DATABASE, DROP DATABASE, Functions, Reference
-@section @code{CREATE DATABASE} Syntax
-
-@example
-CREATE DATABASE [IF NOT EXISTS] db_name
-@end example
-
-@code{CREATE DATABASE} creates a database with the given name. Rules for
-allowable database names are given in @ref{Legal names}. An error occurs if
-the database already exists and you didn't specify @code{IF NOT EXISTS}.
-
-Databases in @strong{MySQL} are implemented as directories containing files
-that correspond to tables in the database. Because there are no tables in a
-database when it is initially created, the @code{CREATE DATABASE} statement
-only creates a directory under the @strong{MySQL} data directory.
-
-@cindex @code{mysqladmin}
-You can also create databases with @code{mysqladmin}.
-@xref{Programs}.
-
-@findex DROP DATABASE
-@node DROP DATABASE, CREATE TABLE, CREATE DATABASE, Reference
-@section @code{DROP DATABASE} Syntax
-
-@example
-DROP DATABASE [IF EXISTS] db_name
-@end example
-
-@code{DROP DATABASE} drops all tables in the database and deletes the
-database. If you do a @code{DROP DATABASE} on a symbolic linked
-database, both the link and the original database is deleted. @strong{Be
-VERY careful with this command!}
-
-@code{DROP DATABASE} returns the number of files that were removed from
-the database directory. Normally, this is three times the number of
-tables, because normally each table corresponds to a @file{.MYD} file, a
-@file{.MYI} file, and a @file{.frm} file.
-
-The @code{DROP DATABASE} command removes from the given database
-directory all files with the following extensions:
-
-@multitable @columnfractions .25 .25 .25 .25
-@item .BAK @tab .DAT @tab .HSH @tab .ISD
-@item .ISM @tab .ISM @tab .MRG @tab .MYD
-@item .MYI @tab .db @tab .frm
-@end multitable
-
-All subdirectories that consists of 2 digits (@code{RAID} directories)
-are also removed.
-
-In @strong{MySQL} Version 3.22 or later, you can use the keywords
-@code{IF EXISTS} to prevent an error from occurring if the database doesn't
-exist.
-
-@cindex @code{mysqladmin}
-You can also drop databases with @code{mysqladmin}. @xref{Programs}.
-
-@findex CREATE TABLE
-@node CREATE TABLE, ALTER TABLE, DROP DATABASE, Reference
-@section @code{CREATE TABLE} Syntax
@menu
-* Silent column changes:: Silent column changes
+* SELECT:: @code{SELECT} Syntax
+* INSERT:: @code{INSERT} Syntax
+* INSERT DELAYED:: @code{INSERT DELAYED} syntax
+* UPDATE:: @code{UPDATE} Syntax
+* DELETE:: @code{DELETE} Syntax
+* TRUNCATE:: @code{TRUNCATE} Syntax
+* REPLACE:: @code{REPLACE} Syntax
+* LOAD DATA:: @code{LOAD DATA INFILE} Syntax
@end menu
-@example
-CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name [(create_definition,...)]
-[table_options] [select_statement]
-
-create_definition:
- col_name type [NOT NULL | NULL] [DEFAULT default_value] [AUTO_INCREMENT]
- [PRIMARY KEY] [reference_definition]
- or PRIMARY KEY (index_col_name,...)
- or KEY [index_name] (index_col_name,...)
- or INDEX [index_name] (index_col_name,...)
- or UNIQUE [INDEX] [index_name] (index_col_name,...)
- or FULLTEXT [INDEX] [index_name] (index_col_name,...)
- or [CONSTRAINT symbol] FOREIGN KEY index_name (index_col_name,...)
- [reference_definition]
- or CHECK (expr)
-
-type:
- TINYINT[(length)] [UNSIGNED] [ZEROFILL]
- or SMALLINT[(length)] [UNSIGNED] [ZEROFILL]
- or MEDIUMINT[(length)] [UNSIGNED] [ZEROFILL]
- or INT[(length)] [UNSIGNED] [ZEROFILL]
- or INTEGER[(length)] [UNSIGNED] [ZEROFILL]
- or BIGINT[(length)] [UNSIGNED] [ZEROFILL]
- or REAL[(length,decimals)] [UNSIGNED] [ZEROFILL]
- or DOUBLE[(length,decimals)] [UNSIGNED] [ZEROFILL]
- or FLOAT[(length,decimals)] [UNSIGNED] [ZEROFILL]
- or DECIMAL(length,decimals) [UNSIGNED] [ZEROFILL]
- or NUMERIC(length,decimals) [UNSIGNED] [ZEROFILL]
- or CHAR(length) [BINARY]
- or VARCHAR(length) [BINARY]
- or DATE
- or TIME
- or TIMESTAMP
- or DATETIME
- or TINYBLOB
- or BLOB
- or MEDIUMBLOB
- or LONGBLOB
- or TINYTEXT
- or TEXT
- or MEDIUMTEXT
- or LONGTEXT
- or ENUM(value1,value2,value3,...)
- or SET(value1,value2,value3,...)
-
-index_col_name:
- col_name [(length)]
-
-reference_definition:
- REFERENCES tbl_name [(index_col_name,...)]
- [MATCH FULL | MATCH PARTIAL]
- [ON DELETE reference_option]
- [ON UPDATE reference_option]
-
-reference_option:
- RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT
-
-table_options:
- TYPE = @{BDB | HEAP | ISAM | InnoDB | MERGE | MYISAM @}
-or AUTO_INCREMENT = #
-or AVG_ROW_LENGTH = #
-or CHECKSUM = @{0 | 1@}
-or COMMENT = "string"
-or MAX_ROWS = #
-or MIN_ROWS = #
-or PACK_KEYS = @{0 | 1@}
-or PASSWORD = "string"
-or DELAY_KEY_WRITE = @{0 | 1@}
-or ROW_FORMAT= @{ default | dynamic | fixed | compressed @}
-or RAID_TYPE= @{1 | STRIPED | RAID0 @} RAID_CHUNKS=# RAID_CHUNKSIZE=#
-or UNION = (table_name,[table_name...])
-or DATA DIRECTORY="directory"
-or INDEX DIRECTORY="directory"
-
-select_statement:
- [IGNORE | REPLACE] SELECT ... (Some legal select statement)
-@end example
-
-@code{CREATE TABLE}
-creates a table with the given name in the current database. Rules for
-allowable table names are given in @ref{Legal names}. An error occurs if
-there is no current database or if the table already exists.
-
-In @strong{MySQL} Version 3.22 or later, the table name can be specified as
-@code{db_name.tbl_name}. This works whether or not there is a current
-database.
-
-In @strong{MySQL} Version 3.23, you can use the @code{TEMPORARY} keyword when
-you create a table. A temporary table will automatically be deleted if a
-connection dies and the name is per connection. This means that two different
-connections can both use the same temporary table name without conflicting
-with each other or with an existing table of the same name. (The existing table
-is hidden until the temporary table is deleted).
-
-In @strong{MySQL} Version 3.23 or later, you can use the keywords
-@code{IF NOT EXISTS} so that an error does not occur if the table already
-exists. Note that there is no verification that the table structures are
-identical.
-
-Each table @code{tbl_name} is represented by some files in the database
-directory. In the case of MyISAM-type tables you will get:
-
-@multitable @columnfractions .2 .8
-@item @strong{File} @tab @strong{Purpose}
-@item @code{tbl_name.frm} @tab Table definition (form) file
-@item @code{tbl_name.MYD} @tab Data file
-@item @code{tbl_name.MYI} @tab Index file
-@end multitable
-
-For more information on the properties of the various column types, see
-@ref{Column types}:
-
-@itemize @bullet
-@item
-If neither @code{NULL} nor @code{NOT NULL} is specified, the column
-is treated as though @code{NULL} had been specified.
-
-@item
-An integer column may have the additional attribute @code{AUTO_INCREMENT}.
-When you insert a value of @code{NULL} (recommended) or @code{0} into an
-@code{AUTO_INCREMENT} column, the column is set to @code{value+1}, where
-@code{value} is the largest value for the column currently in the table.
-@code{AUTO_INCREMENT} sequences begin with @code{1}.
-@xref{mysql_insert_id, , @code{mysql_insert_id()}}.
-
-If you delete the row containing the maximum value for an
-@code{AUTO_INCREMENT} column, the value will be reused with an
-@code{ISAM} or @code{BDB} table but not with a
-@code{MyISAM} or @code{InnoDB} table. If you delete all rows in the table
-with @code{DELETE FROM table_name} (without a @code{WHERE}) in
-@code{AUTOCOMMIT} mode, the sequence starts over for all table types.
-
-@strong{NOTE:} There can be only one @code{AUTO_INCREMENT} column per
-table, and it must be indexed. @strong{MySQL} Version 3.23 will also only
-work properly if the auto_increment column only has positive
-values. Inserting a negative number is regarded as inserting a very large
-positive number. This is done to avoid precision problems when
-numbers 'wrap' over from positive to negative and also to ensure that one
-doesn't accidentally get an auto_increment column that contains 0.
-
-@cindex ODBC compatibility
-@cindex compatibility, with ODBC
-To make @strong{MySQL} compatible with some ODBC applications, you can find
-the last inserted row with the following query:
-
-@example
-SELECT * FROM tbl_name WHERE auto_col IS NULL
-@end example
-
-@item
-@code{NULL} values are handled differently for @code{TIMESTAMP} columns than
-for other column types. You cannot store a literal @code{NULL} in a
-@code{TIMESTAMP} column; setting the column to @code{NULL} sets it to the
-current date and time. Because @code{TIMESTAMP} columns behave this way, the
-@code{NULL} and @code{NOT NULL} attributes do not apply in the normal way and
-are ignored if you specify them.
-
-On the other hand, to make it easier for @strong{MySQL} clients to use
-@code{TIMESTAMP} columns, the server reports that such columns may be
-assigned @code{NULL} values (which is true), even though @code{TIMESTAMP}
-never actually will contain a @code{NULL} value. You can see this when you
-use @code{DESCRIBE tbl_name} to get a description of your table.
-
-Note that setting a @code{TIMESTAMP} column to @code{0} is not the same
-as setting it to @code{NULL}, because @code{0} is a valid @code{TIMESTAMP}
-value.
-
-@item
-If no @code{DEFAULT} value is specified for a column, @strong{MySQL}
-automatically assigns one.
-
-If the column may take @code{NULL} as a value, the default value is
-@code{NULL}.
-
-If the column is declared as @code{NOT NULL}, the default value depends on
-the column type:
-
-@itemize @minus
-@item
-For numeric types other than those declared with the @code{AUTO_INCREMENT}
-attribute, the default is @code{0}. For an @code{AUTO_INCREMENT} column, the
-default value is the next value in the sequence.
-
-@item
-For date and time types other than @code{TIMESTAMP}, the default is the
-appropriate zero value for the type. For the first @code{TIMESTAMP}
-column in a table, the default value is the current date and time.
-@xref{Date and time types}.
-
-@item
-For string types other than @code{ENUM}, the default value is the empty string.
-For @code{ENUM}, the default is the first enumeration value.
-@end itemize
-
-Default values must be constants. This means, for example, that you cannot
-set the default for a date column to be the value of a function such as
-@code{NOW()} or @code{CURRENT_DATE}.
-
-@item
-@code{KEY} is a synonym for @code{INDEX}.
-
-@item
-In @strong{MySQL}, a @code{UNIQUE} key can have only distinct values. An
-error occurs if you try to add a new row with a key that matches an existing
-row.
-
-@item
-@tindex PRIMARY KEY
-A @code{PRIMARY KEY} is a unique @code{KEY} with the extra constraint
-that all key columns must be defined as @code{NOT NULL}. In @strong{MySQL}
-the key is named @code{PRIMARY}. A table can have only one @code{PRIMARY KEY}.
-If you don't have a @code{PRIMARY KEY} and some applications ask for the
-@code{PRIMARY KEY} in your tables, @strong{MySQL} will return the first
-@code{UNIQUE} key, which doesn't have any @code{NULL} columns, as the
-@code{PRIMARY KEY}.
-
-@item
-A @code{PRIMARY KEY} can be a multiple-column index. However, you cannot
-create a multiple-column index using the @code{PRIMARY KEY} key attibute in a
-column specification. Doing so will mark only that single column as primary.
-You must use the @code{PRIMARY KEY(index_col_name, ...)} syntax.
-
-@item
-If the @code{PRIMARY} or @code{UNIQUE} key consists of only one column and this
-is of type integer, you can also refer to it as @code{_rowid}
-(new in Version 3.23.11).
-
-@item
-If you don't assign a name to an index, the index will be assigned the same
-name as the first @code{index_col_name}, with an optional suffix (@code{_2},
-@code{_3}, @code{...}) to make it unique. You can see index names for a
-table using @code{SHOW INDEX FROM tbl_name}.
-@xref{SHOW, , @code{SHOW}}.
-
-@item
-@cindex @code{NULL} values, and indexes
-@cindex indexes, and @code{NULL} values
-Only the @code{MyISAM} table type supports indexes on columns that can have
-@code{NULL} values. In other cases you must declare such columns
-@code{NOT NULL} or an error results.
-
-@item
-With @code{col_name(length)} syntax, you can specify an index that
-uses only a part of a @code{CHAR} or @code{VARCHAR} column. This can
-make the index file much smaller.
-@xref{Indexes}.
-
-@item
-@cindex @code{BLOB} columns, indexing
-@cindex indexes, and @code{BLOB} columns
-@cindex @code{TEXT} columns, indexing
-@cindex indexes, and @code{TEXT} columns
-Only the @code{MyISAM} table type supports indexing on @code{BLOB} and
-@code{TEXT} columns. When putting an index on a @code{BLOB} or @code{TEXT}
-column you MUST always specify the length of the index:
-@example
-CREATE TABLE test (blob_col BLOB, index(blob_col(10)));
-@end example
-
-@item
-When you use @code{ORDER BY} or @code{GROUP BY} with a @code{TEXT} or
-@code{BLOB} column, only the first @code{max_sort_length} bytes are used.
-@xref{BLOB, , @code{BLOB}}.
-
-@item
-In @strong{MySQL} Version 3.23.23 or later, you can also create special
-@strong{FULLTEXT} indexes. They are used for full-text search. Only the
-@code{MyISAM} table type supports @code{FULLTEXT} indexes. They can be created
-only from @code{VARCHAR} and @code{TEXT} columns.
-Indexing always happens over the entire column, partial indexing is not
-supported. See @ref{Fulltext Search} for details of operation.
-
-@item
-The @code{FOREIGN KEY}, @code{CHECK}, and @code{REFERENCES} clauses don't
-actually do anything. The syntax for them is provided only for compatibility,
-to make it easier to port code from other SQL servers and to run applications
-that create tables with references.
-@xref{Missing functions}.
-
-@item
-Each @code{NULL} column takes one bit extra, rounded up to the nearest byte.
-
-@item
-The maximum record length in bytes can be calculated as follows:
-
-@example
-row length = 1
- + (sum of column lengths)
- + (number of NULL columns + 7)/8
- + (number of variable-length columns)
-@end example
-
-@item
-The @code{table_options} and @code{SELECT} options are only
-implemented in @strong{MySQL} Version 3.23 and above.
-
-The different table types are:
-
-@multitable @columnfractions .20 .80
-@item BDB or Berkeley_db @tab Transaction-safe tables with page locking. @xref{BDB}.
-@item HEAP @tab The data for this table is only stored in memory. @xref{HEAP}.
-@item ISAM @tab The original table handler. @xref{ISAM}.
-@item InnoDB @tab Transaction-safe tables with row locking. @xref{InnoDB}.
-@item MERGE @tab A collection of MyISAM tables used as one table. @xref{MERGE}.
-@item MyISAM @tab The new binary portable table handler that is replacing ISAM. @xref{MyISAM}.
-@end multitable
-@xref{Table types}.
-
-If a table type is specified, and that particular type is not available,
-@strong{MySQL} will choose the closest table type to the one that you have
-specified. For example, if @code{TYPE=BDB} is specified, and that distribution
-of @strong{MySQL} does not support @code{BDB} tables, the table will be created
-as @code{MyISAM} instead.
-
-The other table options are used to optimize the behavior of the
-table. In most cases, you don't have to specify any of them.
-The options work for all table types, if not otherwise indicated:
-
-@multitable @columnfractions .20 .80
-@item @code{AUTO_INCREMENT} @tab The next auto_increment value you want to set for your table (MyISAM).
-@item @code{AVG_ROW_LENGTH} @tab An approximation of the average row length for your table. You only need to set this for large tables with variable size records.
-@item @code{CHECKSUM} @tab Set this to 1 if you want @strong{MySQL} to maintain a checksum for all rows (makes the table a little slower to update but makes it easier to find corrupted tables) (MyISAM).
-@item @code{COMMENT} @tab A 60-character comment for your table.
-@item @code{MAX_ROWS} @tab Max number of rows you plan to store in the table.
-@item @code{MIN_ROWS} @tab Minimum number of rows you plan to store in the table.
-@item @code{PACK_KEYS} @tab Set this to 1 if you want to have a smaller index. This usually makes updates slower and reads faster (MyISAM, ISAM).
-@item @code{PASSWORD} @tab Encrypt the @code{.frm} file with a password. This option doesn't do anything in the standard @strong{MySQL} version.
-@item @code{DELAY_KEY_WRITE} @tab Set this to 1 if want to delay key table updates until the table is closed (MyISAM).
-@item @code{ROW_FORMAT} @tab Defines how the rows should be stored. Currently you can only use the DYNAMIC and STATIC options for MyISAM tables.
-@end multitable
-
-When you use a @code{MyISAM} table, @strong{MySQL} uses the product of
-@code{max_rows * avg_row_length} to decide how big the resulting table
-will be. If you don't specify any of the above options, the maximum size
-for a table will be 4G (or 2G if your operating systems only supports 2G
-tables). The reason for this is just to keep down the pointer sizes
-to make the index smaller and faster if you don't really need big files.
-
-If you don't use @code{PACK_KEYS}, the default is to only pack strings,
-not numbers. If you use @code{PACK_KEYS=1}, numbers will be packed as well.
-
-When packing binary number keys, @strong{MySQL} will use prefix compression.
-This means that you will only get a big benefit of this if you have
-many numbers that are the same. Prefix compression means that every
-key needs one extra byte to indicate how many bytes of the previous key are
-the same for the next key (note that the pointer to the row is stored
-in high-byte-first-order directly after the key, to improve
-compression.) This means that if you have many equal keys on two rows
-in a row, all following 'same' keys will usually only take 2 bytes
-(including the pointer to the row). Compare this to the ordinary case
-where the following keys will take storage_size_for_key +
-pointer_size (usually 4). On the other hand, if all keys are
-totally different, you will lose 1 byte per key, if the key isn't a
-key that can have @code{NULL} values (In this case the packed key length will
-be stored in the same byte that is used to mark if a key is @code{NULL}.)
-
-@item
-If you specify a @code{SELECT} after the @code{CREATE} statement,
-@strong{MySQL} will create new fields for all elements in the
-@code{SELECT}. For example:
-
-@example
-mysql> CREATE TABLE test (a int not null auto_increment,
- primary key (a), key(b))
- TYPE=MyISAM SELECT b,c from test2;
-@end example
-
-This will create a @code{MyISAM} table with three columns, a, b, and c.
-Notice that the columns from the @code{SELECT} statement are appended to
-the right side of the table, not overlapped onto it. Take the following
-example:
-
-@example
-mysql> select * from foo;
-+---+
-| n |
-+---+
-| 1 |
-+---+
-
-mysql> create table bar (m int) select n from foo;
-Query OK, 1 row affected (0.02 sec)
-Records: 1 Duplicates: 0 Warnings: 0
-
-mysql> select * from bar;
-+------+---+
-| m | n |
-+------+---+
-| NULL | 1 |
-+------+---+
-1 row in set (0.00 sec)
-@end example
-
-For each row in table @code{foo}, a row is inserted in @code{bar} with
-the values from @code{foo} and default values for the new columns.
-
-If any errors occur while copying the data to the table, it will
-automatically be deleted.
-
-To ensure that the update log/binary log can be used to re-create the
-original tables, @strong{MySQL} will not allow concurrent inserts during
-@code{CREATE TABLE .... SELECT}.
-@item
-The @code{RAID_TYPE} option will help you to break the 2G/4G limit for
-the MyISAM data file (not the index file) on
-operating systems that don't support big files. You can get also more speed
-from the I/O bottleneck by putting @code{RAID} directories on different
-physical disks. @code{RAID_TYPE} will work on any OS, as long as you have
-configured @strong{MySQL} with @code{--with-raid}. For now the only allowed
-@code{RAID_TYPE} is @code{STRIPED} (@code{1} and @code{RAID0} are aliases
-for this).
-
-If you specify @code{RAID_TYPE=STRIPED} for a @code{MyISAM} table,
-@code{MyISAM} will create @code{RAID_CHUNKS} subdirectories named 00,
-01, 02 in the database directory. In each of these directories
-@code{MyISAM} will create a @code{table_name.MYD}. When writing data
-to the data file, the @code{RAID} handler will map the first
-@code{RAID_CHUNKSIZE} *1024 bytes to the first file, the next
-@code{RAID_CHUNKSIZE} *1024 bytes to the next file and so on.
-@item
-@code{UNION} is used when you want to use a collection of identical
-tables as one. This only works with MERGE tables. @xref{MERGE}.
-
-For the moment you need to have @code{SELECT}, @code{UPDATE}, and
-@code{DELETE} privileges on the tables you map to a @code{MERGE} table.
-All mapped tables must be in the same database as the @code{MERGE} table.
-@item
-In the created table the @code{PRIMARY} key will be placed first, followed
-by all @code{UNIQUE} keys and then the normal keys. This helps the
-@strong{MySQL} optimizer to prioritize which key to use and also more quickly
-detect duplicated @code{UNIQUE} keys.
-
-@item
-By using @code{DATA DIRECTORY="directory"} or @code{INDEX
-DIRECTORY="directory"} you can specify where the table handler should
-put it's table and index files. This only works for @code{MyISAM} tables
-in @code{MySQL} 4.0, when you are not using the @code{--skip-symlink}
-option. @xref{Symbolic links to tables}.
-
-@end itemize
-
-@cindex silent column changes
-@node Silent column changes, , CREATE TABLE, CREATE TABLE
-@subsection Silent Column Specification Changes
-
-In some cases, @strong{MySQL} silently changes a column specification from
-that given in a @code{CREATE TABLE} statement. (This may also occur with
-@code{ALTER TABLE}.):
-
-@itemize @bullet
-@item
-@code{VARCHAR} columns with a length less than four are changed to
-@code{CHAR}.
-
-@item
-If any column in a table has a variable length, the entire row is
-variable-length as a result. Therefore, if a table contains any
-variable-length columns (@code{VARCHAR}, @code{TEXT}, or @code{BLOB}),
-all @code{CHAR} columns longer than three characters are changed to
-@code{VARCHAR} columns. This doesn't affect how you use the columns in
-any way; in @strong{MySQL}, @code{VARCHAR} is just a different way to
-store characters. @strong{MySQL} performs this conversion because it
-saves space and makes table operations faster. @xref{Table types}.
-
-@item
-@code{TIMESTAMP} display sizes must be even and in the range from 2 to 14.
-If you specify a display size of 0 or greater than 14, the size is coerced
-to 14. Odd-valued sizes in the range from 1 to 13 are coerced
-to the next higher even number.
-
-@item
-You cannot store a literal @code{NULL} in a @code{TIMESTAMP} column; setting
-it to @code{NULL} sets it to the current date and time. Because
-@code{TIMESTAMP} columns behave this way, the @code{NULL} and @code{NOT NULL}
-attributes do not apply in the normal way and are ignored if you specify
-them. @code{DESCRIBE tbl_name} always reports that a @code{TIMESTAMP}
-column may be assigned @code{NULL} values.
-
-@item
-@strong{MySQL} maps certain column types used by other SQL database vendors
-to @strong{MySQL} types. @xref{Other-vendor column types}.
-@end itemize
-
-If you want to see whether or not @strong{MySQL} used a column type other
-than the one you specified, issue a @code{DESCRIBE tbl_name} statement after
-creating or altering your table.
-
-@cindex @code{myisampack}
-Certain other column type changes may occur if you compress a table
-using @code{myisampack}. @xref{Compressed format}.
-
-@findex ALTER TABLE
-@node ALTER TABLE, RENAME TABLE, CREATE TABLE, Reference
-@section @code{ALTER TABLE} Syntax
-
-@example
-ALTER [IGNORE] TABLE tbl_name alter_spec [, alter_spec ...]
-
-alter_specification:
- ADD [COLUMN] create_definition [FIRST | AFTER column_name ]
- or ADD [COLUMN] (create_definition, create_definition,...)
- or ADD INDEX [index_name] (index_col_name,...)
- or ADD PRIMARY KEY (index_col_name,...)
- or ADD UNIQUE [index_name] (index_col_name,...)
- or ADD FULLTEXT [index_name] (index_col_name,...)
- or ADD [CONSTRAINT symbol] FOREIGN KEY index_name (index_col_name,...)
- [reference_definition]
- or ALTER [COLUMN] col_name @{SET DEFAULT literal | DROP DEFAULT@}
- or CHANGE [COLUMN] old_col_name create_definition
- or MODIFY [COLUMN] create_definition
- or DROP [COLUMN] col_name
- or DROP PRIMARY KEY
- or DROP INDEX index_name
- or DISABLE KEYS
- or ENABLE KEYS
- or RENAME [TO] new_tbl_name
- or ORDER BY col
- or table_options
-@end example
-
-@code{ALTER TABLE} allows you to change the structure of an existing table.
-For example, you can add or delete columns, create or destroy indexes, change
-the type of existing columns, or rename columns or the table itself. You can
-also change the comment for the table and type of the table.
-@xref{CREATE TABLE, , @code{CREATE TABLE}}.
-
-If you use @code{ALTER TABLE} to change a column specification but
-@code{DESCRIBE tbl_name} indicates that your column was not changed, it is
-possible that @strong{MySQL} ignored your modification for one of the reasons
-described in @ref{Silent column changes}. For example, if you try to change
-a @code{VARCHAR} column to @code{CHAR}, @strong{MySQL} will still use
-@code{VARCHAR} if the table contains other variable-length columns.
-
-@code{ALTER TABLE} works by making a temporary copy of the original table.
-The alteration is performed on the copy, then the original table is
-deleted and the new one is renamed. This is done in such a way that
-all updates are automatically redirected to the new table without
-any failed updates. While @code{ALTER TABLE} is executing, the original
-table is readable by other clients. Updates and writes to the table
-are stalled until the new table is ready.
-
-Note that if you use any other option to @code{ALTER TABLE} than
-@code{RENAME}, @strong{MySQL} will always create a temporary table, even
-if the data wouldn't strictly need to be copied (like when you change the
-name of a column). We plan to fix this in the future, but as one doesn't
-normally do @code{ALTER TABLE} that often this isn't that high on our TODO.
-
-@itemize @bullet
-@item
-To use @code{ALTER TABLE}, you need @strong{ALTER}, @strong{INSERT},
-and @strong{CREATE} privileges on the table.
-
-@item
-@code{IGNORE} is a @strong{MySQL} extension to ANSI SQL92.
-It controls how @code{ALTER TABLE} works if there are duplicates on
-unique keys in the new table.
-If @code{IGNORE} isn't specified, the copy is aborted and rolled back.
-If @code{IGNORE} is specified, then for rows with duplicates on a unique
-key, only the first row is used; the others are deleted.
-
-@item
-You can issue multiple @code{ADD}, @code{ALTER}, @code{DROP}, and
-@code{CHANGE} clauses in a single @code{ALTER TABLE} statement. This is a
-@strong{MySQL} extension to ANSI SQL92, which allows only one of each clause
-per @code{ALTER TABLE} statement.
-
-@item
-@code{CHANGE col_name}, @code{DROP col_name}, and @code{DROP
-INDEX} are @strong{MySQL} extensions to ANSI SQL92.
-
-@item
-@code{MODIFY} is an Oracle extension to @code{ALTER TABLE}.
-
-@item
-The optional word @code{COLUMN} is a pure noise word and can be omitted.
-
-@item
-If you use @code{ALTER TABLE tbl_name RENAME TO new_name} without any other
-options, @strong{MySQL} simply renames the files that correspond to the table
-@code{tbl_name}. There is no need to create the temporary table.
-@xref{RENAME TABLE,, @code{RENAME TABLE}}.
-
-@item
-@code{create_definition} clauses use the same syntax for @code{ADD} and
-@code{CHANGE} as for @code{CREATE TABLE}. Note that this syntax includes
-the column name, not just the column type.
-@xref{CREATE TABLE, , @code{CREATE TABLE}}.
-
-@item
-You can rename a column using a @code{CHANGE old_col_name create_definition}
-clause. To do so, specify the old and new column names and the type that
-the column currently has. For example, to rename an @code{INTEGER} column
-from @code{a} to @code{b}, you can do this:
-
-@example
-mysql> ALTER TABLE t1 CHANGE a b INTEGER;
-@end example
-
-If you want to change a column's type but not the name, @code{CHANGE}
-syntax still requires two column names even if they are the same. For
-example:
-
-@example
-mysql> ALTER TABLE t1 CHANGE b b BIGINT NOT NULL;
-@end example
-
-However, as of @strong{MySQL} Version 3.22.16a, you can also use @code{MODIFY}
-to change a column's type without renaming it:
-
-@example
-mysql> ALTER TABLE t1 MODIFY b BIGINT NOT NULL;
-@end example
-
-@item
-If you use @code{CHANGE} or @code{MODIFY} to shorten a column for which
-an index exists on part of the column (for instance, if you have an index
-on the first 10 characters of a @code{VARCHAR} column), you cannot make
-the column shorter than the number of characters that are indexed.
-
-@item
-When you change a column type using @code{CHANGE} or @code{MODIFY},
-@strong{MySQL} tries to convert data to the new type as well as possible.
-
-@item
-In @strong{MySQL} Version 3.22 or later, you can use @code{FIRST} or
-@code{ADD ... AFTER col_name} to add a column at a specific position within
-a table row. The default is to add the column last.
-
-@findex ALTER COLUMN
-@item
-@code{ALTER COLUMN} specifies a new default value for a column
-or removes the old default value.
-If the old default is removed and the column can be @code{NULL}, the new
-default is @code{NULL}. If the column cannot be @code{NULL}, @strong{MySQL}
-assigns a default value, as described in
-@ref{CREATE TABLE, , @code{CREATE TABLE}}.
-
-@findex DROP INDEX
-@item
-@code{DROP INDEX} removes an index. This is a @strong{MySQL} extension to
-ANSI SQL92. @xref{DROP INDEX}.
-
-@item
-If columns are dropped from a table, the columns are also removed from any
-index of which they are a part. If all columns that make up an index are
-dropped, the index is dropped as well.
-
-@item
-If a table contains only one column, the column cannot be dropped.
-If what you intend is to remove the table, use @code{DROP TABLE} instead.
-
-@findex DROP PRIMARY KEY
-@item
-@code{DROP PRIMARY KEY} drops the primary index. If no such
-index exists, it drops the first @code{UNIQUE} index in the table.
-(@strong{MySQL} marks the first @code{UNIQUE} key as the @code{PRIMARY KEY}
-if no @code{PRIMARY KEY} was specified explicitly.)
-
-@findex ORDER BY
-@item
-@code{ORDER BY} allows you to create the new table with the rows in a
-specific order. Note that the table will not remain in this order after
-inserts and deletes. In some cases, it may make sorting easier for
-@strong{MySQL} if the table is in order by the column that you wish to
-order it by later. This option is mainly useful when you know that you
-are mostly going to query the rows in a certain order; By using this
-option after big changes to the table, you may be able to get higher
-performance.
-
-@findex ALTER TABLE
-@item
-If you use @code{ALTER TABLE} on a @code{MyISAM} table, all non-unique
-indexes are created in a separate batch (like in @code{REPAIR}).
-This should make @code{ALTER TABLE} much faster when you have many indexes.
-
-@item
-Since @strong{MySQL 4.0} this feature could be activated explicitly.
-@code{ALTER TABLE ... DISABLE KEYS} makes @strong{MySQL} to stop updating
-non-unique indexes for @code{MyISAM} table.
-@code{ALTER TABLE ... ENABLE KEYS} then should be used to recreate missing
-indexes. As @strong{MySQL} does it with special algorithm which is much
-faster then inserting keys one by one, disabling keys could give a
-considerable speedup on bulk inserts.
-
-@item
-@findex mysql_info()
-With the C API function @code{mysql_info()}, you can find out how many
-records were copied, and (when @code{IGNORE} is used) how many records were
-deleted due to duplication of unique key values.
-
-@item
-@cindex foreign keys
-@cindex references
-The @code{FOREIGN KEY}, @code{CHECK}, and @code{REFERENCES} clauses don't
-actually do anything. The syntax for them is provided only for compatibility,
-to make it easier to port code from other SQL servers and to run applications
-that create tables with references.
-@xref{Missing functions}.
-@end itemize
-
-Here is an example that shows some of the uses of @code{ALTER TABLE}. We
-begin with a table @code{t1} that is created as shown below:
-
-@example
-mysql> CREATE TABLE t1 (a INTEGER,b CHAR(10));
-@end example
-
-To rename the table from @code{t1} to @code{t2}:
-
-@example
-mysql> ALTER TABLE t1 RENAME t2;
-@end example
-
-To change column @code{a} from @code{INTEGER} to @code{TINYINT NOT NULL}
-(leaving the name the same), and to change column @code{b} from
-@code{CHAR(10)} to @code{CHAR(20)} as well as renaming it from @code{b} to
-@code{c}:
-
-@example
-mysql> ALTER TABLE t2 MODIFY a TINYINT NOT NULL, CHANGE b c CHAR(20);
-@end example
-
-To add a new @code{TIMESTAMP} column named @code{d}:
-
-@example
-mysql> ALTER TABLE t2 ADD d TIMESTAMP;
-@end example
-
-To add an index on column @code{d}, and make column @code{a} the primary key:
-
-@example
-mysql> ALTER TABLE t2 ADD INDEX (d), ADD PRIMARY KEY (a);
-@end example
-
-To remove column @code{c}:
-
-@example
-mysql> ALTER TABLE t2 DROP COLUMN c;
-@end example
-
-To add a new @code{AUTO_INCREMENT} integer column named @code{c}:
-
-@example
-mysql> ALTER TABLE t2 ADD c INT UNSIGNED NOT NULL AUTO_INCREMENT,
- ADD INDEX (c);
-@end example
-
-Note that we indexed @code{c}, because @code{AUTO_INCREMENT} columns must be
-indexed, and also that we declare @code{c} as @code{NOT NULL}, because
-indexed columns cannot be @code{NULL}.
-
-When you add an @code{AUTO_INCREMENT} column, column values are filled in
-with sequence numbers for you automatically. You can set the first
-sequence number by executing @code{SET INSERT_ID=#} before
-@code{ALTER TABLE} or using the @code{AUTO_INCREMENT = #} table option.
-@xref{SET OPTION}.
-
-With MyISAM tables, if you don't change the @code{AUTO_INCREMENT}
-column, the sequence number will not be affected. If you drop an
-@code{AUTO_INCREMENT} column and then add another @code{AUTO_INCREMENT}
-column, the numbers will start from 1 again.
-
-@xref{ALTER TABLE problems}.
-
-@findex RENAME TABLE
-@node RENAME TABLE, DROP TABLE, ALTER TABLE, Reference
-@section @code{RENAME TABLE} Syntax
-
-@example
-RENAME TABLE tbl_name TO new_table_name[, tbl_name2 TO new_table_name2,...]
-@end example
-
-The rename is done atomically, which means that no other thread can
-access any of the tables while the rename is running. This makes it
-possible to replace a table with an empty one:
-
-@example
-CREATE TABLE new_table (...);
-RENAME TABLE old_table TO backup_table, new_table TO old_table;
-@end example
-
-The rename is done from left to right, which means that if you want to
-swap two tables names, you have to:
-
-@example
-RENAME TABLE old_table TO backup_table,
- new_table TO old_table,
- backup_table TO new_table;
-@end example
-
-As long as two databases are on the same disk you can also rename
-from one database to another:
-
-@example
-RENAME TABLE current_database.table_name TO other_database.table_name;
-@end example
-
-When you execute @code{RENAME}, you can't have any locked tables or
-active transactions. You must also have the @code{ALTER} and @code{DROP}
-privilege on the original table and @code{CREATE} and @code{INSERT}
-privilege on the new table.
-
-If @strong{MySQL} encounters any errors in a multiple table rename, it
-will do a reverse rename for all renamed tables to get everything back
-to the original state.
-
-@findex DROP TABLE
-@node DROP TABLE, OPTIMIZE TABLE, RENAME TABLE, Reference
-@section @code{DROP TABLE} Syntax
-
-@example
-DROP TABLE [IF EXISTS] tbl_name [, tbl_name,...] [RESTRICT | CASCADE]
-@end example
-
-@code{DROP TABLE} removes one or more tables. All table data and the table
-definition are @emph{removed}, so @strong{be careful} with this command!
-
-In @strong{MySQL} Version 3.22 or later, you can use the keywords
-@code{IF EXISTS} to prevent an error from occurring for tables that don't
-exist.
-
-@code{RESTRICT} and @code{CASCADE} are allowed to make porting easier.
-For the moment they don't do anything.
-
-@strong{NOTE}: @code{DROP TABLE} is not transaction-safe and will
-automatically commit any active transactions.
-
-@cindex tables, defragment
-@cindex tables, fragmentation
-@findex OPTIMIZE TABLE
-@node OPTIMIZE TABLE, CHECK TABLE, DROP TABLE, Reference
-@section @code{OPTIMIZE TABLE} Syntax
-
-@example
-OPTIMIZE TABLE tbl_name[,tbl_name]...
-@end example
-
-@code{OPTIMIZE TABLE} should be used if you have deleted a large part of a
-table or if you have made many changes to a table with variable-length rows
-(tables that have @code{VARCHAR}, @code{BLOB}, or @code{TEXT} columns).
-Deleted records are maintained in a linked list and subsequent @code{INSERT}
-operations reuse old record positions. You can use @code{OPTIMIZE TABLE} to
-reclaim the unused space and to defragment the data file.
-
-For the moment @code{OPTIMIZE TABLE} only works on @strong{MyISAM} and
-@code{BDB} tables. For @code{BDB} tables, @code{OPTIMIZE TABLE} is
-currently mapped to @code{ANALYZE TABLE}. @xref{ANALYZE TABLE}.
-
-You can get optimize table to work on other table types by starting
-@code{mysqld} with @code{--skip-new} or @code{--safe-mode}, but in this
-case @code{OPTIMIZE TABLE} is just mapped to @code{ALTER TABLE}.
-
-@code{OPTIMIZE TABLE} works the following way:
-@itemize @bullet
-@item
-If the table has deleted or split rows, repair the table.
-@item
-If the index pages are not sorted, sort them.
-@item
-If the statistics are not up to date (and the repair couldn't be done
-by sorting the index), update them.
-@end itemize
-
-@code{OPTIMIZE TABLE} for @code{MyISAM} tables is equvialent of running
-@code{myisamchk --quick --check-changed-tables --sort-index --analyze}
-on the table.
-
-Note that the table is locked during the time @code{OPTIMIZE TABLE} is
-running!
-
-@findex CHECK TABLE
-@node CHECK TABLE, BACKUP TABLE, OPTIMIZE TABLE, Reference
-@section @code{CHECK TABLE} Syntax
-
-@example
-CHECK TABLE tbl_name[,tbl_name...] [option [option...]]
-
-option = QUICK | FAST | MEDIUM | EXTEND | CHANGED
-@end example
-
-@code{CHECK TABLE} only works on @code{MyISAM} tables. On
-@code{MyISAM} tables it's the same thing as running @code{myisamchk -m
-table_name} on the table.
-
-If you don't specify any option @code{MEDIUM} is used.
-
-Checks the table(s) for errors. For @code{MyISAM} tables the key statistics
-is updated. The command returns a table with the following columns:
-
-@multitable @columnfractions .35 .65
-@item @strong{Column} @tab @strong{Value}
-@item Table @tab Table name.
-@item Op @tab Always ``check''.
-@item Msg_type @tab One of @code{status}, @code{error}, @code{info}, or @code{warning}.
-@item Msg_text @tab The message.
-@end multitable
-
-Note that you can get many rows of information for each checked
-table. The last row will be of @code{Msg_type status} and should
-normally be @code{OK}. If you don't get @code{OK}, or @code{Not
-checked} you should normally run a repair of the table. @xref{Table
-maintenance}. @code{Not checked} means that the table the given @code{TYPE}
-told @strong{MySQL} that there wasn't any need to check the table.
-
-The different check types stand for the following:
-
-@multitable @columnfractions .20 .80
-@item @strong{Type} @tab @strong{Meaning}
-@item @code{QUICK} @tab Don't scan the rows to check for wrong links.
-@item @code{FAST} @tab Only check tables which haven't been closed properly.
-@item @code{CHANGED} @tab Only check tables which have been changed since last check or haven't been closed properly.
-@item @code{MEDIUM} @tab Scan rows to verify that deleted links are ok. This also calculates a key checksum for the rows and verifies this with a calcualted checksum for the keys.
-@item @code{EXTENDED} @tab Do a full key lookup for all keys for each row. This ensures that the table is 100 % consistent, but will take a long time!
-@end multitable
-
-For dynamic sized @code{MyISAM} tables a started check will always
-do a @code{MEDIUM} check. For static size rows we skip the row scan
-for @code{QUICK} and @code{FAST} as the rows are very seldom corrupted.
-
-You can combine check options as in:
-
-@example
-CHECK TABLE test_table FAST QUICK;
-@end example
-
-Which only would do a quick check on the table if it wasn't closed properly.
-
-@strong{NOTE:} that in some case @code{CHECK TABLE} will change the
-table! This happens if the table is marked as 'corrupted' or 'not
-closed properly' but @code{CHECK TABLE} didn't find any problems in the
-table. In this case @code{CHECK TABLE} will mark the table as ok.
-
-If a table is corrupted, then it's most likely that the problem is in
-the indexes and not in the data part. All of the above check types
-checks the indexes throughly and should thus find most errors.
-
-If you just want to check a table that you assume is ok, you should use
-no check options or the @code{QUICK} option. The later should be used
-when you are in a hurry and can take the very small risk that
-@code{QUICK} didn't find an error in the data file (In most cases
-@strong{MySQL} should find, under normal usage, any error in the data
-file. If this happens then the table will be marked as 'corrupted',
-in which case the table can't be used until it's repaired).
-
-@code{FAST} and @code{CHANGED} are mostly intended to be used from a
-script (for example to be executed from cron) if you want to check your
-table from time to time. In most cases you @code{FAST} is to be prefered
-over @code{CHANGED}. (The only case when it isn't is when you suspect a
-bug you have found a bug in the @code{MyISAM} code.).
-
-@code{EXTENDED} is only to be used after you have run a normal check but
-still get strange errors from a table when @strong{MySQL} tries to
-update a row or find a row by key (this is VERY unlikely to happen if a
-normal check has succeeded!).
-
-Some things reported by check table, can't be corrected automaticly:
-
-@itemize @bullet
-@item
-@code{Found row where the auto_increment column has the value 0}.
-
-This means that you have in the table a row where the
-@code{auto_increment} index column contains the value 0.
-(It's possible to create a row where the auto_increment column is 0 by
-explicitely setting the column to 0 with an @code{UPDATE} statement)
-
-This isn't an error in itself, but could cause trouble if you decide to
-dump the table and restore it or do an @code{ALTER TABLE} on the
-table. In this case the auto_increment column will change value,
-according to the rules of auto_increment columns, which could cause
-problems like a duplicate key error.
-
-To get rid of the warning, just execute an @code{UPDATE} statement
-to set the column to some other value than 0.
-@end itemize
-
-
-@findex BACKUP TABLE
-@node BACKUP TABLE, RESTORE TABLE, CHECK TABLE, Reference
-@section @code{BACKUP TABLE} Syntax
-
-@example
-BACKUP TABLE tbl_name[,tbl_name...] TO '/path/to/backup/directory'
-@end example
-
-Make a copy of all the table files to the backup directory that are the
-minimum needed to restore it. Currenlty only works for @code{MyISAM}
-tables. For @code{MyISAM} table, copies @code{.frm} (definition) and
-@code{.MYD} (data) files. The index file can be rebuilt from those two.
-
-Before using this command, please see @xref{Backup}.
-
-During the backup, read lock will be held for each table, one at time,
-as they are being backed up. If you want to backup several tables as
-a snapshot, you must first issue @code{LOCK TABLES} obtaining a read
-lock for each table in the group.
-
-The command returns a table with the following columns:
-
-@multitable @columnfractions .35 .65
-@item @strong{Column} @tab @strong{Value}
-@item Table @tab Table name
-@item Op @tab Always ``backup''
-@item Msg_type @tab One of @code{status}, @code{error}, @code{info} or @code{warning}.
-@item Msg_text @tab The message.
-@end multitable
-
-Note that @code{BACKUP TABLE} is only available in @strong{MySQL}
-version 3.23.25 and later.
-
-@findex RESTORE TABLE
-@node RESTORE TABLE, ANALYZE TABLE, BACKUP TABLE, Reference
-@section @code{RESTORE TABLE} Syntax
-
-@example
-RESTORE TABLE tbl_name[,tbl_name...] FROM '/path/to/backup/directory'
-@end example
-
-Restores the table(s) from the backup that was made with
-@code{BACKUP TABLE}. Existing tables will not be overwritten - if you
-try to restore over an existing table, you will get an error. Restore
-will take longer than BACKUP due to the need to rebuilt the index. The
-more keys you have, the longer it is going to take. Just as
-@code{BACKUP TABLE}, currently only works of @code{MyISAM} tables.
-
-
-The command returns a table with the following columns:
-
-@multitable @columnfractions .35 .65
-@item @strong{Column} @tab @strong{Value}
-@item Table @tab Table name
-@item Op @tab Always ``restore''
-@item Msg_type @tab One of @code{status}, @code{error}, @code{info} or @code{warning}.
-@item Msg_text @tab The message.
-@end multitable
-
-
-@findex ANALYZE TABLE
-@node ANALYZE TABLE, REPAIR TABLE, RESTORE TABLE, Reference
-@section @code{ANALYZE TABLE} Syntax
-
-@example
-ANALYZE TABLE tbl_name[,tbl_name...]
-@end example
-
-Analyze and store the key distribution for the table. During the
-analyze the table is locked with a read lock. This works on
-@code{MyISAM} and @code{BDB} tables.
-
-This is equivalent to running @code{myisamchk -a} on the table.
-
-@strong{MySQL} uses the stored key distribution to decide in which order
-tables should be joined when one does a join on something else than a
-constant.
-
-The command returns a table with the following columns:
-
-@multitable @columnfractions .35 .65
-@item @strong{Column} @tab @strong{Value}
-@item Table @tab Table name
-@item Op @tab Always ``analyze''
-@item Msg_type @tab One of @code{status}, @code{error}, @code{info} or @code{warning}.
-@item Msg_text @tab The message.
-@end multitable
-
-You can check the stored key distribution with the @code{SHOW INDEX} command.
-@xref{SHOW DATABASE INFO}.
-
-If the table hasn't changed since the last @code{ANALYZE TABLE} command,
-the table will not be analyzed again.
-
-@findex REPAIR TABLE
-@node REPAIR TABLE, DELETE, ANALYZE TABLE, Reference
-@section @code{REPAIR TABLE} Syntax
-
-@example
-REPAIR TABLE tbl_name[,tbl_name...] [QUICK] [EXTENDED]
-@end example
-
-@code{REPAIR TABLE} only works on @code{MyISAM} tables and is the same
-as running @code{myisamchk -r table_name} on the table.
-
-Normally you should never have to run this command, but if disaster strikes
-you are very likely to get back all your data from a MyISAM table with
-@code{REPAIR TABLE}. If your tables get corrupted a lot you should
-try to find the reason for this! @xref{Crashing}. @xref{MyISAM table problems}.
-
-@code{REPAIR TABLE} repairs a possible corrupted table. The command returns a
-table with the following columns:
-
-@multitable @columnfractions .35 .65
-@item @strong{Column} @tab @strong{Value}
-@item Table @tab Table name
-@item Op @tab Always ``repair''
-@item Msg_type @tab One of @code{status}, @code{error}, @code{info} or @code{warning}.
-@item Msg_text @tab The message.
-@end multitable
-
-Note that you can get many rows of information for each repaired
-table. The last one row will be of @code{Msg_type status} and should
-normally be @code{OK}. If you don't get @code{OK}, you should try
-repairing the table with @code{myisamchk -o}, as @code{REPAIR TABLE}
-does not yet implement all the options of @code{myisamchk}. In the near
-future, we will make it more flexible.
-
-If @code{QUICK} is given then @strong{MySQL} will try to do a
-@code{REPAIR} of only the index tree.
-
-If you use @code{EXTENDED} then @strong{MySQL} will create the index row
-by row instead of creating one index at a time with sorting; This may be
-better than sorting on fixed-length keys if you have long @code{char()}
-keys that compress very good.
-
-@findex DELETE
-@node DELETE, TRUNCATE, REPAIR TABLE, Reference
-@section @code{DELETE} Syntax
-
-@example
-DELETE [LOW_PRIORITY] FROM tbl_name
- [WHERE where_definition]
-@c [ORDER BY ...]
- [LIMIT rows]
-@end example
-
-@code{DELETE} deletes rows from @code{tbl_name} that satisfy the condition
-given by @code{where_definition}, and returns the number of records deleted.
-
-@c If an @code{ORDER BY} clause is used, the rows will be deleted in that order.
-@c This is really only useful in conjunction with @code{LIMIT}. For example:
-
-@c @example
-@c DELETE FROM somelog
-@c WHERE user = 'jcole'
-@c ORDER BY timestamp
-@c LIMIT 1
-@c @end example
-
-@c This will delete the oldest entry (by @code{timestamp}) where the row matches
-@c the @code{WHERE} clause.
-
-If you issue a @code{DELETE} with no @code{WHERE} clause, all rows are
-deleted. If you do this in @code{AUTOCOMMIT} mode, this works as
-@code{TRUNCATE}. @xref{TRUNCATE}. One problem with this is that
-@code{DELETE} will return zero as the number of affected records, but
-this will be fixed in 4.0.
-
-If you really want to know how many records are deleted when you are deleting
-all rows, and are willing to suffer a speed penalty, you can use a
-@code{DELETE} statement of this form:
-
-@example
-mysql> DELETE FROM tbl_name WHERE 1>0;
-@end example
-
-Note that this is MUCH slower than @code{DELETE FROM tbl_name} with no
-@code{WHERE} clause, because it deletes rows one at a time.
-
-If you specify the keyword @code{LOW_PRIORITY}, execution of the
-@code{DELETE} is delayed until no other clients are reading from the table.
-
-Deleted records are maintained in a linked list and subsequent @code{INSERT}
-operations reuse old record positions. To reclaim unused space and reduce
-file sizes, use the @code{OPTIMIZE TABLE} statement or the @code{myisamchk}
-utility to reorganize tables. @code{OPTIMIZE TABLE} is easier, but
-@code{myisamchk} is faster.
-See @ref{OPTIMIZE TABLE, , @code{OPTIMIZE TABLE}} and @ref{Optimization}.
-
-The @strong{MySQL}-specific @code{LIMIT rows} option to @code{DELETE} tells
-the server the maximum number of rows to be deleted before control is
-returned to the client. This can be used to ensure that a specific
-@code{DELETE} command doesn't take too much time. You can simply repeat
-the @code{DELETE} command until the number of affected rows is less than
-the @code{LIMIT} value.
-
-@findex TRUNCATE
-@node TRUNCATE, SELECT, DELETE, Reference
-@section @code{TRUNCATE} Syntax
-
-@example
-TRUNCATE TABLE table_name
-@end example
-
-In 3.23 @code{TRUNCATE TABLE} is mapped to
-@code{COMMIT ; DELETE FROM table_name}. @xref{DELETE}.
-
-The differences between @code{TRUNCATE TABLE} and @code{DELETE FROM ..}
-are:
-
-@itemize @bullet
-@item
-Truncates does a drop and re-create of the table, which is much faster
-than deleting rows one by one.
-@item
-Not transaction-safe; You will get an error if you have an active
-transaction or an active table lock.
-@item
-Doesn't return the number of deleted rows.
-@item
-As long as the table definition file @file{table_name.frm} is
-valid, the table can be re-created this way, even if the data or index
-files have become corrupted.
-@end itemize
-
-@code{TRUNCATE} is an Oracle SQL extension.
+@node SELECT, INSERT, Data Manipulation, Data Manipulation
+@subsection @code{SELECT} Syntax
@findex SELECT
-@node SELECT, JOIN, TRUNCATE, Reference
-@section @code{SELECT} Syntax
@c help SELECT
@example
@@ -20251,7 +32094,7 @@ the @code{ASC} keyword.
@item
You can in the @code{WHERE} clause use any of the functions that
-@strong{MySQL} support. @xref{Functions}.
+MySQL support. @xref{Functions}.
@item
The @code{HAVING} clause can refer to any column or alias named in the
@@ -20269,14 +32112,14 @@ Write this instead:
mysql> select col_name from tbl_name WHERE col_name > 0;
@end example
-In @strong{MySQL} Version 3.22.5 or later, you can also write queries like this:
+In MySQL Version 3.22.5 or later, you can also write queries like this:
@example
mysql> select user,max(salary) from users
group by user HAVING max(salary)>10;
@end example
-In older @strong{MySQL} versions, you can write this instead:
+In older MySQL versions, you can write this instead:
@example
mysql> select user,max(salary) AS sum from users
@@ -20285,7 +32128,7 @@ mysql> select user,max(salary) AS sum from users
@item
@code{SQL_SMALL_RESULT}, @code{SQL_BIG_RESULT}, @code{SQL_BUFFER_RESULT},
-@code{STRAIGHT_JOIN}, and @code{HIGH_PRIORITY} are @strong{MySQL} extensions
+@code{STRAIGHT_JOIN}, and @code{HIGH_PRIORITY} are MySQL extensions
to ANSI SQL92.
@item
@@ -20298,15 +32141,15 @@ statement that is waiting for the table to be free.
@item
@code{SQL_BIG_RESULT} can be used with @code{GROUP BY} or @code{DISTINCT}
to tell the optimizer that the result set will have many rows. In this case,
-@strong{MySQL} will directly use disk-based temporary tables if needed.
-@strong{MySQL} will also, in this case, prefer sorting to doing a
+MySQL will directly use disk-based temporary tables if needed.
+MySQL will also, in this case, prefer sorting to doing a
temporary table with a key on the @code{GROUP BY} elements.
@item
@cindex @code{GROUP BY}, extensions to ANSI SQL
If you use @code{GROUP BY}, the output rows will be sorted according to the
@code{GROUP BY} as if you would have had an @code{ORDER BY} over all the fields
-in the @code{GROUP BY}. @strong{MySQL} has extended the @code{GROUP BY} so that
+in the @code{GROUP BY}. MySQL has extended the @code{GROUP BY} so that
you can also specify @code{ASC} and @code{DESC} to @code{GROUP BY}:
@example
@@ -20314,7 +32157,7 @@ SELECT a,COUNT(b) FROM test_table GROUP BY a DESC
@end example
@item
-@strong{MySQL} has extended the use of @code{GROUP BY} to allow you to
+MySQL has extended the use of @code{GROUP BY} to allow you to
select fields which are not mentioned in the @code{GROUP BY} clause.
If you are not getting the results you expect from your query, please
read the @code{GROUP BY} description.
@@ -20322,15 +32165,15 @@ read the @code{GROUP BY} description.
@item
@code{SQL_BUFFER_RESULT} will force the result to be put into a temporary
-table. This will help @strong{MySQL} free the table locks early and will help
+table. This will help MySQL free the table locks early and will help
in cases where it takes a long time to send the result set to the client.
@item
-@code{SQL_SMALL_RESULT}, a @strong{MySQL}-specific option, can be used
+@code{SQL_SMALL_RESULT}, a MySQL-specific option, can be used
with @code{GROUP BY} or @code{DISTINCT} to tell the optimizer that the
-result set will be small. In this case, @strong{MySQL} will use fast
+result set will be small. In this case, MySQL will use fast
temporary tables to store the resulting table instead of using sorting. In
-@strong{MySQL} Version 3.23 this shouldn't normally be needed.
+MySQL Version 3.23 this shouldn't normally be needed.
@item
@code{STRAIGHT_JOIN} forces the optimizer to join the tables in the order in
@@ -20412,7 +32255,7 @@ FROM test_table;
@item
@findex DUMPFILE
-If you use @code{INTO DUMPFILE} instead of @code{INTO OUTFILE}, @strong{MySQL}
+If you use @code{INTO DUMPFILE} instead of @code{INTO OUTFILE}, MySQL
will only write one row into the file, without any column or line
terminations and without any escaping. This is useful if you want to
store a blob in a file.
@@ -20420,7 +32263,7 @@ store a blob in a file.
@item
Note that any file created by @code{INTO OUTFILE} and @code{INTO
DUMPFILE} is going to be readable for all users! The reason is that the
-@strong{MySQL} server can't create a file that is owned by anyone else
+MySQL server can't create a file that is owned by anyone else
than the user it's running as (you should never run @code{mysqld} as root),
the file has to be word readable so that you can retrieve the rows.
@@ -20429,6 +32272,14 @@ If you are using @code{FOR UPDATE} on a table handler with page/row locks,
the examined rows will be write locked.
@end itemize
+
+@menu
+* JOIN:: @code{JOIN} Syntax
+@end menu
+
+@node JOIN, , SELECT, SELECT
+@subsubsection @code{JOIN} Syntax
+
@findex JOIN
@findex INNER JOIN
@findex CROSS JOIN
@@ -20441,10 +32292,8 @@ the examined rows will be write locked.
@findex NATURAL RIGHT JOIN
@findex NATURAL RIGHT OUTER JOIN
@findex STRAIGHT_JOIN
-@node JOIN, INSERT, SELECT, Reference
-@section @code{JOIN} Syntax
-@strong{MySQL} supports the following @code{JOIN} syntaxes for use in
+MySQL supports the following @code{JOIN} syntaxes for use in
@code{SELECT} statements:
@example
@@ -20473,8 +32322,13 @@ ON conditional_expr |
USING (column_list)
@end example
-Note that in versions before Version 3.23.16, the @code{INNER JOIN} didn't take
-a join condition!
+You should never have any conditions in the @code{ON} part that are used to
+restrict which rows you have in the result set. If you want to restrict
+which rows should be in the result, you have to do this in the @code{WHERE}
+clause.
+
+Note that in versions before Version 3.23.16, the @code{INNER JOIN} didn't
+take a @code{join_condition}!
@cindex ODBC compatibility
@cindex compatibility, with ODBC
@@ -20549,13 +32403,13 @@ is always read before the right table. This can be used for those (few)
cases where the join optimizer puts the tables in the wrong order.
@item
-As of @strong{MySQL} Version 3.23.12, you can give hints about which
-index @strong{MySQL} should use when retrieving information from a
-table. This is useful if @code{EXPLAIN} shows that @strong{MySQL} is
+As of MySQL Version 3.23.12, you can give hints about which
+index MySQL should use when retrieving information from a
+table. This is useful if @code{EXPLAIN} shows that MySQL is
using the wrong index. By specifying @code{USE INDEX (key_list)}, you
-can tell @strong{MySQL} to use only one of the specified indexes to
+can tell MySQL to use only one of the specified indexes to
find rows in the table. The alternative syntax @code{IGNORE INDEX
-(key_list)} can be used to tell @strong{MySQL} to not use some
+(key_list)} can be used to tell MySQL to not use some
particular index.
@end itemize
@@ -20575,9 +32429,11 @@ mysql> select * from table1 IGNORE INDEX (key3) WHERE key1=1 and key2=2 AND
@xref{LEFT JOIN optimization, , @code{LEFT JOIN} optimization}.
+
+@node INSERT, INSERT DELAYED, SELECT, Data Manipulation
+@subsection @code{INSERT} Syntax
+
@findex INSERT
-@node INSERT, REPLACE, JOIN, Reference
-@section @code{INSERT} Syntax
@example
INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
@@ -20596,9 +32452,9 @@ or INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
... VALUES} form of the statement inserts rows based on explicitly
specified values. The @code{INSERT ... SELECT} form inserts rows
selected from another table or tables. The @code{INSERT ... VALUES}
-form with multiple value lists is supported in @strong{MySQL} Version
+form with multiple value lists is supported in MySQL Version
3.22.5 or later. The @code{col_name=expression} syntax is supported in
-@strong{MySQL} Version 3.22.10 or later.
+MySQL Version 3.22.10 or later.
@code{tbl_name} is the table into which rows should be inserted. The column
name list or the @code{SET} clause indicates which columns the statement
@@ -20650,7 +32506,7 @@ existing key value. You can determine with the C API function
@code{mysql_info()} how many rows were inserted into the table.
@item
-If @strong{MySQL} was configured using the @code{DONT_USE_DEFAULT_FIELDS}
+If MySQL was configured using the @code{DONT_USE_DEFAULT_FIELDS}
option, @code{INSERT} statements generate an error unless you explicitly
specify values for all columns that require a non-@code{NULL} value.
@xref{configure options, , @code{configure} options}.
@@ -20703,13 +32559,14 @@ type. The column is set to the appropriate zero value for the type.
@findex REPLACE ... SELECT
@findex INSERT ... SELECT
+
@menu
-* INSERT SELECT::
-* INSERT DELAYED::
+* INSERT SELECT:: @code{INSERT ... SELECT} Syntax
@end menu
-@node INSERT SELECT, INSERT DELAYED, INSERT, INSERT
-@subsection @code{INSERT ... SELECT} Syntax
+
+@node INSERT SELECT, , INSERT, INSERT
+@subsubsection @code{INSERT ... SELECT} Syntax
@example
INSERT [LOW_PRIORITY] [IGNORE] [INTO] tbl_name [(column list)] SELECT ...
@@ -20746,30 +32603,33 @@ the query. @xref{INSERT}.
@item
To ensure that the update log/binary log can be used to re-create the
-original tables, @strong{MySQL} will not allow concurrent inserts during
+original tables, MySQL will not allow concurrent inserts during
@code{INSERT .... SELECT}.
@end itemize
You can of course also use @code{REPLACE} instead of @code{INSERT} to
overwrite old rows.
+
+@node INSERT DELAYED, UPDATE, INSERT, Data Manipulation
+@subsection @code{INSERT DELAYED} syntax
+
@findex INSERT DELAYED
@findex DELAYED
+
@cindex INSERT DELAYED
-@node INSERT DELAYED, , INSERT SELECT, INSERT
-@subsection @code{INSERT DELAYED} syntax
@example
INSERT DELAYED ...
@end example
The @code{DELAYED} option for the @code{INSERT} statement is a
-@strong{MySQL}-specific option that is very useful if you have clients
+MySQL-specific option that is very useful if you have clients
that can't wait for the @code{INSERT} to complete. This is a common
-problem when you use @strong{MySQL} for logging and you also
+problem when you use MySQL for logging and you also
periodically run @code{SELECT} and @code{UPDATE} statements that take a
-long time to complete. @code{DELAYED} was introduced in @strong{MySQL}
-Version 3.22.15. It is a @strong{MySQL} extension to ANSI SQL92.
+long time to complete. @code{DELAYED} was introduced in MySQL
+Version 3.22.15. It is a MySQL extension to ANSI SQL92.
@code{INSERT DELAYED} only works with @code{ISAM} and @code{MyISAM}
tables. Note that as @code{MyISAM} tables supports concurrent
@@ -20847,7 +32707,7 @@ the @code{mysqld} server doesn't use all memory for the delayed memory
queue.
@item
-The handler thread will show up in the @strong{MySQL} process list
+The handler thread will show up in the MySQL process list
with @code{delayed_insert} in the @code{Command} column. It will
be killed if you execute a @code{FLUSH TABLES} command or kill it with
@code{KILL thread_id}. However, it will first store all queued rows into the
@@ -20883,14 +32743,150 @@ server to handle a separate thread for each table on which you use
@code{INSERT DELAYED}. This means that you should only use @code{INSERT
DELAYED} when you are really sure you need it!
+
+@node UPDATE, DELETE, INSERT DELAYED, Data Manipulation
+@subsection @code{UPDATE} Syntax
+
+@findex UPDATE
+
+@example
+UPDATE [LOW_PRIORITY] [IGNORE] tbl_name
+ SET col_name1=expr1, [col_name2=expr2, ...]
+ [WHERE where_definition]
+ [LIMIT #]
+@end example
+
+@code{UPDATE} updates columns in existing table rows with new values.
+The @code{SET} clause indicates which columns to modify and the values
+they should be given. The @code{WHERE} clause, if given, specifies
+which rows should be updated. Otherwise all rows are updated. If the
+@code{ORDER BY} clause is specified, the rows will be updated in the
+order that is specified.
+
+If you specify the keyword @code{LOW_PRIORITY}, execution of the
+@code{UPDATE} is delayed until no other clients are reading from the table.
+
+If you specify the keyword @code{IGNORE}, the update statement will not
+abort even if we get duplicate key errors during the update. Rows that
+would cause conflicts will not be updated.
+
+If you access a column from @code{tbl_name} in an expression,
+@code{UPDATE} uses the current value of the column. For example, the
+following statement sets the @code{age} column to one more than its
+current value:
+
+@example
+mysql> UPDATE persondata SET age=age+1;
+@end example
+
+@code{UPDATE} assignments are evaluated from left to right. For example, the
+following statement doubles the @code{age} column, then increments it:
+
+@example
+mysql> UPDATE persondata SET age=age*2, age=age+1;
+@end example
+
+If you set a column to the value it currently has, MySQL notices
+this and doesn't update it.
+
+@findex mysql_info()
+@code{UPDATE} returns the number of rows that were actually changed.
+In MySQL Version 3.22 or later, the C API function @code{mysql_info()}
+returns the number of rows that were matched and updated and the number of
+warnings that occurred during the @code{UPDATE}.
+
+In MySQL Version 3.23, you can use @code{LIMIT #} to ensure that
+only a given number of rows are changed.
+
+
+@node DELETE, TRUNCATE, UPDATE, Data Manipulation
+@subsection @code{DELETE} Syntax
+
+@findex DELETE
+
+@example
+DELETE [LOW_PRIORITY] FROM tbl_name
+ [WHERE where_definition]
+ [LIMIT rows]
+@end example
+
+@code{DELETE} deletes rows from @code{tbl_name} that satisfy the condition
+given by @code{where_definition}, and returns the number of records deleted.
+
+If you issue a @code{DELETE} with no @code{WHERE} clause, all rows are
+deleted. If you do this in @code{AUTOCOMMIT} mode, this works as
+@code{TRUNCATE}. @xref{TRUNCATE}. One problem with this is that
+@code{DELETE} will return zero as the number of affected records, but
+this will be fixed in 4.0.
+
+If you really want to know how many records are deleted when you are deleting
+all rows, and are willing to suffer a speed penalty, you can use a
+@code{DELETE} statement of this form:
+
+@example
+mysql> DELETE FROM tbl_name WHERE 1>0;
+@end example
+
+Note that this is MUCH slower than @code{DELETE FROM tbl_name} with no
+@code{WHERE} clause, because it deletes rows one at a time.
+
+If you specify the keyword @code{LOW_PRIORITY}, execution of the
+@code{DELETE} is delayed until no other clients are reading from the table.
+
+Deleted records are maintained in a linked list and subsequent @code{INSERT}
+operations reuse old record positions. To reclaim unused space and reduce
+file sizes, use the @code{OPTIMIZE TABLE} statement or the @code{myisamchk}
+utility to reorganize tables. @code{OPTIMIZE TABLE} is easier, but
+@code{myisamchk} is faster.
+See @ref{OPTIMIZE TABLE, , @code{OPTIMIZE TABLE}} and @ref{Optimization}.
+
+The MySQL-specific @code{LIMIT rows} option to @code{DELETE} tells
+the server the maximum number of rows to be deleted before control is
+returned to the client. This can be used to ensure that a specific
+@code{DELETE} command doesn't take too much time. You can simply repeat
+the @code{DELETE} command until the number of affected rows is less than
+the @code{LIMIT} value.
+
+
+@node TRUNCATE, REPLACE, DELETE, Data Manipulation
+@subsection @code{TRUNCATE} Syntax
+
+@findex TRUNCATE
+
+@example
+TRUNCATE TABLE table_name
+@end example
+
+Is in 3.23 and the same thing as @code{DELETE FROM table_name}. @xref{DELETE}.
+The differences are:
+
+@itemize @bullet
+@item
+Implemented as a drop and re-create of the table, which makes this
+much faster when deleting many rows.
+@item
+Not transaction-safe; @code{TRUNCATE TABLE} will automatically end the current
+transaction as if @code{COMMIT} would have been called.
+@item
+Doesn't return the number of deleted rows.
+@item
+As long as the table definition file @file{table_name.frm} is
+valid, the table can be re-created this way, even if the data or index
+files have become corrupted.
+@end itemize
+
+@code{TRUNCATE} is an Oracle SQL extension.
+
+
+@node REPLACE, LOAD DATA, TRUNCATE, Data Manipulation
+@subsection @code{REPLACE} Syntax
+
@findex REPLACE
-@node REPLACE, LOAD DATA, INSERT, Reference
-@section @code{REPLACE} Syntax
@example
REPLACE [LOW_PRIORITY | DELAYED]
[INTO] tbl_name [(col_name,...)]
- VALUES (expression,...)
+ VALUES (expression,...),(...),...
or REPLACE [LOW_PRIORITY | DELAYED]
[INTO] tbl_name [(col_name,...)]
SELECT ...
@@ -20905,7 +32901,7 @@ the old record is deleted before the new record is inserted.
@xref{INSERT, , @code{INSERT}}.
In other words, you can't access the values of the old row from a
-@code{REPLACE} statement. In some old @strong{MySQL} version it looked
+@code{REPLACE} statement. In some old MySQL version it looked
like you could do this, but that was a bug that has been corrected.
When one uses a @code{REPLACE} command, @code{mysql_affected_rows()}
@@ -20915,9 +32911,11 @@ this case one row was inserted and then the duplicate was deleted.
The above makes it easy to check if @code{REPLACE} added or replaced a
row.
+
+@node LOAD DATA, , REPLACE, Data Manipulation
+@subsection @code{LOAD DATA INFILE} Syntax
+
@findex LOAD DATA INFILE
-@node LOAD DATA, UPDATE, REPLACE, Reference
-@section @code{LOAD DATA INFILE} Syntax
@example
LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name.txt'
@@ -20937,7 +32935,7 @@ The @code{LOAD DATA INFILE} statement reads rows from a text file into a
table at a very high speed. If the @code{LOCAL} keyword is specified, the
file is read from the client host. If @code{LOCAL} is not specified, the
file must be located on the server. (@code{LOCAL} is available in
-@strong{MySQL} Version 3.22.6 or later.)
+MySQL Version 3.22.6 or later.)
For security reasons, when reading text files located on the server, the
files must either reside in the database directory or be readable by all.
@@ -20961,7 +32959,7 @@ host to the server host. On the other hand, you do not need the
@strong{file} privilege to load local files.
@c old version
-If you are using @strong{MySQL} before Version 3.23.24 you can't read from a
+If you are using MySQL before Version 3.23.24 you can't read from a
FIFO with @code{LOAD DATA INFILE}. If you need to read from a FIFO (for
example the output from gunzip), use @code{LOAD DATA LOCAL INFILE}
instead.
@@ -21335,7 +33333,7 @@ mysql> LOAD DATA INFILE 'persondata.txt'
You must also specify a field list if the order of the fields in the input
file differs from the order of the columns in the table. Otherwise,
-@strong{MySQL} cannot tell how to match up input fields with table columns.
+MySQL cannot tell how to match up input fields with table columns.
If a row has too few fields, the columns for which no input field is present
are set to default values. Default value assignment is described in
@@ -21402,1547 +33400,1073 @@ cat < /dev/tcp/10.1.1.12/4711 > /nt/mysql/db/x/x
mysql -e "LOAD DATA INFILE 'x' INTO TABLE x" x
@end example
-If you are using a version of @strong{MySQL} older than 3.23.25
+If you are using a version of MySQL older than 3.23.25
you can only do the above with @code{LOAD DATA LOCAL INFILE}.
For more information about the efficiency of @code{INSERT} versus
@code{LOAD DATA INFILE} and speeding up @code{LOAD DATA INFILE},
@xref{Insert speed}.
-@findex UPDATE
-@node UPDATE, USE, LOAD DATA, Reference
-@section @code{UPDATE} Syntax
-@example
-UPDATE [LOW_PRIORITY] [IGNORE] tbl_name
- SET col_name1=expr1, [col_name2=expr2, ...]
- [WHERE where_definition]
- [ORDER BY ...]
- [LIMIT #]
-@end example
-
-@code{UPDATE} updates columns in existing table rows with new values.
-The @code{SET} clause indicates which columns to modify and the values
-they should be given. The @code{WHERE} clause, if given, specifies
-which rows should be updated. Otherwise all rows are updated. If the
-@code{ORDER BY} clause is specified, the rows will be updated in the
-order that is specified.
+@node Data Definition, Basic User Commands, Data Manipulation, Reference
+@section Data Definition: @code{CREATE}, @code{DROP}, @code{ALTER}
-If you specify the keyword @code{LOW_PRIORITY}, execution of the
-@code{UPDATE} is delayed until no other clients are reading from the table.
-
-If you specify the keyword @code{IGNORE}, the update statement will not
-abort even if we get duplicate key errors during the update. Rows that
-would cause conflicts will not be updated.
-
-If you access a column from @code{tbl_name} in an expression,
-@code{UPDATE} uses the current value of the column. For example, the
-following statement sets the @code{age} column to one more than its
-current value:
-
-@example
-mysql> UPDATE persondata SET age=age+1;
-@end example
-
-@code{UPDATE} assignments are evaluated from left to right. For example, the
-following statement doubles the @code{age} column, then increments it:
-
-@example
-mysql> UPDATE persondata SET age=age*2, age=age+1;
-@end example
-
-If you set a column to the value it currently has, @strong{MySQL} notices
-this and doesn't update it.
+@menu
+* CREATE DATABASE:: @code{CREATE DATABASE} Syntax
+* DROP DATABASE:: @code{DROP DATABASE} Syntax
+* CREATE TABLE:: @code{CREATE TABLE} Syntax
+* ALTER TABLE:: @code{ALTER TABLE} Syntax
+* RENAME TABLE:: @code{RENAME TABLE} Syntax
+* DROP TABLE:: @code{DROP TABLE} Syntax
+* CREATE INDEX:: @code{CREATE INDEX} Syntax
+* DROP INDEX:: @code{DROP INDEX} Syntax
+@end menu
-@findex mysql_info()
-@code{UPDATE} returns the number of rows that were actually changed.
-In @strong{MySQL} Version 3.22 or later, the C API function @code{mysql_info()}
-returns the number of rows that were matched and updated and the number of
-warnings that occurred during the @code{UPDATE}.
-In @strong{MySQL} Version 3.23, you can use @code{LIMIT #} to ensure that
-only a given number of rows are changed.
+@node CREATE DATABASE, DROP DATABASE, Data Definition, Data Definition
+@subsection @code{CREATE DATABASE} Syntax
-@findex USE
-@node USE, FLUSH, UPDATE, Reference
-@section @code{USE} Syntax
+@findex CREATE DATABASE
@example
-USE db_name
+CREATE DATABASE [IF NOT EXISTS] db_name
@end example
-The @code{USE db_name} statement tells @strong{MySQL} to use the @code{db_name}
-database as the default database for subsequent queries. The database remains
-current until the end of the session or until another @code{USE} statement
-is issued:
+@code{CREATE DATABASE} creates a database with the given name. Rules for
+allowable database names are given in @ref{Legal names}. An error occurs if
+the database already exists and you didn't specify @code{IF NOT EXISTS}.
-@example
-mysql> USE db1;
-mysql> SELECT count(*) FROM mytable; # selects from db1.mytable
-mysql> USE db2;
-mysql> SELECT count(*) FROM mytable; # selects from db2.mytable
-@end example
+Databases in MySQL are implemented as directories containing files
+that correspond to tables in the database. Because there are no tables in a
+database when it is initially created, the @code{CREATE DATABASE} statement
+only creates a directory under the MySQL data directory.
-Making a particular database current by means of the @code{USE} statement
-does not preclude you from accessing tables in other databases. The example
-below accesses the @code{author} table from the @code{db1} database and the
-@code{editor} table from the @code{db2} database:
+@cindex @code{mysqladmin}
+You can also create databases with @code{mysqladmin}.
+@xref{Client-Side Scripts}.
-@example
-mysql> USE db1;
-mysql> SELECT author_name,editor_name FROM author,db2.editor
- WHERE author.editor_id = db2.editor.editor_id;
-@end example
-@cindex Sybase compatibility
-@cindex compatibility, with Sybase
-The @code{USE} statement is provided for Sybase compatibility.
+@node DROP DATABASE, CREATE TABLE, CREATE DATABASE, Data Definition
+@subsection @code{DROP DATABASE} Syntax
-@cindex @code{mysqladmin}
-@cindex clearing, caches
-@cindex caches, clearing
-@findex FLUSH
-@node FLUSH, KILL, USE, Reference
-@section @code{FLUSH} Syntax
+@findex DROP DATABASE
@example
-FLUSH flush_option [,flush_option]
+DROP DATABASE [IF EXISTS] db_name
@end example
-You should use the @code{FLUSH} command if you want to clear some of the
-internal caches @strong{MySQL} uses. To execute @code{FLUSH}, you must have
-the @strong{RELOAD} privilege.
-
-@code{flush_option} can be any of the following:
-
-@multitable @columnfractions .15 .85
-@item @code{HOSTS} @tab Empties the host cache tables. You should flush the
-host tables if some of your hosts change IP number or if you get the
-error message @code{Host ... is blocked}. When more than
-@code{max_connect_errors} errors occur in a row for a given host while
-connection to the @strong{MySQL} server, @strong{MySQL} assumes
-something is wrong and blocks the host from further connection requests.
-Flushing the host tables allows the host to attempt to connect
-again. @xref{Blocked host}.) You can start @code{mysqld} with
-@code{-O max_connection_errors=999999999} to avoid this error message.
-
-@item @code{LOGS} @tab Closes and reopens all log files.
-If you have specified the update log file or a binary log file without
-an extension, the extension number of the log file will be incremented
-by one relative to the previous file. If you have used an extension in
-the file name, @strong{MySQL} will close and reopen the update log file.
-@xref{Update log}. This is the same thing as sending the @code{SIGHUP}
-signal to the @code{mysqld} server.
-
-@item @code{PRIVILEGES} @tab Reloads the privileges from the grant tables in
-the @code{mysql} database.
-
-@item @code{TABLES} @tab Closes all open tables and force all tables in use to be closed.
+@code{DROP DATABASE} drops all tables in the database and deletes the
+database. If you do a @code{DROP DATABASE} on a symbolic linked
+database, both the link and the original database is deleted. @strong{Be
+VERY careful with this command!}
-@item @code{[TABLE | TABLES] table_name [,table_name...]} @tab Flushes only the given tables.
+@code{DROP DATABASE} returns the number of files that were removed from
+the database directory. Normally, this is three times the number of
+tables, because normally each table corresponds to a @file{.MYD} file, a
+@file{.MYI} file, and a @file{.frm} file.
-@item @code{TABLES WITH READ LOCK} @tab Closes all open tables and locks all tables for all databases with a read until one executes @code{UNLOCK TABLES}. This is very convenient way to get backups if you have a file system, like Veritas,that can take snapshots in time.
+The @code{DROP DATABASE} command removes from the given database
+directory all files with the following extensions:
-@item @code{STATUS} @tab Resets most status variables to zero. This is something one should only use when debugging a query.
+@multitable @columnfractions .25 .25 .25 .25
+@item .BAK @tab .DAT @tab .HSH @tab .ISD
+@item .ISM @tab .ISM @tab .MRG @tab .MYD
+@item .MYI @tab .db @tab .frm
@end multitable
-You can also access each of the commands shown above with the @code{mysqladmin}
-utility, using the @code{flush-hosts}, @code{flush-logs}, @code{reload},
-or @code{flush-tables} commands.
+All subdirectories that consists of 2 digits (@code{RAID} directories)
+are also removed.
-Take also a look at the @code{RESET} command used with
-replication. @xref{Replication SQL}.
+In MySQL Version 3.22 or later, you can use the keywords
+@code{IF EXISTS} to prevent an error from occurring if the database doesn't
+exist.
@cindex @code{mysqladmin}
-@findex KILL
-@node KILL, SHOW, FLUSH, Reference
-@section @code{KILL} Syntax
-
-@example
-KILL thread_id
-@end example
-
-Each connection to @code{mysqld} runs in a separate thread. You can see
-which threads are running with the @code{SHOW PROCESSLIST} command and kill
-a thread with the @code{KILL thread_id} command.
+You can also drop databases with @code{mysqladmin}. @xref{Client-Side Scripts}.
-If you have the @strong{process} privilege, you can see and kill all threads.
-Otherwise, you can see and kill only your own threads.
-
-You can also use the @code{mysqladmin processlist} and @code{mysqladmin kill}
-commands to examine and kill threads.
-
-When you do a @code{KILL}, a thread specific @code{kill flag} is set for
-the thread.
-
-In most cases it may take some time for the thread to die as the kill
-flag is only checked at specific intervals.
-@itemize @bullet
-@item
-In @code{SELECT}, @code{ORDER BY} and @code{GROUP BY} loops, the flag is
-checked after reading a block of rows. If the kill flag is set the
-statement is aborted
-@item
-When doing an @code{ALTER TABLE} the kill flag is checked before each block of
-rows are read from the original table. If the kill flag was set the command
-is aborted and the temporary table is deleted.
-@item
-When doing an @code{UPDATE TABLE} and @code{DELETE TABLE}, the kill flag
-is checked after each block read and after each updated or delete
-row. If the kill flag is set the statement is aborted. Note that if you
-are not using transactions, the changes will not be rolled back!
-@item
-@code{GET_LOCK()} will abort with @code{NULL}.
-@item
-An @code{INSERT DELAYED} thread will quickly flush all rows it has in
-memory and die.
-@item
-If the thread is in the table lock handler (state: @code{Locked}),
-the table lock will be quickly aborted.
-@item
-If the thread is waiting for free disk space in a @code{write} call, the
-write is aborted with an disk full error message.
-@end itemize
-
-@findex SHOW DATABASES
-@findex SHOW TABLES
-@findex SHOW COLUMNS
-@findex SHOW FIELDS
-@findex SHOW INDEX
-@findex SHOW KEYS
-@findex SHOW STATUS
-@findex SHOW VARIABLES
-@findex SHOW PROCESSLIST
-@findex SHOW TABLE STATUS
-@findex SHOW GRANTS
-@findex SHOW CREATE TABLE
-@findex SHOW MASTER STATUS
-@findex SHOW MASTER LOGS
-@findex SHOW SLAVE STATUS
-@node SHOW, EXPLAIN, KILL, Reference
-@section @code{SHOW} Syntax
+@menu
+* CREATE TABLE:: @code{CREATE TABLE} Syntax
+* ALTER TABLE:: @code{ALTER TABLE} Syntax
+* RENAME TABLE:: @code{RENAME TABLE} Syntax
+* DROP TABLE:: @code{DROP TABLE} Syntax
+* CREATE INDEX:: @code{CREATE INDEX} Syntax
+* DROP INDEX:: @code{DROP INDEX} Syntax
+@end menu
-@example
- SHOW DATABASES [LIKE wild]
-or SHOW [OPEN] TABLES [FROM db_name] [LIKE wild]
-or SHOW [FULL] COLUMNS FROM tbl_name [FROM db_name] [LIKE wild]
-or SHOW INDEX FROM tbl_name [FROM db_name]
-or SHOW TABLE STATUS [FROM db_name] [LIKE wild]
-or SHOW STATUS [LIKE wild]
-or SHOW VARIABLES [LIKE wild]
-or SHOW LOGS
-or SHOW [FULL] PROCESSLIST
-or SHOW GRANTS FOR user
-or SHOW CREATE TABLE table_name
-or SHOW MASTER STATUS
-or SHOW MASTER LOGS
-or SHOW SLAVE STATUS
-@end example
+@node CREATE TABLE, ALTER TABLE, DROP DATABASE, Data Definition
+@subsection @code{CREATE TABLE} Syntax
-@code{SHOW} provides information about databases, tables, columns, or
-status information about the server. If the @code{LIKE wild} part is
-used, the @code{wild} string can be a string that uses the SQL @samp{%}
-and @samp{_} wild-card characters.
+@findex CREATE TABLE
-@findex SHOW DATABASES
-@findex SHOW TABLES
-@findex SHOW COLUMNS
-@findex SHOW FIELDS
-@findex SHOW INDEX
-@findex SHOW KEYS
@menu
-* SHOW DATABASE INFO::
-* SHOW TABLE STATUS::
-* SHOW STATUS::
-* SHOW VARIABLES::
-* SHOW LOGS::
-* SHOW PROCESSLIST::
-* SHOW GRANTS::
-* SHOW CREATE TABLE::
+* Silent column changes:: Silent column changes
@end menu
-@cindex displaying, information, @code{SHOW}
-@node SHOW DATABASE INFO, SHOW TABLE STATUS, SHOW, SHOW
-@subsection @code{SHOW} Information About Databases, Tables, Columns, and Indexes
-
-You can use @code{db_name.tbl_name} as an alternative to the @code{tbl_name
-FROM db_name} syntax. These two statements are equivalent:
-
@example
-mysql> SHOW INDEX FROM mytable FROM mydb;
-mysql> SHOW INDEX FROM mydb.mytable;
-@end example
-
-@code{SHOW DATABASES} lists the databases on the @strong{MySQL} server
-host. You can also get this list using the @code{mysqlshow} command.
-
-@code{SHOW TABLES} lists the tables in a given database. You can also
-get this list using the @code{mysqlshow db_name} command.
-
-@strong{NOTE:} If a user doesn't have any privileges for a table, the table
-will not show up in the output from @code{SHOW TABLES} or @code{mysqlshow
-db_name}.
-
-@code{SHOW OPEN TABLES} lists the tables that are currently open in
-the table cache. @xref{Table cache}. The @code{Comment} field tells
-how many times the table is @code{cached} and @code{in_use}.
-
-@code{SHOW COLUMNS} lists the columns in a given table. If you specify
-the @code{FULL} option, you will also get the privileges you have for
-each column. If the column types are different than you expect them to
-be based on a @code{CREATE TABLE} statement, note that @strong{MySQL}
-sometimes changes column types. @xref{Silent column changes}.
+CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name [(create_definition,...)]
+[table_options] [select_statement]
-The @code{DESCRIBE} statement provides information similar to
-@code{SHOW COLUMNS}.
-@xref{DESCRIBE, , @code{DESCRIBE}}.
+create_definition:
+ col_name type [NOT NULL | NULL] [DEFAULT default_value] [AUTO_INCREMENT]
+ [PRIMARY KEY] [reference_definition]
+ or PRIMARY KEY (index_col_name,...)
+ or KEY [index_name] (index_col_name,...)
+ or INDEX [index_name] (index_col_name,...)
+ or UNIQUE [INDEX] [index_name] (index_col_name,...)
+ or FULLTEXT [INDEX] [index_name] (index_col_name,...)
+ or [CONSTRAINT symbol] FOREIGN KEY index_name (index_col_name,...)
+ [reference_definition]
+ or CHECK (expr)
-@code{SHOW FIELDS} is a synonym for @code{SHOW COLUMNS}, and
-@code{SHOW KEYS} is a synonym for @code{SHOW INDEX}. You can also
-list a table's columns or indexes with @code{mysqlshow db_name tbl_name}
-or @code{mysqlshow -k db_name tbl_name}.
+type:
+ TINYINT[(length)] [UNSIGNED] [ZEROFILL]
+ or SMALLINT[(length)] [UNSIGNED] [ZEROFILL]
+ or MEDIUMINT[(length)] [UNSIGNED] [ZEROFILL]
+ or INT[(length)] [UNSIGNED] [ZEROFILL]
+ or INTEGER[(length)] [UNSIGNED] [ZEROFILL]
+ or BIGINT[(length)] [UNSIGNED] [ZEROFILL]
+ or REAL[(length,decimals)] [UNSIGNED] [ZEROFILL]
+ or DOUBLE[(length,decimals)] [UNSIGNED] [ZEROFILL]
+ or FLOAT[(length,decimals)] [UNSIGNED] [ZEROFILL]
+ or DECIMAL(length,decimals) [UNSIGNED] [ZEROFILL]
+ or NUMERIC(length,decimals) [UNSIGNED] [ZEROFILL]
+ or CHAR(length) [BINARY]
+ or VARCHAR(length) [BINARY]
+ or DATE
+ or TIME
+ or TIMESTAMP
+ or DATETIME
+ or TINYBLOB
+ or BLOB
+ or MEDIUMBLOB
+ or LONGBLOB
+ or TINYTEXT
+ or TEXT
+ or MEDIUMTEXT
+ or LONGTEXT
+ or ENUM(value1,value2,value3,...)
+ or SET(value1,value2,value3,...)
-@code{SHOW INDEX} returns the index information in a format that closely
-resembles the @code{SQLStatistics} call in ODBC. The following columns
-are returned:
+index_col_name:
+ col_name [(length)]
-@multitable @columnfractions .35 .65
-@item @strong{Column} @tab @strong{Meaning}
-@item @code{Table} @tab Name of the table.
-@item @code{Non_unique} @tab 0 if the index can't contain duplicates.
-@item @code{Key_name} @tab Name of the index.
-@item @code{Seq_in_index} @tab Column sequence number in index,
- starting with 1.
-@item @code{Column_name} @tab Column name.
-@item @code{Collation} @tab How the column is sorted in the index.
- In @strong{MySQL}, this can have values
- @samp{A} (Ascending) or @code{NULL} (Not
- sorted).
-@item @code{Cardinality} @tab Number of unique values in the index.
- This is updated by running
- @code{isamchk -a}.
-@item @code{Sub_part} @tab Number of indexed characters if the
- column is only partly indexed.
- @code{NULL} if the entire key is indexed.
-@item @code{Comment} @tab Various remarks. For now, it tells
- whether index is FULLTEXT or not.
-@end multitable
+reference_definition:
+ REFERENCES tbl_name [(index_col_name,...)]
+ [MATCH FULL | MATCH PARTIAL]
+ [ON DELETE reference_option]
+ [ON UPDATE reference_option]
-Note that as the @code{Cardinality} is counted based on statistics
-stored as integers, it's not necessarily accurate for small tables.
+reference_option:
+ RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT
-@cindex displaying, table status
-@cindex tables, displaying status
-@cindex status, tables
-@node SHOW TABLE STATUS, SHOW STATUS, SHOW DATABASE INFO, SHOW
-@subsection @code{SHOW TABLE STATUS}
+table_options:
+ TYPE = @{BDB | HEAP | ISAM | InnoDB | MERGE | MYISAM @}
+or AUTO_INCREMENT = #
+or AVG_ROW_LENGTH = #
+or CHECKSUM = @{0 | 1@}
+or COMMENT = "string"
+or MAX_ROWS = #
+or MIN_ROWS = #
+or PACK_KEYS = @{0 | 1@}
+or PASSWORD = "string"
+or DELAY_KEY_WRITE = @{0 | 1@}
+or ROW_FORMAT= @{ default | dynamic | fixed | compressed @}
+or RAID_TYPE= @{1 | STRIPED | RAID0 @} RAID_CHUNKS=# RAID_CHUNKSIZE=#
+or UNION = (table_name,[table_name...])
+or DATA DIRECTORY="directory"
+or INDEX DIRECTORY="directory"
-@example
-SHOW TABLE STATUS [FROM db_name] [LIKE wild]
+select_statement:
+ [IGNORE | REPLACE] SELECT ... (Some legal select statement)
@end example
-@code{SHOW TABLE STATUS} (new in Version 3.23) works likes @code{SHOW
-STATUS}, but provides a lot of information about each table. You can
-also get this list using the @code{mysqlshow --status db_name} command.
-The following columns are returned:
-
-@multitable @columnfractions .30 .70
-@item @strong{Column} @tab @strong{Meaning}
-@item @code{Name} @tab Name of the table.
-@item @code{Type} @tab Type of table. @xref{Table types}.
-@item @code{Row_format} @tab The row storage format (Fixed, Dynamic, or Compressed).
-@item @code{Rows} @tab Number of rows.
-@item @code{Avg_row_length} @tab Average row length.
-@item @code{Data_length} @tab Length of the data file.
-@item @code{Max_data_length} @tab Max length of the data file.
-@item @code{Index_length} @tab Length of the index file.
-@item @code{Data_free} @tab Number of allocated but not used bytes.
-@item @code{Auto_increment} @tab Next autoincrement value.
-@item @code{Create_time} @tab When the table was created.
-@item @code{Update_time} @tab When the data file was last updated.
-@item @code{Check_time} @tab When the table was last checked.
-@item @code{Create_options} @tab Extra options used with @code{CREATE TABLE}.
-@item @code{Comment} @tab The comment used when creating the table (or some information why @strong{MySQL} couldn't access the table information).
-@end multitable
-
-@code{InnoDB} tables will report the free space in the tablespace
-in the table comment.
+@code{CREATE TABLE}
+creates a table with the given name in the current database. Rules for
+allowable table names are given in @ref{Legal names}. An error occurs if
+there is no current database or if the table already exists.
-@node SHOW STATUS, SHOW VARIABLES, SHOW TABLE STATUS, SHOW
-@subsection @code{SHOW STATUS}
+In MySQL Version 3.22 or later, the table name can be specified as
+@code{db_name.tbl_name}. This works whether or not there is a current
+database.
-@cindex @code{mysqladmin}
-@code{SHOW STATUS} provides server status information
-(like @code{mysqladmin extended-status}). The output resembles that shown
-below, though the format and numbers probably differ:
+In MySQL Version 3.23, you can use the @code{TEMPORARY} keyword when
+you create a table. A temporary table will automatically be deleted if a
+connection dies and the name is per connection. This means that two different
+connections can both use the same temporary table name without conflicting
+with each other or with an existing table of the same name. (The existing table
+is hidden until the temporary table is deleted).
-@example
-+--------------------------+------------+
-| Variable_name | Value |
-+--------------------------+------------+
-| Aborted_clients | 0 |
-| Aborted_connects | 0 |
-| Bytes_received | 155372598 |
-| Bytes_sent | 1176560426 |
-| Connections | 30023 |
-| Created_tmp_disk_tables | 0 |
-| Created_tmp_tables | 8340 |
-| Created_tmp_files | 60 |
-| Delayed_insert_threads | 0 |
-| Delayed_writes | 0 |
-| Delayed_errors | 0 |
-| Flush_commands | 1 |
-| Handler_delete | 462604 |
-| Handler_read_first | 105881 |
-| Handler_read_key | 27820558 |
-| Handler_read_next | 390681754 |
-| Handler_read_prev | 6022500 |
-| Handler_read_rnd | 30546748 |
-| Handler_read_rnd_next | 246216530 |
-| Handler_update | 16945404 |
-| Handler_write | 60356676 |
-| Key_blocks_used | 14955 |
-| Key_read_requests | 96854827 |
-| Key_reads | 162040 |
-| Key_write_requests | 7589728 |
-| Key_writes | 3813196 |
-| Max_used_connections | 0 |
-| Not_flushed_key_blocks | 0 |
-| Not_flushed_delayed_rows | 0 |
-| Open_tables | 1 |
-| Open_files | 2 |
-| Open_streams | 0 |
-| Opened_tables | 44600 |
-| Questions | 2026873 |
-| Select_full_join | 0 |
-| Select_full_range_join | 0 |
-| Select_range | 99646 |
-| Select_range_check | 0 |
-| Select_scan | 30802 |
-| Slave_running | OFF |
-| Slave_open_temp_tables | 0 |
-| Slow_launch_threads | 0 |
-| Slow_queries | 0 |
-| Sort_merge_passes | 30 |
-| Sort_range | 500 |
-| Sort_rows | 30296250 |
-| Sort_scan | 4650 |
-| Table_locks_immediate | 1920382 |
-| Table_locks_waited | 0 |
-| Threads_cached | 0 |
-| Threads_created | 30022 |
-| Threads_connected | 1 |
-| Threads_running | 1 |
-| Uptime | 80380 |
-+--------------------------+------------+
-@end example
+In MySQL Version 3.23 or later, you can use the keywords
+@code{IF NOT EXISTS} so that an error does not occur if the table already
+exists. Note that there is no verification that the table structures are
+identical.
-@cindex variables, status
-The status variables listed above have the following meaning:
+Each table @code{tbl_name} is represented by some files in the database
+directory. In the case of MyISAM-type tables you will get:
-@multitable @columnfractions .35 .65
-@item @strong{Variable} @tab @strong{Meaning}
-@item @code{Aborted_clients} @tab Number of connections aborted because the client died without closing the connection properly. @xref{Communication errors}.
-@item @code{Aborted_connects} @tab Number of tries to connect to the @strong{MySQL} server that failed. @xref{Communication errors}.
-@item @code{Bytes_received} @tab Number of bytes received from all clients.
-@item @code{Bytes_sent} @tab Number of bytes sent to all clients.
-@item @code{Connections} @tab Number of connection attempts to the @strong{MySQL} server.
-@item @code{Created_tmp_disk_tables} @tab Number of implicit temporary tables on disk created while executing statements.
-@item @code{Created_tmp_tables} @tab Number of implicit temporary tables in memory created while executing statements.
-@item @code{Created_tmp_files} @tab How many temporary files @code{mysqld} have created.
-@item @code{Delayed_insert_threads} @tab Number of delayed insert handler threads in use.
-@item @code{Delayed_writes} @tab Number of rows written with @code{INSERT DELAYED}.
-@item @code{Delayed_errors} @tab Number of rows written with @code{INSERT DELAYED} for which some error occurred (probably @code{duplicate key}).
-@item @code{Flush_commands} @tab Number of executed @code{FLUSH} commands.
-@item @code{Handler_delete} @tab Number of times a row was deleted from a table.
-@item @code{Handler_read_first} @tab Number of times the first entry was read from an index.
-If this is high, it suggests that the server is doing a lot of full index scans, for example,
-@code{SELECT col1 FROM foo}, assuming that col1 is indexed.
-@item @code{Handler_read_key} @tab Number of requests to read a row based on a key. If this
-is high, it is a good indication that your queries and tables are properly indexed.
-@item @code{Handler_read_next} @tab Number of requests to read next row in key order. This
-will be incremented if you are querying an index column with a range constraint. This also
-will be incremented if you are doing an index scan.
-@item @code{Handler_read_rnd} @tab Number of requests to read a row based on a fixed position.
-This will be high if you are doing a lot of queries that require sorting of the result.
-@item @code{Handler_read_rnd_next} @tab Number of requests to read the next row in the datafile.
-This will be high if you are doing a lot of table scans. Generally this suggests that your tables
-are not properly indexed or that your queries are not written to take advantage of the indexes you
-have.
-@item @code{Handler_update} @tab Number of requests to update a row in a table.
-@item @code{Handler_write} @tab Number of requests to insert a row in a table.
-@item @code{Key_blocks_used} @tab The number of used blocks in the key cache.
-@item @code{Key_read_requests} @tab The number of requests to read a key block from the cache.
-@item @code{Key_reads} @tab The number of physical reads of a key block from disk.
-@item @code{Key_write_requests} @tab The number of requests to write a key block to the cache.
-@item @code{Key_writes} @tab The number of physical writes of a key block to disk.
-@item @code{Max_used_connections} @tab The maximum number of connections in use simultaneously.
-@item @code{Not_flushed_key_blocks} @tab Keys blocks in the key cache that has changed but hasn't yet been flushed to disk.
-@item @code{Not_flushed_delayed_rows} @tab Number of rows waiting to be written in @code{INSERT DELAY} queues.
-@item @code{Open_tables} @tab Number of tables that are open.
-@item @code{Open_files} @tab Number of files that are open.
-@item @code{Open_streams} @tab Number of streams that are open (used mainly for logging).
-@item @code{Opened_tables} @tab Number of tables that have been opened.
-@item @code{Select_full_join} @tab Number of joins without keys (Should be 0).
-@item @code{Select_full_range_join} @tab Number of joins where we used a range search on reference table.
-@item @code{Select_range} @tab Number of joins where we used ranges on the first table. (It's normally not critical even if this is big.)
-@item @code{Select_scan} @tab Number of joins where we scanned the first table.
-@item @code{Select_range_check} @tab Number of joins without keys where we check for key usage after each row (Should be 0).
-@item @code{Questions} @tab Number of queries sent to the server.
-@item @code{Slave_open_temp_tables} @tab Number of temporary tables currently
-open by the slave thread
-@item @code{Slow_launch_threads} @tab Number of threads that have taken more than @code{slow_launch_time} to connect.
-@item @code{Slow_queries} @tab Number of queries that have taken more than @code{long_query_time}. @xref{Slow query log}.
-@item @code{Sort_merge_passes} @tab Number of merges the sort has to do. If this value is large you should consider increasing @code{sort_buffer}.
-@item @code{Sort_range} @tab Number of sorts that where done with ranges.
-@item @code{Sort_rows} @tab Number of sorted rows.
-@item @code{Sort_scan} @tab Number of sorts that where done by scanning the table.
-@item @code{Table_locks_immediate} @tab Number of times a table lock was
-acquired immediately. Available after 3.23.33.
-@item @code{Table_locks_waited} @tab Number of times a table lock could not
-be acquired immediately and a wait was needed. If this is high, and you
-have performance problems, you should first optimize your queries, and then
-either split your table(s) or use replication. Available after 3.23.33.
-@item @code{Threads_cached} @tab Number of threads in the thread cache.
-@item @code{Threads_connected} @tab Number of currently open connections.
-@item @code{Threads_created} @tab Number of threads created to handle connections.
-@item @code{Threads_running} @tab Number of threads that are not sleeping.
-@item @code{Uptime} @tab How many seconds the server has been up.
+@multitable @columnfractions .2 .8
+@item @strong{File} @tab @strong{Purpose}
+@item @code{tbl_name.frm} @tab Table definition (form) file
+@item @code{tbl_name.MYD} @tab Data file
+@item @code{tbl_name.MYI} @tab Index file
@end multitable
-Some comments about the above:
+For more information on the properties of the various column types, see
+@ref{Column types}:
@itemize @bullet
@item
-If @code{Opened_tables} is big, then your @code{table_cache}
-variable is probably too small.
-@item
-If @code{key_reads} is big, then your @code{key_cache} is probably too
-small. The cache hit rate can be calculated with
-@code{key_reads}/@code{key_read_requests}.
-@item
-If @code{Handler_read_rnd} is big, then you probably have a lot of
-queries that require @strong{MySQL} to scan whole tables or you have
-joins that don't use keys properly.
-@item
-If @code{Threads_created} is big, you may want to increase the
-@code{thread_cache_size} variable.
-@end itemize
+If neither @code{NULL} nor @code{NOT NULL} is specified, the column
+is treated as though @code{NULL} had been specified.
-@node SHOW VARIABLES, SHOW LOGS, SHOW STATUS, SHOW
-@subsection @code{SHOW VARIABLES}
+@item
+An integer column may have the additional attribute @code{AUTO_INCREMENT}.
+When you insert a value of @code{NULL} (recommended) or @code{0} into an
+@code{AUTO_INCREMENT} column, the column is set to @code{value+1}, where
+@code{value} is the largest value for the column currently in the table.
+@code{AUTO_INCREMENT} sequences begin with @code{1}.
+@xref{mysql_insert_id, , @code{mysql_insert_id()}}.
-@example
-SHOW VARIABLES [LIKE wild]
-@end example
+If you delete the row containing the maximum value for an
+@code{AUTO_INCREMENT} column, the value will be reused with an
+@code{ISAM}, or @code{BDB} table but not with a
+@code{MyISAM} or @code{InnoDB} table. If you delete all rows in the table
+with @code{DELETE FROM table_name} (without a @code{WHERE}) in
+@code{AUTOCOMMIT} mode, the sequence starts over for all table types.
-@code{SHOW VARIABLES} shows the values of some @strong{MySQL} system
-variables. You can also get this information using the @code{mysqladmin
-variables} command. If the default values are unsuitable, you can set most
-of these variables using command-line options when @code{mysqld} starts up.
-@xref{Command-line options}.
+@strong{NOTE:} There can be only one @code{AUTO_INCREMENT} column per
+table, and it must be indexed. MySQL Version 3.23 will also only
+work properly if the auto_increment column only has positive
+values. Inserting a negative number is regarded as inserting a very large
+positive number. This is done to avoid precision problems when
+numbers 'wrap' over from positive to negative and also to ensure that one
+doesn't accidentally get an auto_increment column that contains 0.
-The output resembles that shown below, though the format and numbers may
-differ somewhat:
+@cindex ODBC compatibility
+@cindex compatibility, with ODBC
+To make MySQL compatible with some ODBC applications, you can find
+the last inserted row with the following query:
@example
-+------------------------------+---------------------------+
-| Variable_name | Value |
-+------------------------------+---------------------------+
-| ansi_mode | OFF |
-| back_log | 50 |
-| basedir | /my/monty/ |
-| bdb_cache_size | 16777216 |
-| bdb_log_buffer_size | 32768 |
-| bdb_home | /my/monty/data/ |
-| bdb_max_lock | 10000 |
-| bdb_logdir | |
-| bdb_shared_data | OFF |
-| bdb_tmpdir | /tmp/ |
-| binlog_cache_size | 32768 |
-| concurrent_insert | ON |
-| connect_timeout | 5 |
-| datadir | /my/monty/data/ |
-| delay_key_write | ON |
-| delayed_insert_limit | 100 |
-| delayed_insert_timeout | 300 |
-| delayed_queue_size | 1000 |
-| flush | OFF |
-| flush_time | 0 |
-| ft_min_word_len | 4 |
-| ft_max_word_len | 254 |
-| ft_max_word_len_for_sort | 20 |
-| have_bdb | YES |
-| have_gemini | NO |
-| have_innodb | YES |
-| have_raid | YES |
-| have_ssl | NO |
-| init_file | |
-| interactive_timeout | 28800 |
-| join_buffer_size | 131072 |
-| key_buffer_size | 16776192 |
-| language | /my/monty/share/english/ |
-| large_files_support | ON |
-| log | OFF |
-| log_update | OFF |
-| log_bin | OFF |
-| log_slave_updates | OFF |
-| long_query_time | 10 |
-| low_priority_updates | OFF |
-| lower_case_table_names | 0 |
-| max_allowed_packet | 1048576 |
-| max_binlog_cache_size | 4294967295 |
-| max_connections | 100 |
-| max_connect_errors | 10 |
-| max_delayed_threads | 20 |
-| max_heap_table_size | 16777216 |
-| max_join_size | 4294967295 |
-| max_sort_length | 1024 |
-| max_tmp_tables | 32 |
-| max_write_lock_count | 4294967295 |
-| myisam_bulk_insert_tree_size | 8388608 |
-| myisam_recover_options | DEFAULT |
-| myisam_sort_buffer_size | 8388608 |
-| net_buffer_length | 16384 |
-| net_read_timeout | 30 |
-| net_retry_count | 10 |
-| net_write_timeout | 60 |
-| open_files_limit | 0 |
-| pid_file | /my/monty/data/donna.pid |
-| port | 3306 |
-| protocol_version | 10 |
-| record_buffer | 131072 |
-| query_buffer_size | 0 |
-| safe_show_database | OFF |
-| server_id | 0 |
-| skip_locking | ON |
-| skip_networking | OFF |
-| skip_show_database | OFF |
-| slow_launch_time | 2 |
-| socket | /tmp/mysql.sock |
-| sort_buffer | 2097116 |
-| table_cache | 64 |
-| table_type | MYISAM |
-| thread_cache_size | 4 |
-| thread_stack | 65536 |
-| tmp_table_size | 1048576 |
-| tmpdir | /tmp/ |
-| version | 3.23.29a-gamma-debug |
-| wait_timeout | 28800 |
-+------------------------------+---------------------------+
+SELECT * FROM tbl_name WHERE auto_col IS NULL
@end example
-Each option is described below. Values for buffer sizes, lengths, and stack
-sizes are given in bytes. You can specify values with a suffix of @samp{K}
-or @samp{M} to indicate kilobytes or megabytes. For example, @code{16M}
-indicates 16 megabytes. The case of suffix letters does not matter;
-@code{16M} and @code{16m} are equivalent:
+@item
+@code{NULL} values are handled differently for @code{TIMESTAMP} columns than
+for other column types. You cannot store a literal @code{NULL} in a
+@code{TIMESTAMP} column; setting the column to @code{NULL} sets it to the
+current date and time. Because @code{TIMESTAMP} columns behave this way, the
+@code{NULL} and @code{NOT NULL} attributes do not apply in the normal way and
+are ignored if you specify them.
-@cindex variables, values
-@table @code
-@item @code{ansi_mode}.
-Is @code{ON} if @code{mysqld} was started with @code{--ansi}.
-@xref{ANSI mode}.
+On the other hand, to make it easier for MySQL clients to use
+@code{TIMESTAMP} columns, the server reports that such columns may be
+assigned @code{NULL} values (which is true), even though @code{TIMESTAMP}
+never actually will contain a @code{NULL} value. You can see this when you
+use @code{DESCRIBE tbl_name} to get a description of your table.
-@item @code{back_log}
-The number of outstanding connection requests @strong{MySQL} can have. This
-comes into play when the main @strong{MySQL} thread gets @strong{VERY}
-many connection requests in a very short time. It then takes some time
-(although very little) for the main thread to check the connection and start
-a new thread. The @code{back_log} value indicates how many requests can be
-stacked during this short time before @strong{MySQL} momentarily stops
-answering new requests. You need to increase this only if you expect a large
-number of connections in a short period of time.
+Note that setting a @code{TIMESTAMP} column to @code{0} is not the same
+as setting it to @code{NULL}, because @code{0} is a valid @code{TIMESTAMP}
+value.
-In other words, this value is the size of the listen queue for incoming
-TCP/IP connections. Your operating system has its own limit on the size
-of this queue. The manual page for the Unix @code{listen(2)} system
-call should have more details. Check your OS documentation for the
-maximum value for this variable. Attempting to set @code{back_log}
-higher than your operating system limit will be ineffective.
+@item
+If no @code{DEFAULT} value is specified for a column, MySQL
+automatically assigns one.
-@item @code{basedir}
-The value of the @code{--basedir} option.
+If the column may take @code{NULL} as a value, the default value is
+@code{NULL}.
-@item @code{bdb_cache_size}
-The buffer that is allocated to cache index and rows for @code{BDB}
-tables. If you don't use @code{BDB} tables, you should start
-@code{mysqld} with @code{--skip-bdb} to not waste memory for this
-cache.
+If the column is declared as @code{NOT NULL}, the default value depends on
+the column type:
-@item @code{bdb_log_buffer_size}
-The buffer that is allocated to cache index and rows for @code{BDB}
-tables. If you don't use @code{BDB} tables, you should set this to 0 or
-start @code{mysqld} with @code{--skip-bdb} to not waste memory for this
-cache.
+@itemize @minus
+@item
+For numeric types other than those declared with the @code{AUTO_INCREMENT}
+attribute, the default is @code{0}. For an @code{AUTO_INCREMENT} column, the
+default value is the next value in the sequence.
-@item @code{bdb_home}
-The value of the @code{--bdb-home} option.
+@item
+For date and time types other than @code{TIMESTAMP}, the default is the
+appropriate zero value for the type. For the first @code{TIMESTAMP}
+column in a table, the default value is the current date and time.
+@xref{Date and time types}.
-@item @code{bdb_max_lock}
-The maximum number of locks (1000 by default) you can have active on a
-BDB table. You should increase this if you get errors of type @code{bdb:
-Lock table is out of available locks} or @code{Got error 12 from ...}
-when you have do long transactions or when @code{mysqld} has to examine
-a lot of rows to calculate the query.
+@item
+For string types other than @code{ENUM}, the default value is the empty string.
+For @code{ENUM}, the default is the first enumeration value.
+@end itemize
-@item @code{bdb_logdir}
-The value of the @code{--bdb-logdir} option.
+Default values must be constants. This means, for example, that you cannot
+set the default for a date column to be the value of a function such as
+@code{NOW()} or @code{CURRENT_DATE}.
-@item @code{bdb_shared_data}
-Is @code{ON} if you are using @code{--bdb-shared-data}.
+@item
+@code{KEY} is a synonym for @code{INDEX}.
-@item @code{bdb_tmpdir}
-The value of the @code{--bdb-tmpdir} option.
+@item
+In MySQL, a @code{UNIQUE} key can have only distinct values. An
+error occurs if you try to add a new row with a key that matches an existing
+row.
-@item @code{binlog_cache_size}. The size of the cache to hold the SQL
-statements for the binary log during a transaction. If you often use
-big, multi-statement transactions you can increase this to get more
-performance. @xref{COMMIT}.
+@item
+@tindex PRIMARY KEY
+A @code{PRIMARY KEY} is a unique @code{KEY} with the extra constraint
+that all key columns must be defined as @code{NOT NULL}. In MySQL
+the key is named @code{PRIMARY}. A table can have only one @code{PRIMARY KEY}.
+If you don't have a @code{PRIMARY KEY} and some applications ask for the
+@code{PRIMARY KEY} in your tables, MySQL will return the first
+@code{UNIQUE} key, which doesn't have any @code{NULL} columns, as the
+@code{PRIMARY KEY}.
-@item @code{character_set}
-The default character set.
+@item
+A @code{PRIMARY KEY} can be a multiple-column index. However, you cannot
+create a multiple-column index using the @code{PRIMARY KEY} key attibute in a
+column specification. Doing so will mark only that single column as primary.
+You must use the @code{PRIMARY KEY(index_col_name, ...)} syntax.
-@item @code{character_sets}
-The supported character sets.
+@item
+If the @code{PRIMARY} or @code{UNIQUE} key consists of only one column and this
+is of type integer, you can also refer to it as @code{_rowid}
+(new in Version 3.23.11).
-@item @code{concurrent_inserts}
-If @code{ON} (the default), @strong{MySQL} will allow you to use @code{INSERT}
-on @code{MyISAM} tables at the same time as you run @code{SELECT} queries
-on them. You can turn this option off by starting @code{mysqld} with @code{--safe}
-or @code{--skip-new}.
+@item
+If you don't assign a name to an index, the index will be assigned the same
+name as the first @code{index_col_name}, with an optional suffix (@code{_2},
+@code{_3}, @code{...}) to make it unique. You can see index names for a
+table using @code{SHOW INDEX FROM tbl_name}.
+@xref{SHOW, , @code{SHOW}}.
-@cindex timeout
-@item @code{connect_timeout}
-The number of seconds the @code{mysqld} server is waiting for a connect
-packet before responding with @code{Bad handshake}.
+@item
+@cindex @code{NULL} values, and indexes
+@cindex indexes, and @code{NULL} values
+Only the @code{MyISAM} table type supports indexes on columns that can have
+@code{NULL} values. In other cases you must declare such columns
+@code{NOT NULL} or an error results.
-@item @code{datadir}
-The value of the @code{--datadir} option.
+@item
+With @code{col_name(length)} syntax, you can specify an index that
+uses only a part of a @code{CHAR} or @code{VARCHAR} column. This can
+make the index file much smaller.
+@xref{Indexes}.
-@item @code{delay_key_write}
-If enabled (is on by default), @strong{MySQL} will honor the
-@code{delay_key_write} option @code{CREATE TABLE}. This means that the
-key buffer for tables with this option will not get flushed on every
-index update, but only when a table is closed. This will speed up
-writes on keys a lot, but you should add automatic checking of all tables
-with @code{myisamchk --fast --force} if you use this. Note that if you
-start @code{mysqld} with the @code{--delay-key-write-for-all-tables}
-option this means that all tables will be treated as if they were
-created with the @code{delay_key_write} option. You can clear this flag
-by starting @code{mysqld} with @code{--skip-new} or @code{--safe-mode}.
+@item
+@cindex @code{BLOB} columns, indexing
+@cindex indexes, and @code{BLOB} columns
+@cindex @code{TEXT} columns, indexing
+@cindex indexes, and @code{TEXT} columns
+Only the @code{MyISAM} table type supports indexing on @code{BLOB} and
+@code{TEXT} columns. When putting an index on a @code{BLOB} or @code{TEXT}
+column you MUST always specify the length of the index:
+@example
+CREATE TABLE test (blob_col BLOB, index(blob_col(10)));
+@end example
-@item @code{delayed_insert_limit}
-After inserting @code{delayed_insert_limit} rows, the @code{INSERT
-DELAYED} handler will check if there are any @code{SELECT} statements
-pending. If so, it allows these to execute before continuing.
+@item
+When you use @code{ORDER BY} or @code{GROUP BY} with a @code{TEXT} or
+@code{BLOB} column, only the first @code{max_sort_length} bytes are used.
+@xref{BLOB, , @code{BLOB}}.
-@item @code{delayed_insert_timeout}
-How long a @code{INSERT DELAYED} thread should wait for @code{INSERT}
-statements before terminating.
+@item
+In MySQL Version 3.23.23 or later, you can also create special
+@strong{FULLTEXT} indexes. They are used for full-text search. Only the
+@code{MyISAM} table type supports @code{FULLTEXT} indexes. They can be created
+only from @code{VARCHAR} and @code{TEXT} columns.
+Indexing always happens over the entire column, partial indexing is not
+supported. See @ref{Fulltext Search} for details of operation.
-@item @code{delayed_queue_size}
-What size queue (in rows) should be allocated for handling @code{INSERT
-DELAYED}. If the queue becomes full, any client that does @code{INSERT
-DELAYED} will wait until there is room in the queue again.
+@item
+The @code{FOREIGN KEY}, @code{CHECK}, and @code{REFERENCES} clauses don't
+actually do anything. The syntax for them is provided only for compatibility,
+to make it easier to port code from other SQL servers and to run applications
+that create tables with references.
+@xref{Missing functions}.
-@item @code{flush}
-This is @code{ON} if you have started @strong{MySQL} with the @code{--flush}
-option.
+@item
+Each @code{NULL} column takes one bit extra, rounded up to the nearest byte.
-@item @code{flush_time}
-If this is set to a non-zero value, then every @code{flush_time} seconds all
-tables will be closed (to free up resources and sync things to disk). We
-only recommend this option on Win95, Win98, or on systems where you have
-very little resources.
+@item
+The maximum record length in bytes can be calculated as follows:
-@item @code{ft_min_word_len}
-The minimum length of the word to be included in a @code{FULLTEXT} index.
-@strong{Note: @code{FULLTEXT} index have to be rebuilt (e.g. with
-@code{OPTIMIZE TABLE}) after changing this variable.}
-
-@item @code{ft_max_word_len}
-The maximum length of the word to be included in a @code{FULLTEXT} index.
-@strong{Note: @code{FULLTEXT} index have to be rebuilt after changing
-this variable.}
-
-@item @code{ft_max_word_len_sort}
-The maximum length of the word in a @code{FULLTEXT} index
-to be used in fast index recreation method in
-@code{REPAIR}, @code{CREATE INDEX}, @code{OPTIMIZE TABLE}, or
-@code{ALTER TABLE}. Longer words are inserted the slow way.
-The rule of the thumb is as follows: with @code{ft_max_word_len_sort}
-increasing, @strong{MySQL} will create bigger temporary files
-(thus slowing the process down, due to disk I/O), and will put
-fewer keys in one sort block (againg, decreasing the efficiency).
-When @code{ft_max_word_len_sort} is too small, instead,
-@strong{MySQL} will insert a lot of words into index the slow way -
-but short words will be inserted very fast. It applies only to
-index recreation during @code{REPAIR}, @code{CREATE INDEX},
-@code{OPTIMIZE TABLE}, or @code{ALTER TABLE}.
+@example
+row length = 1
+ + (sum of column lengths)
+ + (number of NULL columns + 7)/8
+ + (number of variable-length columns)
+@end example
-@item @code{have_bdb}
-@code{YES} if @code{mysqld} supports Berkeley DB tables. @code{DISABLED}
-if @code{--skip-bdb} is used.
-@item @code{have_gemini}
-@code{YES} if @code{mysqld} supports Gemini tables. @code{DISABLED}
-if @code{--skip-gemini} is used.
-@item @code{have_innodb}
-@code{YES} if @code{mysqld} supports InnoDB tables. @code{DISABLED}
-if @code{--skip-innodb} is used.
-@item @code{have_raid}
-@code{YES} if @code{mysqld} supports the @code{RAID} option.
-@item @code{have_ssl}
-@code{YES} if @code{mysqld} supports SSL (encryption) on the client/server
-protocol.
+@item
+The @code{table_options} and @code{SELECT} options are only
+implemented in MySQL Version 3.23 and above.
-@item @code{init_file}
-The name of the file specified with the @code{--init-file} option when
-you start the server. This is a file of SQL statements you want the
-server to execute when it starts.
+The different table types are:
-@item @code{interactive_timeout}
-The number of seconds the server waits for activity on an interactive
-connection before closing it. An interactive client is defined as a
-client that uses the @code{CLIENT_INTERACTIVE} option to
-@code{mysql_real_connect()}. See also @code{wait_timeout}.
+@multitable @columnfractions .20 .80
+@item BDB or Berkeley_db @tab Transaction-safe tables with page locking. @xref{BDB}.
+@item HEAP @tab The data for this table is only stored in memory. @xref{HEAP}.
+@item ISAM @tab The original table handler. @xref{ISAM}.
+@item InnoDB @tab Transaction-safe tables with row locking. @xref{InnoDB}.
+@item MERGE @tab A collection of MyISAM tables used as one table. @xref{MERGE}.
+@item MyISAM @tab The new binary portable table handler that is replacing ISAM. @xref{MyISAM}.
+@end multitable
+@xref{Table types}.
-@item @code{join_buffer_size}
-The size of the buffer that is used for full joins (joins that do not
-use indexes). The buffer is allocated one time for each full join
-between two tables. Increase this value to get a faster full join when
-adding indexes is not possible. (Normally the best way to get fast joins
-is to add indexes.)
+If a table type is specified, and that particular type is not available,
+MySQL will choose the closest table type to the one that you have
+specified. For example, if @code{TYPE=BDB} is specified, and that distribution
+of MySQL does not support @code{BDB} tables, the table will be created
+as @code{MyISAM} instead.
-@c Make texi2html support index @anchor{Index cache size}. Then change
-@c some xrefs to point here
-@cindex indexes, block size
-@item @code{key_buffer_size}
-Index blocks are buffered and are shared by all threads.
-@code{key_buffer_size} is the size of the buffer used for index blocks.
+The other table options are used to optimize the behavior of the
+table. In most cases, you don't have to specify any of them.
+The options work for all table types, if not otherwise indicated:
-Increase this to get better index handling (for all reads and multiple
-writes) to as much as you can afford; 64M on a 256M machine that mainly
-runs @strong{MySQL} is quite common. If you, however, make this too big
-(more than 50% of your total memory?) your system may start to page and
-become REALLY slow. Remember that because @strong{MySQL} does not cache
-data read, that you will have to leave some room for the OS filesystem
-cache.
+@multitable @columnfractions .20 .80
+@item @code{AUTO_INCREMENT} @tab The next auto_increment value you want to set for your table (MyISAM).
+@item @code{AVG_ROW_LENGTH} @tab An approximation of the average row length for your table. You only need to set this for large tables with variable size records.
+@item @code{CHECKSUM} @tab Set this to 1 if you want MySQL to maintain a checksum for all rows (makes the table a little slower to update but makes it easier to find corrupted tables) (MyISAM).
+@item @code{COMMENT} @tab A 60-character comment for your table.
+@item @code{MAX_ROWS} @tab Max number of rows you plan to store in the table.
+@item @code{MIN_ROWS} @tab Minimum number of rows you plan to store in the table.
+@item @code{PACK_KEYS} @tab Set this to 1 if you want to have a smaller index. This usually makes updates slower and reads faster (MyISAM, ISAM).
+@item @code{PASSWORD} @tab Encrypt the @code{.frm} file with a password. This option doesn't do anything in the standard MySQL version.
+@item @code{DELAY_KEY_WRITE} @tab Set this to 1 if want to delay key table updates until the table is closed (MyISAM).
+@item @code{ROW_FORMAT} @tab Defines how the rows should be stored. Currently you can only use the DYNAMIC and STATIC options for MyISAM tables.
+@end multitable
-You can check the performance of the key buffer by doing @code{show
-status} and examine the variables @code{Key_read_requests},
-@code{Key_reads}, @code{Key_write_requests}, and @code{Key_writes}. The
-@code{Key_reads/Key_read_request} ratio should normally be < 0.01.
-The @code{Key_write/Key_write_requests} is usually near 1 if you are
-using mostly updates/deletes but may be much smaller if you tend to
-do updates that affect many at the same time or if you are
-using @code{delay_key_write}. @xref{SHOW}.
+When you use a @code{MyISAM} table, MySQL uses the product of
+@code{max_rows * avg_row_length} to decide how big the resulting table
+will be. If you don't specify any of the above options, the maximum size
+for a table will be 4G (or 2G if your operating systems only supports 2G
+tables). The reason for this is just to keep down the pointer sizes
+to make the index smaller and faster if you don't really need big files.
-To get even more speed when writing many rows at the same time, use
-@code{LOCK TABLES}. @xref{LOCK TABLES, , @code{LOCK TABLES}}.
+If you don't use @code{PACK_KEYS}, the default is to only pack strings,
+not numbers. If you use @code{PACK_KEYS=1}, numbers will be packed as well.
-@item @code{language}
-The language used for error messages.
+When packing binary number keys, MySQL will use prefix compression.
+This means that you will only get a big benefit of this if you have
+many numbers that are the same. Prefix compression means that every
+key needs one extra byte to indicate how many bytes of the previous key are
+the same for the next key (note that the pointer to the row is stored
+in high-byte-first-order directly after the key, to improve
+compression.) This means that if you have many equal keys on two rows
+in a row, all following 'same' keys will usually only take 2 bytes
+(including the pointer to the row). Compare this to the ordinary case
+where the following keys will take storage_size_for_key +
+pointer_size (usually 4). On the other hand, if all keys are
+totally different, you will lose 1 byte per key, if the key isn't a
+key that can have @code{NULL} values (In this case the packed key length will
+be stored in the same byte that is used to mark if a key is @code{NULL}.)
-@item @code{large_file_support}
-If @code{mysqld} was compiled with options for big file support.
+@item
+If you specify a @code{SELECT} after the @code{CREATE} statement,
+MySQL will create new fields for all elements in the
+@code{SELECT}. For example:
-@item @code{locked_in_memory}
-If @code{mysqld} was locked in memory with @code{--memlock}
+@example
+mysql> CREATE TABLE test (a int not null auto_increment,
+ primary key (a), key(b))
+ TYPE=MyISAM SELECT b,c from test2;
+@end example
-@item @code{log}
-If logging of all queries is enabled.
+This will create a @code{MyISAM} table with three columns, a, b, and c.
+Notice that the columns from the @code{SELECT} statement are appended to
+the right side of the table, not overlapped onto it. Take the following
+example:
-@item @code{log_update}
-If the update log is enabled.
+@example
+mysql> select * from foo;
++---+
+| n |
++---+
+| 1 |
++---+
-@item @code{log_bin}
-If the binary log is enabled.
+mysql> create table bar (m int) select n from foo;
+Query OK, 1 row affected (0.02 sec)
+Records: 1 Duplicates: 0 Warnings: 0
+
+mysql> select * from bar;
++------+---+
+| m | n |
++------+---+
+| NULL | 1 |
++------+---+
+1 row in set (0.00 sec)
+@end example
-@item @code{log_slave_updates}
-If the updates from the slave should be logged.
+For each row in table @code{foo}, a row is inserted in @code{bar} with
+the values from @code{foo} and default values for the new columns.
-@item @code{long_query_time}
-If a query takes longer than this (in seconds), the @code{Slow_queries} counter
-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}.
+@code{CREATE TABLE ... SELECT} will not automaticly create any indexes
+for you. This is done intentionally to make the command as flexible as
+possible. If you want to have indexes in the created table, you should
+specify these before the @code{SELECT} statement:
-@item @code{lower_case_table_names}
-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}.
+@example
+mysql> create table bar (unique (n)) select n from foo;
+@end example
-@item @code{max_allowed_packet}
-The maximum size of one packet. The message buffer is initialized to
-@code{net_buffer_length} bytes, but can grow up to @code{max_allowed_packet}
-bytes when needed. This value by default is small, to catch big (possibly
-wrong) packets. You must increase this value if you are using big
-@code{BLOB} columns. It should be as big as the biggest @code{BLOB} you want
-to use. The current protocol limits @code{max_allowed_packet} to 16M.
+If any errors occur while copying the data to the table, it will
+automatically be deleted.
-@item @code{max_binlog_cache_size}
-If a multi-statement transaction requires more than this amount of memory,
-one will get the error "Multi-statement transaction required more than
-'max_binlog_cache_size' bytes of storage".
+To ensure that the update log/binary log can be used to re-create the
+original tables, MySQL will not allow concurrent inserts during
+@code{CREATE TABLE .... SELECT}.
+@item
+The @code{RAID_TYPE} option will help you to break the 2G/4G limit for
+the MyISAM data file (not the index file) on
+operating systems that don't support big files. You can get also more speed
+from the I/O bottleneck by putting @code{RAID} directories on different
+physical disks. @code{RAID_TYPE} will work on any OS, as long as you have
+configured MySQL with @code{--with-raid}. For now the only allowed
+@code{RAID_TYPE} is @code{STRIPED} (@code{1} and @code{RAID0} are aliases
+for this).
-@item @code{max_binlog_size}
-Available after 3.23.33. If a write to the binary (replication) log exceeds
-the given value, rotate the logs. You cannot set it to less than 1024 bytes,
-or more than 1 GB. Default is 1 GB.
+If you specify @code{RAID_TYPE=STRIPED} for a @code{MyISAM} table,
+@code{MyISAM} will create @code{RAID_CHUNKS} subdirectories named 00,
+01, 02 in the database directory. In each of these directories
+@code{MyISAM} will create a @code{table_name.MYD}. When writing data
+to the data file, the @code{RAID} handler will map the first
+@code{RAID_CHUNKSIZE} *1024 bytes to the first file, the next
+@code{RAID_CHUNKSIZE} *1024 bytes to the next file and so on.
+@item
+@code{UNION} is used when you want to use a collection of identical
+tables as one. This only works with MERGE tables. @xref{MERGE}.
-@item @code{max_connections}
-The number of simultaneous clients allowed. Increasing this value increases
-the number of file descriptors that @code{mysqld} requires. See below for
-comments on file descriptor limits. @xref{Too many connections}.
+For the moment you need to have @code{SELECT}, @code{UPDATE}, and
+@code{DELETE} privileges on the tables you map to a @code{MERGE} table.
+All mapped tables must be in the same database as the @code{MERGE} table.
+@item
+In the created table the @code{PRIMARY} key will be placed first, followed
+by all @code{UNIQUE} keys and then the normal keys. This helps the
+MySQL optimizer to prioritize which key to use and also more quickly
+detect duplicated @code{UNIQUE} keys.
-@item @code{max_connect_errors}
-If there is more than this number of interrupted connections from a host
-this host will be blocked from further connections. You can unblock a host
-with the command @code{FLUSH HOSTS}.
+@item
+By using @code{DATA DIRECTORY="directory"} or @code{INDEX
+DIRECTORY="directory"} you can specify where the table handler should
+put it's table and index files. This only works for @code{MyISAM} tables
+in @code{MySQL} 4.0, when you are not using the @code{--skip-symlink}
+option. @xref{Symbolic links to tables}.
-@item @code{max_delayed_threads}
-Don't start more than this number of threads to handle @code{INSERT DELAYED}
-statements. If you try to insert data into a new table after all @code{INSERT
-DELAYED} threads are in use, the row will be inserted as if the
-@code{DELAYED} attribute wasn't specified.
+@end itemize
-@item @code{max_heap_table_size}
-Don't allow creation of heap tables bigger than this.
-@item @code{max_join_size}
-Joins that are probably going to read more than @code{max_join_size}
-records return an error. Set this value if your users tend to perform joins
-that lack a @code{WHERE} clause, that take a long time, and that return
-millions of rows.
+@node Silent column changes, , CREATE TABLE, CREATE TABLE
+@subsubsection Silent Column Specification Changes
-@item @code{max_sort_length}
-The number of bytes to use when sorting @code{BLOB} or @code{TEXT}
-values (only the first @code{max_sort_length} bytes of each value
-are used; the rest are ignored).
+@cindex silent column changes
-@item @code{max_user_connections}
-The maximum number of active connections for a single user (0 = no limit).
+In some cases, MySQL silently changes a column specification from
+that given in a @code{CREATE TABLE} statement. (This may also occur with
+@code{ALTER TABLE}.):
-@item @code{max_tmp_tables}
-(This option doesn't yet do anything.)
-Maximum number of temporary tables a client can keep open at the same time.
+@itemize @bullet
+@item
+@code{VARCHAR} columns with a length less than four are changed to
+@code{CHAR}.
-@item @code{max_write_lock_count}
-After this many write locks, allow some read locks to run in between.
+@item
+If any column in a table has a variable length, the entire row is
+variable-length as a result. Therefore, if a table contains any
+variable-length columns (@code{VARCHAR}, @code{TEXT}, or @code{BLOB}),
+all @code{CHAR} columns longer than three characters are changed to
+@code{VARCHAR} columns. This doesn't affect how you use the columns in
+any way; in MySQL, @code{VARCHAR} is just a different way to
+store characters. MySQL performs this conversion because it
+saves space and makes table operations faster. @xref{Table types}.
-@item @code{myisam_recover_options}
-The value of the @code{--myisam-recover} option.
+@item
+@code{TIMESTAMP} display sizes must be even and in the range from 2 to 14.
+If you specify a display size of 0 or greater than 14, the size is coerced
+to 14. Odd-valued sizes in the range from 1 to 13 are coerced
+to the next higher even number.
-@item @code{myisam_sort_buffer_size}
-The buffer that is allocated when sorting the index when doing a
-@code{REPAIR} or when creating indexes with @code{CREATE INDEX} or
-@code{ALTER TABLE}.
+@item
+You cannot store a literal @code{NULL} in a @code{TIMESTAMP} column; setting
+it to @code{NULL} sets it to the current date and time. Because
+@code{TIMESTAMP} columns behave this way, the @code{NULL} and @code{NOT NULL}
+attributes do not apply in the normal way and are ignored if you specify
+them. @code{DESCRIBE tbl_name} always reports that a @code{TIMESTAMP}
+column may be assigned @code{NULL} values.
-@item @code{myisam_bulk_insert_tree_size}
-@code{MyISAM} uses special tree-like cache to make bulk inserts (that is,
-@code{INSERT ... SELECT},
-@code{INSERT ... VALUES (...), (...), ...}, and
-@code{LOAD DATA INFILE}) faster. This variable limits
-the size of the cache tree in bytes @strong{per thread, per table}.
-Default value is 8 MB.
+@item
+MySQL maps certain column types used by other SQL database vendors
+to MySQL types. @xref{Other-vendor column types}.
+@end itemize
-@item @code{myisam_max_extra_sort_file_size}.
-If the creating of the temporary file for fast index creation would be
-this much bigger than using the key cache, then prefer the key cache
-method. This is mainly used to force long character keys in large
-tables to use the slower key cache method to create the index.
-@strong{NOTE} that this parameter is given in megabytes!
+If you want to see whether or not MySQL used a column type other
+than the one you specified, issue a @code{DESCRIBE tbl_name} statement after
+creating or altering your table.
-@item @code{myisam_max_sort_file_size}
-The maximum size of the temporary file @strong{MySQL} is allowed to use
-while recreating the index (during @code{REPAIR}, @code{ALTER TABLE}
-or @code{LOAD DATA INFILE}. If the file size would be bigger than this,
-the index will be created through the key cache (which is slower).
-@strong{NOTE} that this parameter is given in megabytes!
+@cindex @code{myisampack}
+Certain other column type changes may occur if you compress a table
+using @code{myisampack}. @xref{Compressed format}.
-@item @code{net_buffer_length}
-The communication buffer is reset to this size between queries. This
-should not normally be changed, but if you have very little memory, you
-can set it to the expected size of a query. (That is, the expected length of
-SQL statements sent by clients. If statements exceed this length, the buffer
-is automatically enlarged, up to @code{max_allowed_packet} bytes.)
-@item @code{net_read_timeout}
-Number of seconds to wait for more data from a connection before aborting
-the read. Note that when we don't expect data from a connection, the timeout
-is defined by @code{write_timeout}. See also @code{slave_read_timeout}.
+@node ALTER TABLE, RENAME TABLE, CREATE TABLE, Data Definition
+@subsection @code{ALTER TABLE} Syntax
-@item @code{net_retry_count}
-If a read on a communication port is interrupted, retry this many times
-before giving up. This value should be quite high on @code{FreeBSD} as
-internal interrupts are sent to all threads.
+@findex ALTER TABLE
-@item @code{net_write_timeout}
-Number of seconds to wait for a block to be written to a connection before
-aborting the write.
+@example
+ALTER [IGNORE] TABLE tbl_name alter_spec [, alter_spec ...]
-@item @code{open_files_limit}
-If this is not 0, then @code{mysqld} will use this value to reserve file
-descriptors to use with @code{setrlimit()}. If this value is 0 then
-@code{mysqld} will reserve @code{max_connections*5} or
-@code{max_connections + table_cache*2} (whichever is larger) number of
-files. You should try increasing this if @code{mysqld} gives you the
-error 'Too many open files'.
+alter_specification:
+ ADD [COLUMN] create_definition [FIRST | AFTER column_name ]
+ or ADD [COLUMN] (create_definition, create_definition,...)
+ or ADD INDEX [index_name] (index_col_name,...)
+ or ADD PRIMARY KEY (index_col_name,...)
+ or ADD UNIQUE [index_name] (index_col_name,...)
+ or ADD FULLTEXT [index_name] (index_col_name,...)
+ or ADD [CONSTRAINT symbol] FOREIGN KEY index_name (index_col_name,...)
+ [reference_definition]
+ or ALTER [COLUMN] col_name @{SET DEFAULT literal | DROP DEFAULT@}
+ or CHANGE [COLUMN] old_col_name create_definition
+ or MODIFY [COLUMN] create_definition
+ or DROP [COLUMN] col_name
+ or DROP PRIMARY KEY
+ or DROP INDEX index_name
+ or RENAME [TO] new_tbl_name
+ or ORDER BY col
+ or table_options
+@end example
-@item @code{pid_file}
-The value of the @code{--pid-file} option.
+@code{ALTER TABLE} allows you to change the structure of an existing table.
+For example, you can add or delete columns, create or destroy indexes, change
+the type of existing columns, or rename columns or the table itself. You can
+also change the comment for the table and type of the table.
+@xref{CREATE TABLE, , @code{CREATE TABLE}}.
-@item @code{port}
-The value of the @code{--port} option.
+If you use @code{ALTER TABLE} to change a column specification but
+@code{DESCRIBE tbl_name} indicates that your column was not changed, it is
+possible that MySQL ignored your modification for one of the reasons
+described in @ref{Silent column changes}. For example, if you try to change
+a @code{VARCHAR} column to @code{CHAR}, MySQL will still use
+@code{VARCHAR} if the table contains other variable-length columns.
-@item @code{protocol_version}
-The protocol version used by the @strong{MySQL} server.
+@code{ALTER TABLE} works by making a temporary copy of the original table.
+The alteration is performed on the copy, then the original table is
+deleted and the new one is renamed. This is done in such a way that
+all updates are automatically redirected to the new table without
+any failed updates. While @code{ALTER TABLE} is executing, the original
+table is readable by other clients. Updates and writes to the table
+are stalled until the new table is ready.
-@item @code{record_buffer}
-Each thread that does a sequential scan allocates a buffer of this
-size for each table it scans. If you do many sequential scans, you may
-want to increase this value.
+Note that if you use any other option to @code{ALTER TABLE} than
+@code{RENAME}, MySQL will always create a temporary table, even
+if the data wouldn't strictly need to be copied (like when you change the
+name of a column). We plan to fix this in the future, but as one doesn't
+normally do @code{ALTER TABLE} that often this isn't that high on our TODO.
-@item @code{query_buffer_size}
-The initial allocation of the query buffer. If most of your queries are
-long (like when inserting blobs), you should increase this!
+@itemize @bullet
+@item
+To use @code{ALTER TABLE}, you need @strong{ALTER}, @strong{INSERT},
+and @strong{CREATE} privileges on the table.
-@item @code{safe_show_databases}
-Don't show databases for which the user doesn't have any database or
-table privileges. This can improve security if you're concerned about
-people being able to see what databases other users have. See also
-@code{skip_show_databases}.
+@item
+@code{IGNORE} is a MySQL extension to ANSI SQL92.
+It controls how @code{ALTER TABLE} works if there are duplicates on
+unique keys in the new table.
+If @code{IGNORE} isn't specified, the copy is aborted and rolled back.
+If @code{IGNORE} is specified, then for rows with duplicates on a unique
+key, only the first row is used; the others are deleted.
-@item @code{server_id}
-The value of the @code{--server-id} option.
+@item
+You can issue multiple @code{ADD}, @code{ALTER}, @code{DROP}, and
+@code{CHANGE} clauses in a single @code{ALTER TABLE} statement. This is a
+MySQL extension to ANSI SQL92, which allows only one of each clause
+per @code{ALTER TABLE} statement.
-@item @code{skip_locking}
-Is OFF if @code{mysqld} uses external locking.
+@item
+@code{CHANGE col_name}, @code{DROP col_name}, and @code{DROP
+INDEX} are MySQL extensions to ANSI SQL92.
-@item @code{skip_networking}
-Is ON if we only allow local (socket) connections.
+@item
+@code{MODIFY} is an Oracle extension to @code{ALTER TABLE}.
-@item @code{skip_show_databases}
-This prevents people from doing @code{SHOW DATABASES} if they don't have
-the @code{PROCESS_PRIV} privilege. This can improve security if you're
-concerned about people being able to see what databases other users
-have. See also @code{safe_show_databases}.
+@item
+The optional word @code{COLUMN} is a pure noise word and can be omitted.
-@item @code{slave_read_timeout}
-Number of seconds to wait for more data from a master/slave connection
-before aborting the read.
+@item
+If you use @code{ALTER TABLE tbl_name RENAME TO new_name} without any other
+options, MySQL simply renames the files that correspond to the table
+@code{tbl_name}. There is no need to create the temporary table.
+@xref{RENAME TABLE,, @code{RENAME TABLE}}.
-@item @code{slow_launch_time}
-If creating the thread takes longer than this value (in seconds), the
-@code{Slow_launch_threads} counter will be incremented.
+@item
+@code{create_definition} clauses use the same syntax for @code{ADD} and
+@code{CHANGE} as for @code{CREATE TABLE}. Note that this syntax includes
+the column name, not just the column type.
+@xref{CREATE TABLE, , @code{CREATE TABLE}}.
-@item @code{socket}
-The Unix socket used by the server.
+@item
+You can rename a column using a @code{CHANGE old_col_name create_definition}
+clause. To do so, specify the old and new column names and the type that
+the column currently has. For example, to rename an @code{INTEGER} column
+from @code{a} to @code{b}, you can do this:
-@item @code{sort_buffer}
-Each thread that needs to do a sort allocates a buffer of this
-size. Increase this value for faster @code{ORDER BY} or @code{GROUP BY}
-operations.
-@xref{Temporary files}.
+@example
+mysql> ALTER TABLE t1 CHANGE a b INTEGER;
+@end example
-@item @code{table_cache}
-The number of open tables for all threads. Increasing this value
-increases the number of file descriptors that @code{mysqld} requires.
-@strong{MySQL} needs two file descriptors for each unique open table.
-See below for comments on file descriptor limits. You can check if you
-need to increase the table cache by checking the @code{Opened_tables}
-variable. @xref{SHOW}. If this variable is big and you don't do
-@code{FLUSH TABLES} a lot (which just forces all tables to be closed and
-reopenend), then you should increase the value of this variable.
+If you want to change a column's type but not the name, @code{CHANGE}
+syntax still requires two column names even if they are the same. For
+example:
-Make sure that your operating system can handle the number of open file
-descriptors implied by the @code{table_cache} setting. If @code{table_cache}
-is set too high, @strong{MySQL} may run out of file descriptors and refuse
-connections, fail to perform queries, and be very unreliable.
+@example
+mysql> ALTER TABLE t1 CHANGE b b BIGINT NOT NULL;
+@end example
-For information about how the table cache works, see @ref{Table cache}.
+However, as of MySQL Version 3.22.16a, you can also use @code{MODIFY}
+to change a column's type without renaming it:
-@item @code{table_type}
-The default table type
+@example
+mysql> ALTER TABLE t1 MODIFY b BIGINT NOT NULL;
+@end example
-@item @code{thread_cache_size}
-How many threads we should keep in a cache for reuse. When a
-client disconnects, the client's threads are put in the cache if there
-aren't more than @code{thread_cache_size} threads from before. All new
-threads are first taken from the cache, and only when the cache is empty
-is a new thread created. This variable can be increased to improve
-performance if you have a lot of new connections. (Normally this doesn't
-give a notable performance improvement if you have a good
-thread implementation.) By examing the difference between
-the @code{Connections} and @code{Threads_created} you can see how efficient
-the current thread cache is for you.
+@item
+If you use @code{CHANGE} or @code{MODIFY} to shorten a column for which
+an index exists on part of the column (for instance, if you have an index
+on the first 10 characters of a @code{VARCHAR} column), you cannot make
+the column shorter than the number of characters that are indexed.
-@item @code{thread_concurrency}
-On Solaris, @code{mysqld} will call @code{thr_setconcurrency()} with
-this value. @code{thr_setconcurrency()} permits the application to give
-the threads system a hint for the desired number of threads that should
-be run at the same time.
+@item
+When you change a column type using @code{CHANGE} or @code{MODIFY},
+MySQL tries to convert data to the new type as well as possible.
-@item @code{thread_stack}
-The stack size for each thread. Many of the limits detected by the
-@code{crash-me} test are dependent on this value. The default is
-large enough for normal operation. @xref{Benchmarks}.
+@item
+In MySQL Version 3.22 or later, you can use @code{FIRST} or
+@code{ADD ... AFTER col_name} to add a column at a specific position within
+a table row. The default is to add the column last.
-@item @code{timezone}
-The timezone for the server.
+@findex ALTER COLUMN
+@item
+@code{ALTER COLUMN} specifies a new default value for a column
+or removes the old default value.
+If the old default is removed and the column can be @code{NULL}, the new
+default is @code{NULL}. If the column cannot be @code{NULL}, MySQL
+assigns a default value, as described in
+@ref{CREATE TABLE, , @code{CREATE TABLE}}.
-@item @code{tmp_table_size}
-If an in-memory temporary table exceeds this size, @strong{MySQL}
-will automatically convert it to an on-disk @code{MyISAM} table.
-Increase the value of @code{tmp_table_size} if you do many advanced
-@code{GROUP BY} queries and you have lots of memory.
+@findex DROP INDEX
+@item
+@code{DROP INDEX} removes an index. This is a MySQL extension to
+ANSI SQL92. @xref{DROP INDEX}.
-@item @code{tmpdir}
-The directory used for temporary files and temporary tables.
+@item
+If columns are dropped from a table, the columns are also removed from any
+index of which they are a part. If all columns that make up an index are
+dropped, the index is dropped as well.
-@item @code{version}
-The version number for the server.
+@item
+If a table contains only one column, the column cannot be dropped.
+If what you intend is to remove the table, use @code{DROP TABLE} instead.
-@item @code{wait_timeout}
-The number of seconds the server waits for activity on a connection before
-closing it. See also @code{interactive_timeout}.
-@end table
+@findex DROP PRIMARY KEY
+@item
+@code{DROP PRIMARY KEY} drops the primary index. If no such
+index exists, it drops the first @code{UNIQUE} index in the table.
+(MySQL marks the first @code{UNIQUE} key as the @code{PRIMARY KEY}
+if no @code{PRIMARY KEY} was specified explicitly.)
-The manual section that describes tuning @strong{MySQL} contains some
-information of how to tune the above variables. @xref{Server parameters}.
+@findex UNIQUE
+@findex PRIMARY KEY
+If you add a @code{UNIQUE INDEX} or @code{PRIMARY KEY} to a table, this
+is stored before any not @code{UNIQUE} index so that MySQL can detect
+duplicate keys as early as possible.
-@node SHOW LOGS, SHOW PROCESSLIST, SHOW VARIABLES, SHOW
-@subsection @code{SHOW LOGS}
-@code{SHOW LOGS} shows you status information about existing log
-files. It currently only displays information about Berkeley DB log
-files.
+@findex ORDER BY
+@item
+@code{ORDER BY} allows you to create the new table with the rows in a
+specific order. Note that the table will not remain in this order after
+inserts and deletes. In some cases, it may make sorting easier for
+MySQL if the table is in order by the column that you wish to
+order it by later. This option is mainly useful when you know that you
+are mostly going to query the rows in a certain order; By using this
+option after big changes to the table, you may be able to get higher
+performance.
-@itemize @bullet
-@item @code{File} shows the full path to the log file
-@item @code{Type} shows the type of the log file (@code{BDB} for Berkeley
-DB log files)
-@item @code{Status} shows the status of the log file (@code{FREE} if the
-file can be removed, or @code{IN USE} if the file is needed by the transaction
-subsystem)
-@end itemize
+@findex ALTER TABLE
+@item
+If you use @code{ALTER TABLE} on a @code{MyISAM} table, all non-unique
+indexes are created in a separate batch (like in @code{REPAIR}).
+This should make @code{ALTER TABLE} much faster when you have many indexes.
-@cindex threads, display
-@cindex processes, display
-@findex threads
-@findex PROCESSLIST
-@node SHOW PROCESSLIST, SHOW GRANTS, SHOW LOGS, SHOW
-@subsection @code{SHOW PROCESSLIST}
+@item
+@findex mysql_info()
+With the C API function @code{mysql_info()}, you can find out how many
+records were copied, and (when @code{IGNORE} is used) how many records were
+deleted due to duplication of unique key values.
-@code{SHOW PROCESSLIST} shows you which threads are running. You can
-also get this information using the @code{mysqladmin processlist}
-command. If you have the @strong{process} privilege, you can see all
-threads. Otherwise, you can see only your own threads. @xref{KILL, ,
-@code{KILL}}. If you don't use the @code{FULL} option, then only
-the first 100 characters of each query will be shown.
+@item
+@cindex foreign keys
+@cindex references
+The @code{FOREIGN KEY}, @code{CHECK}, and @code{REFERENCES} clauses don't
+actually do anything. The syntax for them is provided only for compatibility,
+to make it easier to port code from other SQL servers and to run applications
+that create tables with references.
+@xref{Missing functions}.
+@end itemize
-This command is very useful if you get the 'too many connections' error
-message and want to find out what's going on. @strong{MySQL} reserves
-one extra connection for a client with the @code{Process_priv} privilege
-to ensure that you should always be able to login and check the system
-(assuming you are not giving this privilege to all your users).
+Here is an example that shows some of the uses of @code{ALTER TABLE}. We
+begin with a table @code{t1} that is created as shown below:
-@cindex privileges, display
-@node SHOW GRANTS, SHOW CREATE TABLE, SHOW PROCESSLIST, SHOW
-@subsection @code{SHOW GRANTS}
+@example
+mysql> CREATE TABLE t1 (a INTEGER,b CHAR(10));
+@end example
-@code{SHOW GRANTS FOR user} lists the grant commands that must be issued to
-duplicate the grants for a user.
+To rename the table from @code{t1} to @code{t2}:
@example
-mysql> SHOW GRANTS FOR root@@localhost;
-+---------------------------------------------------------------------+
-| Grants for root@@localhost |
-+---------------------------------------------------------------------+
-| GRANT ALL PRIVILEGES ON *.* TO 'root'@@'localhost' WITH GRANT OPTION |
-+---------------------------------------------------------------------+
+mysql> ALTER TABLE t1 RENAME t2;
@end example
-@node SHOW CREATE TABLE, , SHOW GRANTS, SHOW
-@subsection @code{SHOW CREATE TABLE}
-
-Shows a @code{CREATE TABLE} statement that will create the given table:
+To change column @code{a} from @code{INTEGER} to @code{TINYINT NOT NULL}
+(leaving the name the same), and to change column @code{b} from
+@code{CHAR(10)} to @code{CHAR(20)} as well as renaming it from @code{b} to
+@code{c}:
@example
-mysql> show create table t\G
-*************************** 1. row ***************************
- Table: t
-Create Table: CREATE TABLE t (
- id int(11) default NULL auto_increment,
- s char(60) default NULL,
- PRIMARY KEY (id)
-) TYPE=MyISAM
-
+mysql> ALTER TABLE t2 MODIFY a TINYINT NOT NULL, CHANGE b c CHAR(20);
@end example
-@code{SHOW CREATE TABLE} will quote table and column names according to
-@code{SQL_QUOTE_SHOW_CREATE} option.
-@ref{SET OPTION, , @code{SET OPTION SQL_QUOTE_SHOW_CREATE}}.
-
-@findex EXPLAIN
-@findex SELECT, optimizing
-@node EXPLAIN, DESCRIBE, SHOW, Reference
-@section @code{EXPLAIN} Syntax (Get Information About a @code{SELECT})
+To add a new @code{TIMESTAMP} column named @code{d}:
@example
- EXPLAIN tbl_name
-or EXPLAIN SELECT select_options
+mysql> ALTER TABLE t2 ADD d TIMESTAMP;
@end example
-@code{EXPLAIN tbl_name} is a synonym for @code{DESCRIBE tbl_name} or
-@code{SHOW COLUMNS FROM tbl_name}.
+To add an index on column @code{d}, and make column @code{a} the primary key:
-When you precede a @code{SELECT} statement with the keyword @code{EXPLAIN},
-@strong{MySQL} explains how it would process the @code{SELECT}, providing
-information about how tables are joined and in which order.
+@example
+mysql> ALTER TABLE t2 ADD INDEX (d), ADD PRIMARY KEY (a);
+@end example
-With the help of @code{EXPLAIN}, you can see when you must add indexes
-to tables to get a faster @code{SELECT} that uses indexes to find the
-records. You can also see if the optimizer joins the tables in an optimal
-order. To force the optimizer to use a specific join order for a
-@code{SELECT} statement, add a @code{STRAIGHT_JOIN} clause.
+To remove column @code{c}:
-For non-simple joins, @code{EXPLAIN} returns a row of information for each
-table used in the @code{SELECT} statement. The tables are listed in the order
-they would be read. @strong{MySQL} resolves all joins using a single-sweep
-multi-join method. This means that @strong{MySQL} reads a row from the first
-table, then finds a matching row in the second table, then in the third table
-and so on. When all tables are processed, it outputs the selected columns and
-backtracks through the table list until a table is found for which there are
-more matching rows. The next row is read from this table and the process
-continues with the next table.
+@example
+mysql> ALTER TABLE t2 DROP COLUMN c;
+@end example
-Output from @code{EXPLAIN} includes the following columns:
+To add a new @code{AUTO_INCREMENT} integer column named @code{c}:
-@table @code
-@item table
-The table to which the row of output refers.
+@example
+mysql> ALTER TABLE t2 ADD c INT UNSIGNED NOT NULL AUTO_INCREMENT,
+ ADD INDEX (c);
+@end example
-@item type
-The join type. Information about the various types is given below.
+Note that we indexed @code{c}, because @code{AUTO_INCREMENT} columns must be
+indexed, and also that we declare @code{c} as @code{NOT NULL}, because
+indexed columns cannot be @code{NULL}.
-@item possible_keys
-The @code{possible_keys} column indicates which indexes @strong{MySQL}
-could use to find the rows in this table. Note that this column is
-totally independent of the order of the tables. That means that some of
-the keys in possible_keys may not be usable in practice with the
-generated table order.
+When you add an @code{AUTO_INCREMENT} column, column values are filled in
+with sequence numbers for you automatically. You can set the first
+sequence number by executing @code{SET INSERT_ID=#} before
+@code{ALTER TABLE} or using the @code{AUTO_INCREMENT = #} table option.
+@xref{SET OPTION}.
-If this column is empty, there are no relevant indexes. In this case,
-you may be able to improve the performance of your query by examining
-the @code{WHERE} clause to see if it refers to some column or columns
-that would be suitable for indexing. If so, create an appropriate index
-and check the query with @code{EXPLAIN} again. @xref{ALTER TABLE}.
+With MyISAM tables, if you don't change the @code{AUTO_INCREMENT}
+column, the sequence number will not be affected. If you drop an
+@code{AUTO_INCREMENT} column and then add another @code{AUTO_INCREMENT}
+column, the numbers will start from 1 again.
-To see what indexes a table has, use @code{SHOW INDEX FROM tbl_name}.
+@xref{ALTER TABLE problems}.
-@item key
-The @code{key} column indicates the key that @strong{MySQL} actually
-decided to use. The key is @code{NULL} if no index was chosen. If
-@strong{MySQL} chooses the wrong index, you can probably force
-@strong{MySQL} to use another index by using @code{myisamchk --analyze},
-@xref{myisamchk syntax}, or by using @code{USE INDEX/IGNORE INDEX}.
-@xref{JOIN}.
-@item key_len
-The @code{key_len} column indicates the length of the key that
-@strong{MySQL} decided to use. The length is @code{NULL} if the
-@code{key} is @code{NULL}. Note that this tells us how many parts of a
-multi-part key @strong{MySQL} will actually use.
+@node RENAME TABLE, DROP TABLE, ALTER TABLE, Data Definition
+@subsection @code{RENAME TABLE} Syntax
-@item ref
-The @code{ref} column shows which columns or constants are used with the
-@code{key} to select rows from the table.
+@findex RENAME TABLE
-@item rows
-The @code{rows} column indicates the number of rows @strong{MySQL}
-believes it must examine to execute the query.
+@example
+RENAME TABLE tbl_name TO new_table_name[, tbl_name2 TO new_table_name2,...]
+@end example
-@item Extra
-This column contains additional information of how @strong{MySQL} will
-resolve the query. Here is an explanation of the different text
-strings that can be found in this column:
+The rename is done atomically, which means that no other thread can
+access any of the tables while the rename is running. This makes it
+possible to replace a table with an empty one:
-@table @code
-@item Distinct
-@strong{MySQL} will not continue searching for more rows for the current row
-combination after it has found the first matching row.
+@example
+CREATE TABLE new_table (...);
+RENAME TABLE old_table TO backup_table, new_table TO old_table;
+@end example
-@item Not exists
-@strong{MySQL} was able to do a @code{LEFT JOIN} optimization on the
-query and will not examine more rows in this table for the previous row
-combination after it finds one row that matches the @code{LEFT JOIN} criteria.
+The rename is done from left to right, which means that if you want to
+swap two tables names, you have to:
-Here is an example for this:
+@example
+RENAME TABLE old_table TO backup_table,
+ new_table TO old_table,
+ backup_table TO new_table;
+@end example
+
+As long as two databases are on the same disk you can also rename
+from one database to another:
@example
-SELECT * FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.id IS NULL;
+RENAME TABLE current_database.table_name TO other_database.table_name;
@end example
-Assume that @code{t2.id} is defined with @code{NOT NULL}. In this case
-@strong{MySQL} will scan @code{t1} and look up the rows in @code{t2}
-through @code{t1.id}. If @strong{MySQL} finds a matching row in
-@code{t2}, it knows that @code{t2.id} can never be @code{NULL}, and will
-not scan through the rest of the rows in @code{t2} that has the same
-@code{id}. In other words, for each row in @code{t1}, @strong{MySQL}
-only needs to do a single lookup in @code{t2}, independent of how many
-matching rows there are in @code{t2}.
+When you execute @code{RENAME}, you can't have any locked tables or
+active transactions. You must also have the @code{ALTER} and @code{DROP}
+privilege on the original table and @code{CREATE} and @code{INSERT}
+privilege on the new table.
-@item @code{range checked for each record (index map: #)}
-@strong{MySQL} didn't find a real good index to use. It will, instead, for
-each row combination in the preceding tables, do a check on which index to
-use (if any), and use this index to retrieve the rows from the table. This
-isn't very fast but is faster than having to do a join without
-an index.
+If MySQL encounters any errors in a multiple table rename, it
+will do a reverse rename for all renamed tables to get everything back
+to the original state.
-@item Using filesort
-@strong{MySQL} will need to do an extra pass to find out how to retrieve
-the rows in sorted order. The sort is done by going through all rows
-according to the @code{join type} and storing the sort key + pointer to
-the row for all rows that match the @code{WHERE}. Then the keys are
-sorted. Finally the rows are retrieved in sorted order.
-@item Using index
-The column information is retrieved from the table using only
-information in the index tree without having to do an additional seek to
-read the actual row. This can be done when all the used columns for
-the table are part of the same index.
+@node DROP TABLE, CREATE INDEX, RENAME TABLE, Data Definition
+@subsection @code{DROP TABLE} Syntax
-@item Using temporary
-To resolve the query @strong{MySQL} will need to create a
-temporary table to hold the result. This typically happens if you do an
-@code{ORDER BY} on a different column set than you did a @code{GROUP
-BY} on.
+@findex DROP TABLE
-@item Where used
-A @code{WHERE} clause will be used to restrict which rows will be
-matched against the next table or sent to the client. If you don't have
-this information and the table is of type @code{ALL} or @code{index},
-you may have something wrong in your query (if you don't intend to
-fetch/examine all rows from the table).
-@end table
+@example
+DROP TABLE [IF EXISTS] tbl_name [, tbl_name,...] [RESTRICT | CASCADE]
+@end example
-If you want to get your queries as fast as possible, you should look out for
-@code{Using filesort} and @code{Using temporary}.
-@end table
+@code{DROP TABLE} removes one or more tables. All table data and the table
+definition are @emph{removed}, so @strong{be careful} with this command!
-The different join types are listed below, ordered from best to worst type:
+In MySQL Version 3.22 or later, you can use the keywords
+@code{IF EXISTS} to prevent an error from occurring for tables that don't
+exist.
-@cindex system table
-@cindex tables, system
-@table @code
-@item system
-The table has only one row (= system table). This is a special case of
-the @code{const} join type.
+@code{RESTRICT} and @code{CASCADE} are allowed to make porting easier.
+For the moment they don't do anything.
-@cindex constant table
-@cindex tables, constant
-@item const
-The table has at most one matching row, which will be read at the start
-of the query. Because there is only one row, values from the column in
-this row can be regarded as constants by the rest of the
-optimizer. @code{const} tables are very fast as they are read only once!
+@strong{NOTE}: @code{DROP TABLE} is not transaction-safe and will
+automatically commit any active transactions.
-@item eq_ref
-One row will be read from this table for each combination of rows from
-the previous tables. This is the best possible join type, other than the
-@code{const} types. It is used when all parts of an index are used by
-the join and the index is @code{UNIQUE} or a @code{PRIMARY KEY}.
-@item ref
-All rows with matching index values will be read from this table for each
-combination of rows from the previous tables. @code{ref} is used if the join
-uses only a leftmost prefix of the key, or if the key is not @code{UNIQUE}
-or a @code{PRIMARY KEY} (in other words, if the join cannot select a single
-row based on the key value). If the key that is used matches only a few rows,
-this join type is good.
+@node CREATE INDEX, DROP INDEX, DROP TABLE, Data Definition
+@subsection @code{CREATE INDEX} Syntax
-@item range
-Only rows that are in a given range will be retrieved, using an index to
-select the rows. The @code{key} column indicates which index is used.
-The @code{key_len} contains the longest key part that was used.
-The @code{ref} column will be NULL for this type.
+@findex CREATE INDEX
-@item index
-This is the same as @code{ALL}, except that only the index tree is
-scanned. This is usually faster than @code{ALL}, as the index file is usually
-smaller than the data file.
+@cindex indexes
+@cindex indexes, multi-part
+@cindex multi-part index
-@item ALL
-A full table scan will be done for each combination of rows from the
-previous tables. This is normally not good if the table is the first
-table not marked @code{const}, and usually @strong{very} bad in all other
-cases. You normally can avoid @code{ALL} by adding more indexes, so that
-the row can be retrieved based on constant values or column values from
-earlier tables.
-@end table
+@example
+CREATE [UNIQUE|FULLTEXT] INDEX index_name ON tbl_name (col_name[(length)],... )
+@end example
-You can get a good indication of how good a join is by multiplying all values
-in the @code{rows} column of the @code{EXPLAIN} output. This should tell you
-roughly how many rows @strong{MySQL} must examine to execute the query. This
-number is also used when you restrict queries with the @code{max_join_size}
-variable.
-@xref{Server parameters}.
+The @code{CREATE INDEX} statement doesn't do anything in MySQL prior
+to Version 3.22. In Version 3.22 or later, @code{CREATE INDEX} is mapped to an
+@code{ALTER TABLE} statement to create indexes.
+@xref{ALTER TABLE, , @code{ALTER TABLE}}.
-The following example shows how a @code{JOIN} can be optimized progressively
-using the information provided by @code{EXPLAIN}.
+Normally, you create all indexes on a table at the time the table itself
+is created with @code{CREATE TABLE}.
+@xref{CREATE TABLE, , @code{CREATE TABLE}}.
+@code{CREATE INDEX} allows you to add indexes to existing tables.
-Suppose you have the @code{SELECT} statement shown below, that you examine
-using @code{EXPLAIN}:
+A column list of the form @code{(col1,col2,...)} creates a multiple-column
+index. Index values are formed by concatenating the values of the given
+columns.
+
+For @code{CHAR} and @code{VARCHAR} columns, indexes can be created that
+use only part of a column, using @code{col_name(length)} syntax. (On
+@code{BLOB} and @code{TEXT} columns the length is required). The
+statement shown below creates an index using the first 10 characters of
+the @code{name} column:
@example
-EXPLAIN SELECT tt.TicketNumber, tt.TimeIn,
- tt.ProjectReference, tt.EstimatedShipDate,
- tt.ActualShipDate, tt.ClientID,
- tt.ServiceCodes, tt.RepetitiveID,
- tt.CurrentProcess, tt.CurrentDPPerson,
- tt.RecordVolume, tt.DPPrinted, et.COUNTRY,
- et_1.COUNTRY, do.CUSTNAME
- FROM tt, et, et AS et_1, do
- WHERE tt.SubmitTime IS NULL
- AND tt.ActualPC = et.EMPLOYID
- AND tt.AssignedPC = et_1.EMPLOYID
- AND tt.ClientID = do.CUSTNMBR;
+mysql> CREATE INDEX part_of_name ON customer (name(10));
@end example
-For this example, assume that:
+Because most names usually differ in the first 10 characters, this index should
+not be much slower than an index created from the entire @code{name} column.
+Also, using partial columns for indexes can make the index file much smaller,
+which could save a lot of disk space and might also speed up @code{INSERT}
+operations!
-@itemize @bullet
-@item
-The columns being compared have been declared as follows:
+Note that you can only add an index on a column that can have @code{NULL}
+values or on a @code{BLOB}/@code{TEXT} column if you are using
+MySQL Version 3.23.2 or newer and are using the @code{MyISAM}
+table type.
-@multitable @columnfractions .1 .2 .7
-@item @strong{Table} @tab @strong{Column} @tab @strong{Column type}
-@item @code{tt} @tab @code{ActualPC} @tab @code{CHAR(10)}
-@item @code{tt} @tab @code{AssignedPC} @tab @code{CHAR(10)}
-@item @code{tt} @tab @code{ClientID} @tab @code{CHAR(10)}
-@item @code{et} @tab @code{EMPLOYID} @tab @code{CHAR(15)}
-@item @code{do} @tab @code{CUSTNMBR} @tab @code{CHAR(15)}
-@end multitable
+For more information about how MySQL uses indexes, see
+@ref{MySQL indexes, , MySQL indexes}.
-@item
-The tables have the indexes shown below:
+@code{FULLTEXT} indexes can index only @code{VARCHAR} and
+@code{TEXT} columns, and only in @code{MyISAM} tables. @code{FULLTEXT} indexes
+are available in MySQL Version 3.23.23 and later.
+@ref{Fulltext Search}.
-@multitable @columnfractions .1 .9
-@item @strong{Table} @tab @strong{Index}
-@item @code{tt} @tab @code{ActualPC}
-@item @code{tt} @tab @code{AssignedPC}
-@item @code{tt} @tab @code{ClientID}
-@item @code{et} @tab @code{EMPLOYID} (primary key)
-@item @code{do} @tab @code{CUSTNMBR} (primary key)
-@end multitable
-@item
-The @code{tt.ActualPC} values aren't evenly distributed.
-@end itemize
+@node DROP INDEX, , CREATE INDEX, Data Definition
+@subsection @code{DROP INDEX} Syntax
-Initially, before any optimizations have been performed, the @code{EXPLAIN}
-statement produces the following information:
+@findex DROP INDEX
@example
-table type possible_keys key key_len ref rows Extra
-et ALL PRIMARY NULL NULL NULL 74
-do ALL PRIMARY NULL NULL NULL 2135
-et_1 ALL PRIMARY NULL NULL NULL 74
-tt ALL AssignedPC,ClientID,ActualPC NULL NULL NULL 3872
- range checked for each record (key map: 35)
+DROP INDEX index_name ON tbl_name
@end example
-Because @code{type} is @code{ALL} for each table, this output indicates that
-@strong{MySQL} is doing a full join for all tables! This will take quite a
-long time, as the product of the number of rows in each table must be
-examined! For the case at hand, this is @code{74 * 2135 * 74 * 3872 =
-45,268,558,720} rows. If the tables were bigger, you can only imagine how
-long it would take.
+@code{DROP INDEX} drops the index named @code{index_name} from the table
+@code{tbl_name}. @code{DROP INDEX} doesn't do anything in MySQL
+prior to Version 3.22. In Version 3.22 or later, @code{DROP INDEX} is mapped to an
+@code{ALTER TABLE} statement to drop the index.
+@xref{ALTER TABLE, , @code{ALTER TABLE}}.
-One problem here is that @strong{MySQL} can't (yet) use indexes on columns
-efficiently if they are declared differently. In this context,
-@code{VARCHAR} and @code{CHAR} are the same unless they are declared as
-different lengths. Because @code{tt.ActualPC} is declared as @code{CHAR(10)}
-and @code{et.EMPLOYID} is declared as @code{CHAR(15)}, there is a length
-mismatch.
-To fix this disparity between column lengths, use @code{ALTER TABLE} to
-lengthen @code{ActualPC} from 10 characters to 15 characters:
+@node Basic User Commands, Transactional Commands, Data Definition, Reference
+@section Basic MySQL User Utility Commands
-@example
-mysql> ALTER TABLE tt MODIFY ActualPC VARCHAR(15);
-@end example
+@menu
+* USE:: @code{USE} Syntax
+* DESCRIBE:: @code{DESCRIBE} Syntax (Get Information About Columns)
+@end menu
-Now @code{tt.ActualPC} and @code{et.EMPLOYID} are both @code{VARCHAR(15)}.
-Executing the @code{EXPLAIN} statement again produces this result:
-@example
-table type possible_keys key key_len ref rows Extra
-tt ALL AssignedPC,ClientID,ActualPC NULL NULL NULL 3872 where used
-do ALL PRIMARY NULL NULL NULL 2135
- range checked for each record (key map: 1)
-et_1 ALL PRIMARY NULL NULL NULL 74
- range checked for each record (key map: 1)
-et eq_ref PRIMARY PRIMARY 15 tt.ActualPC 1
-@end example
+@node USE, DESCRIBE, Basic User Commands, Basic User Commands
+@subsection @code{USE} Syntax
-This is not perfect, but is much better (the product of the @code{rows}
-values is now less by a factor of 74). This version is executed in a couple
-of seconds.
-
-A second alteration can be made to eliminate the column length mismatches
-for the @code{tt.AssignedPC = et_1.EMPLOYID} and @code{tt.ClientID =
-do.CUSTNMBR} comparisons:
+@findex USE
@example
-mysql> ALTER TABLE tt MODIFY AssignedPC VARCHAR(15),
- MODIFY ClientID VARCHAR(15);
+USE db_name
@end example
-Now @code{EXPLAIN} produces the output shown below:
+The @code{USE db_name} statement tells MySQL to use the @code{db_name}
+database as the default database for subsequent queries. The database remains
+current until the end of the session or until another @code{USE} statement
+is issued:
@example
-table type possible_keys key key_len ref rows Extra
-et ALL PRIMARY NULL NULL NULL 74
-tt ref AssignedPC,ClientID,ActualPC ActualPC 15 et.EMPLOYID 52 where used
-et_1 eq_ref PRIMARY PRIMARY 15 tt.AssignedPC 1
-do eq_ref PRIMARY PRIMARY 15 tt.ClientID 1
+mysql> USE db1;
+mysql> SELECT count(*) FROM mytable; # selects from db1.mytable
+mysql> USE db2;
+mysql> SELECT count(*) FROM mytable; # selects from db2.mytable
@end example
-This is almost as good as it can get.
-
-The remaining problem is that, by default, @strong{MySQL} assumes that values
-in the @code{tt.ActualPC} column are evenly distributed, and that isn't the
-case for the @code{tt} table. Fortunately, it is easy to tell @strong{MySQL}
-about this:
+Making a particular database current by means of the @code{USE} statement
+does not preclude you from accessing tables in other databases. The example
+below accesses the @code{author} table from the @code{db1} database and the
+@code{editor} table from the @code{db2} database:
@example
-shell> myisamchk --analyze PATH_TO_MYSQL_DATABASE/tt
-shell> mysqladmin refresh
+mysql> USE db1;
+mysql> SELECT author_name,editor_name FROM author,db2.editor
+ WHERE author.editor_id = db2.editor.editor_id;
@end example
-Now the join is perfect, and @code{EXPLAIN} produces this result:
+@cindex Sybase compatibility
+@cindex compatibility, with Sybase
+The @code{USE} statement is provided for Sybase compatibility.
-@example
-table type possible_keys key key_len ref rows Extra
-tt ALL AssignedPC,ClientID,ActualPC NULL NULL NULL 3872 where used
-et eq_ref PRIMARY PRIMARY 15 tt.ActualPC 1
-et_1 eq_ref PRIMARY PRIMARY 15 tt.AssignedPC 1
-do eq_ref PRIMARY PRIMARY 15 tt.ClientID 1
-@end example
-Note that the @code{rows} column in the output from @code{EXPLAIN} is an
-educated guess from the @strong{MySQL} join optimizer. To optimize a
-query, you should check if the numbers are even close to the truth. If not,
-you may get better performance by using @code{STRAIGHT_JOIN} in your
-@code{SELECT} statement and trying to list the tables in a different order in
-the @code{FROM} clause.
+@node DESCRIBE, , USE, Basic User Commands
+@subsection @code{DESCRIBE} Syntax (Get Information About Columns)
@findex DESC
@findex DESCRIBE
-@node DESCRIBE, COMMIT, EXPLAIN, Reference
-@section @code{DESCRIBE} Syntax (Get Information About Columns)
@example
@{DESCRIBE | DESC@} tbl_name @{col_name | wild@}
@@ -22956,7 +34480,7 @@ may be a column name or a string containing the SQL @samp{%} and @samp{_}
wild-card characters.
If the column types are different than you expect them to be based on a
-@code{CREATE TABLE} statement, note that @strong{MySQL} sometimes
+@code{CREATE TABLE} statement, note that MySQL sometimes
changes column types. @xref{Silent column changes}.
@cindex Oracle compatibility
@@ -22966,18 +34490,30 @@ This statement is provided for Oracle compatibility.
The @code{SHOW} statement provides similar information.
@xref{SHOW, , @code{SHOW}}.
+
+@node Transactional Commands, Fulltext Search, Basic User Commands, Reference
+@section MySQL Transactional and Locking Commands
+
+@menu
+* COMMIT:: @code{BEGIN/COMMIT/ROLLBACK} Syntax
+* LOCK TABLES:: @code{LOCK TABLES/UNLOCK TABLES} Syntax
+* SET TRANSACTION:: @code{SET TRANSACTION} Syntax
+@end menu
+
+
+@node COMMIT, LOCK TABLES, Transactional Commands, Transactional Commands
+@subsection @code{BEGIN/COMMIT/ROLLBACK} Syntax
+
@findex BEGIN
@findex COMMIT
@findex ROLLBACK
-@node COMMIT, LOCK TABLES, DESCRIBE, Reference
-@section @code{BEGIN/COMMIT/ROLLBACK} Syntax
-By default, @strong{MySQL} runs in @code{autocommit} mode. This means that
-as soon as you execute an update, @strong{MySQL} will store the update on
+By default, MySQL runs in @code{autocommit} mode. This means that
+as soon as you execute an update, MySQL will store the update on
disk.
-If you are using transactions safe tables (like @code{BDB} or
-@code{InnoDB}), you can put @strong{MySQL} into
+If you are using transactions safe tables (like @code{BDB},
+@code{InnoDB}, you can put MySQL into
non-@code{autocommit} mode with the following command:
@example
@@ -23007,7 +34543,7 @@ a warning. All transactional safe tables will be restored but any
non-transactional table will not change.
If you are using @code{BEGIN} or @code{SET AUTOCOMMIT=0}, you
-should use the @strong{MySQL} binary log for backups instead of the
+should use the MySQL binary log for backups instead of the
older update log. Transactions are stored in the binary log
in one chunk, upon @code{COMMIT}, to ensure that transactions which are
rolled back are not stored. @xref{Binary log}.
@@ -23024,10 +34560,12 @@ a @code{COMMIT} before executing the command):
You can change the isolation level for transactions with
@code{SET TRANSACTION ISOLATION LEVEL ...}. @xref{SET TRANSACTION}.
+
+@node LOCK TABLES, SET TRANSACTION, COMMIT, Transactional Commands
+@subsection @code{LOCK TABLES/UNLOCK TABLES} Syntax
+
@findex LOCK TABLES
@findex UNLOCK TABLES
-@node LOCK TABLES, SET OPTION, COMMIT, Reference
-@section @code{LOCK TABLES/UNLOCK TABLES} Syntax
@example
LOCK TABLES tbl_name [AS alias] @{READ | [READ LOCAL] | [LOW_PRIORITY] WRITE@}
@@ -23042,17 +34580,9 @@ are locked by the current thread are automatically unlocked when the
thread issues another @code{LOCK TABLES}, or when the connection to the
server is closed.
-The main reasons to use @code{LOCK TABLES} are:
-
-@itemize @bullet
-@item
-Emulate transactions with not transaction safe tables.
-@item
-To get more speed with @code{MyISAM} tables when inserting/updating data
-over many statements. The main reason this gives more speed is that
-@strong{MySQL} will not flush the key cache for the locked tables until
-@code{UNLOCK TABLES} is called.
-@end itemize
+The main reasons to use @code{LOCK TABLES} are for emulating transactions
+or getting more speed when updating tables. This is explained in more
+detail later.
If a thread obtains a @code{READ} lock on a table, that thread (and all other
threads) can only read from the table. If a thread obtains a @code{WRITE}
@@ -23062,11 +34592,13 @@ or @code{WRITE} to the table. Other threads are blocked.
The difference between @code{READ LOCAL} and @code{READ} is that
@code{READ LOCAL} allows non-conflicting @code{INSERT} statements to
execute while the lock is held. This can't however be used if you are
-going to manipulate the database files outside @strong{MySQL} while you
+going to manipulate the database files outside MySQL while you
hold the lock.
-Each thread waits (without timing out) until it obtains all the locks it has
-requested.
+When you use @code{LOCK TABLES}, you must lock all tables that you are
+going to use and you must use the same alias that you are going to use
+in your queries! If you are using a table multiple times in a query
+(with aliases), you must get a lock for each alias!
@code{WRITE} locks normally have higher priority than @code{READ} locks, to
ensure that updates are processed as soon as possible. This means that if one
@@ -23078,15 +34610,32 @@ locks while the thread is waiting for the @code{WRITE} lock. You should only
use @code{LOW_PRIORITY WRITE} locks if you are sure that there will
eventually be a time when no threads will have a @code{READ} lock.
-@code{LOCK TABLES} and @code{UNLOCK TABLES} both commits any active
-transactions.
+@code{LOCK TABLES} works as follows:
+@enumerate
+@item
+Sort all tables to be locked in a internally defined order (from the
+user standpoint the order is undefined).
+@item
+If a table is locked with a read and a write lock, put the write lock
+before the read lock.
+@item
+Lock one table at a time until the thread gets all locks.
+@end enumerate
+
+This policy ensures that table locking is deadlock free. There is
+however other things one needs to be aware of with this schema:
-When you use @code{LOCK TABLES}, you must lock all tables that you are
-going to use and you must use the same alias that you are going to use
-in your queries! If you are using a table multiple times in a query
-(with aliases), you must get a lock for each alias! This policy ensures
-that table locking is deadlock free and makes the locking code smaller,
-simpler and much faster.
+If you are using a @code{LOW_PRIORITY_WRITE} lock for a table, this
+means only that MySQL will wait for this particlar lock until
+there is no threads that wants a @code{READ} lock. When the thread has
+got the @code{WRITE} lock and is waiting to get the lock for the next
+table in the lock table list, all other threads will wait for the
+@code{WRITE} lock to be released. If this becomes a serious problem
+with your application, you should consider converting some of your
+tables to transactions safe tables.
+
+You can safely kill a thread that is waiting for a table lock with
+@code{KILL}. @xref{KILL}.
Note that you should @strong{NOT} lock any tables that you are using with
@code{INSERT DELAYED}. This is because that in this case the @code{INSERT}
@@ -23103,8 +34652,14 @@ If you are going to run many operations on a bunch of tables, it's much
faster to lock the tables you are going to use. The downside is, of course,
that no other thread can update a @code{READ}-locked table and no other
thread can read a @code{WRITE}-locked table.
+
+The reason some things are faster under @code{LOCK TABLES} is that
+MySQL will not flush the key cache for the locked tables until
+@code{UNLOCK TABLES} is called (normally the key cache is flushed after
+each SQL statement). This speeds up inserting/updateing/deletes on
+@code{MyISAM} tables.
@item
-If you are using a table handler in @strong{MySQL} that doesn't support
+If you are using a table handler in MySQL that doesn't support
transactions, you must use @code{LOCK TABLES} if you want to ensure that
no other thread comes between a @code{SELECT} and an @code{UPDATE}. The
example shown below requires @code{LOCK TABLES} in order to execute safely:
@@ -23134,7 +34689,7 @@ table in the server and implemented with @code{pthread_mutex_lock()} and
See @ref{Internal locking}, for more information on locking policy.
-You can also lock all tables in all databases with read locks with the
+You can lock all tables in all databases with read locks with the
@code{FLUSH TABLES WITH READ LOCK} command. @xref{FLUSH}. This is very
convenient way to get backups if you have a file system, like Veritas,
that can take snapshots in time.
@@ -23143,152 +34698,11 @@ that can take snapshots in time.
automatically commit any active transactions before attempting to lock the
tables.
-@findex SET OPTION
-@node SET OPTION, SET TRANSACTION, LOCK TABLES, Reference
-@section @code{SET} Syntax
-
-@example
-SET [OPTION] SQL_VALUE_OPTION= value, ...
-@end example
-
-@code{SET OPTION} sets various options that affect the operation of the
-server or your client. Any option you set remains in effect until the
-current session ends, or until you set the option to a different value.
-
-@table @code
-@item CHARACTER SET character_set_name | DEFAULT
-This maps all strings from and to the client with the given mapping.
-Currently the only option for @code{character_set_name} is
-@code{cp1251_koi8}, but you can easily add new mappings by editing the
-@file{sql/convert.cc} file in the @strong{MySQL} source distribution. The
-default mapping can be restored by using a @code{character_set_name} value of
-@code{DEFAULT}.
-
-Note that the syntax for setting the @code{CHARACTER SET} option differs
-from the syntax for setting the other options.
-
-@item PASSWORD = PASSWORD('some password')
-@cindex passwords, setting
-Set the password for the current user. Any non-anonymous user can change his
-own password!
-
-@item PASSWORD FOR user = PASSWORD('some password')
-Set the password for a specific user on the current server host. Only a user
-with access to the @code{mysql} database can do this. The user should be
-given in @code{user@@hostname} format, where @code{user} and @code{hostname}
-are exactly as they are listed in the @code{User} and @code{Host} columns of
-the @code{mysql.user} table entry. For example, if you had an entry with
-@code{User} and @code{Host} fields of @code{'bob'} and @code{'%.loc.gov'},
-you would write:
-
-@example
-mysql> SET PASSWORD FOR bob@@"%.loc.gov" = PASSWORD("newpass");
-
-or
-
-mysql> UPDATE mysql.user SET password=PASSWORD("newpass") where user="bob' and host="%.loc.gov";
-@end example
-
-@item SQL_AUTO_IS_NULL = 0 | 1
-If set to @code{1} (default) then one can find the last inserted row
-for a table with an auto_increment row with the following construct:
-@code{WHERE auto_increment_column IS NULL}. This is used by some
-ODBC programs like Access.
-
-@item AUTOCOMMIT= 0 | 1
-If set to @code{1} all changes to a table will be done at once. To start
-a multi-command transaction, you have to use the @code{BEGIN}
-statement. @xref{COMMIT}. If set to @code{0} you have to use @code{COMMIT} /
-@code{ROLLBACK} to accept/revoke that transaction. @xref{COMMIT}. Note
-that when you change from not @code{AUTOCOMMIT} mode to
-@code{AUTOCOMMIT} mode, @strong{MySQL} will do an automatic
-@code{COMMIT} on any open transactions.
-
-@item SQL_BIG_TABLES = 0 | 1
-@cindex table is full
-If set to @code{1}, all temporary tables are stored on disk rather than in
-memory. This will be a little slower, but you will not get the error
-@code{The table tbl_name is full} for big @code{SELECT} operations that
-require a large temporary table. The default value for a new connection is
-@code{0} (that is, use in-memory temporary tables).
-
-@item SQL_BIG_SELECTS = 0 | 1
-If set to @code{0}, @strong{MySQL} will abort if a @code{SELECT} is attempted
-that probably will take a very long time. This is useful when an inadvisable
-@code{WHERE} statement has been issued. A big query is defined as a
-@code{SELECT} that probably will have to examine more than
-@code{max_join_size} rows. The default value for a new connection is
-@code{1} (which will allow all @code{SELECT} statements).
-
-@item SQL_BUFFER_RESULT = 0 | 1
-@code{SQL_BUFFER_RESULT} will force the result from @code{SELECT}'s
-to be put into a temporary table. This will help @strong{MySQL} free the
-table locks early and will help in cases where it takes a long time to
-send the result set to the client.
-
-@item SQL_LOW_PRIORITY_UPDATES = 0 | 1
-If set to @code{1}, all @code{INSERT}, @code{UPDATE}, @code{DELETE}, and
-and @code{LOCK TABLE WRITE} statements wait until there is no pending
-@code{SELECT} or @code{LOCK TABLE READ} on the affected table.
-
-@item SQL_MAX_JOIN_SIZE = value | DEFAULT
-Don't allow @code{SELECT}s that will probably need to examine more than
-@code{value} row combinations. By setting this value, you can catch
-@code{SELECT}s where keys are not used properly and that would probably
-take a long time. Setting this to a value other than @code{DEFAULT} will reset
-the @code{SQL_BIG_SELECTS} flag. If you set the @code{SQL_BIG_SELECTS}
-flag again, the @code{SQL_MAX_JOIN_SIZE} variable will be ignored.
-You can set a default value for this variable by starting @code{mysqld} with
-@code{-O max_join_size=#}.
-
-@item SQL_SAFE_MODE = 0 | 1
-If set to @code{1}, @strong{MySQL} will abort if an @code{UPDATE} or
-@code{DELETE} is attempted that doesn't use a key or @code{LIMIT} in the
-@code{WHERE} clause. This makes it possible to catch wrong updates
-when creating SQL commands by hand.
-
-@item SQL_SELECT_LIMIT = value | DEFAULT
-The maximum number of records to return from @code{SELECT} statements. If
-a @code{SELECT} has a @code{LIMIT} clause, the @code{LIMIT} takes precedence
-over the value of @code{SQL_SELECT_LIMIT}. The default value for a new
-connection is ``unlimited.'' If you have changed the limit, the default value
-can be restored by using a @code{SQL_SELECT_LIMIT} value of @code{DEFAULT}.
-
-@item SQL_LOG_OFF = 0 | 1
-If set to @code{1}, no logging will be done to the standard log for this
-client, if the client has the @strong{process} privilege. This does not
-affect the update log!
-
-@item SQL_LOG_UPDATE = 0 | 1
-If set to @code{0}, no logging will be done to the update log for the client,
-if the client has the @strong{process} privilege. This does not affect the
-standard log!
-
-@item SQL_QUOTE_SHOW_CREATE = 0 | 1
-If set to @code{1}, @code{SHOW CREATE TABLE} will quote
-table and column names. This is @strong{on} by default,
-for replication of tables with fancy column names to work.
-@ref{SHOW CREATE TABLE, , @code{SHOW CREATE TABLE}}.
-
-@item TIMESTAMP = timestamp_value | DEFAULT
-Set the time for this client. This is used to get the original timestamp if
-you use the update log to restore rows. @code{timestamp_value} should be a
-UNIX Epoch timestamp, not a @strong{MySQL} timestamp.
-@item LAST_INSERT_ID = #
-Set the value to be returned from @code{LAST_INSERT_ID()}. This is stored in
-the update log when you use @code{LAST_INSERT_ID()} in a command that updates
-a table.
-
-@item INSERT_ID = #
-Set the value to be used by the following @code{INSERT} or @code{ALTER TABLE}
-command when inserting an @code{AUTO_INCREMENT} value. This is mainly used
-with the update log.
-@end table
+@node SET TRANSACTION, , LOCK TABLES, Transactional Commands
+@subsection @code{SET TRANSACTION} Syntax
@findex ISOLATION LEVEL
-@node SET TRANSACTION, GRANT, SET OPTION, Reference
-@section @code{SET TRANSACTION} Syntax
@example
SET [GLOBAL | SESSION] TRANSACTION ISOLATION LEVEL
@@ -23310,553 +34724,271 @@ future transactions.
You can set the default isolation level for @code{mysqld} with
@code{--transaction-isolation=...}. @xref{Command-line options}.
-@cindex privileges, granting
-@cindex privileges, revoking
-@cindex global privileges
-@cindex revoking, privleges
-@cindex granting, privleges
-
-@findex GRANT
-@findex REVOKE
-@node GRANT, HANDLER, SET TRANSACTION, Reference
-@section @code{GRANT} and @code{REVOKE} Syntax
-
-@example
-GRANT priv_type [(column_list)] [, priv_type [(column_list)] ...]
- ON @{tbl_name | * | *.* | db_name.*@}
- TO user_name [IDENTIFIED BY 'password']
- [, user_name [IDENTIFIED BY 'password'] ...]
- [REQUIRE @{SSL|X509@} [ISSUER issuer] [SUBJECT subject]]
- [WITH GRANT OPTION]
-
-REVOKE priv_type [(column_list)] [, priv_type [(column_list)] ...]
- ON @{tbl_name | * | *.* | db_name.*@}
- FROM user_name [, user_name ...]
-@end example
-@code{GRANT} is implemented in @strong{MySQL} Version 3.22.11 or later. For
-earlier @strong{MySQL} versions, the @code{GRANT} statement does nothing.
+@node Fulltext Search, , Transactional Commands, Reference
+@section MySQL Full-text Search
-The @code{GRANT} and @code{REVOKE} commands allow system administrators
-to create users and grant and revoke rights to @strong{MySQL} users at
-four privilege levels:
-
-@table @strong
-@item Global level
-Global privileges apply to all databases on a given server. These privileges
-are stored in the @code{mysql.user} table.
-
-@item Database level
-Database privileges apply to all tables in a given database. These privileges
-are stored in the @code{mysql.db} and @code{mysql.host} tables.
-
-@item Table level
-Table privileges apply to all columns in a given table. These privileges are
-stored in the @code{mysql.tables_priv} table.
-
-@item Column level
-Column privileges apply to single columns in a given table. These privileges are
-stored in the @code{mysql.columns_priv} table.
-@end table
+@cindex searching, full-text
+@cindex full-text search
+@cindex FULLTEXT
-If you give a grant for a users that doesn't exists, that user is created.
-For examples of how @code{GRANT} works, see @ref{Adding users}.
+Since Version 3.23.23, MySQL has support for full-text indexing
+and searching. Full-text indexes in MySQL are an index of type
+@code{FULLTEXT}. @code{FULLTEXT} indexes can be created from @code{VARCHAR}
+and @code{TEXT} columns at @code{CREATE TABLE} time or added later with
+@code{ALTER TABLE} or @code{CREATE INDEX}. For large datasets, adding
+@code{FULLTEXT} index with @code{ALTER TABLE} (or @code{CREATE INDEX}) would
+be much faster than inserting rows into the empty table with a @code{FULLTEXT}
+index.
-For the @code{GRANT} and @code{REVOKE} statements, @code{priv_type} may be
-specified as any of the following:
+Full-text search is performed with the @code{MATCH} function.
@example
-ALL PRIVILEGES FILE RELOAD
-ALTER INDEX SELECT
-CREATE INSERT SHUTDOWN
-DELETE PROCESS UPDATE
-DROP REFERENCES USAGE
-@end example
-
-@code{ALL} is a synonym for @code{ALL PRIVILEGES}. @code{REFERENCES} is not
-yet implemented. @code{USAGE} is currently a synonym for ``no privileges.''
-It can be used when you want to create a user that has no privileges.
+mysql> CREATE TABLE articles (
+ -> id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
+ -> title VARCHAR(200),
+ -> body TEXT,
+ -> FULLTEXT (title,body)
+ -> );
+Query OK, 0 rows affected (0.00 sec)
-To revoke the @strong{grant} privilege from a user, use a @code{priv_type}
-value of @code{GRANT OPTION}:
+mysql> INSERT INTO articles VALUES
+ -> (0,'MySQL Tutorial', 'DBMS stands for DataBase Management ...'),
+ -> (0,'How To Use MySQL Efficiently', 'After you went through a ...'),
+ -> (0,'Optimizing MySQL','In this tutorial we will show how to ...'),
+ -> (0,'1001 MySQL Trick','1. Never run mysqld as root. 2. Normalize ...'),
+ -> (0,'MySQL vs. YourSQL', 'In the following database comparison we ...'),
+ -> (0,'MySQL Security', 'When configured properly, MySQL could be ...');
+Query OK, 5 rows affected (0.00 sec)
+Records: 5 Duplicates: 0 Warnings: 0
-@example
-REVOKE GRANT OPTION ON ... FROM ...;
+mysql> SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('database');
++----+-------------------+---------------------------------------------+
+| id | title | body |
++----+-------------------+---------------------------------------------+
+| 5 | MySQL vs. YourSQL | In the following database comparison we ... |
+| 1 | MySQL Tutorial | DBMS stands for DataBase Management ... |
++----+-------------------+---------------------------------------------+
+2 rows in set (0.00 sec)
@end example
-The only @code{priv_type} values you can specify for a table are @code{SELECT},
-@code{INSERT}, @code{UPDATE}, @code{DELETE}, @code{CREATE}, @code{DROP},
-@code{GRANT}, @code{INDEX}, and @code{ALTER}.
-
-The only @code{priv_type} values you can specify for a column (that is, when
-you use a @code{column_list} clause) are @code{SELECT}, @code{INSERT}, and
-@code{UPDATE}.
-
-You can set global privileges by using @code{ON *.*} syntax. You can set
-database privileges by using @code{ON db_name.*} syntax. If you specify
-@code{ON *} and you have a current database, you will set the privileges for
-that database. (@strong{WARNING:} If you specify @code{ON *} and you
-@emph{don't} have a current database, you will affect the global privileges!)
-
-In order to accommodate granting rights to users from arbitrary hosts,
-@strong{MySQL} supports specifying the @code{user_name} value in the form
-@code{user@@host}. If you want to specify a @code{user} string
-containing special characters (such as @samp{-}), or a @code{host} string
-containing special characters or wild-card characters (such as @samp{%}), you
-can quote the user or host name (for example, @code{'test-user'@@'test-hostname'}).
-
-You can specify wild cards in the hostname. For example,
-@code{user@@"%.loc.gov"} applies to @code{user} for any host in the
-@code{loc.gov} domain, and @code{user@@"144.155.166.%"} applies to @code{user}
-for any host in the @code{144.155.166} class C subnet.
+The function @code{MATCH} matches a natural language query @code{AGAINST}
+a text collection (which is simply the set of columns covered by a
+@code{FULLTEXT} index). For every row in a table it returns relevance -
+a similarity measure between the text in that row (in the columns that are
+part of the collection) and the query. When it is used in a @code{WHERE}
+clause (see example above) the rows returned are automatically sorted with
+relevance decreasing. Relevance is a non-negative floating-point number.
+Zero relevance means no similarity. Relevance is computed based on the
+number of words in the row, the number of unique words in that row, the
+total number of words in the collection, and the number of documents (rows)
+that contain a particular word.
-The simple form @code{user} is a synonym for @code{user@@"%"}.
-@strong{NOTE:} If you allow anonymous users to connect to the @strong{MySQL}
-server (which is the default), you should also add all local users as
-@code{user@@localhost} because otherwise the anonymous user entry for the
-local host in the @code{mysql.user} table will be used when the user tries to
-log into the @strong{MySQL} server from the local machine! Anonymous users
-are defined by inserting entries with @code{User=''} into the
-@code{mysql.user} table. You can verify if this applies to you by executing
-this query:
+The above is a basic example of using @code{MATCH} function. Rows are
+returned with relevance decreasing.
@example
-mysql> SELECT Host,User FROM mysql.user WHERE User='';
+mysql> SELECT id,MATCH (title,body) AGAINST ('Tutorial') FROM articles;
++----+-----------------------------------------+
+| id | MATCH (title,body) AGAINST ('Tutorial') |
++----+-----------------------------------------+
+| 1 | 0.64840710366884 |
+| 2 | 0 |
+| 3 | 0.66266459031789 |
+| 4 | 0 |
+| 5 | 0 |
+| 6 | 0 |
++----+-----------------------------------------+
+5 rows in set (0.00 sec)
@end example
-For the moment, @code{GRANT} only supports host, table, database, and
-column names up to 60 characters long. A user name can be up to 16
-characters.
-
-The privileges for a table or column are formed from the
-logical OR of the privileges at each of the four privilege
-levels. For example, if the @code{mysql.user} table specifies that a
-user has a global @strong{select} privilege, this can't be denied by an
-entry at the database, table, or column level.
-
-The privileges for a column can be calculated as follows:
+This example shows how to retrieve the relevances. As neither @code{WHERE}
+nor @code{ORDER BY} clauses are present, returned rows are not ordered.
@example
-global privileges
-OR (database privileges AND host privileges)
-OR table privileges
-OR column privileges
+mysql> SELECT id, body, MATCH (title,body) AGAINST (
+ -> 'Security implications of running MySQL as root') AS score
+ -> FROM articles WHERE MATCH (title,body) AGAINST
+ -> ('Security implications of running MySQL as root');
++----+-----------------------------------------------+-----------------+
+| id | body | score |
++----+-----------------------------------------------+-----------------+
+| 4 | 1. Never run mysqld as root. 2. Normalize ... | 1.5055546709332 |
+| 6 | When configured properly, MySQL could be ... | 1.31140957288 |
++----+-----------------------------------------------+-----------------+
+2 rows in set (0.00 sec)
@end example
-In most cases, you grant rights to a user at only one of the privilege
-levels, so life isn't normally as complicated as above. The details of the
-privilege-checking procedure are presented in
-@ref{Privilege system}.
-
-If you grant privileges for a user/hostname combination that does not exist
-in the @code{mysql.user} table, an entry is added and remains there until
-deleted with a @code{DELETE} command. In other words, @code{GRANT} may
-create @code{user} table entries, but @code{REVOKE} will not remove them;
-you must do that explicitly using @code{DELETE}.
-
-@cindex passwords, setting
-In @strong{MySQL} Version 3.22.12 or later,
-if a new user is created or if you have global grant privileges, the user's
-password will be set to the password specified by the @code{IDENTIFIED BY}
-clause, if one is given. If the user already had a password, it is replaced
-by the new one.
-
-@strong{WARNING:} If you create a new user but do not specify an
-@code{IDENTIFIED BY} clause, the user has no password. This is insecure.
-
-Passwords can also be set with the @code{SET PASSWORD} command.
-@xref{SET OPTION, , @code{SET OPTION}}.
+This is more complex example - the query returns the relevance and still
+sorts the rows with relevance decreasing. To achieve it one should specify
+@code{MATCH} twice. Note, that this will cause no additional overhead, as
+MySQL optimizer will notice that these two @code{MATCH} calls are
+identical and will call full-text search code only once.
-If you grant privileges for a database, an entry in the @code{mysql.db}
-table is created if needed. When all privileges for the database have been
-removed with @code{REVOKE}, this entry is deleted.
+MySQL uses a very simple parser to split text into words. A
+``word'' is any sequence of letters, numbers, @samp{'}, and @samp{_}. Any
+``word'' that is present in the stopword list or just too short (3
+characters or less) is ignored.
-If a user doesn't have any privileges on a table, the table is not displayed
-when the user requests a list of tables (for example, with a @code{SHOW TABLES}
-statement).
+Every correct word in the collection and in the query is weighted,
+according to its significance in the query or collection. This way, a
+word that is present in many documents will have lower weight (and may
+even have a zero weight), because it has lower semantic value in this
+particular collection. Otherwise, if the word is rare, it will receive a
+higher weight. The weights of the words are then combined to compute the
+relevance of the row.
-The @code{WITH GRANT OPTION} clause gives the user the ability to give
-to other users any privileges the user has at the specified privilege level.
-You should be careful to whom you give the @strong{grant} privilege, as two
-users with different privileges may be able to join privileges!
+Such a technique works best with large collections (in fact, it was
+carefully tuned this way). For very small tables, word distribution
+does not reflect adequately their semantical value, and this model
+may sometimes produce bizarre results.
-You cannot grant another user a privilege you don't have yourself;
-the @strong{grant} privilege allows you to give away only those privileges
-you possess.
+@example
+mysql> SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('MySQL');
+Empty set (0.00 sec)
+@end example
-Be aware that when you grant a user the @strong{grant} privilege at a
-particular privilege level, any privileges the user already possesses (or
-is given in the future!) at that level are also grantable by that user.
-Suppose you grant a user the @strong{insert} privilege on a database. If
-you then grant the @strong{select} privilege on the database and specify
-@code{WITH GRANT OPTION}, the user can give away not only the @strong{select}
-privilege, but also @strong{insert}. If you then grant the @strong{update}
-privilege to the user on the database, the user can give away the
-@strong{insert}, @strong{select} and @strong{update}.
+Search for the word @code{MySQL} produces no results in the above example.
+Word @code{MySQL} is present in more than half of rows, and as such, is
+effectively treated as a stopword (that is, with semantical value zero).
+It is, really, the desired behavior - a natural language query should not
+return every second row in 1GB table.
-You should not grant @strong{alter} privileges to a normal user. If you
-do that, the user can try to subvert the privilege system by renaming
-tables!
+A word that matches half of rows in a table is less likely to locate relevant
+documents. In fact, it will most likely find plenty of irrelevant documents.
+We all know this happens far too often when we are trying to find something on
+the Internet with a search engine. It is with this reasoning that such rows
+have been assigned a low semantical value in @strong{this particular dataset}.
-Note that if you are using table or column privileges for even one user, the
-server examines table and column privileges for all users and this will slow
-down @strong{MySQL} a bit.
+@menu
+* Fulltext restrictions:: Fulltext restrictions
+* Fulltext Fine-tuning:: Fine-tuning MySQL Full-text Search
+* Fulltext Features to Appear in MySQL 4.0:: New Features of Full-text Search to Appear in MySQL 4.0
+* Fulltext TODO:: Full-text Search TODO
+@end menu
-When @code{mysqld} starts, all privileges are read into memory.
-Database, table, and column privileges take effect at once, and
-user-level privileges take effect the next time the user connects.
-Modifications to the grant tables that you perform using @code{GRANT} or
-@code{REVOKE} are noticed by the server immediately.
-If you modify the grant tables manually (using @code{INSERT}, @code{UPDATE},
-etc.), you should execute a @code{FLUSH PRIVILEGES} statement or run
-@code{mysqladmin flush-privileges} to tell the server to reload the grant
-tables.
-@xref{Privilege changes}.
-@cindex ANSI SQL, differences from
-The biggest differences between the ANSI SQL and @strong{MySQL} versions of
-@code{GRANT} are:
+@node Fulltext restrictions, Fulltext Fine-tuning, Fulltext Search, Fulltext Search
+@subsection Fulltext restrictions
@itemize @bullet
@item
-In @strong{MySQL} privileges are given for an username + hostname combination
-and not only for an username.
-
-@item
-ANSI SQL doesn't have global or database-level privileges, and ANSI SQL
-doesn't support all privilege types that @strong{MySQL} supports.
-@strong{MySQL} doesn't support the ANSI SQL @code{TRIGGER}, @code{EXECUTE} or
-@code{UNDER} privileges.
-
-@item
-ANSI SQL privileges are structured in a hierarchal manner. If you remove
-an user, all privileges the user has granted are revoked. In
-@strong{MySQL} the granted privileges are not automatically revoked, but
-you have to revoke these yourself if needed.
-
-@item
-If you in @strong{MySQL} have the @code{INSERT} grant on only part of the
-columns in a table, you can execute @code{INSERT} statements on the
-table; The columns for which you don't have the @code{INSERT} privilege
-will set to their default values. ANSI SQL requires you to have the
-@code{INSERT} privilege on all columns.
-
+All parameters to the @code{MATCH} function must be columns from the
+same table that is part of the same fulltext index.
@item
-When you drop a table in ANSI SQL, all privileges for the table are revoked.
-If you revoke a privilege in ANSI SQL, all privileges that were granted based
-on this privilege are also revoked. In @strong{MySQL}, privileges can be
-dropped only with explicit @code{REVOKE} commands or by manipulating the
-@strong{MySQL} grant tables.
+The argument to @code{AGAINST} must be a constant string.
@end itemize
-@findex HANDLER
-@node HANDLER, CREATE INDEX, GRANT, Reference
-@section @code{HANDLER} Syntax
-
-@example
-HANDLER table OPEN [ AS alias ]
-HANDLER table READ index @{ = | >= | <= | < @} (value1, value2, ... ) [ WHERE ... ] [LIMIT ... ]
-HANDLER table READ index @{ FIRST | NEXT | PREV | LAST @} [ WHERE ... ] [LIMIT ... ]
-HANDLER table READ @{ FIRST | NEXT @} [ WHERE ... ] [LIMIT ... ]
-HANDLER table CLOSE
-@end example
-
-The @code{HANDLER} statement provides direct access to @strong{MySQL} table
-interface, bypassing SQL optimizer. Thus, it is faster then SELECT.
-
-The first form of @code{HANDLER} statement opens a table, making
-in accessible via the following @code{HANDLER ... READ} routines.
-The second form fetches one (or, specified by @code{LIMIT} clause) row
-where the index specified complies to the condition and @code{WHERE}
-condition is met. If the index consists of several parts (spans over
-several columns) the values are specified in comma-separated list,
-providing values only for few first columns is possible.
+@node Fulltext Fine-tuning, Fulltext Features to Appear in MySQL 4.0, Fulltext restrictions, Fulltext Search
+@subsection Fine-tuning MySQL Full-text Search
-The third form fetches one (or, specified by @code{LIMIT} clause) row
-from the table in index order, matching @code{WHERE} condition.
-
-The fourth form (without index specification) fetches one (or, specified
-by @code{LIMIT} clause) row from the table in natural row order (as stored
-in data file) matching @code{WHERE} condition. It is faster than
-@code{HANDLER table READ index} when full table scan is desired.
-
-The last form closes the table, opened with @code{HANDLER ... OPEN}.
+Unfortunately, full-text search has no user-tunable parameters yet,
+although adding some is very high on the TODO. However, if you have a
+MySQL source distribution (@xref{Installing source}.), you can
+somewhat alter the full-text search behavior.
-@code{HANDLER} is somewhat low-level statement, for example it does not
-provide consistency. That is @code{HANDLER ... OPEN} does @strong{not}
-takes a snapshot of the table, and does @strong{not} locks the table. The
-above means, that after @code{HANDLER ... OPEN} table data can be
-modified (by this or other thread) and these modifications may appear only
-partially in @code{HANDLER ... NEXT} or @code{HANDLER ... PREV} scans.
+Note that full-text search was carefully tuned for the best searching
+effectiveness. Modifying the default behavior will, in most cases,
+only make the search results worse. Do not alter the MySQL sources
+unless you know what you are doing!
-@cindex indexes
-@cindex indexes, multi-part
-@cindex multi-part index
-@findex CREATE INDEX
-@node CREATE INDEX, DROP INDEX, HANDLER, Reference
-@section @code{CREATE INDEX} Syntax
+@itemize @bullet
+@item
+Minimal length of word to be indexed is defined in
+@code{myisam/ftdefs.h} file by the line
@example
-CREATE [UNIQUE|FULLTEXT] INDEX index_name ON tbl_name (col_name[(length)],... )
+#define MIN_WORD_LEN 4
@end example
+Change it to the value you prefer, recompile MySQL, and rebuild
+your @code{FULLTEXT} indexes.
-The @code{CREATE INDEX} statement doesn't do anything in @strong{MySQL} prior
-to Version 3.22. In Version 3.22 or later, @code{CREATE INDEX} is mapped to an
-@code{ALTER TABLE} statement to create indexes.
-@xref{ALTER TABLE, , @code{ALTER TABLE}}.
-
-Normally, you create all indexes on a table at the time the table itself
-is created with @code{CREATE TABLE}.
-@xref{CREATE TABLE, , @code{CREATE TABLE}}.
-@code{CREATE INDEX} allows you to add indexes to existing tables.
-
-A column list of the form @code{(col1,col2,...)} creates a multiple-column
-index. Index values are formed by concatenating the values of the given
-columns.
-
-For @code{CHAR} and @code{VARCHAR} columns, indexes can be created that
-use only part of a column, using @code{col_name(length)} syntax. (On
-@code{BLOB} and @code{TEXT} columns the length is required). The
-statement shown below creates an index using the first 10 characters of
-the @code{name} column:
+@item
+The stopword list is defined in @code{myisam/ft_static.c}
+Modify it to your taste, recompile MySQL and rebuild
+your @code{FULLTEXT} indexes.
+@item
+The 50% threshold is caused by the particular weighting scheme chosen. To
+disable it, change the following line in @code{myisam/ftdefs.h}:
@example
-mysql> CREATE INDEX part_of_name ON customer (name(10));
+#define GWS_IN_USE GWS_PROB
@end example
-
-Because most names usually differ in the first 10 characters, this index should
-not be much slower than an index created from the entire @code{name} column.
-Also, using partial columns for indexes can make the index file much smaller,
-which could save a lot of disk space and might also speed up @code{INSERT}
-operations!
-
-Note that you can only add an index on a column that can have @code{NULL}
-values or on a @code{BLOB}/@code{TEXT} column if you are using
-@strong{MySQL} Version 3.23.2 or newer and are using the @code{MyISAM}
-table type.
-
-For more information about how @strong{MySQL} uses indexes, see
-@ref{MySQL indexes, , @strong{MySQL} indexes}.
-
-@code{FULLTEXT} indexes can index only @code{VARCHAR} and
-@code{TEXT} columns, and only in @code{MyISAM} tables. @code{FULLTEXT} indexes
-are available in @strong{MySQL} Version 3.23.23 and later.
-@ref{Fulltext Search}.
-
-@findex DROP INDEX
-@node DROP INDEX, Comments, CREATE INDEX, Reference
-@section @code{DROP INDEX} Syntax
-
+to
@example
-DROP INDEX index_name ON tbl_name
+#define GWS_IN_USE GWS_FREQ
@end example
+and recompile MySQL.
+There is no need to rebuild the indexes in this case.
-@code{DROP INDEX} drops the index named @code{index_name} from the table
-@code{tbl_name}. @code{DROP INDEX} doesn't do anything in @strong{MySQL}
-prior to Version 3.22. In Version 3.22 or later, @code{DROP INDEX} is mapped to an
-@code{ALTER TABLE} statement to drop the index.
-@xref{ALTER TABLE, , @code{ALTER TABLE}}.
+@end itemize
-@findex Comment syntax
-@cindex comments, adding
-@node Comments, CREATE FUNCTION, DROP INDEX, Reference
-@section Comment Syntax
-The @strong{MySQL} server supports the @code{# to end of line}, @code{--
-to end of line} and @code{/* in-line or multiple-line */} comment
-styles:
+@node Fulltext Features to Appear in MySQL 4.0, Fulltext TODO, Fulltext Fine-tuning, Fulltext Search
+@subsection New Features of Full-text Search to Appear in MySQL 4.0
-@example
-mysql> select 1+1; # This comment continues to the end of line
-mysql> select 1+1; -- This comment continues to the end of line
-mysql> select 1 /* this is an in-line comment */ + 1;
-mysql> select 1+
-/*
-this is a
-multiple-line comment
-*/
-1;
-@end example
+This section includes a list of the fulltext features that are already
+implemented in the 4.0 tree. It explains
+@strong{More functions for full-text search} entry of @ref{TODO MySQL 4.0}.
-Note that the @code{--} comment style requires you to have at least one space
-after the @code{--}!
+@itemize @bullet
+@item @code{REPAIR TABLE} with @code{FULLTEXT} indexes,
+@code{ALTER TABLE} with @code{FULLTEXT} indexes, and
+@code{OPTIMIZE TABLE} with @code{FULLTEXT} indexes are now
+up to 100 times faster.
-Although the server understands the comment syntax just described,
-there are some limitations on the way that the @code{mysql} client
-parses @code{/* ... */} comments:
+@item @code{MATCH ... AGAINST} is going to supports the following
+@strong{boolean operators}:
@itemize @bullet
-@item
-Single-quote and double-quote characters are taken to indicate the beginning
-of a quoted string, even within a comment. If the quote is not matched by a
-second quote within the comment, the parser doesn't realize the comment has
-ended. If you are running @code{mysql} interactively, you can tell that it
-has gotten confused like this because the prompt changes from @code{mysql>}
-to @code{'>} or @code{">}.
-
-@item
-A semicolon is taken to indicate the end of the current SQL statement
-and anything following it to indicate the beginning of the next statement.
+@item @code{+}word means the that word @strong{must} be present in every
+row returned.
+@item @code{-}word means the that word @strong{must not} be present in every
+row returned.
+@item @code{<} and @code{>} can be used to decrease and increase word
+weight in the query.
+@item @code{~} can be used to assign a @strong{negative} weight to a noise
+word.
+@item @code{*} is a truncation operator.
@end itemize
-These limitations apply both when you run @code{mysql} interactively
-and when you put commands in a file and tell @code{mysql} to read its
-input from that file with @code{mysql < some-file}.
-
-@strong{MySQL} doesn't support the @samp{--} ANSI SQL comment style.
-@xref{Missing comments}.
-
-@findex CREATE FUNCTION
-@findex DROP FUNCTION
-@findex UDF functions
-@findex User-defined functions
-@findex Functions, user-defined
-@node CREATE FUNCTION, Reserved words, Comments, Reference
-@section @code{CREATE FUNCTION/DROP FUNCTION} Syntax
-
-@example
-CREATE [AGGREGATE] FUNCTION function_name RETURNS @{STRING|REAL|INTEGER@}
- SONAME shared_library_name
+Boolean search utilizes a more simplistic way of calculating the relevance,
+that does not have a 50% threshold.
-DROP FUNCTION function_name
-@end example
+@item Searches are now up to 2 times faster due to optimized search algorithm.
-A user-definable function (UDF) is a way to extend @strong{MySQL} with a new
-function that works like native (built in) @strong{MySQL} functions such as
-@code{ABS()} and @code{CONCAT()}.
+@item Utility program @code{ft_dump} added for low-level @code{FULLTEXT}
+index operations (querying/dumping/statistics).
-@code{AGGREGATE} is a new option for @strong{MySQL} Version 3.23. An
-@code{AGGREGATE} function works exactly like a native @strong{MySQL}
-@code{GROUP} function like @code{SUM} or @code{COUNT()}.
+@end itemize
-@code{CREATE FUNCTION} saves the function's name, type, and shared library
-name in the @code{mysql.func} system table. You must have the
-@strong{insert} and @strong{delete} privileges for the @code{mysql} database
-to create and drop functions.
-All active functions are reloaded each time the server starts, unless
-you start @code{mysqld} with the @code{--skip-grant-tables} option. In
-this case, UDF initialization is skipped and UDFs are unavailable.
-(An active function is one that has been loaded with @code{CREATE FUNCTION}
-and not removed with @code{DROP FUNCTION}.)
+@node Fulltext TODO, , Fulltext Features to Appear in MySQL 4.0, Fulltext Search
+@subsection Full-text Search TODO
-For instructions on writing user-definable functions, see @ref{Adding
-functions}. For the UDF mechanism to work, functions must be written in C or
-C++, your operating system must support dynamic loading and you must have
-compiled @code{mysqld} dynamically (not statically).
+@itemize @bullet
+@item Make all operations with @code{FULLTEXT} index @strong{faster}.
+@item Support for braces @code{()} in boolean full-text search.
+@item Phrase search, proximity operators
+@item Boolean search can work without @code{FULLTEXT} index
+(yes, @strong{very} slow).
+@item Support for "always-index words". They could be any strings
+the user wants to treat as words, examples are "C++", "AS/400", "TCP/IP", etc.
+@item Support for full-text search in @code{MERGE} tables.
+@item Support for multi-byte charsets.
+@item Make stopword list to depend of the language of the data.
+@item Stemming (dependent of the language of the data, of course).
+@item Generic user-supplyable UDF (?) preparser.
+@item Make the model more flexible (by adding some adjustable
+parameters to @code{FULLTEXT} in @code{CREATE/ALTER TABLE}).
+@end itemize
-@cindex keywords
-@cindex reserved words, exceptions
-@node Reserved words, , CREATE FUNCTION, Reference
-@section Is MySQL Picky About Reserved Words?
-A common problem stems from trying to create a table with column names that
-use the names of datatypes or functions built into @strong{MySQL}, such as
-@code{TIMESTAMP} or @code{GROUP}. You're allowed to do it (for example,
-@code{ABS} is an allowed column name), but whitespace is not allowed between
-a function name and the @samp{(} when using functions whose names are also
-column names.
-The following words are explicitly reserved in @strong{MySQL}. Most of
-them are forbidden by ANSI SQL92 as column and/or table names
-(for example, @code{group}).
-A few are reserved because @strong{MySQL} needs them and is
-(currently) using a @code{yacc} parser:
-@c This is fixed by including the symbols table from lex.h here and then running
-@c fix-mysql-reserved-words in emacs (or let David do it):
-@c (defun fix-mysql-reserved-words ()
-@c (interactive)
-@c (let ((cnt 0))
-@c (insert "\n@item ")
-@c (while (looking-at "[ \t]*{ +\"\\([^\"]+\\)\"[ \t]*,.*\n")
-@c (replace-match "@code{\\1}")
-@c (incf cnt)
-@c (if (> cnt 3)
-@c (progn
-@c (setf cnt 0)
-@c (insert "\n@item "))
-@c (insert " @tab ")))))
-@c But remove the non alphanumeric entries by hand first.
-@c Updated after 3.23.4 990928 by David
-
-@multitable @columnfractions .25 .25 .25 .25
-@item @code{action} @tab @code{add} @tab @code{aggregate} @tab @code{all}
-@item @code{alter} @tab @code{after} @tab @code{and} @tab @code{as}
-@item @code{asc} @tab @code{avg} @tab @code{avg_row_length} @tab @code{auto_increment}
-@item @code{between} @tab @code{bigint} @tab @code{bit} @tab @code{binary}
-@item @code{blob} @tab @code{bool} @tab @code{both} @tab @code{by}
-@item @code{cascade} @tab @code{case} @tab @code{char} @tab @code{character}
-@item @code{change} @tab @code{check} @tab @code{checksum} @tab @code{column}
-@item @code{columns} @tab @code{comment} @tab @code{constraint} @tab @code{create}
-@item @code{cross} @tab @code{current_date} @tab @code{current_time} @tab @code{current_timestamp}
-@item @code{data} @tab @code{database} @tab @code{databases} @tab @code{date}
-@item @code{datetime} @tab @code{day} @tab @code{day_hour} @tab @code{day_minute}
-@item @code{day_second} @tab @code{dayofmonth} @tab @code{dayofweek} @tab @code{dayofyear}
-@item @code{dec} @tab @code{decimal} @tab @code{default} @tab @code{delayed}
-@item @code{delay_key_write} @tab @code{delete} @tab @code{desc} @tab @code{describe}
-@item @code{distinct} @tab @code{distinctrow} @tab @code{double} @tab @code{drop}
-@item @code{end} @tab @code{else} @tab @code{escape} @tab @code{escaped}
-@item @code{enclosed} @tab @code{enum} @tab @code{explain} @tab @code{exists}
-@item @code{fields} @tab @code{file} @tab @code{first} @tab @code{float}
-@item @code{float4} @tab @code{float8} @tab @code{flush} @tab @code{foreign}
-@item @code{from} @tab @code{for} @tab @code{full} @tab @code{function}
-@item @code{global} @tab @code{grant} @tab @code{grants} @tab @code{group}
-@item @code{having} @tab @code{heap} @tab @code{high_priority} @tab @code{hour}
-@item @code{hour_minute} @tab @code{hour_second} @tab @code{hosts} @tab @code{identified}
-@item @code{ignore} @tab @code{in} @tab @code{index} @tab @code{infile}
-@item @code{inner} @tab @code{insert} @tab @code{insert_id} @tab @code{int}
-@item @code{integer} @tab @code{interval} @tab @code{int1} @tab @code{int2}
-@item @code{int3} @tab @code{int4} @tab @code{int8} @tab @code{into}
-@item @code{if} @tab @code{is} @tab @code{isam} @tab @code{join}
-@item @code{key} @tab @code{keys} @tab @code{kill} @tab @code{last_insert_id}
-@item @code{leading} @tab @code{left} @tab @code{length} @tab @code{like}
-@item @code{lines} @tab @code{limit} @tab @code{load} @tab @code{local}
-@item @code{lock} @tab @code{logs} @tab @code{long} @tab @code{longblob}
-@item @code{longtext} @tab @code{low_priority} @tab @code{max} @tab @code{max_rows}
-@item @code{match} @tab @code{mediumblob} @tab @code{mediumtext} @tab @code{mediumint}
-@item @code{middleint} @tab @code{min_rows} @tab @code{minute} @tab @code{minute_second}
-@item @code{modify} @tab @code{month} @tab @code{monthname} @tab @code{myisam}
-@item @code{natural} @tab @code{numeric} @tab @code{no} @tab @code{not}
-@item @code{null} @tab @code{on} @tab @code{optimize} @tab @code{option}
-@item @code{optionally} @tab @code{or} @tab @code{order} @tab @code{outer}
-@item @code{outfile} @tab @code{pack_keys} @tab @code{partial} @tab @code{password}
-@item @code{precision} @tab @code{primary} @tab @code{procedure} @tab @code{process}
-@item @code{processlist} @tab @code{privileges} @tab @code{read} @tab @code{real}
-@item @code{references} @tab @code{reload} @tab @code{regexp} @tab @code{rename}
-@item @code{replace} @tab @code{restrict} @tab @code{returns} @tab @code{revoke}
-@item @code{rlike} @tab @code{row} @tab @code{rows} @tab @code{second}
-@item @code{select} @tab @code{set} @tab @code{show} @tab @code{shutdown}
-@item @code{smallint} @tab @code{soname} @tab @code{sql_big_tables} @tab @code{sql_big_selects}
-@item @code{sql_low_priority_updates} @tab @code{sql_log_off} @tab @code{sql_log_update} @tab @code{sql_select_limit}
-@item @code{sql_small_result} @tab @code{sql_big_result} @tab @code{sql_warnings} @tab @code{straight_join}
-@item @code{starting} @tab @code{status} @tab @code{string} @tab @code{table}
-@item @code{tables} @tab @code{temporary} @tab @code{terminated} @tab @code{text}
-@item @code{then} @tab @code{time} @tab @code{timestamp} @tab @code{tinyblob}
-@item @code{tinytext} @tab @code{tinyint} @tab @code{trailing} @tab @code{to}
-@item @code{type} @tab @code{use} @tab @code{using} @tab @code{unique}
-@item @code{unlock} @tab @code{unsigned} @tab @code{update} @tab @code{usage}
-@item @code{values} @tab @code{varchar} @tab @code{variables} @tab @code{varying}
-@item @code{varbinary} @tab @code{with} @tab @code{write} @tab @code{when}
-@item @code{where} @tab @code{year} @tab @code{year_month} @tab @code{zerofill}
-@end multitable
-
-The following symbols (from the table above) are disallowed by ANSI SQL
-but allowed by @strong{MySQL} as column/table names. This is because some
-of these names are very natural names and a lot of people have already
-used them.
-
-@itemize @bullet
-@item @code{ACTION}
-@item @code{BIT}
-@item @code{DATE}
-@item @code{ENUM}
-@item @code{NO}
-@item @code{TEXT}
-@item @code{TIME}
-@item @code{TIMESTAMP}
-@end itemize
+@node Table types, Clients, Reference, Top
+@chapter MySQL Table Types
@cindex table types, choosing
@cindex @code{BDB} table type
@@ -23868,38 +35000,36 @@ used them.
@cindex MySQL table types
@cindex @code{MyISAM} table type
@cindex types, of tables
-@node Table types, Tutorial, Reference, Top
-@chapter MySQL Table Types
-As of @strong{MySQL} Version 3.23.6, you can choose between three basic
+As of MySQL Version 3.23.6, you can choose between three basic
table formats (@code{ISAM}, @code{HEAP} and @code{MyISAM}. Newer
-@strong{MySQL} may support additional table type (@code{BDB}
+MySQL may support additional table type (@code{BDB},
or @code{InnoDB}), depending on how you compile it.
-When you create a new table, you can tell @strong{MySQL} which table
-type it should use for the table. @strong{MySQL} will always create a
+When you create a new table, you can tell MySQL which table
+type it should use for the table. MySQL will always create a
@code{.frm} file to hold the table and column definitions. Depending on
the table type, the index and data will be stored in other files.
Note that to use @code{InnoDB} tables you have to use at least
the @code{innodb_data_file_path} startup option. @xref{InnoDB start}.
-The default table type in @strong{MySQL} is @code{MyISAM}. If you are
+The default table type in MySQL is @code{MyISAM}. If you are
trying to use a table type that is not compiled-in or activated,
-@strong{MySQL} will instead create a table of type @code{MyISAM}. This
+MySQL will instead create a table of type @code{MyISAM}. This
is a very useful feature when you want to copy tables between different
SQL servers that supports different table types (like copying tables to
a slave that is optimized for speed by not having transactional tables).
This automatic table changing can however also be very confusing for new
-@strong{MySQL} users. We plan to fix this by introducing warnings in
-@strong{MySQL} 4.0 and giving a warning when a table type is automatically
+MySQL users. We plan to fix this by introducing warnings in
+MySQL 4.0 and giving a warning when a table type is automatically
changed.
You can convert tables between different types with the @code{ALTER
TABLE} statement. @xref{ALTER TABLE, , @code{ALTER TABLE}}.
-Note that @strong{MySQL} supports two different kinds of
-tables. Transaction-safe tables (@code{BDB} or @code{InnoDB})
+Note that MySQL supports two different kinds of
+tables. Transaction-safe tables (@code{BDB}, @code{InnoDB}
and not transaction-safe tables (@code{HEAP}, @code{ISAM},
@code{MERGE}, and @code{MyISAM}).
@@ -23907,7 +35037,7 @@ Advantages of transaction-safe tables (TST):
@itemize @bullet
@item
-Safer. Even if @strong{MySQL} crashes or you get hardware problems, you
+Safer. Even if MySQL crashes or you get hardware problems, you
can get your data back, either by automatic recovery or from a backup
+ the transaction log.
@item
@@ -23940,14 +35070,15 @@ of both worlds.
* MERGE:: MERGE tables
* ISAM:: ISAM tables
* HEAP:: HEAP tables
-* InnoDB:: InnoDB tables
* BDB:: BDB or Berkeley_db tables
+* InnoDB:: InnoDB tables
@end menu
+
@node MyISAM, MERGE, Table types, Table types
@section MyISAM Tables
-@code{MyISAM} is the default table type in @strong{MySQL} Version 3.23. It's
+@code{MyISAM} is the default table type in MySQL Version 3.23. It's
based on the @code{ISAM} code and has a lot of useful extensions.
The index is stored in a file with the @code{.MYI} (MYIndex) extension,
@@ -24034,7 +35165,7 @@ to get more speed (with the @code{DATA/INDEX DIRECTORY="path"} option to
@code{CREATE TABLE}). @xref{CREATE TABLE}.
@end itemize
-@code{MyISAM} also supports the following things, which @strong{MySQL}
+@code{MyISAM} also supports the following things, which MySQL
will be able to use in the near future:
@itemize @bullet
@@ -24046,7 +35177,7 @@ Tables with @code{VARCHAR} may have fixed or dynamic record length.
@item
@code{VARCHAR} and @code{CHAR} may be up to 64K.
All key segments have their own language definition. This will enable
-@strong{MySQL} to have different language definitions per column.
+MySQL to have different language definitions per column.
@item
A hashed computed index can be used for @code{UNIQUE}. This will allow
you to have @code{UNIQUE} on any combination of columns in a table. (You
@@ -24066,9 +35197,9 @@ The following options to @code{mysqld} can be used to change the behavior of
@item @code{--myisam-recover=#} @tab Automatic recover of crashed tables.
@item @code{-O myisam_sort_buffer_size=#} @tab Buffer used when recovering tables.
@item @code{--delay-key-write-for-all-tables} @tab Don't flush key buffers between writes for any MyISAM table
-@item @code{-O myisam_max_extra_sort_file_size=#} @tab Used to help @strong{MySQL} to decide when to use the slow but safe key cache index create method. @strong{NOTE} that this parameter is given in megabytes!
-@item @code{-O myisam_max_sort_file_size=#} @tab Don't use the fast sort index method to created index if the temporary file would get bigger than this. @strong{NOTE} that this paramter is given in megabytes!
-@item @code{-O myisam_bulk_insert_tree_size=#} @tab Size of tree cache used in bulk insert optimization. @strong{NOTE} that this is the total size used for all index in one table.
+@item @code{-O myisam_max_extra_sort_file_size=#} @tab Used to help MySQL to decide when to use the slow but safe key cache index create method. @strong{NOTE} that this parameter is given in megabytes!
+@item @code{-O myisam_max_sort_file_size=#} @tab Don't use the fast sort index method to created index if the temporary file would get bigger than this.
+@strong{NOTE} that this paramter is given in megabytes!
@end multitable
The automatic recovery is activated if you start @code{mysqld} with
@@ -24118,14 +35249,16 @@ backup media.
@menu
* Key space:: Space needed for keys
* MyISAM table formats:: MyISAM table formats
-* MyISAM table problems::
+* MyISAM table problems:: MyISAM table problems.
@end menu
-@cindex key space, MyISAM
+
@node Key space, MyISAM table formats, MyISAM, MyISAM
@subsection Space Needed for Keys
-@strong{MySQL} can support different index types, but the normal type is
+@cindex key space, MyISAM
+
+MySQL can support different index types, but the normal type is
ISAM or MyISAM. These use a B-tree index, and you can roughly calculate
the size for the index file as @code{(key_length+4)/0.67}, summed over
all keys. (This is for the worst case when all keys are inserted in
@@ -24144,6 +35277,7 @@ In @code{MyISAM} tables, you can also prefix compress numbers by specifying
many integer keys that have an identical prefix when the numbers are stored
high-byte first.
+
@node MyISAM table formats, MyISAM table problems, Key space, MyISAM
@subsection MyISAM Table Formats
@@ -24157,6 +35291,7 @@ compressed tables, can only be created with the @code{myisampack} tool.
* Compressed format:: Compressed table characteristics
@end menu
+
@node Static format, Dynamic format, MyISAM table formats, MyISAM table formats
@subsubsection Static (Fixed-length) Table Characteristics
@@ -24174,7 +35309,7 @@ records with each disk read.
The security is evidenced if your computer crashes when writing to a
fixed-size MyISAM file, in which case @code{myisamchk} can easily figure out where each
row starts and ends. So it can usually reclaim all records except the
-partially written one. Note that in @strong{MySQL} all indexes can always be
+partially written one. Note that in MySQL all indexes can always be
reconstructed:
@itemize @bullet
@@ -24196,11 +35331,13 @@ system.
Usually requires more disk space than dynamic tables.
@end itemize
-@cindex dynamic table characteristics
-@cindex tables, dynamic
+
@node Dynamic format, Compressed format, Static format, MyISAM table formats
@subsubsection Dynamic Table Characteristics
+@cindex dynamic table characteristics
+@cindex tables, dynamic
+
This format is used if the table contains any @code{VARCHAR}, @code{BLOB},
or @code{TEXT} columns or if the table was created with
@code{ROW_FORMAT=dynamic}.
@@ -24260,16 +35397,18 @@ If not, there will be another link. You may check how many links there are
with @code{myisamchk -ed}. All links may be removed with @code{myisamchk -r}.
@end itemize
-@cindex tables, compressed format
+
@node Compressed format, , Dynamic format, MyISAM table formats
@subsubsection Compressed Table Characteristics
+@cindex tables, compressed format
+
This is a read-only type that is generated with the optional
@code{myisampack} tool (@code{pack_isam} for @code{ISAM} tables):
@itemize @bullet
@item
-All @strong{MySQL} distributions, even those that existed before @strong{MySQL}
+All MySQL distributions, even those that existed before MySQL
went GPL, can read tables that were compressed with @code{myisampack}.
@item
Compressed tables take very little disk space. This minimizes disk usage, which
@@ -24306,18 +35445,20 @@ columns.
Can be uncompressed with @code{myisamchk}.
@end itemize
+
@node MyISAM table problems, , MyISAM table formats, MyISAM
@subsection MyISAM table problems.
-The file format that @strong{MySQL} uses to store data has been extensively
+The file format that MySQL uses to store data has been extensively
tested, but there are always circumstances that may cause database tables
to become corrupted.
@menu
-* Corrupted MyISAM tables::
-* MyISAM table close::
+* Corrupted MyISAM tables:: Corrupted MyISAM tables.
+* MyISAM table close:: Clients is using or hasn't closed the table properly
@end menu
+
@node Corrupted MyISAM tables, MyISAM table close, MyISAM table problems, MyISAM table problems
@subsubsection Corrupted MyISAM tables.
@@ -24365,6 +35506,7 @@ checking if there is a recent row @code{restarted mysqld} in the mysqld
error file). If this isn't the case, then you should try to make a test
case of this. @xref{Reproduceable test case}.
+
@node MyISAM table close, , Corrupted MyISAM tables, MyISAM table problems
@subsubsection Clients is using or hasn't closed the table properly
@@ -24385,7 +35527,7 @@ The counter works as follows:
@itemize @bullet
@item
-The first time a table is updated in @strong{MySQL}, a counter in the
+The first time a table is updated in MySQL, a counter in the
header of the index files is incremented.
@item
The counter is not changed during further updates.
@@ -24408,8 +35550,8 @@ In other words, the only ways this can go out of sync are:
The @code{MyISAM} tables are copied without a @code{LOCK} and
@code{FLUSH TABLES}.
@item
-@strong{MySQL} has crashed between an update and the final close
-(Note that the table may still be ok, as @strong{MySQL} always issues writes
+MySQL has crashed between an update and the final close
+(Note that the table may still be ok, as MySQL always issues writes
for everything between each statement).
@item
Someone has done a @code{myisamchk --repair} or @code{myisamchk
@@ -24423,12 +35565,14 @@ be avoided as it currently replaces the data file with a new one, which
is not signaled to the other servers.
@end itemize
-@cindex tables, merging
-@cindex MERGE tables, defined
+
@node MERGE, ISAM, MyISAM, Table types
@section MERGE Tables
-@code{MERGE} tables are new in @strong{MySQL} Version 3.23.25. The code
+@cindex tables, merging
+@cindex MERGE tables, defined
+
+@code{MERGE} tables are new in MySQL Version 3.23.25. The code
is still in gamma, but should be resonable stable.
A @code{MERGE} table is a collection of identical @code{MyISAM} tables
@@ -24443,14 +35587,15 @@ mapped tables. (We plan to fix this in 4.0).
With identical tables we mean that all tables are created with identical
column and key 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}.
+columns are packed differently, doesn't have exactly the same columns or
+have the keys in different order. 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
contains a list of the index files (@code{.MYI} files) that should
-be used as one.
+be used as one. All used tables must be in the same database as the
+@code{MERGE} table itself.
For the moment you need to have @code{SELECT}, @code{UPDATE}, and
@code{DELETE} privileges on the tables you map to a @code{MERGE} table.
@@ -24498,7 +35643,7 @@ The disadvantages with @code{MERGE} tables are:
@itemize @bullet
@item
-You can't use @code{INSERT} on @code{MERGE} tables, as @strong{MySQL}
+You can't use @code{INSERT} on @code{MERGE} tables, as MySQL
can't know in which of the tables we should insert the row.
@item
You can only use identical @code{MyISAM} tables for a @code{MERGE} table.
@@ -24539,7 +35684,7 @@ Note that we didn't create a @code{UNIQUE} or @code{PRIMARY KEY} in the
table.
Note that you can also manipulate the @code{.MRG} file directly from
-the outside of the @strong{MySQL} server:
+the outside of the MySQL server:
@example
shell> cd /mysql-data-directory/current-database
@@ -24576,10 +35721,11 @@ Change the @code{.MRG} file and issue a @code{FLUSH TABLE} on the
read the new definition file.
@end itemize
-@cindex tables, ISAM
@node ISAM, HEAP, MERGE, Table types
@section ISAM Tables
+@cindex tables, ISAM
+
You can also use the deprecated ISAM table type. This will disappear
rather soon because @code{MyISAM} is a better implementation of the same
thing. ISAM uses a @code{B-tree} index. The index is stored in a file
@@ -24618,15 +35764,17 @@ TABLE} statement:
mysql> ALTER TABLE tbl_name TYPE = MYISAM;
@end example
-@cindex tables, @code{HEAP}
-@node HEAP, InnoDB, ISAM, Table types
+
+@node HEAP, BDB, ISAM, Table types
@section HEAP Tables
+@cindex tables, @code{HEAP}
+
@code{HEAP} tables use a hashed index and are stored in memory. This
-makes them very fast, but if @strong{MySQL} crashes you will lose all
+makes them very fast, but if MySQL crashes you will lose all
data stored in them. @code{HEAP} is very useful for temporary tables!
-The @strong{MySQL} internal HEAP tables use 100% dynamic hashing
+The MySQL internal HEAP tables use 100% dynamic hashing
without overflow areas. There is no extra space needed for free lists.
@code{HEAP} tables also don't have problems with delete + inserts, which
normally is common with hashed tables:
@@ -24678,7 +35826,7 @@ the same time.
To free memory, you should execute @code{DELETE FROM heap_table},
@code{TRUNCATE heap_table} or @code{DROP TABLE heap_table}.
@item
-@strong{MySQL} cannot find out approximately how many rows there
+MySQL cannot find out approximately how many rows there
are between two values (this is used by the range optimizer to decide which
index to use). This may affect some queries if you change a @code{MyISAM}
table to a @code{HEAP} table.
@@ -24696,7 +35844,303 @@ 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.
-@node InnoDB, BDB, HEAP, Table types
+
+@node BDB, InnoDB, HEAP, Table types
+@section BDB or Berkeley_DB Tables
+
+@cindex tables, @code{BDB}
+@cindex tables, @code{Berkeley DB}
+
+@menu
+* BDB overview:: Overview of BDB Tables
+* BDB install:: Installing BDB
+* BDB start:: BDB startup options
+* BDB characteristic:: Some characteristic of @code{BDB} tables:
+* BDB TODO:: Some things we need to fix for BDB in the near future:
+* BDB portability:: Operating systems supported by @strong{BDB}
+* BDB errors:: Errors You May Get When Using BDB Tables
+@end menu
+
+@node BDB overview, BDB install, BDB, BDB
+@subsection Overview of BDB Tables
+
+Support for BDB tables is included in the MySQL source distribution
+starting from Version 3.23.34 and is activated in the MySQL-Max
+binary.
+
+BerkeleyDB, available at @uref{http://www.sleepycat.com/} has provided
+MySQL with a transactional table handler. By using BerkeleyDB
+tables, your tables may have a greater chance of surviving crashes, and also
+provides @code{COMMIT} and @code{ROLLBACK} on transactions. The
+MySQL source distribution comes with a BDB distribution that has a
+couple of small patches to make it work more smoothly with MySQL.
+You can't use a non-patched @code{BDB} version with MySQL.
+
+We at MySQL AB are working in close cooperation with Sleepycat to
+keep the quality of the MySQL/BDB interface high.
+
+When it comes to supporting BDB tables, we are committed to help our
+users to locate the problem and help creating a reproducable test case
+for any problems involving BDB tables. Any such test case will be
+forwarded to Sleepycat who in turn will help us find and fix the
+problem. As this is a two stage operation, any problems with BDB tables
+may take a little longer for us to fix than for other table handlers.
+However, as the BerkeleyDB code itself has been used by many other
+applications than MySQL, we don't envision any big problems with
+this. @xref{Table handler support}.
+
+
+@node BDB install, BDB start, BDB overview, BDB
+@subsection Installing BDB
+
+If you have downloaded a binary version of MySQL that includes
+support for BerkeleyDB, simply follow the instructions for installing a
+binary version of MySQL.
+@xref{Installing binary}. @xref{mysqld-max, , @code{mysqld-max}}.
+
+To compile MySQL with Berkeley DB support, download MySQL
+Version 3.23.34 or newer and configure @code{MySQL} with the
+@code{--with-berkeley-db} option. @xref{Installing source}.
+
+@example
+cd /path/to/source/of/mysql-3.23.34
+./configure --with-berkeley-db
+@end example
+
+Please refer to the manual provided with the @code{BDB} distribution for
+more updated information.
+
+Even though Berkeley DB is in itself very tested and reliable,
+the MySQL interface is still considered beta quality.
+We are actively improving and optimizing it to get it stable very
+soon.
+
+
+@node BDB start, BDB characteristic, BDB install, BDB
+@subsection BDB startup options
+
+If you are running with @code{AUTOCOMMIT=0} then your changes in @code{BDB}
+tables will not be updated until you execute @code{COMMIT}. Instead of commit
+you can execute @code{ROLLBACK} to forget your changes. @xref{COMMIT}.
+
+If you are running with @code{AUTOCOMMIT=1} (the default), your changes
+will be committed immediately. You can start an extended transaction with
+the @code{BEGIN WORK} SQL command, after which your changes will not be
+committed until you execute @code{COMMIT} (or decide to @code{ROLLBACK}
+the changes).
+
+The following options to @code{mysqld} can be used to change the behavior of
+BDB tables:
+
+@multitable @columnfractions .30 .70
+@item @strong{Option} @tab @strong{Meaning}
+@item @code{--bdb-home=directory} @tab Base directory for BDB tables. This should be the same directory you use for --datadir.
+@item @code{--bdb-lock-detect=#} @tab Berkeley lock detect. One of (DEFAULT, OLDEST, RANDOM, or YOUNGEST).
+@item @code{--bdb-logdir=directory} @tab Berkeley DB log file directory.
+@item @code{--bdb-no-sync} @tab Don't synchronously flush logs.
+@item @code{--bdb-no-recover} @tab Don't start Berkeley DB in recover mode.
+@item @code{--bdb-shared-data} @tab Start Berkeley DB in multi-process mode (Don't use @code{DB_PRIVATE} when initializing Berkeley DB)
+@item @code{--bdb-tmpdir=directory} @tab Berkeley DB tempfile name.
+@item @code{--skip-bdb} @tab Don't use berkeley db.
+@item @code{-O bdb_max_lock=1000} @tab Set the maximum number of locks possible. @xref{SHOW VARIABLES}.
+@end multitable
+
+If you use @code{--skip-bdb}, MySQL will not initialize the
+Berkeley DB library and this will save a lot of memory. Of course,
+you cannot use @code{BDB} tables if you are using this option.
+
+Normally you should start @code{mysqld} without @code{--bdb-no-recover} if you
+intend to use BDB tables. This may, however, give you problems when you
+try to start @code{mysqld} if the BDB log files are corrupted. @xref{Starting
+server}.
+
+With @code{bdb_max_lock} you can specify the maximum number of locks
+(10000 by default) you can have active on a BDB table. You should
+increase this if you get errors of type @code{bdb: Lock table is out of
+available locks} or @code{Got error 12 from ...} when you have do long
+transactions or when @code{mysqld} has to examine a lot of rows to
+calculate the query.
+
+You may also want to change @code{binlog_cache_size} and
+@code{max_binlog_cache_size} if you are using big multi-line transactions.
+@xref{COMMIT}.
+
+
+@node BDB characteristic, BDB TODO, BDB start, BDB
+@subsection Some characteristic of @code{BDB} tables:
+
+@itemize @bullet
+@item
+To be able to rollback transactions BDB maintain log files. For maximum
+performance you should place these on another disk than your databases
+by using the @code{--bdb_log_dir} options.
+@item
+MySQL performs a checkpoint each time a new BDB log
+file is started, and removes any log files that are not needed for
+current transactions. One can also run @code{FLUSH LOGS} at any time
+to checkpoint the Berkeley DB tables.
+
+For disaster recovery, one should use table backups plus
+MySQL's binary log. @xref{Backup}.
+
+@strong{Warning}: If you delete old log files that are in use, BDB will
+not be able to do recovery at all and you may lose data if something
+goes wrong.
+@item
+MySQL requires a @code{PRIMARY KEY} in each BDB table to be
+able to refer to previously read rows. If you don't create one,
+MySQL will create an maintain a hidden @code{PRIMARY KEY} for
+you. The hidden key has a length of 5 bytes and is incremented for each
+insert attempt.
+@item
+If all columns you access in a @code{BDB} table are part of the same index or
+part of the primary key, then MySQL can execute the query
+without having to access the actual row. In a @code{MyISAM} table the
+above holds only if the columns are part of the same index.
+@item
+The @code{PRIMARY KEY} will be faster than any other key, as the
+@code{PRIMARY KEY} is stored together with the row data. As the other keys are
+stored as the key data + the @code{PRIMARY KEY}, it's important to keep the
+@code{PRIMARY KEY} as short as possible to save disk and get better speed.
+@item
+@code{LOCK TABLES} works on @code{BDB} tables as with other tables. If
+you don't use @code{LOCK TABLE}, MYSQL will issue an internal
+multiple-write lock on the table to ensure that the table will be
+properly locked if another thread issues a table lock.
+@item
+Internal locking in @code{BDB} tables is done on page level.
+@item
+@code{SELECT COUNT(*) FROM table_name} is slow as @code{BDB} tables doesn't
+maintain a count of the number of rows in the table.
+@item
+Scanning is slower than with @code{MyISAM} tables as one has data in BDB
+tables stored in B-trees and not in a separate data file.
+@item
+The application must always be prepared to handle cases where
+any change of a @code{BDB} table may make an automatic rollback and any
+read may fail with a deadlock error.
+@item
+Keys are not compressed to previous keys as with ISAM or MyISAM
+tables. In other words, the key information will take a little more
+space in @code{BDB} tables compared to MyISAM tables which don't use
+@code{PACK_KEYS=0}.
+@item
+There is often holes in the BDB table to allow you to insert new rows in
+the middle of the key tree. This makes BDB tables somewhat larger than
+MyISAM tables.
+@item
+The optimizer needs to know an approximation of the number of rows in
+the table. MySQL solves this by counting inserts and
+maintaining this in a separate segment in each BDB table. If you don't
+do a lot of @code{DELETE} or @code{ROLLBACK}:s this number should be
+accurate enough for the MySQL optimizer, but as MySQL
+only store the number on close, it may be wrong if MySQL dies
+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 @code{mysqld} will
+wait for enough free disk before continuing.
+@end itemize
+
+
+@node BDB TODO, BDB portability, BDB characteristic, BDB
+@subsection Some things we need to fix for BDB in the near future:
+
+@itemize @bullet
+@item
+It's very slow to open many BDB tables at the same time. If you are
+going to use BDB tables, you should not have a very big table cache (>
+256 ?) and you should use @code{--no-auto-rehash} with the @code{mysql}
+client. We plan to partly fix this in 4.0.
+@item
+@code{SHOW TABLE STATUS} doesn't yet provide that much information for BDB
+tables.
+@item
+Optimize performance.
+@item
+Change to not use page locks at all when we are scanning tables.
+@end itemize
+
+
+@node BDB portability, BDB errors, BDB TODO, BDB
+@subsection Operating systems supported by @strong{BDB}
+
+If you after having built MySQL with support for BDB tables get
+the following error in the log file when you start @code{mysqld}:
+
+@example
+bdb: architecture lacks fast mutexes: applications cannot be threaded
+Can't init dtabases
+@end example
+
+This means that @code{BDB} tables are not supported for your architecture.
+In this case you have to rebuild MySQL without BDB table support.
+
+NOTE: The following list is not complete; We will update this as we get
+more information about this.
+
+Currently we know that BDB tables works with the following operating
+system.
+
+@itemize @bullet
+@item
+Linux 2.x intel
+@item
+Solaris sparc
+@item
+SCO OpenServer
+@item
+SCO UnixWare 7.0.1
+@end itemize
+
+It doesn't work with the following operating systems:
+
+@itemize @bullet
+@item
+Linux 2.x Alpha
+@item
+Max OS X
+@end itemize
+
+
+@node BDB errors, , BDB portability, BDB
+@subsection Errors You May Get When Using BDB Tables
+
+@itemize @bullet
+@item
+If you get the following error in the @code{hostname.err log} when
+starting @code{mysqld}:
+
+@example
+bdb: Ignoring log file: .../log.XXXXXXXXXX: unsupported log version #
+@end example
+it means that the new @code{BDB} version doesn't support the old log
+file format. In this case you have to delete all @code{BDB} log BDB
+from your database directory (the files that has the format
+@code{log.XXXXXXXXXX} ) and restart @code{mysqld}. We would also
+recommend you to do a @code{mysqldump --opt} of your old @code{BDB}
+tables, delete the old table and restore the dump.
+@item
+If you are running in not @code{auto_commit} mode and delete a table you
+are using by another thread you may get the following error messages in
+the MySQL error file:
+
+@example
+001119 23:43:56 bdb: Missing log fileid entry
+001119 23:43:56 bdb: txn_abort: Log undo failed for LSN: 1 3644744: Invalid
+@end example
+
+This is not fatal but we don't recommend that you delete tables if you are
+not in @code{auto_commit} mode, until this problem is fixed (the fix is
+not trivial).
+@end itemize
+
+
+@node InnoDB, , BDB, Table types
@section InnoDB Tables
@menu
@@ -24716,20 +36160,21 @@ SUM_OVER_ALL_KEYS(max_length_of_key + sizeof(char*) * 2)
* InnoDB contact information:: InnoDB contact information.
@end menu
+
@node InnoDB overview, InnoDB start, InnoDB, InnoDB
@subsection InnoDB tables overview
-InnoDB tables are included in the @strong{MySQL} source distribution
+InnoDB tables are included in the MySQL source distribution
starting from 3.23.34a and are activated in the @strong{MySQL -max}
binary.
-If you have downloaded a binary version of @strong{MySQL} that includes
+If you have downloaded a binary version of MySQL that includes
support for InnoDB (mysqld-max), simply follow the instructions for
-installing a binary version of @strong{MySQL}. @xref{Installing binary}.
+installing a binary version of MySQL. @xref{Installing binary}.
@xref{mysqld-max, , @code{mysqld-max}}.
-To compile @strong{MySQL} with InnoDB support, download MySQL-3.23.37 or newer
-and configure @code{MySQL} with the @code{--with-innodb} option.
+To compile MySQL with InnoDB support, download MySQL-3.23.37 or newer
+and configure MySQL with the @code{--with-innodb} option.
@xref{Installing source}.
@example
@@ -24737,7 +36182,17 @@ cd /path/to/source/of/mysql-3.23.37
./configure --with-innodb
@end example
-InnoDB provides @strong{MySQL} with a transaction-safe table handler with
+To get InnoDB to work you have to specify where the data for InnoDB
+tables should be stored by specifying the @code{innodb_data_file_path}
+option on the command line or in an MySQL option file. @xref{InnoDB
+start}. If you have configured MySQL for InnoDB but you have not
+specified the above option, @code{mysqld} will print at start:
+
+@example
+Can't initialize InnoDB as 'innodb_data_file_path' is not set
+@end example
+
+InnoDB provides MySQL with a transaction-safe table handler with
commit, rollback, and crash recovery capabilities. InnoDB does
locking on row level, and also provides an Oracle-style consistent
non-locking read in @code{SELECTS}, which increases transaction
@@ -24753,23 +36208,24 @@ You can find the latest information about InnoDB at
InnoDB manual is always placed there, and you can also order commercial
support for InnoDB.
-Technically, InnoDB is a database backend placed under @strong{MySQL}. InnoDB
+Technically, InnoDB is a database backend placed under MySQL. InnoDB
has its own buffer pool for caching data and indexes in main
memory. InnoDB stores its tables and indexes in a tablespace, which
may consist of several files. This is different from, for example,
@code{MyISAM} tables where each table is stored as a separate file.
InnoDB is distributed under the GNU GPL License Version 2 (of June 1991).
-In the source distribution of @strong{MySQL}, InnoDB appears as a subdirectory.
+In the source distribution of MySQL, InnoDB appears as a subdirectory.
+
@node InnoDB start, InnoDB init, InnoDB overview, InnoDB
@subsection InnoDB startup options
-Beginning from @strong{MySQL}-3.23.37 the prefix of the options is changed
+Beginning from MySQL-3.23.37 the prefix of the options is changed
from @code{innobase_...} to @code{innodb_...}.
To use InnoDB tables you @strong{MUST} specify configuration parameters
-in the @strong{MySQL} configuration file in the @code{[mysqld]} section of
+in the MySQL configuration file in the @code{[mysqld]} section of
the configuration file @file{my.cnf}. @xref{Option files}.
The only required parameter to use InnoDB is @code{innodb_data_file_path},
@@ -24796,6 +36252,12 @@ set-variable = innodb_file_io_threads=4
set-variable = innodb_lock_wait_timeout=50
@end example
+Note that data files must be < 4G, and < 2G on
+some file systems! The total size of data files has
+to be >= 10 MB.
+InnoDB does not create directories:
+you have to create them yourself.
+
Suppose you have a Linux machine with 512 MB RAM and
three 20 GB hard disks (at directory paths @file{/},
@file{/dr2} and @file{/dr3}).
@@ -24875,7 +36337,7 @@ log archiving. The value of this parameter should currently be set the
same as @code{innodb_log_group_home_dir}.
@item @code{innodb_log_archive} @tab
This value should currently be set to 0. As recovery from a backup is
-done by @strong{MySQL} using its own log files, there is currently no need to
+done by MySQL using its own log files, there is currently no need to
archive InnoDB log files.
@item @code{innodb_buffer_pool_size} @tab
The size of the memory buffer InnoDB uses to cache data and indexes of
@@ -24890,7 +36352,7 @@ and other internal data structures. A sensible value for this might be
2M, but the more tables you have in your application the more you will
need to allocate here. If InnoDB runs out of memory in this pool, it
will start to allocate memory from the operating system, and write
-warning messages to the @strong{MySQL} error log.
+warning messages to the MySQL error log.
@item @code{innodb_file_io_threads} @tab
Number of file i/o threads in InnoDB. Normally, this should be 4, but
on Windows NT disk i/o may benefit from a larger number.
@@ -24906,27 +36368,21 @@ resolve the situation.
(Available from 3.23.40 up.)
The default value for this is @code{fdatasync}.
Another option is @code{O_DSYNC}.
-Options @code{littlesync} and @code{nosync} have the
-risk that in an operating system crash or a power outage you may easily
-end up with a half-written database page, and you have to do a recovery
-from a backup. See the section "InnoDB performance tuning", item 6, below
-for tips on how to set this parameter. If you are happy with your database
-performance it is wisest not to specify this parameter at all, in which
-case it will get the default value.
@end multitable
+
@node InnoDB init, Using InnoDB tables, InnoDB start, InnoDB
@subsection Creating InnoDB table space
-Suppose you have installed @strong{MySQL} and have edited @file{my.cnf} so that
+Suppose you have installed MySQL and have edited @file{my.cnf} so that
it contains the necessary InnoDB configuration parameters.
-Before starting @strong{MySQL} you should check that the directories you have
+Before starting MySQL you should check that the directories you have
specified for InnoDB data files and log files exist and that you have
access rights to those directories. InnoDB
cannot create directories, only files. Check also you have enough disk space
for the data and log files.
-When you now start @strong{MySQL}, InnoDB will start creating your data files
+When you now start MySQL, InnoDB will start creating your data files
and log files. InnoDB will print something like the following:
@example
@@ -24951,9 +36407,9 @@ InnoDB: Started
mysqld: ready for connections
@end example
-A new InnoDB database has now been created. You can connect to the @strong{MySQL}
-server with the usual @strong{MySQL} client programs like @code{mysql}.
-When you shut down the @strong{MySQL} server with @file{mysqladmin shutdown},
+A new InnoDB database has now been created. You can connect to the MySQL
+server with the usual MySQL client programs like @code{mysql}.
+When you shut down the MySQL server with @file{mysqladmin shutdown},
InnoDB output will be like the following:
@example
@@ -24968,7 +36424,7 @@ will see the files created. The log directory will also contain
a small file named @file{ib_arch_log_0000000000}. That file
resulted from the database creation, after which InnoDB switched off
log archiving.
-When @strong{MySQL} is again started, the output will be like the following:
+When MySQL is again started, the output will be like the following:
@example
~/mysqlm/sql > mysqld
@@ -24977,9 +36433,10 @@ mysqld: ready for connections
@end example
@menu
-* Error creating InnoDB::
+* Error creating InnoDB:: If something goes wrong in database creation
@end menu
+
@node Error creating InnoDB, , InnoDB init, InnoDB init
@subsubsection If something goes wrong in database creation
@@ -24987,13 +36444,14 @@ If something goes wrong in an InnoDB database creation, you should
delete all files created by InnoDB. This means all data files, all log
files, the small archived log file, and in the case you already did
create some InnoDB tables, delete also the corresponding @file{.frm}
-files for these tables from the @strong{MySQL} database
+files for these tables from the MySQL database
directories. Then you can try the InnoDB database creation again.
+
@node Using InnoDB tables, Adding and removing, InnoDB init, InnoDB
@subsection Creating InnoDB tables
-Suppose you have started the @strong{MySQL} client with the command
+Suppose you have started the MySQL client with the command
@code{mysql test}.
To create a table in the InnoDB format you must specify
@code{TYPE = InnoDB} in the table creation SQL command:
@@ -25004,15 +36462,15 @@ CREATE TABLE CUSTOMER (A INT, B CHAR (20), INDEX (A)) TYPE = InnoDB;
This SQL command will create a table and an index on column @code{A}
into the InnoDB tablespace consisting of the data files you specified
-in @file{my.cnf}. In addition @strong{MySQL} will create a file
-@file{CUSTOMER.frm} to the @strong{MySQL} database directory @file{test}.
+in @file{my.cnf}. In addition MySQL will create a file
+@file{CUSTOMER.frm} to the MySQL database directory @file{test}.
Internally, InnoDB will add to its own data dictionary an entry
for table @code{'test/CUSTOMER'}. Thus you can create a table
-of the same name @code{CUSTOMER} in another database of @strong{MySQL}, and
+of the same name @code{CUSTOMER} in another database of MySQL, and
the table names will not collide inside InnoDB.
You can query the amount of free space in the InnoDB tablespace
-by issuing the table status command of @strong{MySQL} for any table you have
+by issuing the table status command of MySQL for any table you have
created with @code{TYPE = InnoDB}. Then the amount of free
space in the tablespace appears in the table comment section in the
output of @code{SHOW}. An example:
@@ -25030,7 +36488,7 @@ You must drop the tables individually. Also take care not to delete or
add @file{.frm} files to your InnoDB database manually: use
@code{CREATE TABLE} and @code{DROP TABLE} commands.
InnoDB has its own internal data dictionary, and you will get problems
-if the @strong{MySQL} @file{.frm} files are out of 'sync' with the InnoDB
+if the MySQL @file{.frm} files are out of 'sync' with the InnoDB
internal data dictionary.
@subsubsection Converting MyISAM tables to InnoDB
@@ -25073,13 +36531,14 @@ it is better that you kill the database process and delete all InnoDB data
and log files and all InnoDB table @file{.frm} files, and start
your job again, rather than wait for millions of disk i/os to complete.
+
@node Adding and removing, Backing up, Using InnoDB tables, InnoDB
@subsection Adding and removing InnoDB data and log files
You cannot increase the size of an InnoDB data file. To add more into
your tablespace you have to add a new data file. To do this you have to
-shut down your @strong{MySQL} database, edit the @file{my.cnf} file, adding a
-new file to @code{innodb_data_file_path}, and then start @strong{MySQL}
+shut down your MySQL database, edit the @file{my.cnf} file, adding a
+new file to @code{innodb_data_file_path}, and then start MySQL
again.
Currently you cannot remove a data file from InnoDB. To decrease the
@@ -25088,13 +36547,14 @@ all your tables, create a new database, and import your tables to the
new database.
If you want to change the number or the size of your InnoDB log files,
-you have to shut down @strong{MySQL} and make sure that it shuts down without errors.
+you have to shut down MySQL and make sure that it shuts down without errors.
Then copy the old log files into a safe place just in case something
went wrong in the shutdown and you will need them to recover the
database. Delete then the old log files from the log file directory,
-edit @file{my.cnf}, and start @strong{MySQL} again. InnoDB will tell
+edit @file{my.cnf}, and start MySQL again. InnoDB will tell
you at the startup that it is creating new log files.
+
@node Backing up, Moving, Adding and removing, InnoDB
@subsection Backing up and recovering an InnoDB database
@@ -25103,7 +36563,7 @@ To take a 'binary' backup of your database you have to do the following:
@itemize @bullet
@item
-Shut down your @strong{MySQL} database and make sure it shuts down without errors.
+Shut down your MySQL database and make sure it shuts down without errors.
@item
Copy all your data files into a safe place.
@item
@@ -25134,12 +36594,12 @@ dumps. Then you can take the binary backup, and you will then have
a consistent snapshot of your database in two formats.
To be able to recover your InnoDB database to the present from the
-binary backup described above, you have to run your @strong{MySQL} database
-with the general logging and log archiving of @strong{MySQL} switched on. Here
-by the general logging we mean the logging mechanism of the @strong{MySQL} server
+binary backup described above, you have to run your MySQL database
+with the general logging and log archiving of MySQL switched on. Here
+by the general logging we mean the logging mechanism of the MySQL server
which is independent of InnoDB logs.
-To recover from a crash of your @strong{MySQL} server process, the only thing
+To recover from a crash of your MySQL server process, the only thing
you have to do is to restart it. InnoDB will automatically check the
logs and perform a roll-forward of the database to the present.
InnoDB will automatically roll back uncommitted transactions which were
@@ -25174,13 +36634,14 @@ mysqld: ready for connections
If your database gets corrupted or your disk fails, you have
to do the recovery from a backup. In the case of corruption, you should
first find a backup which is not corrupted. From a backup do the recovery
-from the general log files of @strong{MySQL} according to instructions in the
+from the general log files of MySQL according to instructions in the
MySQL manual.
@menu
-* InnoDB checkpoints::
+* InnoDB checkpoints:: Checkpoints
@end menu
+
@node InnoDB checkpoints, , Backing up, Backing up
@subsubsection Checkpoints
@@ -25212,6 +36673,7 @@ the total size of the log files as big as the buffer pool or even bigger.
The drawback in big log files is that crash recovery can last longer
because there will be more log to apply to the database.
+
@node Moving, InnoDB transaction model, Backing up, InnoDB
@subsection Moving an InnoDB database to another machine
@@ -25232,6 +36694,7 @@ the big rollback segment the big import transaction will generate.
Do the commit only after importing a whole table or a segment of
a table.
+
@node InnoDB transaction model, Implementation, Moving, InnoDB
@subsection InnoDB transaction model
@@ -25245,7 +36708,7 @@ to lock every row in the database, or any random subset of the rows,
without InnoDB running out of memory.
In InnoDB all user activity happens inside transactions. If the
-auto commit mode is used in @strong{MySQL}, then each SQL statement
+auto commit mode is used in MySQL, then each SQL statement
will form a single transaction. If the auto commit mode is
switched off, then we can think that a user always has a transaction
open. If he issues
@@ -25259,13 +36722,15 @@ on the other hand cancels all modifications made by the current
transaction.
@menu
-* InnoDB consistent read::
-* InnoDB locking reads::
-* InnoDB Next-key locking::
-* InnoDB Locks set::
-* InnoDB Deadlock detection::
+* InnoDB consistent read:: Consistent read
+* InnoDB locking reads:: Locking reads
+* InnoDB Next-key locking:: Next-key locking: avoiding the phantom problem
+* InnoDB Locks set:: Locks set by different SQL statements in InnoDB
+* InnoDB Deadlock detection:: Deadlock detection and rollback
+* InnoDB Consistent read example:: An example of how the consistent read works in InnoDB
@end menu
+
@node InnoDB consistent read, InnoDB locking reads, InnoDB transaction model, InnoDB transaction model
@subsubsection Consistent read
@@ -25291,6 +36756,7 @@ on the tables it accesses, and therefore other users are free to
modify those tables at the same time a consistent read is being performed
on the table.
+
@node InnoDB locking reads, InnoDB Next-key locking, InnoDB consistent read, InnoDB transaction model
@subsubsection Locking reads
@@ -25348,6 +36814,7 @@ available data setting exclusive locks on each row it reads.
Thus it sets the same locks a searched SQL @code{UPDATE} would set
on the rows.
+
@node InnoDB Next-key locking, InnoDB Locks set, InnoDB locking reads, InnoDB transaction model
@subsubsection Next-key locking: avoiding the phantom problem
@@ -25402,6 +36869,7 @@ anyone meanwhile inserting a duplicate for your row. Thus the next-key
locking allows you to 'lock' the non-existence of something in your
table.
+
@node InnoDB Locks set, InnoDB Deadlock detection, InnoDB Next-key locking, InnoDB transaction model
@subsubsection Locks set by different SQL statements in InnoDB
@@ -25425,7 +36893,7 @@ on the duplicate index record.
@code{INSERT INTO T SELECT ... FROM S WHERE ...} sets an exclusive
(non-next-key) lock on each row inserted into @code{T}. Does
the search on @code{S} as a consistent read, but sets shared next-key
-locks on @code{S} if the @strong{MySQL} logging is on. InnoDB has to set
+locks on @code{S} if the MySQL logging is on. InnoDB has to set
locks in the latter case because in roll-forward recovery from a
backup every SQL statement has to be executed in exactly the same
way as it was done originally.
@@ -25445,22 +36913,23 @@ lock on every record the search encounters.
lock on every record the search encounters.
@item
@code{LOCK TABLES ... } : sets table locks. In the implementation
-the @strong{MySQL} layer of code sets these locks. The automatic deadlock detection
+the MySQL layer of code sets these locks. The automatic deadlock detection
of InnoDB cannot detect deadlocks where such table locks are involved:
see the next section below. See also section 13 'InnoDB restrictions'
-about the following: since @strong{MySQL} does know about row level locks,
+about the following: since MySQL does know about row level locks,
it is possible that you
get a table lock on a table where another user currently has row level
locks. But that does not put transaction integerity into danger.
@end itemize
-@node InnoDB Deadlock detection, , InnoDB Locks set, InnoDB transaction model
+
+@node InnoDB Deadlock detection, InnoDB Consistent read example, InnoDB Locks set, InnoDB transaction model
@subsubsection Deadlock detection and rollback
InnoDB automatically detects a deadlock of transactions and rolls
back the transaction whose lock request was the last one to build
a deadlock, that is, a cycle in the waits-for graph of transactions.
-InnoDB cannot detect deadlocks where a lock set by a @strong{MySQL}
+InnoDB cannot detect deadlocks where a lock set by a MySQL
@code{LOCK TABLES} statement is involved, or if a lock set
in another table handler than InnoDB is involved. You have to resolve
these situations using @code{innodb_lock_wait_timeout} set in
@@ -25473,6 +36942,56 @@ set by the SQL statement may be preserved. This is because InnoDB
stores row locks in a format where it cannot afterwards know which was
set by which SQL statement.
+@node InnoDB Consistent read example, , InnoDB Deadlock detection, InnoDB transaction model
+@subsubsection An example of how the consistent read works in InnoDB
+
+When you issue a consistent read, that is, an ordinary @code{SELECT}
+statement, InnoDB will give your transaction a timepoint according
+to which your query sees the database. Thus, if transaction B deletes
+a row and commits after your timepoint was assigned, then you will
+not see the row deleted. Similarly with inserts and updates.
+
+You can advance your timepoint by committing your transaction
+and then doing another @code{SELECT}.
+
+This is called multiversioned concurrency control.
+
+@example
+ User A User B
+
+ set autocommit=0; set autocommit=0;
+time
+| SELECT * FROM t;
+| empty set
+| INSERT INTO t VALUES (1, 2);
+|
+v SELECT * FROM t;
+ empty set
+ COMMIT;
+
+ SELECT * FROM t;
+ empty set;
+
+ COMMIT;
+
+ SELECT * FROM t;
+ ----------------------
+ | 1 | 2 |
+ ----------------------
+@end example
+
+Thus user A sees the row inserted by B only when B has committed the
+insert, and A has committed his own transaction so that the timepoint
+is advanced past the the commit of B.
+
+If you want to see the 'freshest' state of the database, you should use
+a locking read:
+
+@example
+SELECT * FROM t LOCK IN SHARE MODE;
+@end example
+
+
@subsection Performance tuning tips
@strong{1.}
@@ -25515,15 +37034,6 @@ The default method InnoDB uses is the @code{fdatasync} function.
If you are not satisfied with the database write performance, you may
try setting @code{innodb_flush_method} in @file{my.cnf}
to @code{O_DSYNC}, though O_DSYNC seems to be slower on most systems.
-You can also try setting it to @code{littlesync}, which means that
-InnoDB does not call the file flush for every write it does to a
-file, but only
-in log flush at transaction commits and data file flush at a checkpoint.
-The drawback in @code{littlesync} is that if the operating system
-crashes, you can easily end up with a half-written database page,
-and you have to
-do a recovery from a backup. With @code{nosync} you have even less safety:
-InnoDB will only flush the database files to disk at database shutdown
@strong{7.} In importing data to InnoDB, make sure that MySQL does not have
@code{autocommit=1} on. Then every insert requires a log flush to disk.
@@ -25570,6 +37080,154 @@ INSERT INTO yourtable VALUES (1, 2), (5, 5);
This tip is of course valid for inserts into any table type, not just InnoDB.
+@subsubsection The InnoDB Monitor
+
+Starting from version 3.23.41 InnoDB includes the InnoDB
+Monitor which prints information on the InnoDB internal state.
+When swithed on, InnoDB Monitor
+will make the MySQL server to print data to the standard
+output about once every 10 seconds. This data is useful in
+performance tuning.
+
+The printed information includes data on:
+@itemize @bullet
+@item
+table and record locks held by each active transaction,
+@item
+lock waits of a transactions,
+@item
+semaphore waits of threads,
+@item
+pending file i/o requests,
+@item
+buffer pool statistics, and
+@item
+purge and insert buffer merge activity of the main thread
+of InnoDB.
+@end itemize
+
+You can start InnoDB Monitor through the following
+SQL command:
+
+@example
+CREATE TABLE innodb_monitor(a int) type = innodb;
+@end example
+
+and stop it by
+
+@example
+DROP TABLE innodb_monitor;
+@end example
+
+The @code{CREATE TABLE} syntax is just a way to pass a command
+to the InnoDB engine through the MySQL SQL parser: the created
+table is not relevant at all for InnoDB Monitor. If you shut down
+the database when the monitor is running, and you want to start
+the monitor again, you have to drop the
+table before you can issue a new @code{CREATE TABLE}
+to start the monitor.
+This syntax may change in a future release.
+
+
+A sample output of the InnoDB Monitor:
+
+@example
+================================
+010809 18:45:06 INNODB MONITOR OUTPUT
+================================
+--------------------------
+LOCKS HELD BY TRANSACTIONS
+--------------------------
+LOCK INFO:
+Number of locks in the record hash table 1294
+LOCKS FOR TRANSACTION ID 0 579342744
+TABLE LOCK table test/mytable trx id 0 582333343 lock_mode IX
+
+RECORD LOCKS space id 0 page no 12758 n bits 104 table test/mytable index
+PRIMARY trx id 0 582333343 lock_mode X
+Record lock, heap no 2 PHYSICAL RECORD: n_fields 74; 1-byte offs FALSE;
+info bits 0
+ 0: len 4; hex 0001a801; asc ;; 1: len 6; hex 000022b5b39f; asc ";; 2: len 7;
+hex 000002001e03ec; asc ;; 3: len 4; hex 00000001;
+...
+-----------------------------------------------
+CURRENT SEMAPHORES RESERVED AND SEMAPHORE WAITS
+-----------------------------------------------
+SYNC INFO:
+Sorry, cannot give mutex list info in non-debug version!
+Sorry, cannot give rw-lock list info in non-debug version!
+-----------------------------------------------------
+SYNC ARRAY INFO: reservation count 6041054, signal count 2913432
+4a239430 waited for by thread 49627477 op. S-LOCK file NOT KNOWN line 0
+Mut ex 0 sp 5530989 r 62038708 sys 2155035; rws 0 8257574 8025336; rwx 0 1121090 1848344
+-----------------------------------------------------
+CURRENT PENDING FILE I/O'S
+--------------------------
+Pending normal aio reads:
+Reserved slot, messages 40157658 4a4a40b8
+Reserved slot, messages 40157658 4a477e28
+...
+Reserved slot, messages 40157658 4a4424a8
+Reserved slot, messages 40157658 4a39ea38
+Total of 36 reserved aio slots
+Pending aio writes:
+Total of 0 reserved aio slots
+Pending insert buffer aio reads:
+Total of 0 reserved aio slots
+Pending log writes or reads:
+Reserved slot, messages 40158c98 40157f98
+Total of 1 reserved aio slots
+Pending synchronous reads or writes:
+Total of 0 reserved aio slots
+-----------
+BUFFER POOL
+-----------
+LRU list length 8034
+Free list length 0
+Flush list length 999
+Buffer pool size in pages 8192
+Pending reads 39
+Pending writes: LRU 0, flush list 0, single page 0
+Pages read 31383918, created 51310, written 2985115
+----------------------------
+END OF INNODB MONITOR OUTPUT
+============================
+010809 18:45:22 InnoDB starts purge
+010809 18:45:22 InnoDB purged 0 pages
+@end example
+
+Some notes on the output:
+
+@itemize @bullet
+@item
+If the section LOCKS HELD
+BY TRANSACTIONS reports lock waits, then your application
+may have lock contention. The output can also help to
+trace reasons for transaction deadlocks.
+@item
+Section SYNC INFO will report reserved semaphores
+if you compile InnoDB with <code>UNIV_SYNC_DEBUG</code>
+defined in <tt>univ.i</tt>.
+@item
+Section SYNC ARRAY INFO reports threads waiting
+for a semaphore and statistics on how many times
+threads have needed a spin or a wait on a mutex or
+a rw-lock semaphore. A big number of threads waiting
+for semaphores may be a result of disk i/o, or
+contention problems inside InnoDB. Contention can be
+due to heavy parallelism of queries, or problems in
+operating system thread scheduling.
+@item
+Section CURRENT PENDING FILE I/O'S lists pending
+file i/o requests. A large number of these indicates
+that the workload is disk i/o -bound.
+@item
+Section BUFFER POOL gives you statistics
+on pages read and written. You can calculate from these
+numbers how many data file i/o's your queries are
+currently doing.
+@end itemize
+
@node Implementation, Table and index, InnoDB transaction model, InnoDB
@subsection Implementation of multiversioning
@@ -25619,6 +37277,7 @@ its index records from the database. This removal operation is
called a purge, and it is quite fast, usually taking the same order of
time as the SQL statement which did the deletion.
+
@node Table and index, File space management, Implementation, InnoDB
@subsection Table and index structures
@@ -25648,12 +37307,13 @@ index. Note that if the primary key is long, the secondary indexes
will use more space.
@menu
-* InnoDB physical structure::
-* InnoDB Insert buffering::
-* InnoDB Adaptive hash::
-* InnoDB Physical record::
+* InnoDB physical structure:: Physical structure of an index
+* InnoDB Insert buffering:: Insert buffering
+* InnoDB Adaptive hash:: Adaptive hash indexes
+* InnoDB Physical record:: Physical record structure
@end menu
+
@node InnoDB physical structure, InnoDB Insert buffering, Table and index, Table and index
@subsubsection Physical structure of an index
@@ -25669,6 +37329,7 @@ If records are inserted in a random order, then the pages will be
1/2 - 15/16 full. If the fillfactor of an index page drops below 1/2,
InnoDB will try to contract the index tree to free the page.
+
@node InnoDB Insert buffering, InnoDB Adaptive hash, InnoDB physical structure, Table and index
@subsubsection Insert buffering
@@ -25696,6 +37357,7 @@ same page in of the index tree, and hence save disk i/o's.
It has been measured that the insert buffer can speed up insertions
to a table up to 15 times.
+
@node InnoDB Adaptive hash, InnoDB Physical record, InnoDB Insert buffering, Table and index
@subsubsection Adaptive hash indexes
@@ -25719,6 +37381,7 @@ In a sense, through the adaptive hash index mechanism InnoDB adapts itself
to ample main memory, coming closer to the architecture of main memory
databases.
+
@node InnoDB Physical record, , InnoDB Adaptive hash, Table and index
@subsubsection Physical record structure
@@ -25776,15 +37439,17 @@ The behavior of auto-increment is not defined if a user gives a negative
value to the column or if the value becomes bigger than the maximum
integer that can be stored in the specified integer type.
+
@node File space management, Error handling, Table and index, InnoDB
@subsection File space management and disk i/o
@menu
-* InnoDB Disk i/o::
-* InnoDB File space::
-* InnoDB File Defragmenting::
+* InnoDB Disk i/o:: Disk i/o
+* InnoDB File space:: File space management
+* InnoDB File Defragmenting:: Defragmenting a table
@end menu
+
@node InnoDB Disk i/o, InnoDB File space, File space management, File space management
@subsubsection Disk i/o
@@ -25800,12 +37465,42 @@ On Windows NT InnoDB uses non-buffered i/o. That means that the disk
pages InnoDB reads or writes are not buffered in the operating system
file cache. This saves some memory bandwidth.
-You can also use a raw disk in InnoDB, though this has not been tested yet:
-just define the raw disk in place of a data file in @file{my.cnf}.
-You must give the exact size in bytes of the raw disk in @file{my.cnf},
-because at startup InnoDB checks that the size of the file
-is the same as specified in the configuration file. Using a raw disk
-you can on some versions of Unix perform non-buffered i/o.
+Starting from 3.23.41 InnoDB uses a novel file flush technique
+called doublewrite.
+It adds safety to crash recovery after an operating system crash
+or a power outage, and improves performance on most Unix flavors
+by reducing the need for fsync operations.
+
+Doublewrite means that InnoDB before writing pages to a data file
+first writes them to a contiguous tablespace area called the
+doublewrite buffer. Only after the write and the flush to the doublewrite
+buffer has completed, InnoDB writes the pages to their proper
+positions in the data file. If the operating system crashes in the
+middle of a page write, InnoDB will in recovery find a good
+copy of the page from the doublewrite buffer.
+
+Starting from 3.23.41
+you can also use a raw disk partition as a data file, though this has
+not been tested yet. When you create a new data file you have
+to put the keyword @code{newraw} immediately after the data
+file size in @code{innodb_data_file_path}. The partition must be
+>= than you specify as the size. Note that 1M in InnoDB is
+1024 x 1024 bytes, while in disk specifications 1 MB usually means
+1000 000 bytes.
+
+@example
+innodb_data_file_path=hdd1:3Gnewraw;hdd2:2Gnewraw
+@end example
+
+When you start the database again you MUST change the keyword
+to @code{raw}. Otherwise InnoDB will write over your
+partition!
+
+@example
+innodb_data_file_path=hdd1:3Graw;hdd2:2Graw
+@end example
+
+Using a raw disk you can on some Unixes perform non-buffered i/o.
There are two read-ahead heuristics in InnoDB: sequential read-ahead
and random read-ahead. In sequential read-ahead InnoDB notices that
@@ -25816,6 +37511,7 @@ in a tablespace seems to be in the process of being
fully read into the buffer pool. Then InnoDB posts the remaining
reads to the i/o system.
+
@node InnoDB File space, InnoDB File Defragmenting, InnoDB Disk i/o, File space management
@subsubsection File space management
@@ -25863,6 +37559,7 @@ but remember that deleted rows can be physically removed only in a
purge operation after they are no longer needed in transaction rollback or
consistent read.
+
@node InnoDB File Defragmenting, , InnoDB File space, File space management
@subsubsection Defragmenting a table
@@ -25886,6 +37583,7 @@ records are deleted only from the end, then the the file space management
algorithm of InnoDB guarantees that fragmentation in the index will
not occur.
+
@node Error handling, InnoDB restrictions, File space management, InnoDB
@subsection Error handling
@@ -25899,7 +37597,7 @@ The following list specifies the error handling of InnoDB.
@itemize @bullet
@item
If you run out of file space in the tablespace,
-you will get the @strong{MySQL} @code{'Table is full'} error
+you will get the MySQL @code{'Table is full'} error
and InnoDB rolls back the SQL statement.
@item
A transaction deadlock or a timeout in a lock wait will give
@@ -25914,10 +37612,11 @@ statement.
@item
A 'row too long' error rolls back the SQL statement.
@item
-Other errors are mostly detected by the @strong{MySQL} layer of code, and
+Other errors are mostly detected by the MySQL layer of code, and
they roll back the corresponding SQL statement.
@end itemize
+
@node InnoDB restrictions, InnoDB contact information, Error handling, InnoDB
@subsection Some restrictions on InnoDB tables
@@ -25940,7 +37639,7 @@ create an index over the whole column.
@item
@code{INSERT DELAYED} is not supported for InnoDB tables.
@item
-The @strong{MySQL} @code{LOCK TABLES} operation does not know of InnoDB
+The MySQL @code{LOCK TABLES} operation does not know of InnoDB
row level locks set in already completed SQL statements: this means that
you can get a table lock on a table even if there still exist transactions
of other users which have row level locks on the same table. Thus
@@ -25957,18 +37656,21 @@ A table cannot contain more than 1000 columns.
@item
@code{DELETE FROM TABLE} does not regenerate the table but instead
deletes all rows, one by one, which is not that fast. In future versions
-of @strong{MySQL} you can use @code{TRUNCATE} which is fast.
+of MySQL you can use @code{TRUNCATE} which is fast.
@item
Before dropping a database with InnoDB tables one has to drop
the individual InnoDB tables first.
@item
The default database page size in InnoDB is 16 kB. By recompiling the
code one can set it from 8 kB to 64 kB.
-The maximun row length is slightly less than a half of a database page,
-the row length also includes @code{BLOB} and @code{TEXT} type
-columns. The restriction on the size of @code{BLOB} and
-@code{TEXT} columns will be removed by June 2001 in a future version of
-InnoDB.
+The maximun row length is slightly less than half of a database page
+in versions <= 3.23.40 of InnoDB. Starting from source
+release 3.23.41 BLOB and
+TEXT columns are allowed to be < 4 GB, the total row length must also be
+< 4 GB. InnoDB does not store fields whose size is <= 30 bytes on separate
+pages. After InnoDB has modified the row by storing long fields on
+separate pages, the remaining length of the row must be slightly less
+than half a database page.
@item
The maximum data or log file size is 2 GB or 4 GB depending on how large
files your operating system supports. Support for > 4 GB files will
@@ -25978,6 +37680,7 @@ The maximum tablespace size is 4 billion database pages. This is also
the maximum size for a table. The minimum tablespace size is 10 MB.
@end itemize
+
@node InnoDB contact information, , InnoDB restrictions, InnoDB
@subsection InnoDB contact information
@@ -25995,10303 +37698,652 @@ P.O.Box 800
Finland
@end example
-@cindex tables, @code{BDB}
-@cindex tables, @code{Berkeley DB}
-@node BDB, , InnoDB, Table types
-@section BDB or Berkeley_DB Tables
-
-@menu
-* BDB overview:: Overview of BDB Tables
-* BDB install:: Installing BDB
-* BDB start:: BDB startup options
-* BDB characteristic:: Some characteristic of @code{BDB} tables:
-* BDB TODO:: Some things we need to fix for BDB in the near future:
-* BDB portability:: Operating systems supported by @strong{BDB}
-* BDB errors:: Errors You May Get When Using BDB Tables
-@end menu
-
-@node BDB overview, BDB install, BDB, BDB
-@subsection Overview of BDB Tables
-
-Support for BDB tables is included in the @strong{MySQL} source distribution
-starting from Version 3.23.34 and is activated in the @strong{MySQL}-Max
-binary.
-
-BerkeleyDB, available at @uref{http://www.sleepycat.com/} has provided
-@strong{MySQL} with a transactional table handler. By using BerkeleyDB
-tables, your tables may have a greater chance of surviving crashes, and also
-provides @code{COMMIT} and @code{ROLLBACK} on transactions. The
-@strong{MySQL} source distribution comes with a BDB distribution that has a
-couple of small patches to make it work more smoothly with @strong{MySQL}.
-You can't use a non-patched @code{BDB} version with @strong{MySQL}.
-
-We at @strong{MySQL AB} are working in close cooperation with Sleepycat to
-keep the quality of the @strong{MySQL}/BDB interface high.
-
-When it comes to supporting BDB tables, we are committed to help our
-users to locate the problem and help creating a reproducable test case
-for any problems involving BDB tables. Any such test case will be
-forwarded to Sleepycat who in turn will help us find and fix the
-problem. As this is a two stage operation, any problems with BDB tables
-may take a little longer for us to fix than for other table handlers.
-However, as the BerkeleyDB code itself has been used by many other
-applications than @strong{MySQL}, we don't envision any big problems with
-this. @xref{Table handler support}.
-
-@node BDB install, BDB start, BDB overview, BDB
-@subsection Installing BDB
-
-If you have downloaded a binary version of @strong{MySQL} that includes
-support for BerkeleyDB, simply follow the instructions for installing a
-binary version of @strong{MySQL}.
-@xref{Installing binary}. @xref{mysqld-max, , @code{mysqld-max}}.
-
-To compile @strong{MySQL} with Berkeley DB support, download @strong{MySQL}
-Version 3.23.34 or newer and configure @code{MySQL} with the
-@code{--with-berkeley-db} option. @xref{Installing source}.
-
-@example
-cd /path/to/source/of/mysql-3.23.34
-./configure --with-berkeley-db
-@end example
-
-Please refer to the manual provided with the @code{BDB} distribution for
-more updated information.
-
-Even though Berkeley DB is in itself very tested and reliable,
-the @strong{MySQL} interface is still considered beta quality.
-We are actively improving and optimizing it to get it stable very
-soon.
-
-@node BDB start, BDB characteristic, BDB install, BDB
-@subsection BDB startup options
-
-If you are running with @code{AUTOCOMMIT=0} then your changes in @code{BDB}
-tables will not be updated until you execute @code{COMMIT}. Instead of commit
-you can execute @code{ROLLBACK} to forget your changes. @xref{COMMIT}.
-
-If you are running with @code{AUTOCOMMIT=1} (the default), your changes
-will be committed immediately. You can start an extended transaction with
-the @code{BEGIN WORK} SQL command, after which your changes will not be
-committed until you execute @code{COMMIT} (or decide to @code{ROLLBACK}
-the changes).
-
-The following options to @code{mysqld} can be used to change the behavior of
-BDB tables:
-
-@multitable @columnfractions .30 .70
-@item @strong{Option} @tab @strong{Meaning}
-@item @code{--bdb-home=directory} @tab Base directory for BDB tables. This should be the same directory you use for --datadir.
-@item @code{--bdb-lock-detect=#} @tab Berkeley lock detect. One of (DEFAULT, OLDEST, RANDOM, or YOUNGEST).
-@item @code{--bdb-logdir=directory} @tab Berkeley DB log file directory.
-@item @code{--bdb-no-sync} @tab Don't synchronously flush logs.
-@item @code{--bdb-no-recover} @tab Don't start Berkeley DB in recover mode.
-@item @code{--bdb-shared-data} @tab Start Berkeley DB in multi-process mode (Don't use @code{DB_PRIVATE} when initializing Berkeley DB)
-@item @code{--bdb-tmpdir=directory} @tab Berkeley DB tempfile name.
-@item @code{--skip-bdb} @tab Don't use berkeley db.
-@item @code{-O bdb_max_lock=1000} @tab Set the maximum number of locks possible. @xref{SHOW VARIABLES}.
-@end multitable
-
-If you use @code{--skip-bdb}, @strong{MySQL} will not initialize the
-Berkeley DB library and this will save a lot of memory. Of course,
-you cannot use @code{BDB} tables if you are using this option.
-
-Normally you should start @code{mysqld} without @code{--bdb-no-recover} if you
-intend to use BDB tables. This may, however, give you problems when you
-try to start @code{mysqld} if the BDB log files are corrupted. @xref{Starting
-server}.
-
-With @code{bdb_max_lock} you can specify the maximum number of locks
-(10000 by default) you can have active on a BDB table. You should
-increase this if you get errors of type @code{bdb: Lock table is out of
-available locks} or @code{Got error 12 from ...} when you have do long
-transactions or when @code{mysqld} has to examine a lot of rows to
-calculate the query.
-
-You may also want to change @code{binlog_cache_size} and
-@code{max_binlog_cache_size} if you are using big multi-line transactions.
-@xref{COMMIT}.
-
-@node BDB characteristic, BDB TODO, BDB start, BDB
-@subsection Some characteristic of @code{BDB} tables:
-
-@itemize @bullet
-@item
-To be able to rollback transactions BDB maintain log files. For maximum
-performance you should place these on another disk than your databases
-by using the @code{--bdb_log_dir} options.
-@item
-@strong{MySQL} performs a checkpoint each time a new BDB log
-file is started, and removes any log files that are not needed for
-current transactions. One can also run @code{FLUSH LOGS} at any time
-to checkpoint the Berkeley DB tables.
-
-For disaster recovery, one should use table backups plus
-@strong{MySQL}'s binary log. @xref{Backup}.
-
-@strong{Warning}: If you delete old log files that are in use, BDB will
-not be able to do recovery at all and you may loose data if something
-goes wrong.
-@item
-@strong{MySQL} requires a @code{PRIMARY KEY} in each BDB table to be
-able to refer to previously read rows. If you don't create one,
-@strong{MySQL} will create an maintain a hidden @code{PRIMARY KEY} for
-you. The hidden key has a length of 5 bytes and is incremented for each
-insert attempt.
-@item
-If all columns you access in a @code{BDB} table are part of the same index or
-part of the primary key, then @strong{MySQL} can execute the query
-without having to access the actual row. In a @code{MyISAM} table the
-above holds only if the columns are part of the same index.
-@item
-The @code{PRIMARY KEY} will be faster than any other key, as the
-@code{PRIMARY KEY} is stored together with the row data. As the other keys are
-stored as the key data + the @code{PRIMARY KEY}, it's important to keep the
-@code{PRIMARY KEY} as short as possible to save disk and get better speed.
-@item
-@code{LOCK TABLES} works on @code{BDB} tables as with other tables. If
-you don't use @code{LOCK TABLE}, @strong{MYSQL} will issue an internal
-multiple-write lock on the table to ensure that the table will be
-properly locked if another thread issues a table lock.
-@item
-Internal locking in @code{BDB} tables is done on page level.
-@item
-@code{SELECT COUNT(*) FROM table_name} is slow as @code{BDB} tables doesn't
-maintain a count of the number of rows in the table.
-@item
-Scanning is slower than with @code{MyISAM} tables as one has data in BDB
-tables stored in B-trees and not in a separate data file.
-@item
-The application must always be prepared to handle cases where
-any change of a @code{BDB} table may make an automatic rollback and any
-read may fail with a deadlock error.
-@item
-Keys are not compressed to previous keys as with ISAM or MyISAM
-tables. In other words, the key information will take a little more
-space in @code{BDB} tables compared to MyISAM tables which don't use
-@code{PACK_KEYS=0}.
-@item
-There is often holes in the BDB table to allow you to insert new rows in
-the middle of the key tree. This makes BDB tables somewhat larger than
-MyISAM tables.
-@item
-The optimizer needs to know an approximation of the number of rows in
-the table. @strong{MySQL} solves this by counting inserts and
-maintaining this in a separate segment in each BDB table. If you don't
-do a lot of @code{DELETE} or @code{ROLLBACK}:s this number should be
-accurate enough for the @strong{MySQL} optimizer, but as @strong{MySQL}
-only store the number on close, it may be wrong if @strong{MySQL} dies
-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 @code{mysqld} will
-wait for enough free disk before continuing.
-@end itemize
-
-@node BDB TODO, BDB portability, BDB characteristic, BDB
-@subsection Some things we need to fix for BDB in the near future:
-
-@itemize @bullet
-@item
-It's very slow to open many BDB tables at the same time. If you are
-going to use BDB tables, you should not have a very big table cache (>
-256 ?) and you should use @code{--no-auto-rehash} with the @code{mysql}
-client. We plan to partly fix this in 4.0.
-@item
-@code{SHOW TABLE STATUS} doesn't yet provide that much information for BDB
-tables.
-@item
-Optimize performance.
-@item
-Change to not use page locks at all when we are scanning tables.
-@end itemize
-
-@node BDB portability, BDB errors, BDB TODO, BDB
-@subsection Operating systems supported by @strong{BDB}
-
-If you after having built @strong{MySQL} with support for BDB tables get
-the following error in the log file when you start @code{mysqld}:
-
-@example
-bdb: architecture lacks fast mutexes: applications cannot be threaded
-Can't init dtabases
-@end example
-
-This means that @code{BDB} tables are not supported for your architecture.
-In this case you have to rebuild @strong{MySQL} without BDB table support.
-
-NOTE: The following list is not complete; We will update this as we get
-more information about this.
-
-Currently we know that BDB tables works with the following operating
-system.
-
-@itemize @bullet
-@item
-Linux 2.x intel
-@item
-Solaris sparc
-@item
-SCO OpenServer
-@item
-SCO UnixWare 7.0.1
-@end itemize
-
-It doesn't work with the following operating systems:
-
-@itemize @bullet
-@item
-Linux 2.x Alpha
-@item
-Max OS X
-@end itemize
-
-@node BDB errors, , BDB portability, BDB
-@subsection Errors You May Get When Using BDB Tables
-
-@itemize @bullet
-@item
-If you get the following error in the @code{hostname.err log} when
-starting @code{mysqld}:
-
-@example
-bdb: Ignoring log file: .../log.XXXXXXXXXX: unsupported log version #
-@end example
-it means that the new @code{BDB} version doesn't support the old log
-file format. In this case you have to delete all @code{BDB} log BDB
-from your database directory (the files that has the format
-@code{log.XXXXXXXXXX} ) and restart @code{mysqld}. We would also
-recommend you to do a @code{mysqldump --opt} of your old @code{BDB}
-tables, delete the old table and restore the dump.
-@item
-If you are running in not @code{auto_commit} mode and delete a table you
-are using by another thread you may get the following error messages in
-the @strong{MySQL} error file:
-
-@example
-001119 23:43:56 bdb: Missing log fileid entry
-001119 23:43:56 bdb: txn_abort: Log undo failed for LSN: 1 3644744: Invalid
-@end example
-
-This is not fatal but we don't recommend that you delete tables if you are
-not in @code{auto_commit} mode, until this problem is fixed (the fix is
-not trivial).
-@end itemize
-
-@cindex tutorial
-@cindex terminal monitor, defined
-@cindex monitor, terminal
-@cindex options, provided by MySQL
-@node Tutorial, Server, Table types, Top
-@chapter MySQL Tutorial
-
-@menu
-* Connecting-disconnecting:: Connecting to and disconnecting from the server
-* Entering queries:: Entering queries
-* Database use:: Creating and using a database
-* Getting information:: Getting information about databases and tables
-* Examples:: Examples
-* Batch mode:: Using @code{mysql} in batch mode
-* Twin:: Queries from twin project
-@end menu
-
-This chapter provides a tutorial introduction to @strong{MySQL} by showing
-how to use the @code{mysql} client program to create and use a simple
-database. @code{mysql} (sometimes referred to as the ``terminal monitor'' or
-just ``monitor'') is an interactive program that allows you to connect to a
-@strong{MySQL} server, run queries, and view the results. @code{mysql} may
-also be used in batch mode: you place your queries in a file beforehand, then
-tell @code{mysql} to execute the contents of the file. Both ways of using
-@code{mysql} are covered here.
-
-To see a list of options provided by @code{mysql}, invoke it with
-the @code{--help} option:
-
-@example
-shell> mysql --help
-@end example
-
-This chapter assumes that @code{mysql} is installed on your machine and that
-a @strong{MySQL} server is available to which you can connect. If this is
-not true, contact your @strong{MySQL} administrator. (If @emph{you} are the
-administrator, you will need to consult other sections of this manual.)
-
-This chapter describes the entire process of setting up and using a
-database. If you are interested only in accessing an already-existing
-database, you may want to skip over the sections that describe how to
-create the database and the tables it contains.
-
-Because this chapter is tutorial in nature, many details are necessarily left
-out. Consult the relevant sections of the manual for more
-information on the topics covered here.
-
-@cindex connecting, to the server
-@cindex disconnecting, from the server
-@cindex server, connecting
-@cindex server, disconnecting
-@node Connecting-disconnecting, Entering queries, Tutorial, Tutorial
-@section Connecting to and Disconnecting from the Server
-
-To connect to the server, you'll usually need to provide a @strong{MySQL}
-user name when you invoke @code{mysql} and, most likely, a password. If the
-server runs on a machine other than the one where you log in, you'll also
-need to specify a hostname. Contact your administrator to find out what
-connection parameters you should use to connect (that is, what host, user name,
-and password to use). Once you know the proper parameters, you should be
-able to connect like this:
-
-@example
-shell> mysql -h host -u user -p
-Enter password: ********
-@end example
-
-The @code{********} represents your password; enter it when @code{mysql}
-displays the @code{Enter password:} prompt.
-
-If that works, you should see some introductory information followed by a
-@code{mysql>} prompt:
-
-
-@example
-shell> mysql -h host -u user -p
-Enter password: ********
-Welcome to the MySQL monitor. Commands end with ; or \g.
-Your MySQL connection id is 459 to server version: 3.22.20a-log
-
-Type 'help' for help.
-
-mysql>
-@end example
-
-The prompt tells you that @code{mysql} is ready for you to enter commands.
-
-Some @strong{MySQL} installations allow users to connect as the anonymous
-(unnamed) user to the server running on the local host. If this is the case
-on your machine, you should be able to connect to that server by invoking
-@code{mysql} without any options:
-
-@example
-shell> mysql
-@end example
-
-After you have connected successfully, you can disconnect any time by typing
-@code{QUIT} at the @code{mysql>} prompt:
-
-@example
-mysql> QUIT
-Bye
-@end example
-
-You can also disconnect by pressing Control-D.
-
-Most examples in the following sections assume you are connected to the
-server. They indicate this by the @code{mysql>} prompt.
-
-@cindex running, queries
-@cindex queries, entering
-@cindex entering, queries
-@node Entering queries, Database use, Connecting-disconnecting, Tutorial
-@section Entering Queries
-
-Make sure you are connected to the server, as discussed in the previous
-section. Doing so will not in itself select any database to work with, but
-that's okay. At this point, it's more important to find out a little about
-how to issue queries than to jump right in creating tables, loading data
-into them, and retrieving data from them. This section describes the basic
-principles of entering commands, using several queries you can try out to
-familiarize yourself with how @code{mysql} works.
-
-Here's a simple command that asks the server to tell you its version number
-and the current date. Type it in as shown below following the @code{mysql>}
-prompt and hit the RETURN key:
-
-@example
-mysql> SELECT VERSION(), CURRENT_DATE;
-+--------------+--------------+
-| version() | CURRENT_DATE |
-+--------------+--------------+
-| 3.22.20a-log | 1999-03-19 |
-+--------------+--------------+
-1 row in set (0.01 sec)
-mysql>
-@end example
-
-This query illustrates several things about @code{mysql}:
-
-@itemize @bullet
-@item
-A command normally consists of a SQL statement followed by a semicolon.
-(There are some exceptions where a semicolon is not needed. @code{QUIT},
-mentioned earlier, is one of them. We'll get to others later.)
-
-@item
-When you issue a command, @code{mysql} sends it to the server for execution
-and displays the results, then prints another @code{mysql>} to indicate
-that it is ready for another command.
-
-@item
-@code{mysql} displays query output as a table (rows and columns). The first
-row contains labels for the columns. The rows following are the query
-results. Normally, column labels are the names of the columns you fetch from
-database tables. If you're retrieving the value of an expression rather than
-a table column (as in the example just shown), @code{mysql} labels the column
-using the expression itself.
-
-@item
-@code{mysql} shows how many rows were returned and how long the query took
-to execute, which gives you a rough idea of server performance. These values
-are imprecise because they represent wall clock time (not CPU or machine
-time), and because they are affected by factors such as server load and
-network latency. (For brevity, the ``rows in set'' line is not shown in
-the remaining examples in this chapter.)
-@end itemize
-
-Keywords may be entered in any lettercase. The following queries are
-equivalent:
-
-@example
-mysql> SELECT VERSION(), CURRENT_DATE;
-mysql> select version(), current_date;
-mysql> SeLeCt vErSiOn(), current_DATE;
-@end example
-
-Here's another query. It demonstrates that you can use @code{mysql} as a
-simple calculator:
-
-@example
-mysql> SELECT SIN(PI()/4), (4+1)*5;
-+-------------+---------+
-| SIN(PI()/4) | (4+1)*5 |
-+-------------+---------+
-| 0.707107 | 25 |
-+-------------+---------+
-@end example
-
-The commands shown thus far have been relatively short, single-line
-statements. You can even enter multiple statements on a single line.
-Just end each one with a semicolon:
-
-@example
-mysql> SELECT VERSION(); SELECT NOW();
-+--------------+
-| version() |
-+--------------+
-| 3.22.20a-log |
-+--------------+
-
-+---------------------+
-| NOW() |
-+---------------------+
-| 1999-03-19 00:15:33 |
-+---------------------+
-@end example
-
-A command need not be given all on a single line, so lengthy commands that
-require several lines are not a problem. @code{mysql} determines where your
-statement ends by looking for the terminating semicolon, not by looking for
-the end of the input line. (In other words, @code{mysql}
-accepts free-format input: it collects input lines but does not execute them
-until it sees the semicolon.)
-
-Here's a simple multiple-line statement:
-
-@example
-mysql> SELECT
- -> USER()
- -> ,
- -> CURRENT_DATE;
-+--------------------+--------------+
-| USER() | CURRENT_DATE |
-+--------------------+--------------+
-| joesmith@@localhost | 1999-03-18 |
-+--------------------+--------------+
-@end example
-
-In this example, notice how the prompt changes from @code{mysql>} to
-@code{->} after you enter the first line of a multiple-line query. This is
-how @code{mysql} indicates that it hasn't seen a complete statement and is
-waiting for the rest. The prompt is your friend, because it provides
-valuable feedback. If you use that feedback, you will always be aware of
-what @code{mysql} is waiting for.
-
-If you decide you don't want to execute a command that you are in the
-process of entering, cancel it by typing @code{\c}:
-
-@example
-mysql> SELECT
- -> USER()
- -> \c
-mysql>
-@end example
-
-Here, too, notice the prompt. It switches back to @code{mysql>} after you
-type @code{\c}, providing feedback to indicate that @code{mysql} is ready
-for a new command.
-
-The following table shows each of the prompts you may see and summarizes what
-they mean about the state that @code{mysql} is in:
-
-@cindex prompts, meanings
-@multitable @columnfractions .10 .9
-@item @strong{Prompt} @tab @strong{Meaning}
-@item @code{mysql>} @tab Ready for new command.
-@item @code{@ @ @ @ ->} @tab Waiting for next line of multiple-line command.
-@item @code{@ @ @ @ '>} @tab Waiting for next line, collecting a string that begins
-with a single quote (@samp{'}).
-@item @code{@ @ @ @ ">} @tab Waiting for next line, collecting a string that begins
-with a double quote (@samp{"}).
-@end multitable
-
-Multiple-line statements commonly occur by accident when you intend to
-issue a command on a single line, but forget the terminating semicolon. In
-this case, @code{mysql} waits for more input:
-
-@example
-mysql> SELECT USER()
- ->
-@end example
-
-If this happens to you (you think you've entered a statement but the only
-response is a @code{->} prompt), most likely @code{mysql} is waiting for the
-semicolon. If you don't notice what the prompt is telling you, you might sit
-there for a while before realizing what you need to do. Enter a semicolon to
-complete the statement, and @code{mysql} will execute it:
-
-@example
-mysql> SELECT USER()
- -> ;
-+--------------------+
-| USER() |
-+--------------------+
-| joesmith@@localhost |
-+--------------------+
-@end example
-
-The @code{'>} and @code{">} prompts occur during string collection.
-In @strong{MySQL}, you can write strings surrounded by either @samp{'}
-or @samp{"} characters (for example, @code{'hello'} or @code{"goodbye"}),
-and @code{mysql} lets you enter strings that span multiple lines. When you
-see a @code{'>} or @code{">} prompt, it means that you've entered a line
-containing a string that begins with a @samp{'} or @samp{"} quote character,
-but have not yet entered the matching quote that terminates the string.
-That's fine if you really are entering a multiple-line string, but how likely
-is that? Not very. More often, the @code{'>} and @code{">} prompts indicate
-that you've inadvertantly left out a quote character. For example:
-
-@example
-mysql> SELECT * FROM my_table WHERE name = "Smith AND age < 30;
- ">
-@end example
-
-If you enter this @code{SELECT} statement, then hit RETURN and wait for the
-result, nothing will happen. Instead of wondering why this
-query takes so long, notice the clue provided by the @code{">} prompt. It
-tells you that @code{mysql} expects to see the rest of an unterminated
-string. (Do you see the error in the statement? The string @code{"Smith} is
-missing the second quote.)
-
-At this point, what do you do? The simplest thing is to cancel the command.
-However, you cannot just type @code{\c} in this case, because @code{mysql}
-interprets it as part of the string that it is collecting! Instead, enter
-the closing quote character (so @code{mysql} knows you've finished the
-string), then type @code{\c}:
-
-@example
-mysql> SELECT * FROM my_table WHERE name = "Smith AND age < 30;
- "> "\c
-mysql>
-@end example
-
-The prompt changes back to @code{mysql>}, indicating that @code{mysql}
-is ready for a new command.
-
-It's important to know what the @code{'>} and @code{">} prompts signify,
-because if you mistakenly enter an unterminated string, any further lines you
-type will appear to be ignored by @code{mysql} --- including a line
-containing @code{QUIT}! This can be quite confusing, especially if you
-don't know that you need to supply the terminating quote before you can
-cancel the current command.
-
-@cindex databases, creating
-@cindex databases, using
-@cindex creating, databases
-@node Database use, Getting information, Entering queries, Tutorial
-@section Creating and Using a Database
-
-@menu
-* Creating database:: Creating a database
-* Creating tables:: Creating a table
-* Loading tables:: Loading data into a table
-* Retrieving data:: Retrieving information from a table
-@end menu
-
-Now that you know how to enter commands, it's time to access a database.
-
-Suppose you have several pets in your home (your menagerie) and you'd
-like to keep track of various types of information about them. You can do so
-by creating tables to hold your data and loading them with the desired
-information. Then you can answer different sorts of questions about your
-animals by retrieving data from the tables. This section shows you how to:
-
-@itemize @bullet
-@item
-Create a database
-@item
-Create a table
-@item
-Load data into the table
-@item
-Retrieve data from the table in various ways
-@item
-Use multiple tables
-@end itemize
-
-The menagerie database will be simple (deliberately), but it is not difficult
-to think of real-world situations in which a similar type of database might
-be used. For example, a database like this could be used by a farmer to keep
-track of livestock, or by a veterinarian to keep track of patient records.
-A menagerie distribution containing some of the queries and sample data used
-in the following sections can be obtained from the @strong{MySQL} Web site.
-It's available in either
-@uref{http://www.mysql.com/Downloads/Contrib/Examples/menagerie.tar.gz,compressed @code{tar} format}
-or
-@uref{http://www.mysql.com/Downloads/Contrib/Examples/menagerie.zip,Zip format}.
-
-Use the @code{SHOW} statement to find out what databases currently exist
-on the server:
-
-@example
-mysql> SHOW DATABASES;
-+----------+
-| Database |
-+----------+
-| mysql |
-| test |
-| tmp |
-+----------+
-@end example
-
-The list of databases is probably different on your machine, but the
-@code{mysql} and @code{test} databases are likely to be among them. The
-@code{mysql} database is required because it describes user access
-privileges. The @code{test} database is often provided as a workspace for
-users to try things out.
-
-If the @code{test} database exists, try to access it:
-
-@example
-mysql> USE test
-Database changed
-@end example
-
-Note that @code{USE}, like @code{QUIT}, does not require a semicolon. (You
-can terminate such statements with a semicolon if you like; it does no harm.)
-The @code{USE} statement is special in another way, too: it must be given on
-a single line.
-
-You can use the @code{test} database (if you have access to it) for the
-examples that follow, but anything you create in that database can be
-removed by anyone else with access to it. For this reason, you should
-probably ask your @strong{MySQL} administrator for permission to use a
-database of your own. Suppose you want to call yours @code{menagerie}. The
-administrator needs to execute a command like this:
-
-@example
-mysql> GRANT ALL ON menagerie.* TO your_mysql_name;
-@end example
-
-where @code{your_mysql_name} is the @strong{MySQL} user name assigned to
-you.
-
-@cindex selecting, databases
-@cindex databases, selecting
-@node Creating database, Creating tables, Database use, Database use
-@subsection Creating and Selecting a Database
-
-If the administrator creates your database for you when setting up your
-permissions, you can begin using it. Otherwise, you need to create it
-yourself:
-
-@example
-mysql> CREATE DATABASE menagerie;
-@end example
-
-Under Unix, database names are case sensitive (unlike SQL keywords), so you
-must always refer to your database as @code{menagerie}, not as
-@code{Menagerie}, @code{MENAGERIE}, or some other variant. This is also true
-for table names. (Under Windows, this restriction does not apply, although
-you must refer to databases and tables using the same lettercase throughout a
-given query.)
-
-Creating a database does not select it for use; you must do that explicitly.
-To make @code{menagerie} the current database, use this command:
-@example
-mysql> USE menagerie
-Database changed
-@end example
-Your database needs to be created only once, but you must select it for use
-each time you begin a @code{mysql} session. You can do this by issuing a
-@code{USE} statement as shown above. Alternatively, you can select the
-database on the command line when you invoke @code{mysql}. Just specify its
-name after any connection parameters that you might need to provide. For
-example:
-
-@example
-shell> mysql -h host -u user -p menagerie
-Enter password: ********
-@end example
-
-Note that @code{menagerie} is not your password on the command just shown.
-If you want to supply your password on the command line after the @code{-p}
-option, you must do so with no intervening space (for example, as
-@code{-pmypassword}, not as @code{-p mypassword}). However, putting your
-password on the command line is not recommended, because doing so exposes it
-to snooping by other users logged in on your machine.
-
-@cindex tables, creating
-@cindex creating, tables
-@node Creating tables, Loading tables, Creating database, Database use
-@subsection Creating a Table
-
-Creating the database is the easy part, but at this point it's empty, as
-@code{SHOW TABLES} will tell you:
-
-@example
-mysql> SHOW TABLES;
-Empty set (0.00 sec)
-@end example
-
-The harder part is deciding what the structure of your database should be:
-what tables you will need and what columns will be in each of them.
-
-You'll want a table that contains a record for each of your pets. This can
-be called the @code{pet} table, and it should contain, as a bare minimum,
-each animal's name. Because the name by itself is not very interesting, the
-table should contain other information. For example, if more than one person
-in your family keeps pets, you might want to list each animal's owner. You
-might also want to record some basic descriptive information such as species
-and sex.
-
-How about age? That might be of interest, but it's not a good thing to store
-in a database. Age changes as time passes, which means you'd have to update
-your records often. Instead, it's better to store a fixed value such as
-date of birth. Then, whenever you need age, you can calculate it as the
-difference between the current date and the birth date. @strong{MySQL}
-provides functions for doing date arithmetic, so this is not difficult.
-Storing birth date rather than age has other advantages, too:
-
-@itemize @bullet
-@item
-You can use the database for tasks such as generating reminders for upcoming
-pet birthdays. (If you think this type of query is somewhat silly, note that
-it is the same question you might ask in the context of a business database
-to identify clients to whom you'll soon need to send out birthday greetings,
-for that computer-assisted personal touch.)
-
-@item
-You can calculate age in relation to dates other than the current date. For
-example, if you store death date in the database, you can easily calculate
-how old a pet was when it died.
-@end itemize
-
-You can probably think of other types of information that would be useful in
-the @code{pet} table, but the ones identified so far are sufficient for now:
-name, owner, species, sex, birth, and death.
-
-Use a @code{CREATE TABLE} statement to specify the layout of your table:
-
-@example
-mysql> CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20),
- -> species VARCHAR(20), sex CHAR(1), birth DATE, death DATE);
-@end example
-
-@code{VARCHAR} is a good choice for the @code{name}, @code{owner}, and
-@code{species} columns because the column values will vary in length. The
-lengths of those columns need not all be the same, and need not be
-@code{20}. You can pick any length from @code{1} to @code{255}, whatever
-seems most reasonable to you. (If you make a poor choice and it turns
-out later that you need a longer field, @strong{MySQL} provides an
-@code{ALTER TABLE} statement.)
-
-Animal sex can be represented in a variety of ways, for example, @code{"m"}
-and @code{"f"}, or perhaps @code{"male"} and @code{"female"}. It's simplest
-to use the single characters @code{"m"} and @code{"f"}.
-
-The use of the @code{DATE} data type for the @code{birth} and @code{death}
-columns is a fairly obvious choice.
-
-Now that you have created a table, @code{SHOW TABLES} should produce some
-output:
-
-@example
-mysql> SHOW TABLES;
-+---------------------+
-| Tables in menagerie |
-+---------------------+
-| pet |
-+---------------------+
-@end example
-
-To verify that your table was created the way you expected, use
-a @code{DESCRIBE} statement:
-
-@example
-mysql> DESCRIBE pet;
-+---------+-------------+------+-----+---------+-------+
-| Field | Type | Null | Key | Default | Extra |
-+---------+-------------+------+-----+---------+-------+
-| name | varchar(20) | YES | | NULL | |
-| owner | varchar(20) | YES | | NULL | |
-| species | varchar(20) | YES | | NULL | |
-| sex | char(1) | YES | | NULL | |
-| birth | date | YES | | NULL | |
-| death | date | YES | | NULL | |
-+---------+-------------+------+-----+---------+-------+
-@end example
-
-You can use @code{DESCRIBE} any time, for example, if you forget the names of
-the columns in your table or what types they are.
-
-@cindex loading, tables
-@cindex tables, loading data
-@cindex data, loading into tables
-@node Loading tables, Retrieving data, Creating tables, Database use
-@subsection Loading Data into a Table
-
-After creating your table, you need to populate it. The @code{LOAD DATA} and
-@code{INSERT} statements are useful for this.
-
-Suppose your pet records can be described as shown below.
-(Observe that @strong{MySQL} expects dates in @code{YYYY-MM-DD} format;
-this may be different than what you are used to.)
-
-@multitable @columnfractions .16 .16 .16 .16 .16 .16
-@item @strong{name} @tab @strong{owner} @tab @strong{species} @tab @strong{sex} @tab @strong{birth} @tab @strong{death}
-@item Fluffy @tab Harold @tab cat @tab f @tab 1993-02-04 @tab
-@item Claws @tab Gwen @tab cat @tab m @tab 1994-03-17 @tab
-@item Buffy @tab Harold @tab dog @tab f @tab 1989-05-13 @tab
-@item Fang @tab Benny @tab dog @tab m @tab 1990-08-27 @tab
-@item Bowser @tab Diane @tab dog @tab m @tab 1989-08-31 @tab 1995-07-29
-@item Chirpy @tab Gwen @tab bird @tab f @tab 1998-09-11 @tab
-@item Whistler @tab Gwen @tab bird @tab @tab 1997-12-09 @tab
-@item Slim @tab Benny @tab snake @tab m @tab 1996-04-29 @tab
-@end multitable
-
-Because you are beginning with an empty table, an easy way to populate it is to
-create a text file containing a row for each of your animals, then load the
-contents of the file into the table with a single statement.
-
-You could create a text file @file{pet.txt} containing one record per line,
-with values separated by tabs, and given in the order in which the columns
-were listed in the @code{CREATE TABLE} statement. For missing values (such
-as unknown sexes or death dates for animals that are still living), you can
-use @code{NULL} values. To represent these in your text file, use
-@code{\N}. For example, the record for Whistler the bird would look like
-this (where the whitespace between values is a single tab character):
-
-@multitable @columnfractions .15 .15 .15 .15 .25 .15
-@item @code{Whistler} @tab @code{Gwen} @tab @code{bird} @tab @code{\N} @tab @code{1997-12-09} @tab @code{\N}
-@end multitable
-
-To load the text file @file{pet.txt} into the @code{pet} table, use this
-command:
-
-@example
-mysql> LOAD DATA LOCAL INFILE "pet.txt" INTO TABLE pet;
-@end example
-
-You can specify the column value separator and end of line marker explicitly
-in the @code{LOAD DATA} statement if you wish, but the defaults are tab and
-linefeed. These are sufficient for the statement to read the file
-@file{pet.txt} properly.
-
-When you want to add new records one at a time, the @code{INSERT} statement
-is useful. In its simplest form, you supply values for each column, in the
-order in which the columns were listed in the @code{CREATE TABLE} statement.
-Suppose Diane gets a new hamster named Puffball. You could add a new record
-using an @code{INSERT} statement like this:
-
-@example
-mysql> INSERT INTO pet
- -> VALUES ('Puffball','Diane','hamster','f','1999-03-30',NULL);
-@end example
-
-Note that string and date values are specified as quoted strings here. Also,
-with @code{INSERT}, you can insert @code{NULL} directly to represent a
-missing value. You do not use @code{\N} like you do with @code{LOAD DATA}.
-
-From this example, you should be able to see that there would be a lot more
-typing involved to load
-your records initially using several @code{INSERT} statements rather
-than a single @code{LOAD DATA} statement.
-
-@cindex data, retrieving
-@cindex tables, retrieving data
-@cindex retrieving, data from tables
-@cindex unloading, tables
-@node Retrieving data, , Loading tables, Database use
-@subsection Retrieving Information from a Table
-
-@menu
-* Selecting all:: Selecting all data
-* Selecting rows:: Selecting particular rows
-* Selecting columns:: Selecting particular columns
-* Sorting rows:: Sorting rows
-* Date calculations:: Date calculations
-* Working with NULL:: Working with @code{NULL} values
-* Pattern matching:: Pattern matching
-* Counting rows:: Counting rows
-* Multiple tables::
-@end menu
-
-The @code{SELECT} statement is used to pull information from a table.
-The general form of the statement is:
-
-@example
-SELECT what_to_select
-FROM which_table
-WHERE conditions_to_satisfy
-@end example
-
-@code{what_to_select} indicates what you want to see. This can be a list of
-columns, or @code{*} to indicate ``all columns.'' @code{which_table}
-indicates the table from which you want to retrieve data. The @code{WHERE}
-clause is optional. If it's present, @code{conditions_to_satisfy} specifies
-conditions that rows must satisfy to qualify for retrieval.
-
-@node Selecting all, Selecting rows, Retrieving data, Retrieving data
-@subsubsection Selecting All Data
-
-The simplest form of @code{SELECT} retrieves everything from a table:
-
-@example
-mysql> SELECT * FROM pet;
-+----------+--------+---------+------+------------+------------+
-| name | owner | species | sex | birth | death |
-+----------+--------+---------+------+------------+------------+
-| Fluffy | Harold | cat | f | 1993-02-04 | NULL |
-| Claws | Gwen | cat | m | 1994-03-17 | NULL |
-| Buffy | Harold | dog | f | 1989-05-13 | NULL |
-| Fang | Benny | dog | m | 1990-08-27 | NULL |
-| Bowser | Diane | dog | m | 1998-08-31 | 1995-07-29 |
-| Chirpy | Gwen | bird | f | 1998-09-11 | NULL |
-| Whistler | Gwen | bird | NULL | 1997-12-09 | NULL |
-| Slim | Benny | snake | m | 1996-04-29 | NULL |
-| Puffball | Diane | hamster | f | 1999-03-30 | NULL |
-+----------+--------+---------+------+------------+------------+
-@end example
-
-This form of @code{SELECT} is useful if you want to review your entire table,
-for instance, after you've just loaded it with your initial dataset. As it
-happens, the output just shown reveals an error in your data file: Bowser
-appears to have been born after he died! Consulting your original pedigree
-papers, you find that the correct birth year is 1989, not 1998.
-
-There are are least a couple of ways to fix this:
-
-@itemize @bullet
-@item
-Edit the file @file{pet.txt} to correct the error, then empty the table
-and reload it using @code{DELETE} and @code{LOAD DATA}:
-
-@example
-mysql> SET AUTOCOMMIT=1; # Used for quick re-create of the table
-mysql> DELETE FROM pet;
-mysql> LOAD DATA LOCAL INFILE "pet.txt" INTO TABLE pet;
-@end example
-
-However, if you do this, you must also re-enter the record for Puffball.
-
-@item
-Fix only the erroneous record with an @code{UPDATE} statement:
-
-@example
-mysql> UPDATE pet SET birth = "1989-08-31" WHERE name = "Bowser";
-@end example
-@end itemize
-
-As shown above, it is easy to retrieve an entire table. But typically you
-don't want to do that, particularly when the table becomes large. Instead,
-you're usually more interested in answering a particular question, in which
-case you specify some constraints on the information you want. Let's look at
-some selection queries in terms of questions about your pets that they
-answer.
-
-@cindex rows, selecting
-@cindex tables, selecting rows
-@node Selecting rows, Selecting columns, Selecting all, Retrieving data
-@subsubsection Selecting Particular Rows
-
-You can select only particular rows from your table. For example, if you want
-to verify the change that you made to Bowser's birth date, select Bowser's
-record like this:
-
-@example
-mysql> SELECT * FROM pet WHERE name = "Bowser";
-+--------+-------+---------+------+------------+------------+
-| name | owner | species | sex | birth | death |
-+--------+-------+---------+------+------------+------------+
-| Bowser | Diane | dog | m | 1989-08-31 | 1995-07-29 |
-+--------+-------+---------+------+------------+------------+
-@end example
-
-The output confirms that the year is correctly recorded now as 1989, not 1998.
-
-String comparisons are normally case insensitive, so you can specify the
-name as @code{"bowser"}, @code{"BOWSER"}, etc. The query result will be
-the same.
-
-You can specify conditions on any column, not just @code{name}. For example,
-if you want to know which animals were born after 1998, test the @code{birth}
-column:
-
-@example
-mysql> SELECT * FROM pet WHERE birth >= "1998-1-1";
-+----------+-------+---------+------+------------+-------+
-| name | owner | species | sex | birth | death |
-+----------+-------+---------+------+------------+-------+
-| Chirpy | Gwen | bird | f | 1998-09-11 | NULL |
-| Puffball | Diane | hamster | f | 1999-03-30 | NULL |
-+----------+-------+---------+------+------------+-------+
-@end example
-
-You can combine conditions, for example, to locate female dogs:
-
-@example
-mysql> SELECT * FROM pet WHERE species = "dog" AND sex = "f";
-+-------+--------+---------+------+------------+-------+
-| name | owner | species | sex | birth | death |
-+-------+--------+---------+------+------------+-------+
-| Buffy | Harold | dog | f | 1989-05-13 | NULL |
-+-------+--------+---------+------+------------+-------+
-@end example
-
-The preceding query uses the @code{AND} logical operator. There is also an
-@code{OR} operator:
-
-@example
-mysql> SELECT * FROM pet WHERE species = "snake" OR species = "bird";
-+----------+-------+---------+------+------------+-------+
-| name | owner | species | sex | birth | death |
-+----------+-------+---------+------+------------+-------+
-| Chirpy | Gwen | bird | f | 1998-09-11 | NULL |
-| Whistler | Gwen | bird | NULL | 1997-12-09 | NULL |
-| Slim | Benny | snake | m | 1996-04-29 | NULL |
-+----------+-------+---------+------+------------+-------+
-@end example
-
-@code{AND} and @code{OR} may be intermixed. If you do that, it's a good idea
-to use parentheses to indicate how conditions should be grouped:
-
-@example
-mysql> SELECT * FROM pet WHERE (species = "cat" AND sex = "m")
- -> OR (species = "dog" AND sex = "f");
-+-------+--------+---------+------+------------+-------+
-| name | owner | species | sex | birth | death |
-+-------+--------+---------+------+------------+-------+
-| Claws | Gwen | cat | m | 1994-03-17 | NULL |
-| Buffy | Harold | dog | f | 1989-05-13 | NULL |
-+-------+--------+---------+------+------------+-------+
-@end example
-
-@cindex columns, selecting
-@cindex tables, selecting columns
-@node Selecting columns, Sorting rows, Selecting rows, Retrieving data
-@subsubsection Selecting Particular Columns
-
-
-If you don't want to see entire rows from your table, just name the columns
-in which you're interested, separated by commas. For example, if you want to
-know when your animals were born, select the @code{name} and @code{birth}
-columns:
-
-@example
-mysql> SELECT name, birth FROM pet;
-+----------+------------+
-| name | birth |
-+----------+------------+
-| Fluffy | 1993-02-04 |
-| Claws | 1994-03-17 |
-| Buffy | 1989-05-13 |
-| Fang | 1990-08-27 |
-| Bowser | 1989-08-31 |
-| Chirpy | 1998-09-11 |
-| Whistler | 1997-12-09 |
-| Slim | 1996-04-29 |
-| Puffball | 1999-03-30 |
-+----------+------------+
-@end example
-
-To find out who owns pets, use this query:
-
-@example
-mysql> SELECT owner FROM pet;
-+--------+
-| owner |
-+--------+
-| Harold |
-| Gwen |
-| Harold |
-| Benny |
-| Diane |
-| Gwen |
-| Gwen |
-| Benny |
-| Diane |
-+--------+
-@end example
-
-@findex DISTINCT
-However, notice that the query simply retrieves the @code{owner} field from
-each record, and some of them appear more than once. To minimize the output,
-retrieve each unique output record just once by adding the keyword
-@code{DISTINCT}:
-
-@example
-mysql> SELECT DISTINCT owner FROM pet;
-+--------+
-| owner |
-+--------+
-| Benny |
-| Diane |
-| Gwen |
-| Harold |
-+--------+
-@end example
-
-You can use a @code{WHERE} clause to combine row selection with column
-selection. For example, to get birth dates for dogs and cats only,
-use this query:
-
-@example
-mysql> SELECT name, species, birth FROM pet
- -> WHERE species = "dog" OR species = "cat";
-+--------+---------+------------+
-| name | species | birth |
-+--------+---------+------------+
-| Fluffy | cat | 1993-02-04 |
-| Claws | cat | 1994-03-17 |
-| Buffy | dog | 1989-05-13 |
-| Fang | dog | 1990-08-27 |
-| Bowser | dog | 1989-08-31 |
-+--------+---------+------------+
-@end example
-
-@cindex rows, sorting
-@cindex sorting, table rows
-@cindex sorting, data
-@cindex tables, sorting rows
-@node Sorting rows, Date calculations, Selecting columns, Retrieving data
-@subsubsection Sorting Rows
-
-You may have noticed in the preceding examples that the result rows are
-displayed in no particular order. However, it's often easier to examine
-query output when the rows are sorted in some meaningful way. To sort a
-result, use an @code{ORDER BY} clause.
-
-Here are animal birthdays, sorted by date:
-
-@example
-mysql> SELECT name, birth FROM pet ORDER BY birth;
-+----------+------------+
-| name | birth |
-+----------+------------+
-| Buffy | 1989-05-13 |
-| Bowser | 1989-08-31 |
-| Fang | 1990-08-27 |
-| Fluffy | 1993-02-04 |
-| Claws | 1994-03-17 |
-| Slim | 1996-04-29 |
-| Whistler | 1997-12-09 |
-| Chirpy | 1998-09-11 |
-| Puffball | 1999-03-30 |
-+----------+------------+
-@end example
-
-To sort in reverse order, add the @code{DESC} (descending) keyword to the
-name of the column you are sorting by:
-
-@example
-mysql> SELECT name, birth FROM pet ORDER BY birth DESC;
-+----------+------------+
-| name | birth |
-+----------+------------+
-| Puffball | 1999-03-30 |
-| Chirpy | 1998-09-11 |
-| Whistler | 1997-12-09 |
-| Slim | 1996-04-29 |
-| Claws | 1994-03-17 |
-| Fluffy | 1993-02-04 |
-| Fang | 1990-08-27 |
-| Bowser | 1989-08-31 |
-| Buffy | 1989-05-13 |
-+----------+------------+
-@end example
-
-You can sort on multiple columns. For example, to sort by type of
-animal, then by birth date within animal type with youngest animals first,
-use the following query:
-
-@example
-mysql> SELECT name, species, birth FROM pet ORDER BY species, birth DESC;
-+----------+---------+------------+
-| name | species | birth |
-+----------+---------+------------+
-| Chirpy | bird | 1998-09-11 |
-| Whistler | bird | 1997-12-09 |
-| Claws | cat | 1994-03-17 |
-| Fluffy | cat | 1993-02-04 |
-| Fang | dog | 1990-08-27 |
-| Bowser | dog | 1989-08-31 |
-| Buffy | dog | 1989-05-13 |
-| Puffball | hamster | 1999-03-30 |
-| Slim | snake | 1996-04-29 |
-+----------+---------+------------+
-@end example
-
-Note that the @code{DESC} keyword applies only to the column name immediately
-preceding it (@code{birth}); @code{species} values are still sorted in
-ascending order.
-
-@cindex date calculations
-@cindex calculating, dates
-@cindex extracting, dates
-@cindex age, calculating
-@node Date calculations, Working with NULL, Sorting rows, Retrieving data
-@subsubsection Date Calculations
-
-@strong{MySQL} provides several functions that you can use to perform
-calculations on dates, for example, to calculate ages or extract
-parts of dates.
-
-To determine how many years old each of your pets is, compute age as the
-difference between the birth date and the current date. Do this by
-converting the two dates to days, take the difference, and divide by 365 (the
-number of days in a year):
-
-@example
-mysql> SELECT name, (TO_DAYS(NOW())-TO_DAYS(birth))/365 FROM pet;
-+----------+-------------------------------------+
-| name | (TO_DAYS(NOW())-TO_DAYS(birth))/365 |
-+----------+-------------------------------------+
-| Fluffy | 6.15 |
-| Claws | 5.04 |
-| Buffy | 9.88 |
-| Fang | 8.59 |
-| Bowser | 9.58 |
-| Chirpy | 0.55 |
-| Whistler | 1.30 |
-| Slim | 2.92 |
-| Puffball | 0.00 |
-+----------+-------------------------------------+
-@end example
-
-Although the query works, there are some things about it that could be
-improved. First, the result could be scanned more easily if the rows were
-presented in some order. Second, the heading for the age column isn't very
-meaningful.
-
-The first problem can be handled by adding an @code{ORDER BY name} clause to
-sort the output by name. To deal with the column heading, provide a name for
-the column so that a different label appears in the output (this is called a
-column alias):
-
-@example
-mysql> SELECT name, (TO_DAYS(NOW())-TO_DAYS(birth))/365 AS age
- -> FROM pet ORDER BY name;
-+----------+------+
-| name | age |
-+----------+------+
-| Bowser | 9.58 |
-| Buffy | 9.88 |
-| Chirpy | 0.55 |
-| Claws | 5.04 |
-| Fang | 8.59 |
-| Fluffy | 6.15 |
-| Puffball | 0.00 |
-| Slim | 2.92 |
-| Whistler | 1.30 |
-+----------+------+
-@end example
-
-To sort the output by @code{age} rather than @code{name}, just use a
-different @code{ORDER BY} clause:
-
-@example
-mysql> SELECT name, (TO_DAYS(NOW())-TO_DAYS(birth))/365 AS age
- -> FROM pet ORDER BY age;
-+----------+------+
-| name | age |
-+----------+------+
-| Puffball | 0.00 |
-| Chirpy | 0.55 |
-| Whistler | 1.30 |
-| Slim | 2.92 |
-| Claws | 5.04 |
-| Fluffy | 6.15 |
-| Fang | 8.59 |
-| Bowser | 9.58 |
-| Buffy | 9.88 |
-+----------+------+
-@end example
-
-A similar query can be used to determine age at death for animals that have
-died. You determine which animals these are by checking whether or not the
-@code{death} value is @code{NULL}. Then, for those with non-@code{NULL}
-values, compute the difference between the @code{death} and @code{birth}
-values:
-
-@example
-mysql> SELECT name, birth, death, (TO_DAYS(death)-TO_DAYS(birth))/365 AS age
- -> FROM pet WHERE death IS NOT NULL ORDER BY age;
-+--------+------------+------------+------+
-| name | birth | death | age |
-+--------+------------+------------+------+
-| Bowser | 1989-08-31 | 1995-07-29 | 5.91 |
-+--------+------------+------------+------+
-@end example
-
-The query uses @code{death IS NOT NULL} rather than @code{death != NULL}
-because @code{NULL} is a special value. This is explained later.
-@xref{Working with NULL, , Working with @code{NULL}}.
-
-What if you want to know which animals have birthdays next month? For this
-type of calculation, year and day are irrelevant; you simply want to extract
-the month part of the @code{birth} column. @strong{MySQL} provides several
-date-part extraction functions, such as @code{YEAR()}, @code{MONTH()}, and
-@code{DAYOFMONTH()}. @code{MONTH()} is the appropriate function here. To
-see how it works, run a simple query that displays the value of both
-@code{birth} and @code{MONTH(birth)}:
-
-@example
-mysql> SELECT name, birth, MONTH(birth) FROM pet;
-+----------+------------+--------------+
-| name | birth | MONTH(birth) |
-+----------+------------+--------------+
-| Fluffy | 1993-02-04 | 2 |
-| Claws | 1994-03-17 | 3 |
-| Buffy | 1989-05-13 | 5 |
-| Fang | 1990-08-27 | 8 |
-| Bowser | 1989-08-31 | 8 |
-| Chirpy | 1998-09-11 | 9 |
-| Whistler | 1997-12-09 | 12 |
-| Slim | 1996-04-29 | 4 |
-| Puffball | 1999-03-30 | 3 |
-+----------+------------+--------------+
-@end example
-
-Finding animals with birthdays in the upcoming month is easy, too. Suppose
-the current month is April. Then the month value is @code{4} and you look
-for animals born in May (month 5) like this:
-
-@example
-mysql> SELECT name, birth FROM pet WHERE MONTH(birth) = 5;
-+-------+------------+
-| name | birth |
-+-------+------------+
-| Buffy | 1989-05-13 |
-+-------+------------+
-@end example
-
-There is a small complication if the current month is December, of course.
-You don't just add one to the month number (@code{12}) and look for animals
-born in month 13, because there is no such month. Instead, you look for
-animals born in January (month 1).
-
-You can even write the query so that it works no matter what the current
-month is. That way you don't have to use a particular month number
-in the query. @code{DATE_ADD()} allows you to add a time interval to a
-given date. If you add a month to the value of @code{NOW()}, then extract
-the month part with @code{MONTH()}, the result produces the month in which to
-look for birthdays:
-
-@example
-mysql> SELECT name, birth FROM pet
- -> WHERE MONTH(birth) = MONTH(DATE_ADD(NOW(), INTERVAL 1 MONTH));
-@end example
-
-A different way to accomplish the same task is to add @code{1} to get the
-next month after the current one (after using the modulo function (@code{MOD})
-to wrap around the month value to @code{0} if it is currently
-@code{12}):
-
-@example
-mysql> SELECT name, birth FROM pet
- -> WHERE MONTH(birth) = MOD(MONTH(NOW()), 12) + 1;
-@end example
-
-Note that @code{MONTH} returns a number between 1 and 12. And
-@code{MOD(something,12)} returns a number between 0 and 11. So the
-addition has to be after the @code{MOD()} otherwise we would go from
-November (11) to January (1).
-
-@findex NULL
-@cindex NULL value
-@node Working with NULL, Pattern matching, Date calculations, Retrieving data
-@subsubsection Working with @code{NULL} Values
-
-The @code{NULL} value can be surprising until you get used to it.
-Conceptually, @code{NULL} means missing value or unknown value and it
-is treated somewhat differently than other values. To test for @code{NULL},
-you cannot use the arithmetic comparison operators such as @code{=}, @code{<},
-or @code{!=}. To demonstrate this for yourself, try the following query:
-
-@example
-mysql> SELECT 1 = NULL, 1 != NULL, 1 < NULL, 1 > NULL;
-+----------+-----------+----------+----------+
-| 1 = NULL | 1 != NULL | 1 < NULL | 1 > NULL |
-+----------+-----------+----------+----------+
-| NULL | NULL | NULL | NULL |
-+----------+-----------+----------+----------+
-@end example
-
-Clearly you get no meaningful results from these comparisons. Use
-the @code{IS NULL} and @code{IS NOT NULL} operators instead:
-
-@example
-mysql> SELECT 1 IS NULL, 1 IS NOT NULL;
-+-----------+---------------+
-| 1 IS NULL | 1 IS NOT NULL |
-+-----------+---------------+
-| 0 | 1 |
-+-----------+---------------+
-@end example
-
-In @strong{MySQL}, 0 or @code{NULL} means false and anything else means true.
-The default truth value from a boolean operation is 1.
-
-This special treatment of @code{NULL} is why, in the previous section, it
-was necessary to determine which animals are no longer alive using
-@code{death IS NOT NULL} instead of @code{death != NULL}.
-
-@cindex pattern matching
-@cindex matching, patterns
-@cindex expressions, extended
-@node Pattern matching, Counting rows, Working with NULL, Retrieving data
-@subsubsection Pattern Matching
-
-@strong{MySQL} provides standard SQL pattern matching as well as a form of
-pattern matching based on extended regular expressions similar to those used
-by Unix utilities such as @code{vi}, @code{grep}, and @code{sed}.
-
-SQL pattern matching allows you to use @samp{_} to match any single
-character and @samp{%} to match an arbitrary number of characters (including
-zero characters). In @strong{MySQL}, SQL patterns are case insensitive by
-default. Some examples are shown below. Note that you do not use @code{=}
-or @code{!=} when you use SQL patterns; use the @code{LIKE} or @code{NOT
-LIKE} comparison operators instead.
-
-To find names beginning with @samp{b}:
-
-@example
-mysql> SELECT * FROM pet WHERE name LIKE "b%";
-+--------+--------+---------+------+------------+------------+
-| name | owner | species | sex | birth | death |
-+--------+--------+---------+------+------------+------------+
-| Buffy | Harold | dog | f | 1989-05-13 | NULL |
-| Bowser | Diane | dog | m | 1989-08-31 | 1995-07-29 |
-+--------+--------+---------+------+------------+------------+
-@end example
-
-To find names ending with @samp{fy}:
-
-@example
-mysql> SELECT * FROM pet WHERE name LIKE "%fy";
-+--------+--------+---------+------+------------+-------+
-| name | owner | species | sex | birth | death |
-+--------+--------+---------+------+------------+-------+
-| Fluffy | Harold | cat | f | 1993-02-04 | NULL |
-| Buffy | Harold | dog | f | 1989-05-13 | NULL |
-+--------+--------+---------+------+------------+-------+
-@end example
-
-To find names containing a @samp{w}:
-
-@example
-mysql> SELECT * FROM pet WHERE name LIKE "%w%";
-+----------+-------+---------+------+------------+------------+
-| name | owner | species | sex | birth | death |
-+----------+-------+---------+------+------------+------------+
-| Claws | Gwen | cat | m | 1994-03-17 | NULL |
-| Bowser | Diane | dog | m | 1989-08-31 | 1995-07-29 |
-| Whistler | Gwen | bird | NULL | 1997-12-09 | NULL |
-+----------+-------+---------+------+------------+------------+
-@end example
-
-To find names containing exactly five characters, use the @samp{_} pattern
-character:
-
-@example
-mysql> SELECT * FROM pet WHERE name LIKE "_____";
-+-------+--------+---------+------+------------+-------+
-| name | owner | species | sex | birth | death |
-+-------+--------+---------+------+------------+-------+
-| Claws | Gwen | cat | m | 1994-03-17 | NULL |
-| Buffy | Harold | dog | f | 1989-05-13 | NULL |
-+-------+--------+---------+------+------------+-------+
-@end example
-
-The other type of pattern matching provided by @strong{MySQL} uses extended
-regular expressions. When you test for a match for this type of pattern, use
-the @code{REGEXP} and @code{NOT REGEXP} operators (or @code{RLIKE} and
-@code{NOT RLIKE}, which are synonyms).
-
-Some characteristics of extended regular expressions are:
-
-@itemize @bullet
-@item
-@samp{.} matches any single character.
-
-@item
-A character class @samp{[...]} matches any character within the brackets.
-For example, @samp{[abc]} matches @samp{a}, @samp{b}, or @samp{c}. To name a
-range of characters, use a dash. @samp{[a-z]} matches any lowercase letter,
-whereas @samp{[0-9]} matches any digit.
-
-@item
-@samp{*} matches zero or more instances of the thing preceding it. For
-example, @samp{x*} matches any number of @samp{x} characters,
-@samp{[0-9]*} matches any number of digits, and @samp{.*} matches any
-number of anything.
-
-@item
-Regular expressions are case sensitive, but you can use a character class to
-match both lettercases if you wish. For example, @samp{[aA]} matches
-lowercase or uppercase @samp{a} and @samp{[a-zA-Z]} matches any letter in
-either case.
-
-@item
-The pattern matches if it occurs anywhere in the value being tested.
-(SQL patterns match only if they match the entire value.)
-
-@item
-To anchor a pattern so that it must match the beginning or end of the value
-being tested, use @samp{^} at the beginning or @samp{$} at the end of the
-pattern.
-@end itemize
-
-To demonstrate how extended regular expressions work, the @code{LIKE} queries
-shown above are rewritten below to use @code{REGEXP}.
-
-To find names beginning with @samp{b}, use @samp{^} to match the beginning of
-the name:
-
-@example
-mysql> SELECT * FROM pet WHERE name REGEXP "^b";
-+--------+--------+---------+------+------------+------------+
-| name | owner | species | sex | birth | death |
-+--------+--------+---------+------+------------+------------+
-| Buffy | Harold | dog | f | 1989-05-13 | NULL |
-| Bowser | Diane | dog | m | 1989-08-31 | 1995-07-29 |
-+--------+--------+---------+------+------------+------------+
-@end example
-
-Prior to @strong{MySQL} Version 3.23.4, @code{REGEXP} is case sensitive,
-and the previous query will return no rows. To match either lowercase or
-uppercase @samp{b}, use this query instead:
-
-@example
-mysql> SELECT * FROM pet WHERE name REGEXP "^[bB]";
-@end example
-
-From @strong{MySQL} 3.23.4 on, to force a @code{REGEXP} comparison to
-be case sensitive, use the @code{BINARY} keyword to make one of the
-strings a binary string. This query will match only lowercase @samp{b}
-at the beginning of a name:
-
-@example
-mysql> SELECT * FROM pet WHERE name REGEXP BINARY "^b";
-@end example
-
-To find names ending with @samp{fy}, use @samp{$} to match the end of the
-name:
-
-@example
-mysql> SELECT * FROM pet WHERE name REGEXP "fy$";
-+--------+--------+---------+------+------------+-------+
-| name | owner | species | sex | birth | death |
-+--------+--------+---------+------+------------+-------+
-| Fluffy | Harold | cat | f | 1993-02-04 | NULL |
-| Buffy | Harold | dog | f | 1989-05-13 | NULL |
-+--------+--------+---------+------+------------+-------+
-@end example
-
-To find names containing a lowercase or uppercase @samp{w}, use this query:
-
-@example
-mysql> SELECT * FROM pet WHERE name REGEXP "w";
-+----------+-------+---------+------+------------+------------+
-| name | owner | species | sex | birth | death |
-+----------+-------+---------+------+------------+------------+
-| Claws | Gwen | cat | m | 1994-03-17 | NULL |
-| Bowser | Diane | dog | m | 1989-08-31 | 1995-07-29 |
-| Whistler | Gwen | bird | NULL | 1997-12-09 | NULL |
-+----------+-------+---------+------+------------+------------+
-@end example
-
-Because a regular expression pattern matches if it occurs anywhere in the
-value, it is not necessary in the previous query to put a wild card on either
-side of the pattern to get it to match the entire value like it would be if
-you used a SQL pattern.
-
-To find names containing exactly five characters, use @samp{^} and @samp{$}
-to match the beginning and end of the name, and five instances of @samp{.}
-in between:
-
-@example
-mysql> SELECT * FROM pet WHERE name REGEXP "^.....$";
-+-------+--------+---------+------+------------+-------+
-| name | owner | species | sex | birth | death |
-+-------+--------+---------+------+------------+-------+
-| Claws | Gwen | cat | m | 1994-03-17 | NULL |
-| Buffy | Harold | dog | f | 1989-05-13 | NULL |
-+-------+--------+---------+------+------------+-------+
-@end example
-
-You could also write the previous query using the @samp{@{n@}}
-``repeat-@code{n}-times'' operator:
-
-@example
-mysql> SELECT * FROM pet WHERE name REGEXP "^.@{5@}$";
-+-------+--------+---------+------+------------+-------+
-| name | owner | species | sex | birth | death |
-+-------+--------+---------+------+------------+-------+
-| Claws | Gwen | cat | m | 1994-03-17 | NULL |
-| Buffy | Harold | dog | f | 1989-05-13 | NULL |
-+-------+--------+---------+------+------------+-------+
-@end example
-
-@cindex rows, counting
-@cindex tables, counting rows
-@cindex counting, table rows
-@node Counting rows, Multiple tables, Pattern matching, Retrieving data
-@subsubsection Counting Rows
-
-Databases are often used to answer the question, ``How often does a certain
-type of data occur in a table?'' For example, you might want to know how
-many pets you have, or how many pets each owner has, or you might want to
-perform various kinds of censuses on your animals.
-
-Counting the total number of animals you have is the same question as ``How
-many rows are in the @code{pet} table?'' because there is one record per pet.
-The @code{COUNT()} function counts the number of non-@code{NULL} results, so
-the query to count your animals looks like this:
-
-@example
-mysql> SELECT COUNT(*) FROM pet;
-+----------+
-| COUNT(*) |
-+----------+
-| 9 |
-+----------+
-@end example
-
-Earlier, you retrieved the names of the people who owned pets. You can
-use @code{COUNT()} if you want to find out how many pets each owner has:
-
-@example
-mysql> SELECT owner, COUNT(*) FROM pet GROUP BY owner;
-+--------+----------+
-| owner | COUNT(*) |
-+--------+----------+
-| Benny | 2 |
-| Diane | 2 |
-| Gwen | 3 |
-| Harold | 2 |
-+--------+----------+
-@end example
-
-Note the use of @code{GROUP BY} to group together all records for each
-@code{owner}. Without it, all you get is an error message:
-
-@example
-mysql> SELECT owner, COUNT(owner) FROM pet;
-ERROR 1140 at line 1: Mixing of GROUP columns (MIN(),MAX(),COUNT()...)
-with no GROUP columns is illegal if there is no GROUP BY clause
-@end example
-
-@code{COUNT()} and @code{GROUP BY} are useful for characterizing your
-data in various ways. The following examples show different ways to
-perform animal census operations.
-
-Number of animals per species:
-
-@example
-mysql> SELECT species, COUNT(*) FROM pet GROUP BY species;
-+---------+----------+
-| species | COUNT(*) |
-+---------+----------+
-| bird | 2 |
-| cat | 2 |
-| dog | 3 |
-| hamster | 1 |
-| snake | 1 |
-+---------+----------+
-@end example
-
-Number of animals per sex:
-
-@example
-mysql> SELECT sex, COUNT(*) FROM pet GROUP BY sex;
-+------+----------+
-| sex | COUNT(*) |
-+------+----------+
-| NULL | 1 |
-| f | 4 |
-| m | 4 |
-+------+----------+
-@end example
-
-(In this output, @code{NULL} indicates sex unknown.)
-
-Number of animals per combination of species and sex:
-
-@example
-mysql> SELECT species, sex, COUNT(*) FROM pet GROUP BY species, sex;
-+---------+------+----------+
-| species | sex | COUNT(*) |
-+---------+------+----------+
-| bird | NULL | 1 |
-| bird | f | 1 |
-| cat | f | 1 |
-| cat | m | 1 |
-| dog | f | 1 |
-| dog | m | 2 |
-| hamster | f | 1 |
-| snake | m | 1 |
-+---------+------+----------+
-@end example
-
-You need not retrieve an entire table when you use @code{COUNT()}. For
-example, the previous query, when performed just on dogs and cats, looks like
-this:
-
-@example
-mysql> SELECT species, sex, COUNT(*) FROM pet
- -> WHERE species = "dog" OR species = "cat"
- -> GROUP BY species, sex;
-+---------+------+----------+
-| species | sex | COUNT(*) |
-+---------+------+----------+
-| cat | f | 1 |
-| cat | m | 1 |
-| dog | f | 1 |
-| dog | m | 2 |
-+---------+------+----------+
-@end example
-
-Or, if you wanted the number of animals per sex only for known-sex animals:
-
-@example
-mysql> SELECT species, sex, COUNT(*) FROM pet
- -> WHERE sex IS NOT NULL
- -> GROUP BY species, sex;
-+---------+------+----------+
-| species | sex | COUNT(*) |
-+---------+------+----------+
-| bird | f | 1 |
-| cat | f | 1 |
-| cat | m | 1 |
-| dog | f | 1 |
-| dog | m | 2 |
-| hamster | f | 1 |
-| snake | m | 1 |
-+---------+------+----------+
-@end example
-
-@cindex tables, multiple
-@node Multiple tables, , Counting rows, Retrieving data
-@subsubsection Using More Than one Table
-
-The @code{pet} table keeps track of which pets you have. If you want to
-record other information about them, such as events in their lives like
-visits to the vet or when litters are born, you need another table. What
-should this table look like? It needs:
-
-@itemize @bullet
-@item
-To contain the pet name so you know which animal each event pertains
-to.
-
-@item
-A date so you know when the event occurred.
-
-@item
-A field to describe the event.
-
-@item
-An event type field, if you want to be able to categorize events.
-@end itemize
-
-Given these considerations, the @code{CREATE TABLE} statement for the
-@code{event} table might look like this:
-
-@example
-mysql> CREATE TABLE event (name VARCHAR(20), date DATE,
- -> type VARCHAR(15), remark VARCHAR(255));
-@end example
-
-As with the @code{pet} table, it's easiest to load the initial records
-by creating a tab-delimited text file containing the information:
-
-@multitable @columnfractions .15 .15 .15 .55
-@item Fluffy @tab 1995-05-15 @tab litter @tab 4 kittens, 3 female, 1 male
-@item Buffy @tab 1993-06-23 @tab litter @tab 5 puppies, 2 female, 3 male
-@item Buffy @tab 1994-06-19 @tab litter @tab 3 puppies, 3 female
-@item Chirpy @tab 1999-03-21 @tab vet @tab needed beak straightened
-@item Slim @tab 1997-08-03 @tab vet @tab broken rib
-@item Bowser @tab 1991-10-12 @tab kennel
-@item Fang @tab 1991-10-12 @tab kennel
-@item Fang @tab 1998-08-28 @tab birthday @tab Gave him a new chew toy
-@item Claws @tab 1998-03-17 @tab birthday @tab Gave him a new flea collar
-@item Whistler @tab 1998-12-09 @tab birthday @tab First birthday
-@end multitable
-
-Load the records like this:
-
-@example
-mysql> LOAD DATA LOCAL INFILE "event.txt" INTO TABLE event;
-@end example
-
-Based on what you've learned from the queries you've run on the @code{pet}
-table, you should be able to perform retrievals on the records in the
-@code{event} table; the principles are the same. But when is the
-@code{event} table by itself insufficient to answer questions you might ask?
-
-Suppose you want to find out the ages of each pet when they had their
-litters. The @code{event} table indicates when this occurred, but to
-calculate the age of the mother, you need her birth date. Because that is
-stored in the @code{pet} table, you need both tables for the query:
-
-@example
-mysql> SELECT pet.name, (TO_DAYS(date) - TO_DAYS(birth))/365 AS age, remark
- -> FROM pet, event
- -> WHERE pet.name = event.name AND type = "litter";
-+--------+------+-----------------------------+
-| name | age | remark |
-+--------+------+-----------------------------+
-| Fluffy | 2.27 | 4 kittens, 3 female, 1 male |
-| Buffy | 4.12 | 5 puppies, 2 female, 3 male |
-| Buffy | 5.10 | 3 puppies, 3 female |
-+--------+------+-----------------------------+
-@end example
-
-There are several things to note about this query:
-
-@itemize @bullet
-@item
-The @code{FROM} clause lists two tables because the query needs to pull
-information from both of them.
-
-@item
-When combining (joining) information from multiple tables, you need to
-specify how records in one table can be matched to records in the other.
-This is easy because they both have a @code{name} column. The query uses
-@code{WHERE} clause to match up records in the two tables based on the
-@code{name} values.
-@item
-Because the @code{name} column occurs in both tables, you must be specific
-about which table you mean when referring to the column. This is done
-by prepending the table name to the column name.
-@end itemize
-
-You need not have two different tables to perform a join. Sometimes it is
-useful to join a table to itself, if you want to compare records in a table
-to other records in that same table. For example, to find breeding pairs
-among your pets, you can join the @code{pet} table with itself to pair up
-males and females of like species:
-
-@example
-mysql> SELECT p1.name, p1.sex, p2.name, p2.sex, p1.species
- -> FROM pet AS p1, pet AS p2
- -> WHERE p1.species = p2.species AND p1.sex = "f" AND p2.sex = "m";
-+--------+------+--------+------+---------+
-| name | sex | name | sex | species |
-+--------+------+--------+------+---------+
-| Fluffy | f | Claws | m | cat |
-| Buffy | f | Fang | m | dog |
-| Buffy | f | Bowser | m | dog |
-+--------+------+--------+------+---------+
-@end example
-
-In this query, we specify aliases for the table name in order
-to refer to the columns and keep straight which instance of the table
-each column reference is associated with.
-
-@cindex databases, information about
-@cindex tables, information about
-@findex DESCRIBE
-@node Getting information, Examples, Database use, Tutorial
-@section Getting Information About Databases and Tables
-
-What if you forget the name of a database or table, or what the structure of
-a given table is (for example, what its columns are called)? @strong{MySQL}
-addresses this problem through several statements that provide information
-about the databases and tables it supports.
-
-You have already seen @code{SHOW DATABASES}, which lists the databases
-managed by the server. To find out which database is currently selected,
-use the @code{DATABASE()} function:
-
-@example
-mysql> SELECT DATABASE();
-+------------+
-| DATABASE() |
-+------------+
-| menagerie |
-+------------+
-@end example
-
-If you haven't selected any database yet, the result is blank.
-
-To find out what tables the current database contains (for example, when
-you're not sure about the name of a table), use this command:
-
-@example
-mysql> SHOW TABLES;
-+---------------------+
-| Tables in menagerie |
-+---------------------+
-| event |
-| pet |
-+---------------------+
-@end example
-
-If you want to find out about the structure of a table, the @code{DESCRIBE}
-command is useful; it displays information about each of a table's columns:
-
-@example
-mysql> DESCRIBE pet;
-+---------+-------------+------+-----+---------+-------+
-| Field | Type | Null | Key | Default | Extra |
-+---------+-------------+------+-----+---------+-------+
-| name | varchar(20) | YES | | NULL | |
-| owner | varchar(20) | YES | | NULL | |
-| species | varchar(20) | YES | | NULL | |
-| sex | char(1) | YES | | NULL | |
-| birth | date | YES | | NULL | |
-| death | date | YES | | NULL | |
-+---------+-------------+------+-----+---------+-------+
-@end example
-
-@code{Field} indicates the column name, @code{Type} is the data type for
-the column, @code{Null} indicates whether or not the column can contain
-@code{NULL} values, @code{Key} indicates whether or not the column is
-indexed, and @code{Default} specifies the column's default value.
-
-If you have indexes on a table,
-@code{SHOW INDEX FROM tbl_name} produces information about them.
-
-@cindex queries, examples
-@cindex examples, queries
-@node Examples, Batch mode, Getting information, Tutorial
-@section Examples of Common Queries
-
-Here are examples of how to solve some common problems with
-@strong{MySQL}.
-
-Some of the examples use the table @code{shop} to hold the price of each
-article (item number) for certain traders (dealers). Supposing that each
-trader has a single fixed price per article, then (@code{item},
-@code{trader}) is a primary key for the records.
-
-Start the command line tool @code{mysql} and select a database:
-
-@example
-mysql your-database-name
-@end example
-
-(In most @strong{MySQL} installations, you can use the database-name 'test').
-
-You can create the example table as:
-
-@example
-CREATE TABLE shop (
- article INT(4) UNSIGNED ZEROFILL DEFAULT '0000' NOT NULL,
- dealer CHAR(20) DEFAULT '' NOT NULL,
- price DOUBLE(16,2) DEFAULT '0.00' NOT NULL,
- PRIMARY KEY(article, dealer));
-
-INSERT INTO shop VALUES
-(1,'A',3.45),(1,'B',3.99),(2,'A',10.99),(3,'B',1.45),(3,'C',1.69),
-(3,'D',1.25),(4,'D',19.95);
-@end example
-
-Okay, so the example data is:
-
-@example
-mysql> SELECT * FROM shop;
-
-+---------+--------+-------+
-| article | dealer | price |
-+---------+--------+-------+
-| 0001 | A | 3.45 |
-| 0001 | B | 3.99 |
-| 0002 | A | 10.99 |
-| 0003 | B | 1.45 |
-| 0003 | C | 1.69 |
-| 0003 | D | 1.25 |
-| 0004 | D | 19.95 |
-+---------+--------+-------+
-@end example
-
-@menu
-* example-Maximum-column:: The maximum value for a column
-* example-Maximum-row:: The row holding the maximum of a certain column
-* example-Maximum-column-group:: Maximum of column per group
-* example-Maximum-column-group-row:: The rows holding the group-wise maximum of a certain field
-* example-user-variables:: Using user variables
-* example-Foreign keys:: Using foreign keys
-* Searching on two keys::
-* Calculating days::
-@end menu
-
-@node example-Maximum-column, example-Maximum-row, Examples, Examples
-@subsection The Maximum Value for a Column
-
-``What's the highest item number?''
-
-@example
-SELECT MAX(article) AS article FROM shop
-
-+---------+
-| article |
-+---------+
-| 4 |
-+---------+
-@end example
-
-@node example-Maximum-row, example-Maximum-column-group, example-Maximum-column, Examples
-@subsection The Row Holding the Maximum of a Certain Column
-
-``Find number, dealer, and price of the most expensive article.''
-
-In ANSI SQL this is easily done with a sub-query:
-
-@example
-SELECT article, dealer, price
-FROM shop
-WHERE price=(SELECT MAX(price) FROM shop)
-@end example
-
-In @strong{MySQL} (which does not yet have sub-selects), just do it in
-two steps:
-
-@enumerate
-@item
-Get the maximum price value from the table with a @code{SELECT} statement.
-@item
-Using this value compile the actual query:
-@example
-SELECT article, dealer, price
-FROM shop
-WHERE price=19.95
-@end example
-@end enumerate
-
-Another solution is to sort all rows descending by price and only
-get the first row using the @strong{MySQL} specific @code{LIMIT} clause:
-
-@example
-SELECT article, dealer, price
-FROM shop
-ORDER BY price DESC
-LIMIT 1
-@end example
-
-@strong{NOTE}: If there are several most expensive articles (for example, each 19.95)
-the @code{LIMIT} solution shows only one of them!
-
-@node example-Maximum-column-group, example-Maximum-column-group-row, example-Maximum-row, Examples
-@subsection Maximum of Column per Group
-
-``What's the highest price per article?''
-
-@example
-SELECT article, MAX(price) AS price
-FROM shop
-GROUP BY article
-
-+---------+-------+
-| article | price |
-+---------+-------+
-| 0001 | 3.99 |
-| 0002 | 10.99 |
-| 0003 | 1.69 |
-| 0004 | 19.95 |
-+---------+-------+
-@end example
-
-@node example-Maximum-column-group-row, example-user-variables, example-Maximum-column-group, Examples
-@subsection The Rows Holding the Group-wise Maximum of a Certain Field
-
-``For each article, find the dealer(s) with the most expensive price.''
-
-In ANSI SQL, I'd do it with a sub-query like this:
-
-@example
-SELECT article, dealer, price
-FROM shop s1
-WHERE price=(SELECT MAX(s2.price)
- FROM shop s2
- WHERE s1.article = s2.article);
-@end example
-
-In @strong{MySQL} it's best do it in several steps:
-
-@enumerate
-@item
-Get the list of (article,maxprice).
-@item
-For each article get the corresponding rows that have the stored maximum
-price.
-@end enumerate
-
-This can easily be done with a temporary table:
-
-@example
-CREATE TEMPORARY TABLE tmp (
- article INT(4) UNSIGNED ZEROFILL DEFAULT '0000' NOT NULL,
- price DOUBLE(16,2) DEFAULT '0.00' NOT NULL);
-
-LOCK TABLES shop read;
-
-INSERT INTO tmp SELECT article, MAX(price) FROM shop GROUP BY article;
-
-SELECT shop.article, dealer, shop.price FROM shop, tmp
-WHERE shop.article=tmp.article AND shop.price=tmp.price;
-
-UNLOCK TABLES;
-
-DROP TABLE tmp;
-@end example
-
-If you don't use a @code{TEMPORARY} table, you must also lock the 'tmp' table.
-
-``Can it be done with a single query?''
-
-Yes, but only by using a quite inefficient trick that I call the
-``MAX-CONCAT trick'':
-
-@example
-SELECT article,
- SUBSTRING( MAX( CONCAT(LPAD(price,6,'0'),dealer) ), 7) AS dealer,
- 0.00+LEFT( MAX( CONCAT(LPAD(price,6,'0'),dealer) ), 6) AS price
-FROM shop
-GROUP BY article;
-
-+---------+--------+-------+
-| article | dealer | price |
-+---------+--------+-------+
-| 0001 | B | 3.99 |
-| 0002 | A | 10.99 |
-| 0003 | C | 1.69 |
-| 0004 | D | 19.95 |
-+---------+--------+-------+
-@end example
-
-The last example can, of course, be made a bit more efficient by doing the
-splitting of the concatenated column in the client.
-
-@node example-user-variables, example-Foreign keys, example-Maximum-column-group-row, Examples
-@subsection Using user variables
-
-You can use @strong{MySQL} user variables to remember results without
-having to store them in a temporary variables in the client.
-@xref{Variables}.
-
-For example, to find the articles with the highest and lowest price you
-can do:
-
-@example
-select @@min_price:=min(price),@@max_price:=max(price) from shop;
-select * from shop where price=@@min_price or price=@@max_price;
-
-+---------+--------+-------+
-| article | dealer | price |
-+---------+--------+-------+
-| 0003 | D | 1.25 |
-| 0004 | D | 19.95 |
-+---------+--------+-------+
-@end example
-
-@cindex foreign keys
-@cindex keys, foreign
-@node example-Foreign keys, Searching on two keys, example-user-variables, Examples
-@subsection Using Foreign Keys
-
-You don't need foreign keys to join 2 tables.
-
-The only thing @strong{MySQL} doesn't do is @code{CHECK} to make sure that
-the keys you use really exist in the table(s) you're referencing and it
-doesn't automatically delete rows from table with a foreign key
-definition. If you use your keys like normal, it'll work just fine:
-
-
-@example
-CREATE TABLE persons (
- id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
- name CHAR(60) NOT NULL,
- PRIMARY KEY (id)
-);
-
-CREATE TABLE shirts (
- id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
- style ENUM('t-shirt', 'polo', 'dress') NOT NULL,
- color ENUM('red', 'blue', 'orange', 'white', 'black') NOT NULL,
- owner SMALLINT UNSIGNED NOT NULL REFERENCES persons,
- PRIMARY KEY (id)
-);
-
-
-INSERT INTO persons VALUES (NULL, 'Antonio Paz');
-
-INSERT INTO shirts VALUES
-(NULL, 'polo', 'blue', LAST_INSERT_ID()),
-(NULL, 'dress', 'white', LAST_INSERT_ID()),
-(NULL, 't-shirt', 'blue', LAST_INSERT_ID());
-
-
-INSERT INTO persons VALUES (NULL, 'Lilliana Angelovska');
-
-INSERT INTO shirts VALUES
-(NULL, 'dress', 'orange', LAST_INSERT_ID()),
-(NULL, 'polo', 'red', LAST_INSERT_ID()),
-(NULL, 'dress', 'blue', LAST_INSERT_ID()),
-(NULL, 't-shirt', 'white', LAST_INSERT_ID());
-
-
-SELECT * FROM persons;
-+----+---------------------+
-| id | name |
-+----+---------------------+
-| 1 | Antonio Paz |
-| 2 | Lilliana Angelovska |
-+----+---------------------+
-
-SELECT * FROM shirts;
-+----+---------+--------+-------+
-| id | style | color | owner |
-+----+---------+--------+-------+
-| 1 | polo | blue | 1 |
-| 2 | dress | white | 1 |
-| 3 | t-shirt | blue | 1 |
-| 4 | dress | orange | 2 |
-| 5 | polo | red | 2 |
-| 6 | dress | blue | 2 |
-| 7 | t-shirt | white | 2 |
-+----+---------+--------+-------+
-
-
-SELECT s.* FROM persons p, shirts s
- WHERE p.name LIKE 'Lilliana%'
- AND s.owner = p.id
- AND s.color <> 'white';
-
-+----+-------+--------+-------+
-| id | style | color | owner |
-+----+-------+--------+-------+
-| 4 | dress | orange | 2 |
-| 5 | polo | red | 2 |
-| 6 | dress | blue | 2 |
-+----+-------+--------+-------+
-@end example
-
-@findex UNION
-@cindex searching, two keys
-@cindex keys, searching on two
-@node Searching on two keys, Calculating days, example-Foreign keys, Examples
-@subsection Searching on Two Keys
-
-@strong{MySQL} doesn't yet optimize when you search on two different
-keys combined with @code{OR} (Searching on one key with different @code{OR}
-parts is optimized quite good):
-
-@example
-SELECT field1_index, field2_index FROM test_table WHERE field1_index = '1'
-OR field2_index = '1'
-@end example
-
-The reason is that we haven't yet had time to come up with an efficient
-way to handle this in the general case. (The @code{AND} handling is,
-in comparison, now completely general and works very well).
-
-For the moment you can solve this very efficiently by using a
-@code{TEMPORARY} table. This type of optimization is also very good if
-you are using very complicated queries where the SQL server does the
-optimizations in the wrong order.
-
-@example
-CREATE TEMPORARY TABLE tmp
-SELECT field1_index, field2_index FROM test_table WHERE field1_index = '1';
-INSERT INTO tmp
-SELECT field1_index, field2_index FROM test_table WHERE field2_index = '1';
-SELECT * from tmp;
-DROP TABLE tmp;
-@end example
-
-The above way to solve this query is in effect an @code{UNION} of two queries.
-
-@cindex bit_functions, example
-@findex BIT_OR
-@findex BIT_COUNT
-@findex <<
-@node Calculating days, , Searching on two keys, Examples
-@subsection Calculating visits per day
-
-The following shows an idea of how you can use the bit group functions
-to calculate the number of days per month a user has visited a web page.
-
-@example
-CREATE TABLE t1 (year YEAR(4), month INT(2) UNSIGNED ZEROFILL, day INT(2) UNSIGNED ZEROFILL);
-INSERT INTO t1 VALUES(2000,1,1),(2000,1,20),(2000,1,30),(2000,2,2),(2000,2,23),(2000,2,23);
-
-SELECT year,month,BIT_COUNT(BIT_OR(1<<day)) AS days FROM t1 GROUP BY year,month;
-
-Which returns:
-
-+------+-------+------+
-| year | month | days |
-+------+-------+------+
-| 2000 | 01 | 3 |
-| 2000 | 02 | 2 |
-+------+-------+------+
-@end example
-
-The above calculates how many different days was used for a given
-year/month combination, with automatic removal of duplicate entries.
-
-@cindex modes, batch
-@cindex batch mode
-@cindex running, batch mode
-@cindex script files
-@cindex files, script
-@node Batch mode, Twin, Examples, Tutorial
-@section Using @code{mysql} in Batch Mode
-
-In the previous sections, you used @code{mysql} interactively to enter
-queries and view the results. You can also run @code{mysql} in batch
-mode. To do this, put the commands you want to run in a file, then
-tell @code{mysql} to read its input from the file:
-
-@example
-shell> mysql < batch-file
-@end example
-
-If you need to specify connection parameters on the command line, the
-command might look like this:
-
-@example
-shell> mysql -h host -u user -p < batch-file
-Enter password: ********
-@end example
-
-When you use @code{mysql} this way, you are creating a script file, then
-executing the script.
-
-Why use a script? Here are a few reasons:
-
-@itemize @bullet
-@item
-If you run a query repeatedly (say, every day or every week), making it a
-script allows you to avoid retyping it each time you execute it.
-
-@item
-You can generate new queries from existing ones that are similar by copying
-and editing script files.
-
-@item
-Batch mode can also be useful while you're developing a query, particularly
-for multiple-line commands or multiple-statement sequences of commands. If
-you make a mistake, you don't have to retype everything. Just edit your
-script to correct the error, then tell @code{mysql} to execute it again.
-
-@item
-If you have a query that produces a lot of output, you can run the output
-through a pager rather than watching it scroll off the top of your screen:
-
-@example
-shell> mysql < batch-file | more
-@end example
-
-@item
-You can catch the output in a file for further processing:
-
-@example
-shell> mysql < batch-file > mysql.out
-@end example
-
-@item
-You can distribute your script to other people so they can run the commands,
-too.
-
-@item
-Some situations do not allow for interactive use, for example, when you run
-a query from a @code{cron} job. In this case, you must use batch mode.
-@end itemize
-
-The default output format is different (more concise) when you run
-@code{mysql} in batch mode than when you use it interactively. For
-example, the output of @code{SELECT DISTINCT species FROM pet} looks like
-this when run interactively:
-
-@example
-+---------+
-| species |
-+---------+
-| bird |
-| cat |
-| dog |
-| hamster |
-| snake |
-+---------+
-@end example
-
-But like this when run in batch mode:
-
-@example
-species
-bird
-cat
-dog
-hamster
-snake
-@end example
-
-If you want to get the interactive output format in batch mode, use
-@code{mysql -t}. To echo to the output the commands that are executed, use
-@code{mysql -vvv}.
-
-@cindex Twin Studies, queries
-@cindex queries, Twin Studeis project
-@node Twin, , Batch mode, Tutorial
-@section Queries from Twin Project
-
-At Analytikerna and Lentus, we have been doing the systems and field work
-for a big research project. This project is a collaboration between the
-Institute of Environmental Medicine at Karolinska Institutet Stockholm
-and the Section on Clinical Research in Aging and Psychology at the
-University of Southern California.
-
-The project involves a screening part where all twins in Sweden older
-than 65 years are interviewed by telephone. Twins who meet certain
-criteria are passed on to the next stage. In this latter stage, twins who
-want to participate are visited by a doctor/nurse team. Some of the
-examinations include physical and neuropsychological examination,
-laboratory testing, neuroimaging, psychological status assessment, and family
-history collection. In addition, data are collected on medical and
-environmental risk factors.
-
-More information about Twin studies can be found at:
-
-@example
-@url{http://www.imm.ki.se/TWIN/TWINUKW.HTM}
-@end example
-
-The latter part of the project is administered with a Web interface
-written using Perl and @strong{MySQL}.
-
-Each night all data from the interviews are moved into a @strong{MySQL}
-database.
-
-@menu
-* Twin pool:: Find all non-distributed twins
-* Twin event:: Show a table on twin pair status
-@end menu
-
-@node Twin pool, Twin event, Twin, Twin
-@subsection Find all Non-distributed Twins
-
-The following query is used to determine who goes into the second part of the
-project:
-
-@example
-select
- concat(p1.id, p1.tvab) + 0 as tvid,
- concat(p1.christian_name, " ", p1.surname) as Name,
- p1.postal_code as Code,
- p1.city as City,
- pg.abrev as Area,
- if(td.participation = "Aborted", "A", " ") as A,
- p1.dead as dead1,
- l.event as event1,
- td.suspect as tsuspect1,
- id.suspect as isuspect1,
- td.severe as tsevere1,
- id.severe as isevere1,
- p2.dead as dead2,
- l2.event as event2,
- h2.nurse as nurse2,
- h2.doctor as doctor2,
- td2.suspect as tsuspect2,
- id2.suspect as isuspect2,
- td2.severe as tsevere2,
- id2.severe as isevere2,
- l.finish_date
-from
- twin_project as tp
- /* For Twin 1 */
- left join twin_data as td on tp.id = td.id and tp.tvab = td.tvab
- left join informant_data as id on tp.id = id.id and tp.tvab = id.tvab
- left join harmony as h on tp.id = h.id and tp.tvab = h.tvab
- left join lentus as l on tp.id = l.id and tp.tvab = l.tvab
- /* For Twin 2 */
- left join twin_data as td2 on p2.id = td2.id and p2.tvab = td2.tvab
- left join informant_data as id2 on p2.id = id2.id and p2.tvab = id2.tvab
- left join harmony as h2 on p2.id = h2.id and p2.tvab = h2.tvab
- left join lentus as l2 on p2.id = l2.id and p2.tvab = l2.tvab,
- person_data as p1,
- person_data as p2,
- postal_groups as pg
-where
- /* p1 gets main twin and p2 gets his/her twin. */
- /* ptvab is a field inverted from tvab */
- p1.id = tp.id and p1.tvab = tp.tvab and
- p2.id = p1.id and p2.ptvab = p1.tvab and
- /* Just the sceening survey */
- tp.survey_no = 5 and
- /* Skip if partner died before 65 but allow emigration (dead=9) */
- (p2.dead = 0 or p2.dead = 9 or
- (p2.dead = 1 and
- (p2.death_date = 0 or
- (((to_days(p2.death_date) - to_days(p2.birthday)) / 365)
- >= 65))))
- and
- (
- /* Twin is suspect */
- (td.future_contact = 'Yes' and td.suspect = 2) or
- /* Twin is suspect - Informant is Blessed */
- (td.future_contact = 'Yes' and td.suspect = 1 and id.suspect = 1) or
- /* No twin - Informant is Blessed */
- (ISNULL(td.suspect) and id.suspect = 1 and id.future_contact = 'Yes') or
- /* Twin broken off - Informant is Blessed */
- (td.participation = 'Aborted'
- and id.suspect = 1 and id.future_contact = 'Yes') or
- /* Twin broken off - No inform - Have partner */
- (td.participation = 'Aborted' and ISNULL(id.suspect) and p2.dead = 0))
- and
- l.event = 'Finished'
- /* Get at area code */
- and substring(p1.postal_code, 1, 2) = pg.code
- /* Not already distributed */
- and (h.nurse is NULL or h.nurse=00 or h.doctor=00)
- /* Has not refused or been aborted */
- and not (h.status = 'Refused' or h.status = 'Aborted'
- or h.status = 'Died' or h.status = 'Other')
-order by
- tvid;
-@end example
-
-Some explanations:
-@table @asis
-@item @code{concat(p1.id, p1.tvab) + 0 as tvid}
-We want to sort on the concatenated @code{id} and @code{tvab} in
-numerical order. Adding @code{0} to the result causes @strong{MySQL} to
-treat the result as a number.
-@item column @code{id}
-This identifies a pair of twins. It is a key in all tables.
-@item column @code{tvab}
-This identifies a twin in a pair. It has a value of @code{1} or @code{2}.
-@item column @code{ptvab}
-This is an inverse of @code{tvab}. When @code{tvab} is @code{1} this is
-@code{2}, and vice versa. It exists to save typing and to make it easier for
-@strong{MySQL} to optimize the query.
-@end table
-
-This query demonstrates, among other things, how to do lookups on a
-table from the same table with a join (@code{p1} and @code{p2}). In the example, this
-is used to check whether a twin's partner died before the age of 65. If so,
-the row is not returned.
-
-All of the above exist in all tables with twin-related information. We
-have a key on both @code{id,tvab} (all tables), and @code{id,ptvab}
-(@code{person_data}) to make queries faster.
-
-On our production machine (A 200MHz UltraSPARC), this query returns
-about 150-200 rows and takes less than one second.
-
-The current number of records in the tables used above:
-@multitable @columnfractions .3 .5
-@item @strong{Table} @tab @strong{Rows}
-@item @code{person_data} @tab 71074
-@item @code{lentus} @tab 5291
-@item @code{twin_project} @tab 5286
-@item @code{twin_data} @tab 2012
-@item @code{informant_data} @tab 663
-@item @code{harmony} @tab 381
-@item @code{postal_groups} @tab 100
-@end multitable
-
-@node Twin event, , Twin pool, Twin
-@subsection Show a Table on Twin Pair Status
-
-Each interview ends with a status code called @code{event}. The query
-shown below is used to display a table over all twin pairs combined by
-event. This indicates in how many pairs both twins are finished, in how many
-pairs one twin is finished and the other refused, and so on.
-
-@example
-select
- t1.event,
- t2.event,
- count(*)
-from
- lentus as t1,
- lentus as t2,
- twin_project as tp
-where
- /* We are looking at one pair at a time */
- t1.id = tp.id
- and t1.tvab=tp.tvab
- and t1.id = t2.id
- /* Just the sceening survey */
- and tp.survey_no = 5
- /* This makes each pair only appear once */
- and t1.tvab='1' and t2.tvab='2'
-group by
- t1.event, t2.event;
-
-@end example
-
-@cindex functions, server
-@cindex server functions
-@node Server, Replication, Tutorial, Top
-@chapter MySQL Server Functions
-
-@menu
-* Languages:: What languages are supported by @strong{MySQL}?
-* Table size:: How big @strong{MySQL} tables can be
-@end menu
-
-This chapter describes the languages @strong{MySQL} supports, how sorting
-works in @strong{MySQL}, and how to add new character sets to @strong{MySQL}.
-You will also find information about maximum table sizes in this chapter.
-
-@cindex error messages, languages
-@cindex messages, languages
-@cindex files, error messages
-@cindex language support
-@node Languages, Table size, Server, Server
-@section What Languages Are Supported by MySQL?
-
-@code{mysqld} can issue error messages in the following languages:
-Czech, Danish, Dutch, English (the default), Estonian, French, German, Greek,
-Hungarian, Italian, Japanese, Korean, Norwegian, Norwegian-ny, Polish,
-Portuguese, Romanian, Russian, Slovak, Spanish, and Swedish.
-
-To start @code{mysqld} with a particular language, use either the
-@code{--language=lang} or @code{-L lang} options. For example:
-
-@example
-shell> mysqld --language=swedish
-@end example
-
-or:
-
-@example
-shell> mysqld --language=/usr/local/share/swedish
-@end example
-
-Note that all language names are specified in lowercase.
-
-The language files are located (by default) in
-@file{@var{mysql_base_dir}/share/@var{LANGUAGE}/}.
-
-To update the error message file, you should edit the @file{errmsg.txt} file
-and execute the following command to generate the @file{errmsg.sys} file:
-
-@example
-shell> comp_err errmsg.txt errmsg.sys
-@end example
-
-If you upgrade to a newer version of @strong{MySQL}, remember to repeat
-your changes with the new @file{errmsg.txt} file.
-
-@menu
-* Character sets:: The character set used for data and sorting
-* Adding character set:: Adding a new character set
-* Character arrays:: The character definition arrays
-* String collating:: String collating support
-* Multi-byte characters:: Multi-byte character support
-@end menu
-
-@cindex character sets
-@cindex data, character sets
-@cindex sorting, character sets
-@node Character sets, Adding character set, Languages, Languages
-@subsection The Character Set Used for Data and Sorting
-
-By default, @strong{MySQL} uses the ISO-8859-1 (Latin1) character set
-with sorting according to Swedish/Finnish. This is the character set suitable
-in the USA and western Europe.
-
-All standard @strong{MySQL} binaries are compiled with
-@code{--with-extra-charsets=complex}. This will add code to all
-standard programs to be able to handle @code{latin1} and all multi-byte
-character sets within the binary. Other character sets will be
-loaded from a character-set definition file when needed.
-
-The character set determines what characters are allowed in names and how
-things are sorted by the @code{ORDER BY} and @code{GROUP BY} clauses of
-the @code{SELECT} statement.
-
-You can change the character set with the @code{--default-character-set}
-option when you start the server. The character sets available depend
-on the @code{--with-charset=charset} and @code{--with-extra-charset=
-list-of-charset | complex | all} options to @code{configure}, and the
-character set configuration files listed in
-@file{SHAREDIR/charsets/Index}. @xref{configure options}.
-
-If you change the character set when running @strong{MySQL} (which may
-also change the sort order), you must run myisamchk -r -q on all
-tables. Otherwise your indexes may not be ordered correctly.
-
-When a client connects to a @strong{MySQL} server, the server sends the
-default character set in use to the client. The client will switch to
-use this character set for this connection.
-
-One should use @code{mysql_real_escape_string()} when escaping strings
-for a SQL query. @code{mysql_real_escape_string()} is identical to the
-old @code{mysql_escape_string()} function, except that it takes the MYSQL
-connection handle as the first parameter.
-
-If the client is compiled with different paths than where the server is
-installed and the user who configured @strong{MySQL} didn't included all
-character sets in the @strong{MySQL} binary, one must specify for
-the client where it can find the additional character sets it will need
-if the server runs with a different character set than the client.
-
-One can specify this by putting in a @strong{MySQL} option file:
-
-@example
-[client]
-character-sets-dir=/usr/local/mysql/share/mysql/charsets
-@end example
-
-where the path points to where the dynamic @strong{MySQL} character sets
-are stored.
-
-One can force the client to use specific character set by specifying:
-
-@example
-[client]
-default-character-set=character-set-name
-@end example
-
-but normally this is never needed.
-
-@cindex character sets, adding
-@cindex adding, character sets
-@node Adding character set, Character arrays, Character sets, Languages
-@subsection Adding a New Character Set
-
-To add another character set to @strong{MySQL}, use the following procedure.
-
-Decide if the set is simple or complex. If the character set
-does not need to use special string collating routines for
-sorting and does not need multi-byte character support, it is
-simple. If it needs either of those features, it is complex.
-
-For example, @code{latin1} and @code{danish} are simple charactersets while
-@code{big5} or @code{czech} are complex character sets.
-
-In the following section, we have assumed that you name your character
-set @code{MYSET}.
-
-For a simple character set do the following:
-
-@enumerate
-@item
-Add MYSET to the end of the @file{sql/share/charsets/Index} file
-Assign an unique number to it.
-
-@item
-Create the file @file{sql/share/charsets/MYSET.conf}.
-(You can use @file{sql/share/charsets/latin1.conf} as a base for this).
-
-The syntax for the file very simple:
-
-@itemize @bullet
-@item
-Comments start with a '#' character and proceed to the end of the line.
-@item
-Words are separated by arbitrary amounts of whitespace.
-@item
-When defining the character set, every word must be a number in hexadecimal
-format
-@item
-The @code{ctype} array takes up the first 257 words. The
-@code{to_lower}, @code{to_upper} and @code{sort_order} arrays take up
-256 words each after that.
-@end itemize
-
-@xref{Character arrays}.
-
-@item
-Add the character set name to the @code{CHARSETS_AVAILABLE} and
-@code{COMPILED_CHARSETS} lists in @code{configure.in}.
-
-@item
-Reconfigure, recompile, and test.
-
-@end enumerate
-
-For a complex character set do the following:
-
-@enumerate
-@item
-Create the file @file{strings/ctype-MYSET.c} in the @strong{MySQL} source
-distribution.
-
-@item
-Add MYSET to the end of the @file{sql/share/charsets/Index} file.
-Assign an unique number to it.
-
-@item
-Look at one of the existing @file{ctype-*.c} files to see what needs to
-be defined, for example @file{strings/ctype-big5.c}. Note that the
-arrays in your file must have names like @code{ctype_MYSET},
-@code{to_lower_MYSET}, and so on. This corresponds to the arrays
-in the simple character set. @xref{Character arrays}. For a complex
-character set
-
-@item
-Near the top of the file, place a special comment like this:
-
-@example
-/*
- * This comment is parsed by configure to create ctype.c,
- * so don't change it unless you know what you are doing.
- *
- * .configure. number_MYSET=MYNUMBER
- * .configure. strxfrm_multiply_MYSET=N
- * .configure. mbmaxlen_MYSET=N
- */
-@end example
-
-The @code{configure} program uses this comment to include
-the character set into the @strong{MySQL} library automatically.
-
-The strxfrm_multiply and mbmaxlen lines will be explained in
-the following sections. Only include them if you the string
-collating functions or the multi-byte character set functions,
-respectively.
-
-@item
-You should then create some of the following functions:
-
-@itemize @bullet
-@item @code{my_strncoll_MYSET()}
-@item @code{my_strcoll_MYSET()}
-@item @code{my_strxfrm_MYSET()}
-@item @code{my_like_range_MYSET()}
-@end itemize
-
-@xref{String collating}.
-
-@item
-Add the character set name to the @code{CHARSETS_AVAILABLE} and
-@code{COMPILED_CHARSETS} lists in @code{configure.in}.
-
-@item
-Reconfigure, recompile, and test.
-@end enumerate
-
-The file @file{sql/share/charsets/README} includes some more instructions.
-
-If you want to have the character set included in the @strong{MySQL}
-distribution, mail a patch to @email{internals@@lists.mysql.com}.
-
-@node Character arrays, String collating, Adding character set, Languages
-@subsection The character definition arrays
-
-@code{to_lower[]} and @code{to_upper[]} are simple arrays that hold the
-lowercase and uppercase characters corresponding to each member of the
-character set. For example:
-
-@example
-to_lower['A'] should contain 'a'
-to_upper['a'] should contain 'A'
-@end example
-
-@code{sort_order[]} is a map indicating how characters should be ordered for
-comparison and sorting purposes. For many character sets, this is the same as
-@code{to_upper[]} (which means sorting will be case insensitive).
-@strong{MySQL} will sort characters based on the value of
-@code{sort_order[character]}. For more complicated sorting rules, see
-the discussion of string collating below. @xref{String collating}.
-
-@code{ctype[]} is an array of bit values, with one element for one character.
-(Note that @code{to_lower[]}, @code{to_upper[]}, and @code{sort_order[]}
-are indexed by character value, but @code{ctype[]} is indexed by character
-value + 1. This is an old legacy to be able to handle EOF.)
-
-You can find the following bitmask definitions in @file{m_ctype.h}:
-
-@example
-#define _U 01 /* Uppercase */
-#define _L 02 /* Lowercase */
-#define _N 04 /* Numeral (digit) */
-#define _S 010 /* Spacing character */
-#define _P 020 /* Punctuation */
-#define _C 040 /* Control character */
-#define _B 0100 /* Blank */
-#define _X 0200 /* heXadecimal digit */
-@end example
-
-The @code{ctype[]} entry for each character should be the union of the
-applicable bitmask values that describe the character. For example,
-@code{'A'} is an uppercase character (@code{_U}) as well as a
-hexadecimal digit (@code{_X}), so @code{ctype['A'+1]} should contain the
-value:
-
-@example
-_U + _X = 01 + 0200 = 0201
-@end example
-
-@cindex collating, strings
-@cindex string collating
-@node String collating, Multi-byte characters, Character arrays, Languages
-@subsection String Collating Support
-
-If the sorting rules for your language are too complex to be handled
-with the simple @code{sort_order[]} table, you need to use the string
-collating functions.
-
-Right now the best documentation on this is the character sets that are
-already implemented. Look at the big5, czech, gbk, sjis, and tis160
-character sets for examples.
-
-You must specify the @code{strxfrm_multiply_MYSET=N} value in the
-special comment at the top of the file. @code{N} should be set to
-the maximum ratio the strings may grow during @code{my_strxfrm_MYSET} (it
-must be a positive integer).
-
-@cindex characters, multi-byte
-@cindex multi-byte characters
-@node Multi-byte characters, , String collating, Languages
-@subsection Multi-byte Character Support
-
-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. 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 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
-@cindex operating systems, file size limits
-@cindex limits, file size
-@cindex files, size limits
-@node Table size, , Languages, Server
-@section How Big MySQL Tables Can Be
-
-@strong{MySQL} Version 3.22 has a 4G limit on table size. With the new
-@code{MyISAM} in @strong{MySQL} Version 3.23 the maximum table size is
-pushed up to 8 million terabytes (2 ^ 63 bytes).
-
-Note, however, that operating systems have their own file size
-limits. Here are some examples:
-
-@multitable @columnfractions .5 .5
-@item @strong{Operating System} @tab @strong{File Size Limit}
-@item Linux-Intel 32 bit @tab 2G, 4G or more, depends on Linux version
-@item Linux-Alpha @tab 8T (?)
-@item Solaris 2.5.1 @tab 2G (possible 4G with patch)
-@item Solaris 2.6 @tab 4G
-@item Solaris 2.7 Intel @tab 4G
-@item Solaris 2.7 ULTRA-SPARC @tab 8T (?)
-@end multitable
-
-On Linux 2.2 you can get bigger tables than 2G by using the LFS patch for
-the ext2 file system. On Linux 2.4 there exists also patches for ReiserFS
-to get support for big files.
-
-This means that the table size for @strong{MySQL} is normally limited by
-the operating system.
-
-By default, @strong{MySQL} tables have a maximum size of about 4G. You can
-check the maximum table size for a table with the @code{SHOW TABLE STATUS}
-command or with the @code{myisamchk -dv table_name}.
-@xref{SHOW}.
-
-If you need bigger tables than 4G (and your operating system supports
-this), you should set the @code{AVG_ROW_LENGTH} and @code{MAX_ROWS}
-parameter when you create your table. @xref{CREATE TABLE}. You can
-also set these later with @code{ALTER TABLE}. @xref{ALTER TABLE}.
-
-If your big table is going to be read-only, you could use
-@code{myisampack} to merge and compress many tables to one.
-@code{myisampack} usually compresses a table by at least 50%, so you can
-have, in effect, much bigger tables. @xref{myisampack, ,
-@code{myisampack}}.
-
-You can go around the operating system file limit for @code{MyISAM} data
-files by using the @code{RAID} option. @xref{CREATE TABLE}.
-
-Another solution can be the included MERGE library, which allows you to
-handle a collection of identical tables as one. @xref{MERGE, MERGE
-tables}.
-
-@cindex replication
-@cindex increasing, speed
-@cindex speed, increasing
-@cindex databases, replicating
-@node Replication, Fulltext Search, Server, Top
-@chapter Replication in MySQL
-
-@menu
-* Replication Intro:: Introduction
-* Replication Implementation:: Replication Implementation Overview
-* Replication HOWTO:: HOWTO
-* Replication Features:: Replication Features
-* Replication Options:: Replication Options in my.cnf
-* Replication SQL:: SQL Commands related to replication
-* Replication FAQ:: Frequently Asked Questions about replication
-* Replication Problems:: Troubleshooting Replication.
-@end menu
-
-This chapter describes the various replication features in @strong{MySQL}.
-It serves as a reference to the options available with replication.
-You will be introduced to replication and learn how to implement it.
-Towards the end, there are some frequently asked questions and descriptions
-of problems and how to solve them.
-
-@node Replication Intro, Replication Implementation, Replication, Replication
-@section Introduction
-
-One way replication can be used is to increase both robustness and
-speed. For robustness you can have two systems and can switch to the backup if
-you have problems with the master. The extra speed is achieved by
-sending a part of the non-updating queries to the replica server. Of
-course this only works if non-updating queries dominate, but that is the
-normal case.
-
-Starting in Version 3.23.15, @strong{MySQL} supports one-way replication
-internally. One server acts as the master, while the other acts as the
-slave. Note that one server could play the roles of master in one pair
-and slave in the other. The master server keeps a binary log of updates
-(@xref{Binary log}.) and an index file to binary logs to keep track of
-log rotation. The slave, upon connecting, informs the master where it
-left off since the last successfully propagated update, catches up on
-the updates, and then blocks and waits for the master to notify it of
-the new updates.
-
-Note that if you are replicating a database, all updates to this
-database should be done through the master!
-
-On older servers one can use the update log to do simple replication.
-@xref{Log Replication}.
-
-Another benefit of using replication is that one can get live backups of
-the system by doing a backup on a slave instead of doing it on the
-master. @xref{Backup}.
-
-@cindex master-slave setup
-@node Replication Implementation, Replication HOWTO, Replication Intro, Replication
-@section Replication Implementation Overview
-
-@strong{MySQL} replication is based on the server keeping track of all
-changes to your database (updates, deletes, etc) in the binary
-log. (@xref{Binary log}.) and the slave server(s) reading the saved
-queries from the master server's binary log so that the slave can
-execute the same queries on its copy of the data.
-
-It is @strong{very important} to realize that the binary log is simply a
-record starting from a fixed point in time (the moment you enable binary
-logging). Any slaves which you set up will need copies of all the data
-from your master as it existed the moment that you enabled binary
-logging on the master. If you start your slaves with data that doesn't
-agree with what was on the master @strong{when the binary log was
-started}, your slaves may fail.
-
-A future version (4.0) of @strong{MySQL} will remove the need to keep a
-(possibly large) snapshot of data for new slaves that you might wish to
-set up through the live backup functionality with no locking required.
-However, at this time, it is necessary to block all writes either with a
-global read lock or by shutting down the master while taking a snapshot.
-
-Once a slave is properly configured and running, it will simply connect
-to the master and wait for updates to process. If the master goes away
-or the slave loses connectivity with your master, it will keep trying to
-connect every @code{master-connect-retry} seconds until it is able to
-reconnect and resume listening for updates.
-
-Each slave keeps track of where it left off. The master server has no
-knowledge of how many slaves there are or which ones are up-to-date at
-any given time.
-
-The next section explains the master/slave setup process in more detail.
-
-@node Replication HOWTO, Replication Features, Replication Implementation, Replication
-@section HOWTO
-
-Below is a quick description of how to set up complete replication on
-your current @strong{MySQL} server. It assumes you want to replicate all
-your databases and have not configured replication before. You will need
-to shutdown your master server briefly to complete the steps outlined
-below.
-
-@enumerate
-@item
-Make sure you have a recent version of @strong{MySQL} installed on the master
-and slave(s).
-
-Use Version 3.23.29 or higher. Previous releases used a different binary
-log format and had bugs which have been fixed in newer releases. Please,
-do not report bugs until you have verified that the problem is present
-in the latest release.
-@item
-Set up special a replication user on the master with the @code{FILE}
-privilege and permission to connect from all the slaves. If the user is
-only doing replication (which is recommended), you don't need to grant any
-additional privileges.
-
-For example, to create a user named @code{repl} which can access your
-master from any host, you might use this command:
-
-@example
-GRANT FILE ON *.* TO repl@@"%" IDENTIFIED BY '<password>';
-@end example
-
-@item
-Shut down @strong{MySQL} on the master.
-
-@example
-mysqladmin -u root -p<password> shutdown
-@end example
-
-@item
-Snapshot all the data on your master server.
-
-The easiest way to do this (on Unix) is to simply use @strong{tar} to
-produce an archive of your entire data directory. The exact data
-directory location depends on your installation.
-
-@example
-tar -cvf /tmp/mysql-snapshot.tar /path/to/data-dir
-@end example
-
-Windows users can use WinZip or similar software to create an archive of
-the data directory.
-
-@item
-In @code{my.cnf} on the master add @code{log-bin} and
-@code{server-id=unique number} to the @code{[mysqld]} section and
-restart it. It is very important that the id of the slave is different from
-the id of the master. Think of @code{server-id} as something similar
-to the IP address - it uniquely identifies the server instance in the
-community of replication partners.
-
-@example
-[mysqld]
-log-bin
-server-id=1
-@end example
-
-@item
-Restart @strong{MySQL} on the master.
-
-@item
-Add the following to @code{my.cnf} on the slave(s):
-
-@example
-master-host=<hostname of the master>
-master-user=<replication user name>
-master-password=<replication user password>
-master-port=<TCP/IP port for master>
-server-id=<some unique number between 2 and 2^32-1>
-@end example
-
-replacing the values in <> with what is relevant to your system.
-
-@code{server-id} must be different for each server participating in
-replication. If you don't specify a server-id, it will be set to 1 if
-you have not defined @code{master-host}, else it will be set to 2. Note
-that in the case of @code{server-id} omission the master will refuse
-connections from all slaves, and the slave will refuse to connect to a
-master. Thus, omitting @code{server-id} is only good for backup with a
-binary log.
-
-
-@item
-Copy the snapshot data into your data directory on your slave(s). Make
-sure that the privileges on the files and directories are correct. The
-user which @strong{MySQL} runs as needs to be able to read and write to
-them, just as on the master.
-
-@item Restart the slave(s).
-
-@end enumerate
-
-After you have done the above, the slave(s) should connect to the master
-and catch up on any updates which happened since the snapshot was taken.
-
-If you have forgotten to set @code{server-id} for the slave you will get
-the following error in the error log file:
-
-@example
-Warning: one should set server_id to a non-0 value if master_host is set.
-The server will not act as a slave.
-@end example
-
-If you have forgot to do this for the master, the slaves will not be
-able to connect to the master.
-
-If a slave is not able to replicate for any reason, you will find error
-messages in the error log on the slave.
-
-Once a slave is replicating, you will find a file called
-@code{master.info} in the same directory as your error log. The
-@code{master.info} file is used by the slave to keep track of how much
-of the master's binary log is has processed. @strong{Do not} remove or
-edit the file, unless you really know what you are doing. Even in that case,
-it is preferred that you use @code{CHANGE MASTER TO} command.
-
-@cindex options, replication
-@cindex @code{my.cnf} file
-@cindex files,@code{my.cnf}
-@node Replication Features, Replication Options, Replication HOWTO, Replication
-@section Replication Features and known problems
-
-Below is an explanation of what is supported and what is not:
-
-@itemize @bullet
-@item
-Replication will be done correctly with @code{AUTO_INCREMENT},
-@code{LAST_INSERT_ID}, and @code{TIMESTAMP} values.
-@item
-@code{RAND()} in updates does not replicate properly. Use
-@code{RAND(some_non_rand_expr)} if you are replicating updates with
-@code{RAND()}. You can, for example, use @code{UNIX_TIMESTAMP()} for the
-argument to @code{RAND()}.
-@item
-You have to use the same character set (@code{--default-character-set})
-on the master and the slave. If not, you may get duplicate key errors on
-the slave, because a key that is regarded as unique on the master may
-not be that in the other character set.
-@item
-@code{LOAD DATA INFILE} will be handled properly as long as the file
-still resides on the master server at the time of update
-propagation. @code{LOAD LOCAL DATA INFILE} will be skipped.
-@item
-Update queries that use user variables are not replication-safe (yet).
-@item
-@code{FLUSH} commands are not stored in the binary log and are because
-of this not replicated to the slaves. This is not normally a problem as
-@code{FLUSH} doesn't change anything. This does however mean that if you
-update the @code{MySQL} privilege tables directly without using
-@code{GRANT} statement and you replicate the @code{MySQL} privilege
-database, you must do a @code{FLUSH PRIVILEGES} on your slaves to put
-the new privileges into effect.
-@item
-Temporary tables starting in 3.23.29 are replicated properly with the
-exception of the case when you shut down slave server ( not just slave thread),
-you have some temporary tables open, and the are used in subsequent updates.
-To deal with this problem, to shut down the slave, do @code{SLAVE STOP}, then
-check @code{Slave_open_temp_tables} variable to see if it is 0, then issue
-@code{mysqladmin shutdown}. If the number is not 0, restart the slave thread
-with @code{SLAVE START} and see
-if you have better luck next time. There will be a cleaner solution, but it
-has to wait until version 4.0.
-In earlier versions temporary tables are not being replicated properly - we
-recommend that you either upgrade, or execute @code{SET SQL_LOG_BIN=0} on
-your clients before all queries with temp tables.
-@item
-@strong{MySQL} only supports one master and many slaves. We will in 4.x
-add a voting algorithm to automatically change master if something goes
-wrong with the current master. We will also introduce 'agent' processes
-to help doing load balancing by sending select queries to different
-slaves.
-@item
-Starting in Version 3.23.26, it is safe to connect servers in a circular
-master-slave relationship with @code{log-slave-updates} enabled.
-Note, however, that many queries will not work right in this kind of
-setup unless your client code is written to take care of the potential
-problems that can happen from updates that occur in different sequence
-on different servers.
-
-This means that you can do a setup like the following:
-
-@example
-A -> B -> C -> A
-@end example
-
-This setup will only works if you only do non conflicting updates
-between the tables. In other words, if you insert data in A and C, you
-should never insert a row in A that may have a conflicting key with a
-row insert in C. You should also not update the sam rows on two servers
-if the order in which the updates are applied matters.
-
-Note that the log format has changed in Version 3.23.26 so that
-pre-3.23.26 slaves will not be able to read it.
-@item
-If the query on the slave gets an error, the slave thread will
-terminate, and a message will appear in the @code{.err} file. You should
-then connect to the slave manually, fix the cause of the error (for
-example, non-existent table), and then run @code{SLAVE START} sql
-command (available starting in Version 3.23.16). In Version 3.23.15, you
-will have to restart the server.
-@item
-If connection to the master is lost, the slave will retry immediately,
-and then in case of failure every @code{master-connect-retry} (default
-60) seconds. Because of this, it is safe to shut down the master, and
-then restart it after a while. The slave will also be able to deal with
-network connectivity outages.
-@item
-Shutting down the slave (cleanly) is also safe, as it keeps track of
-where it left off. Unclean shutdowns might produce problems, especially
-if disk cache was not synced before the system died. Your system fault
-tolerance will be greatly increased if you have a good UPS.
-@item
-If the master is listening on a non-standard port, you will also need to
-specify this with @code{master-port} parameter in @code{my.cnf} .
-@item
-In Version 3.23.15, all of the tables and databases will be
-replicated. Starting in Version 3.23.16, you can restrict replication to
-a set of databases with @code{replicate-do-db} directives in
-@code{my.cnf} or just exclude a set of databases with
-@code{replicate-ignore-db}. Note that up until Version 3.23.23, there was a bug
-that did not properly deal with @code{LOAD DATA INFILE} if you did it in
-a database that was excluded from replication.
-@item
-Starting in Version 3.23.16, @code{SET SQL_LOG_BIN = 0} will turn off
-replication (binary) logging on the master, and @code{SET SQL_LOG_BIN =
-1} will turn in back on - you must have the process privilege to do
-this.
-@item
-Starting in Version 3.23.19, you can clean up stale replication leftovers when
-something goes wrong and you want a clean start with @code{FLUSH MASTER}
-and @code{FLUSH SLAVE} commands. In Version 3.23.26 we have renamed them to
-@code{RESET MASTER} and @code{RESET SLAVE} respectively to clarify
-what they do. The old @code{FLUSH} variants still work, though, for
-compatibility.
-
-@item
-Starting in Version 3.23.21, you can use @code{LOAD TABLE FROM MASTER} for
-network backup and to set up replication initially. We have recently
-received a number of bug reports concerning it that we are investigating, so
-we recommend that you use it only in testing until we make it more stable.
-@item
-Starting in Version 3.23.23, you can change masters and adjust log position
-with @code{CHANGE MASTER TO}.
-@item
-Starting in Version 3.23.23, you tell the master that updates in certain
-databases should not be logged to the binary log with @code{binlog-ignore-db}.
-@item
-Starting in Version 3.23.26, you can use @code{replicate-rewrite-db} to tell
-the slave to apply updates from one database on the master to the one
-with a different name on the slave.
-@item
-Starting in Version 3.23.28, you can use @code{PURGE MASTER LOGS TO 'log-name'}
-to get rid of old logs while the slave is running.
-@end itemize
-
-@node Replication Options, Replication SQL, Replication Features, Replication
-@section Replication Options in my.cnf
-
-If you are using replication, we recommend you to use @strong{MySQL} Version
-3.23.30 or later. Older versions work, but they do have some bugs and are
-missing some features.
-
-On both master and slave you need to use the @code{server-id} option.
-This sets an unique replication id. You should pick a unique value in the
-range between 1 to 2^32-1 for each master and slave.
-Example: @code{server-id=3}
-
-The following table has the options you can use for the @strong{MASTER}:
-
-@multitable @columnfractions .3 .7
-
-@item @strong{Option} @tab @strong{Description}
-@item @code{log-bin=filename} @tab
-Write to a binary update log to the specified location. Note that if you
-give it a parameter with an extension (for example,
-@code{log-bin=/mysql/logs/replication.log} ) versions up to 3.23.24 will
-not work right during replication if you do @code{FLUSH LOGS} . The
-problem is fixed in Version 3.23.25. If you are using this kind of log
-name, @code{FLUSH LOGS} will be ignored on binlog. To clear the log, run
-@code{FLUSH MASTER}, and do not forget to run @code{FLUSH SLAVE} on all
-slaves. In Version 3.23.26 and in later versions you should use
-@code{RESET MASTER} and @code{RESET SLAVE}
-
-@item @code{log-bin-index=filename} @tab
-Because the user could issue the @code{FLUSH LOGS} command, we need to
-know which log is currently active and which ones have been rotated out
-and in what sequence. This information is stored in the binary log index file.
-The default is `hostname`.index. You can use this option if you want to
-be a rebel. (Example: @code{log-bin-index=db.index})
-
-@item @code{sql-bin-update-same} @tab
-If set, setting @code{SQL_LOG_BIN} to a value will automatically set
-@code{SQL_LOG_UPDATE} to the same value and vice versa.
-
-@item @code{binlog-do-db=database_name} @tab
-Tells the master it should log updates for the specified database, and
-exclude all others not explicitly mentioned.
-(Example: @code{binlog-do-db=some_database})
-
-@item @code{binlog-ignore-db=database_name} @tab
-Tells the master that updates to the given database should not be logged
-to the binary log (Example: @code{binlog-ignore-db=some_database})
-@end multitable
-
-The following table has the options you can use for the @strong{SLAVE}:
-
-@multitable @columnfractions .3 .7
-
-@item @strong{Option} @tab @strong{Description}
-@item @code{master-host=host} @tab
-Master hostname or IP address for replication. If not set, the slave
-thread will not be started.
-(Example: @code{master-host=db-master.mycompany.com})
-
-@item @code{master-user=username} @tab
-The user the slave thread will us for authentication when connecting to
-the master. The user must have @code{FILE} privilege. If the master user
-is not set, user @code{test} is assumed. (Example:
-@code{master-user=scott})
-
-@item @code{master-password=password} @tab
-The password the slave thread will authenticate with when connecting to
-the master. If not set, an empty password is assumed. (Example:
-@code{master-password=tiger})
-
-@item @code{master-port=portnumber} @tab
-The port the master is listening on. If not set, the compiled setting of
-@code{MYSQL_PORT} is assumed. If you have not tinkered with
-@code{configure} options, this should be 3306. (Example:
-@code{master-port=3306})
-
-@item @code{master-connect-retry=seconds} @tab
-The number of seconds the slave thread will sleep before retrying to
-connect to the master in case the master goes down or the connection is
-lost. Default is 60. (Example: @code{master-connect-retry=60})
-
-@item @code{master-ssl} @tab
-Turn SSL on (Example: @code{master-ssl})
-
-@item @code{master-ssl-key} @tab
-Master SSL keyfile name (Example: @code{master-ssl-key=SSL/master-key.pem})
-
-@item @code{master-ssl-cert} @tab
-Master SSL certificate file name (Example: @code{master-ssl-key=SSL/master-cert.pem})
-
-@item @code{master-info-file=filename} @tab
-The location of the file that remembers where we left off on the master
-during the replication process. The default is master.info in the data
-directory. Sasha: The only reason I see for ever changing the default
-is the desire to be rebelious. (Example:
-@code{master-info-file=master.info})
-
-@item @code{replicate-do-table=db_name.table_name} @tab
-Tells the slave thread to restrict replication to the specified database.
-To specify more than one table, use the directive multiple times,
-once for each table. .
-(Example: @code{replicate-do-table=some_db.some_table})
-
-@item @code{replicate-ignore-table=db_name.table_name} @tab
-Tells the slave thread to not replicate to the specified table. To
-specify more than one table to ignore, use the directive multiple
-times, once for each table.(Example:
-@code{replicate-ignore-table=db_name.some_table})
-
-@item @code{replicate-wild-do-table=db_name.table_name} @tab
-Tells the slave thread to restrict replication to the tables that match the
-specified wildcard pattern. .
-To specify more than one table, use the directive multiple times,
-once for each table. .
-(Example: @code{replicate-do-table=foo%.bar%} will replicate only updates
-to tables in all databases that start with foo and whose table names
-start with bar)
-
-@item @code{replicate-wild-ignore-table=db_name.table_name} @tab
-Tells the slave thread to not replicate to the tables that match the given
-wild card pattern. To
-specify more than one table to ignore, use the directive multiple
-times, once for each table.(Example:
-@code{replicate-ignore-table=foo%.bar%} - will not upates to tables in all databases that start with foo and whose table names
-start with bar)
-
-@item @code{replicate-ignore-db=database_name} @tab
-Tells the slave thread to not replicate to the specified database. To
-specify more than one database to ignore, use the directive multiple
-times, once for each database. This option will not work if you use cross
-database updates. If you need cross database updates to work, make sure
-you have 3.23.28 or later, and use
-@code{replicate-wild-ignore-table=db_name.%}(Example:
-@code{replicate-ignore-db=some_db})
-
-@item @code{replicate-do-db=database_name} @tab
-Tells the slave thread to restrict replication to the specified database.
-To specify more than one database, use the directive multiple times,
-once for each database. Note that this will only work if you do not use
-cross-database queries such as @code{UPDATE some_db.some_table SET
-foo='bar'} while having selected a different or no database. If you need
-cross database updates to work, make sure
-you have 3.23.28 or later, and use
-@code{replicate-wild-do-table=db_name.%}
-(Example: @code{replicate-do-db=some_db})
-
-@item @code{log-slave-updates} @tab
-Tells the slave to log the updates from the slave thread to the binary
-log. Off by default. You will need to turn it on if you plan to
-daisy-chain the slaves.
-
-@item @code{replicate-rewrite-db=from_name->to_name} @tab
-Updates to a database with a different name than the original (Example:
-@code{replicate-rewrite-db=master_db_name->slave_db_name}
-
-@item @code{skip-slave-start} @tab
-Tells the slave server not to start the slave on the startup. The user
-can start it later with @code{SLAVE START}.
-
-@item @code{slave_read_timeout=#}
-Number of seconds to wait for more data from the master before aborting
-the read.
-@end multitable
-
-@cindex SQL commands, replication
-@cindex commands, replication
-@cindex replication, commands
-@node Replication SQL, Replication FAQ, Replication Options, Replication
-@section SQL Commands Related to Replication
-
-Replication can be controlled through the SQL interface. Below is the
-summary of commands:
-
-@multitable @columnfractions .30 .70
-@item @strong{Command} @tab @strong{Description}
-
-@item @code{SLAVE START}
- @tab Starts the slave thread. (Slave)
-
-@item @code{SLAVE STOP}
- @tab Stops the slave thread. (Slave)
-
-@item @code{SET SQL_LOG_BIN=0}
- @tab Disables update logging if the user has process privilege.
- Ignored otherwise. (Master)
-
-@item @code{SET SQL_LOG_BIN=1}
- @tab Re-enables update logging if the user has process privilege.
- Ignored otherwise. (Master)
-
-@item @code{SET SQL_SLAVE_SKIP_COUNTER=n}
- @tab Skip the next @code{n} events from the master. Only valid when
-the slave thread is not running, otherwise, gives an error. Useful for
-recovering from replication glitches.
-
-@item @code{RESET MASTER}
- @tab Deletes all binary logs listed in the index file, resetting the binlog
-index file to be empty. In pre-3.23.26 versions, @code{FLUSH MASTER} (Master)
-
-@item @code{RESET SLAVE}
- @tab Makes the slave forget its replication position in the master
-logs. In pre 3.23.26 versions the command was called
-@code{FLUSH SLAVE}(Slave)
-
-@item @code{LOAD TABLE tblname FROM MASTER}
- @tab Downloads a copy of the table from master to the slave. (Slave)
-
-@item @code{CHANGE MASTER TO master_def_list}
- @tab Changes the master parameters to the values specified in
-@code{master_def_list} and restarts the slave thread. @code{master_def_list}
-is a comma-separated list of @code{master_def} where @code{master_def} is
-one of the following: @code{MASTER_HOST}, @code{MASTER_USER},
-@code{MASTER_PASSWORD}, @code{MASTER_PORT}, @code{MASTER_CONNECT_RETRY},
-@code{MASTER_LOG_FILE}, @code{MASTER_LOG_POS}. Example:
-
-@example
-
-CHANGE MASTER TO
- MASTER_HOST='master2.mycompany.com',
- MASTER_USER='replication',
- MASTER_PASSWORD='bigs3cret',
- MASTER_PORT=3306,
- MASTER_LOG_FILE='master2-bin.001',
- MASTER_LOG_POS=4;
-
-@end example
-
-You only need to specify the values that need to be changed. The values that
-you omit will stay the same with the exception of when you change the host or
-the port. In that case, the slave will assume that since you are connecting to
-a different host or a different port, the master is different. Therefore, the
-old values of log and position are not applicable anymore, and will
-automatically be reset to an empty string and 0, respectively (the start
-values). Note that if you restart the slave, it will remember its last master.
-If this is not desirable, you should delete the @file{master.info} file before
-restarting, and the slave will read its master from @code{my.cnf} or the
-command line. (Slave)
-
-@item @code{SHOW MASTER STATUS} @tab Provides status information on the binlog of the master. (Master)
-
-@item @code{SHOW SLAVE STATUS} @tab Provides status information on essential parameters of the slave thread. (Slave)
-@item @code{SHOW MASTER LOGS} @tab Only available starting in Version 3.23.28. Lists the binary logs on the master. You should use this command prior to @code{PURGE MASTER LOGS TO} to find out how far you should go.
-
-@item @code{PURGE MASTER LOGS TO 'logname'}
- @tab Available starting in Version 3.23.28. Deletes all the
-replication logs that are listed in the log
-index as being prior to the specified log, and removed them from the
-log index, so that the given log now becomes first. Example:
-
-@example
-PURGE MASTER LOGS TO 'mysql-bin.010'
-@end example
-
-This command will do nothing and fail with an error if you have an
-active slave that is currently reading one of the logs you are trying to
-delete. However, if you have a dormant slave, and happen to purge one of
-the logs it wants to read, the slave will be unable to replicate once it
-comes up. The command is safe to run while slaves are replicating - you
-do not need to stop them.
-
-You must first check all the slaves with @code{SHOW SLAVE STATUS} to
-see which log they are on, then do a listing of the logs on the
-master with @code{SHOW MASTER LOGS}, find the earliest log among all
-the slaves (if all the slaves are up to date, this will be the
-last log on the list), backup all the logs you are about to delete
-(optional) and purge up to the target log.
-
-@end multitable
-
-@node Replication FAQ, Replication Problems, Replication SQL, Replication
-@section Replication FAQ
-
-@cindex @code{Binlog_Dump}
-@strong{Q}: Why do I sometimes see more than one @code{Binlog_Dump} thread on
-the master after I have restarted the slave?
-
-@strong{A}: @code{Binlog_Dump} is a continuous process that is handled by the
-server in the following way:
-
-@itemize @bullet
-@item
-Catch up on the updates.
-@item
-Once there are no more updates left, go into @code{pthread_cond_wait()},
-from which we can be awakened either by an update or a kill.
-@item
-On wake up, check the reason. If we are not supposed to die, continue
-the @code{Binlog_dump} loop.
-@item
-If there is some fatal error, such as detecting a dead client,
-terminate the loop.
-@end itemize
-
-So if the slave thread stops on the slave, the corresponding
-@code{Binlog_Dump} thread on the master will not notice it until after
-at least one update to the master (or a kill), which is needed to wake
-it up from @code{pthread_cond_wait()}. In the meantime, the slave
-could have opened another connection, which resulted in another
-@code{Binlog_Dump} thread.
-
-The above problem should not be present in Version 3.23.26 and later
-versions. In Version 3.23.26 we added @code{server-id} to each
-replication server, and now all the old zombie threads are killed on the
-master when a new replication thread connects from the same slave
-
-@strong{Q}: How do I rotate replication logs?
-
-@strong{A}: In Version 3.23.28 you should use @code{PURGE MASTER LOGS
-TO} command after determining which logs can be deleted, and optionally
-backing them up first. In earlier versions the process is much more
-painful, and cannot be safely done without stopping all the slaves in
-the case that you plan to re-use log names. You will need to stop the
-slave threads, edit the binary log index file, delete all the old logs,
-restart the master, start slave threads, and then remove the old log files.
-
-
-@strong{Q}: How do I upgrade on a hot replication setup?
-
-@strong{A}: If you are upgrading pre-3.23.26 versions, you should just
-lock the master tables, let the slave catch up, then run @code{FLUSH
-MASTER} on the master, and @code{FLUSH SLAVE} on the slave to reset the
-logs, then restart new versions of the master and the slave. Note that
-the slave can stay down for some time - since the master is logging
-all the updates, the slave will be able to catch up once it is up and
-can connect.
-
-After 3.23.26, we have locked the replication protocol for modifications, so
-you can upgrade masters and slave on the fly to a newer 3.23 version and you
-can have different versions of @strong{MySQL} running on the slave and the
-master, as long as they are both newer than 3.23.26.
-
-@cindex replication, two-way
-@strong{Q}: What issues should I be aware of when setting up two-way
-replication?
-
-@strong{A}: @strong{MySQL} replication currently does not support any
-locking protocol between master and slave to guarantee the atomicity of
-a distributed (cross-server) update. In in other words, it is possible
-for client A to make an update to co-master 1, and in the meantime,
-before it propagates to co-master 2, client B could make an update to
-co-master 2 that will make the update of client A work differently than
-it did on co-master 1. Thus when the update of client A will make it
-to co-master 2, it will produce tables that will be different than
-what you have on co-master 1, even after all the updates from co-master
-2 have also propagated. So you should not co-chain two servers in a
-two-way replication relationship, unless you are sure that you updates
-can safely happen in any order, or unless you take care of mis-ordered
-updates somehow in the client code.
-
-
-You must also realize that two-way replication actually does not improve
-performance very much, if at all, as far as updates are concerned. Both
-servers need to do the same amount of updates each, as you would have
-one server do. The only difference is that there will be a little less
-lock contention, because the updates originating on another server will
-be serialized in one slave thread. This benefit, though, might be
-offset by network delays.
-
-@cindex performance, improving
-@cindex increasing, performance
-@strong{Q}: How can I use replication to improve performance of my system?
-
-@strong{A}: You should set up one server as the master, and direct all
-writes to it, and configure as many slaves as you have the money and
-rackspace for, distributing the reads among the master and the slaves.
-You can also start the slaves with @code{--skip-bdb},
-@code{--low-priority-updates} and @code{--delay-key-write-for-all-tables}
-to get speed improvements for the slave. In this case the slave will
-use non-transactional @code{MyISAM} tables instead of @code{BDB} tables
-to get more speed.
-
-@strong{Q}: What should I do to prepare my client code to use
-performance-enhancing replication?
-
-@strong{A}:
-If the part of your code that is responsible for database access has
-been properly abstracted/modularized, converting it to run with the
-replicated setup should be very smooth and easy - just change the
-implementation of your database access to read from some slave or the
-master, and to always write to the master. If your code does not have
-this level of abstraction,
-setting up a replicated system will give you an opportunity/motivation
-to it clean up.
- You should start by creating a wrapper library
-/module with the following functions:
-
-@itemize
-@item
-@code{safe_writer_connect()}
-@item
-@code{safe_reader_connect()}
-@item
-@code{safe_reader_query()}
-@item
-@code{safe_writer_query()}
-@end itemize
-
-@code{safe_} means that the function will take care of handling all
-the error conditions.
-
-You should then convert your client code to use the wrapper library.
-It may be a painful and scary process at first, but it will pay off in
-the long run. All applications that follow the above pattern will be
-able to take advantage of one-master/many slaves solution. The
-code will be a lot easier to maintain, and adding troubleshooting
-options will be trivial. You will just need to modify one or two
-functions, for example, to log how long each query took, or which
-query, among your many thousands, gave you an error. If you have written a lot of code already,
-you may want to automate the conversion task by using Monty's
-@code{replace} utility, which comes with the standard distribution of
-@strong{MySQL}, or just write your own Perl script. Hopefully, your
-code follows some recognizable pattern. If not, then you are probably
-better off re-writing it anyway, or at least going through and manually
-beating it into a pattern.
-
-Note that, of course, you can use different names for the
-functions. What is important is having unified interface for connecting
-for reads, connecting for writes, doing a read, and doing a write.
-
-
-@strong{Q}: When and how much can @strong{MySQL} replication improve the performance
-of my system?
-
-@strong{A}: @strong{MySQL} replication is most beneficial for a system
-with frequent reads and not so frequent writes. In theory, by using a
-one master/many slaves setup you can scale by adding more slaves until
-you either run out of network bandwidth, or your update
-load grows to the point
-that the master cannot handle it.
-
-In order to determine how many slaves you can get before the added
-benefits begin to level out, and how much you can improve performance
-of your site, you need to know your query patterns, and empirically
- (by benchmarking) determine the relationship between the throughput
-on reads (reads per second, or @code{max_reads}) and on writes
-@code{max_writes}) on a typical master and a typical slave. The
-example below will show you a rather simplified calculation of what you
-can get with replication for our imagined system.
-
-Let's say our system load consists of 10% writes and 90% reads, and we
-have determined that @code{max_reads} = 1200 - 2 * @code{max_writes},
-or in other words, our system can do 1200 reads per second with no
-writes, our average write is twice as slow as average read,
-and the relationship is
-linear. Let us suppose that our master and slave are of the same
-capacity, and we have N slaves and 1 master. Then we have for each
-server (master or slave):
-
-@code{reads = 1200 - 2 * writes} (from bencmarks)
-
-@code{reads = 9* writes / (N + 1) } (reads split, but writes go
-to all servers)
-
-@code{9*writes/(N+1) + 2 * writes = 1200}
-
-@code{writes = 1200/(2 + 9/(N+1)}
-
-So if N = 0, which means we have no replication, our system can handle
-1200/11, about 109 writes per second (which means we will have 9 times
-as many reads due to the nature of our application).
-
-If N = 1, we can get up to 184 writes per second.
-
-If N = 8, we get up to 400.
-
-If N = 17, 480 writes.
-
-Eventually as N approaches infinity (and our budget negative infinity),
-we can get very close to 600 writes per second, increasing system
-throughput about 5.5 times. However, with only 8 servers, we increased
-it almost 4 times already.
-
-Note that our computations assumed infinite network bandwidth, and
-neglected several other factors that could turn out to be significant on
-your system. In many cases, you may not be able to make a computation
-similar to the one above that will accurately predict what will happen
-on your system if you add N replication slaves. However, answering the
-following questions should help you decided whether and how much, if at
-all, the replication will improve the performance of your system:
-
-@itemize @bullet
-@item
-What is the read/write ratio on your system?
-@item
-How much more write load can one server handle if you reduce the reads?
-@item
-How many slaves do you have bandwidth for on your network?
-@end itemize
-
-@strong{Q}: How can I use replication to provide redundancy/high
-availability?
-
-@strong{A}: With the currently available features, you would have to
-set up a master and a slave (or several slaves), and write a script
-that will monitor the
-master to see if it is up, and instruct your applications and
-the slaves of the master change in case of failure. Some suggestions:
-
-@itemize @bullet
-@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 by
-having a dynamic DNS entry for the master. With @strong{bind} you can
-use @code{nsupdate} to dynamically update your DNS.
-@item
-You should run your slaves with the @code{log-bin} option and without
-@code{log-slave-updates}. This way the slave will be ready to become a
-master as soon as you issue @code{STOP SLAVE}; @code{RESET MASTER}, and
-@code{CHANGE MASTER TO} on the other slaves. It will also help you catch
-spurious updates that may happen because of misconfiguration of the
-slave (ideally, you want to configure access rights so that no client
-can update the slave, except for the slave thread) combined with the
-bugs in your client programs (they should never update the slave
-directly).
-
-@end itemize
-
-We are currently working on integrating an automatic master election
-system into @strong{MySQL}, but until it is ready, you will have to
-create your own monitoring tools.
-
-@node Replication Problems, , Replication FAQ, Replication
-@section Troubleshooting Replication
-
-If you have followed the instructions, and your replication setup is not
-working, first eliminate the user error factor by checking the following:
-
-@itemize @bullet
-@item
-Is the master logging to the binary log? Check with @code{SHOW MASTER STATUS}.
-If it is, @code{Position} will be non-zero. If not, verify that you have
-given the master @code{log-bin} option and have set @code{server-id}.
-@item
-Is the slave running? Check with @code{SHOW SLAVE STATUS}. The answer is found
-in @code{Slave_running} column. If not, verify slave options and check the
-error log for messages.
-@item
-If the slave is running, did it establish connection with the master? Do
-@code{SHOW PROCESSLIST}, find the thread with @code{system user} value in
-@code{User} column and @code{none} in the @code{Host} column, and check the
-@code{State} column. If it says @code{connecting to master}, verify the
-privileges for the replication user on the master, master host name, your
-DNS setup, whether the master is actually running, whether it is reachable
-from the slave, and if all that seems ok, read the error logs.
-@item
-If the slave was running, but then stopped, look at SHOW SLAVE STATUS
-output and check the error logs. It usually
-happens when some query that succeeded on the master fails on the slave. This
-should never happen if you have taken a proper snapshot of the master, and
-never modify the data on the slave outside of the slave thread. If it does,
-it is a bug, read below on how to report it.
-@item
-If a query on that succeeded on the master refuses to run on the slave, and
-a full database resync ( the proper thing to do ) does not seem feasible,
-try the following:
-@itemize bullet
-@item
-First see if there is some stray record in the way. Understand how it got
-there, then delete it and run @code{SLAVE START}
-@item
-If the above does not work or does not apply, try to understand if it would
-be safe to make the update manually ( if needed) and then ignore the next
-query from the master.
-@item
-If you have decided you can skip the next query, do
-@code{SET SQL_SLAVE_SKIP_COUNTER=1; SLAVE START;} to skip a query that
-does not use auto_increment, or last_insert_id or
-@code{SET SQL_SLAVE_SKIP_COUNTER=2; SLAVE START;} otherwise. The reason
-auto_increment/last_insert_id queries are different is that they take
-two events in the binary log of the master.
-
-@item
-If you are sure the slave started out perfectly in sync with the master,
-and no one has updated the tables involved outside of slave thread,
-report the bug, so
-you will not have to do the above tricks again.
-@end itemize
-@item
-Make sure you are not running into an old bug by upgrading to the most recent
-version.
-@item
-If all else fails, read the error logs. If they are big,
-@code{grep -i slave /path/to/your-log.err} on the slave. There is no
-generic pattern to search for on the master, as the only errors it logs
-are general system errors - if it can, it will send the error to the slave
-when things go wrong.
-@end itemize
-
-When you have determined that there is no user error involved, and replication
-still either does not work at all or is unstable, it is time to start working
-on a bug report. We need to get as much info as possible from you to be able
-to track down the bug. Please do spend some time and effort preparing a good
-bug report. Ideally, we would like to have a test case in the format found in
-@code{mysql-test/t/rpl*} directory of the source tree. If you submit a test
-case like that, you can expect a patch within a day or two in most cases,
-although, of course, you mileage may vary depending on a number of factors.
-
-Second best option is a just program with easily configurable connection
-arguments for the master and the slave that will demonstrate the problem on our
-systems. You can write one in Perl or in C, depending on which language you
-know better.
-
-If you have one of the above ways to demonstrate the bug, use
-@code{mysqlbug} to prepare a bug report and send it to
-@email{bugs@@lists.mysql.com}. If you have a phantom - a problem that
-does occur but you cannot duplicate "at will":
-
-@itemize @bullet
-@item
-Verify that there is no user error involved. For example, if you update the
-slave outside of the slave thread, the data will be out of sync, and you can
-have unique key violations on updates, in which case the slave thread will
-stop and wait for you to clean up the tables manually to bring them in sync.
-@item
-Run slave with @code{log-slave-updates} and @code{log-bin} - this will keep
-a log of all updates on the slave.
-@item
-Save all evidence before resetting the replication. If we have no or only
-sketchy information, it would take us a while to track down the problem. The
-evidence you should collect is:
-@itemize @bullet
-@item
-All binary logs on the master
-@item
-All binary log on the slave
-@item
-The output of @code{SHOW MASTER STATUS} on the master at the time
-you have discovered the problem
-@item
-The output of @code{SHOW SLAVE STATUS} on the master at the time
-you have discovered the problem
-@item
-Error logs on the master and on the slave
-@end itemize
-@item
-Use @code{mysqlbinlog} to examine the binary logs. The following should
-be helpful
-to find the trouble query, for example:
-@example
-mysqlbinlog -j pos_from_slave_status /path/to/log_from_slave_status | head
-@end example
-@end itemize
-
-Once you have collected the evidence on the phantom problem, try hard to
-isolate it into a separate test case first. Then report the problem to
-@email{bugs@@lists.mysql.com} with as much info as possible.
-
-@cindex searching, full-text
-@cindex full-text search
-@cindex FULLTEXT
-@node Fulltext Search, Performance, Replication, Top
-@chapter MySQL Full-text Search
-
-Since Version 3.23.23, @strong{MySQL} has support for full-text indexing
-and searching. Full-text indexes in @strong{MySQL} are an index of type
-@code{FULLTEXT}. @code{FULLTEXT} indexes can be created from @code{VARCHAR}
-and @code{TEXT} columns at @code{CREATE TABLE} time or added later with
-@code{ALTER TABLE} or @code{CREATE INDEX}. For large datasets, adding
-@code{FULLTEXT} index with @code{ALTER TABLE} (or @code{CREATE INDEX}) would
-be much faster than inserting rows into the empty table with a @code{FULLTEXT}
-index.
-
-Full-text search is performed with the @code{MATCH} function.
-
-@example
-mysql> CREATE TABLE articles (
- -> id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
- -> title VARCHAR(200),
- -> body TEXT,
- -> FULLTEXT (title,body)
- -> );
-Query OK, 0 rows affected (0.00 sec)
-
-mysql> INSERT INTO articles VALUES
- -> (0,'MySQL Tutorial', 'DBMS stands for DataBase Management ...'),
- -> (0,'How To Use MySQL Efficiently', 'After you went through a ...'),
- -> (0,'Optimizing MySQL','In this tutorial we will show how to ...'),
- -> (0,'1001 MySQL Trick','1. Never run mysqld as root. 2. Normalize ...'),
- -> (0,'MySQL vs. YourSQL', 'In the following database comparison we ...'),
- -> (0,'MySQL Security', 'When configured properly, MySQL could be ...');
-Query OK, 5 rows affected (0.00 sec)
-Records: 5 Duplicates: 0 Warnings: 0
-
-mysql> SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('database');
-+----+-------------------+---------------------------------------------+
-| id | title | body |
-+----+-------------------+---------------------------------------------+
-| 5 | MySQL vs. YourSQL | In the following database comparison we ... |
-| 1 | MySQL Tutorial | DBMS stands for DataBase Management ... |
-+----+-------------------+---------------------------------------------+
-2 rows in set (0.00 sec)
-@end example
-
-The function @code{MATCH} matches a natural language query @code{AGAINST}
-a text collection (which is simply the set of columns covered by a
-@code{FULLTEXT} index). For every row in a table it returns relevance -
-a similarity measure between the text in that row (in the columns that are
-part of the collection) and the query. When it is used in a @code{WHERE}
-clause (see example above) the rows returned are automatically sorted with
-relevance decreasing. Relevance is a non-negative floating-point number.
-Zero relevance means no similarity. Relevance is computed based on the
-number of words in the row, the number of unique words in that row, the
-total number of words in the collection, and the number of documents (rows)
-that contain a particular word.
-
-The above is a basic example of using @code{MATCH} function. Rows are
-returned with relevance decreasing.
-
-@example
-mysql> SELECT id,MATCH (title,body) AGAINST ('Tutorial') FROM articles;
-+----+-----------------------------------------+
-| id | MATCH (title,body) AGAINST ('Tutorial') |
-+----+-----------------------------------------+
-| 1 | 0.64840710366884 |
-| 2 | 0 |
-| 3 | 0.66266459031789 |
-| 4 | 0 |
-| 5 | 0 |
-| 6 | 0 |
-+----+-----------------------------------------+
-5 rows in set (0.00 sec)
-@end example
-
-This example shows how to retrieve the relevances. As neither @code{WHERE}
-nor @code{ORDER BY} clauses are present, returned rows are not ordered.
-
-@example
-mysql> SELECT id, body, MATCH (title,body) AGAINST (
- -> 'Security implications of running MySQL as root') AS score
- -> FROM articles WHERE MATCH (title,body) AGAINST
- -> ('Security implications of running MySQL as root');
-+----+-----------------------------------------------+-----------------+
-| id | body | score |
-+----+-----------------------------------------------+-----------------+
-| 4 | 1. Never run mysqld as root. 2. Normalize ... | 1.5055546709332 |
-| 6 | When configured properly, MySQL could be ... | 1.31140957288 |
-+----+-----------------------------------------------+-----------------+
-2 rows in set (0.00 sec)
-@end example
-
-This is more complex example - the query returns the relevance and still
-sorts the rows with relevance decreasing. To achieve it one should specify
-@code{MATCH} twice. Note, that this will cause no additional overhead, as
-@strong{MySQL} optimizer will notice that these two @code{MATCH} calls are
-identical and will call full-text search code only once.
-
-@strong{MySQL} uses a very simple parser to split text into words. A
-``word'' is any sequence of letters, numbers, @samp{'}, and @samp{_}. Any
-``word'' that is present in the stopword list or just too short (3
-characters or less) is ignored.
-
-Every correct word in the collection and in the query is weighted,
-according to its significance in the query or collection. This way, a
-word that is present in many documents will have lower weight (and may
-even have a zero weight), because it has lower semantic value in this
-particular collection. Otherwise, if the word is rare, it will receive a
-higher weight. The weights of the words are then combined to compute the
-relevance of the row.
-
-Such a technique works best with large collections (in fact, it was
-carefully tuned this way). For very small tables, word distribution
-does not reflect adequately their semantical value, and this model
-may sometimes produce bizarre results.
-
-@example
-mysql> SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('MySQL');
-Empty set (0.00 sec)
-@end example
-
-Search for the word @code{MySQL} produces no results in the above example.
-Word @code{MySQL} is present in more than half of rows, and as such, is
-effectively treated as a stopword (that is, with semantical value zero).
-It is, really, the desired behavior - a natural language query should not
-return every second row in 1GB table.
-
-A word that matches half of rows in a table is less likely to locate relevant
-documents. In fact, it will most likely find plenty of irrelevant documents.
-We all know this happens far too often when we are trying to find something on
-the Internet with a search engine. It is with this reasoning that such rows
-have been assigned a low semantical value in @strong{this particular dataset}.
-
-@menu
-* Fulltext Fine-tuning::
-* Fulltext Features to Appear in MySQL 4.0::
-* Fulltext TODO::
-@end menu
-
-@node Fulltext Fine-tuning, Fulltext Features to Appear in MySQL 4.0, Fulltext Search, Fulltext Search
-@section Fine-tuning MySQL Full-text Search
-
-Unfortunately, full-text search has no user-tunable parameters yet,
-although adding some is very high on the TODO. However, if you have a
-@strong{MySQL} source distribution (@xref{Installing source}.), you can
-somewhat alter the full-text search behavior.
-
-Note that full-text search was carefully tuned for the best searching
-effectiveness. Modifying the default behavior will, in most cases,
-only make the search results worse. Do not alter the @strong{MySQL} sources
-unless you know what you are doing!
-
-@itemize
-
-@item
-Minimal length of word to be indexed is defined in
-@code{myisam/ftdefs.h} file by the line
-@example
-#define MIN_WORD_LEN 4
-@end example
-Change it to the value you prefer, recompile @strong{MySQL}, and rebuild
-your @code{FULLTEXT} indexes.
-
-@item
-The stopword list is defined in @code{myisam/ft_static.c}
-Modify it to your taste, recompile @strong{MySQL} and rebuild
-your @code{FULLTEXT} indexes.
-
-@item
-The 50% threshold is caused by the particular weighting scheme chosen. To
-disable it, change the following line in @code{myisam/ftdefs.h}:
-@example
-#define GWS_IN_USE GWS_PROB
-@end example
-to
-@example
-#define GWS_IN_USE GWS_FREQ
-@end example
-and recompile @strong{MySQL}.
-There is no need to rebuild the indexes in this case.
-
-@end itemize
-
-@node Fulltext Features to Appear in MySQL 4.0, Fulltext TODO, Fulltext Fine-tuning, Fulltext Search
-@section New Features of Full-text Search to Appear in MySQL 4.0
-
-This section includes a list of the fulltext features that are already
-implemented in the 4.0 tree. It explains
-@strong{More functions for full-text search} entry of @ref{TODO MySQL 4.0}.
-
-@itemize @bullet
-@item @code{REPAIR TABLE} with @code{FULLTEXT} indexes,
-@code{ALTER TABLE} with @code{FULLTEXT} indexes, and
-@code{OPTIMIZE TABLE} with @code{FULLTEXT} indexes are now
-up to 100 times faster.
-
-@item @code{MATCH ... AGAINST} now supports the following
-@strong{boolean operators}:
-
-@itemize @bullet
-@item @code{+}word means the that word @strong{must} be present in every
-row returned.
-@item @code{-}word means the that word @strong{must not} be present in every
-row returned.
-@item @code{<} and @code{>} can be used to decrease and increase word
-weight in the query.
-@item @code{~} can be used to assign a @strong{negative} weight to a noise
-word.
-@item @code{*} is a truncation operator.
-@end itemize
-
-Boolean search utilizes a more simplistic way of calculating the relevance,
-that does not have a 50% threshold.
-
-@item Searches are now up to 2 times faster due to optimized search algorithm.
-
-@item Utility program @code{ft_dump} added for low-level @code{FULLTEXT}
-index operations (querying/dumping/statistics).
-
-@end itemize
-
-@node Fulltext TODO, , Fulltext Features to Appear in MySQL 4.0, Fulltext Search
-@section Full-text Search TODO
-
-@itemize @bullet
-@item Make all operations with @code{FULLTEXT} index @strong{faster}.
-@item Support for braces @code{()} in boolean full-text search.
-@item Phrase search, proximity operators
-@item Boolean search can work without @code{FULLTEXT} index
-(yes, @strong{very} slow).
-@item Support for "always-index words". They could be any strings
-the user wants to treat as words, examples are "C++", "AS/400", "TCP/IP", etc.
-@item Support for full-text search in @code{MERGE} tables.
-@item Support for multi-byte charsets.
-@item Make stopword list to depend of the language of the data.
-@item Stemming (dependent of the language of the data, of course).
-@item Generic user-supplyable UDF (?) preparser.
-@item Make the model more flexible (by adding some adjustable
-parameters to @code{FULLTEXT} in @code{CREATE/ALTER TABLE}).
-@end itemize
-
-@cindex performance, maximizing
-@cindex optimization
-@node Performance, MySQL Benchmarks, Fulltext Search, Top
-@chapter Getting Maximum Performance from MySQL
-
-Optimization is a complicated task because it ultimately requires
-understanding of the whole system. While it may be possible to do some
-local optimizations with small knowledge of your system/application, the
-more optimal you want your system to become the more you will have to
-know about it.
-
-So this chapter will try to explain and give some examples of different
-ways to optimize @strong{MySQL}. But remember that there are always some
-(increasingly harder) additional ways to make the system even faster.
-
-@menu
-* Optimize Basics:: Optimization overview
-* System:: System/Compile time and startup parameter tuning
-* Data size:: Get your data as small as possible
-* MySQL indexes:: How @strong{MySQL} uses indexes
-* Query Speed:: Speed of queries that access or update data
-* Tips:: Other optimization tips
-* Benchmarks:: Using your own benchmarks
-* Design:: Design choices
-* Design Limitations:: MySQL design limitations/tradeoffs
-* Portability:: Portability
-* Internal use:: What have we used MySQL for?
-@end menu
-
-@node Optimize Basics, System, Performance, Performance
-@section Optimization Overview
-
-The most important part for getting a system fast is of course the basic
-design. You also need to know what kinds of things your system will be
-doing, and what your bottlenecks are.
-
-The most common bottlenecks are:
-@itemize @bullet
-@item Disk seeks.
-It takes time for the disk to find a piece of data. With modern disks in
-1999, the mean time for this is usually lower than 10ms, so we can in
-theory do about 1000 seeks a second. This time improves slowly with new
-disks and is very hard to optimize for a single table. The way to
-optimize this is to spread the data on more than one disk.
-@item Disk reading/writing.
-When the disk is at the correct position we need to read the data. With
-modern disks in 1999, one disk delivers something like 10-20Mb/s. This
-is easier to optimize than seeks because you can read in parallel from
-multiple disks.
-@item CPU cycles.
-When we have the data in main memory (or if it already were
-there) we need to process it to get to our result. Having small
-tables compared to the memory is the most common limiting
-factor. But then, with small tables speed is usually not the problem.
-@item Memory bandwidth.
-When the CPU needs more data than can fit in the CPU cache the main
-memory bandwidth becomes a bottleneck. This is an uncommon bottleneck
-for most systems, but one should be aware of it.
-@end itemize
-
-@cindex compiling, optimizing
-@cindex system optimization
-@cindex startup parameters, tuning
-@node System, Data size, Optimize Basics, Performance
-@section System/Compile Time and Startup Parameter Tuning
-
-We start with the system level things since some of these decisions have
-to be made very early. In other cases a fast look at this part may
-suffice because it not that important for the big gains. However, it is always
-nice to have a feeling about how much one could gain by changing things
-at this level.
-
-The default OS to use is really important! To get the most use of
-multiple CPU machines one should use Solaris (because the threads works
-really nice) or Linux (because the 2.2 kernel has really good SMP
-support). Also on 32-bit machines Linux has a 2G file size limit by
-default. Hopefully this will be fixed soon when new filesystems are
-released (XFS/Reiserfs). If you have a desperate need for files bigger
-than 2G on Linux-intel 32 bit, you should get the LFS patch for the ext2
-file system.
-
-Because we have not run @strong{MySQL} in production on that many platforms, we
-advice you to test your intended platform before choosing it, if possible.
-
-@cindex locking
-Other tips:
-@itemize @bullet
-@item
-If you have enough RAM, you could remove all swap devices. Some
-operating systems will use a swap device in some contexts even if you
-have free memory.
-@item
-Use the @code{--skip-locking} @strong{MySQL} option to avoid external
-locking. Note that this will not impact @strong{MySQL}'s functionality as
-long as you only run one server. Just remember to take down the server (or
-lock relevant parts) before you run @code{myisamchk}. On some system
-this switch is mandatory because the external locking does not work in any
-case.
-
-The @code{--skip-locking} option is on by default when compiling with
-MIT-pthreads, because @code{flock()} isn't fully supported by
-MIT-pthreads on all platforms. It's also on default for Linux
-as Linux file locking are not yet safe.
-
-The only case when you can't use @code{--skip-locking} is if you run
-multiple @strong{MySQL} @emph{servers} (not clients) on the same data,
-or run @code{myisamchk} on the table without first flushing and locking
-the @code{mysqld} server tables first.
-
-You can still use @code{LOCK TABLES}/@code{UNLOCK TABLES} even if you
-are using @code{--skip-locking}
-@end itemize
-
-@menu
-* Compile and link options:: How compiling and linking affects the speed of MySQL
-* Disk issues:: Disk issues
-* Symbolic links:: Using Symbolic Links
-* Server parameters:: Tuning server parameters
-* Table cache:: How MySQL opens and closes tables
-* Creating many tables:: Drawbacks of creating large numbers of tables in the same database
-* Open tables:: Why so many open tables?
-* Memory use:: How MySQL uses memory
-* Internal locking:: How MySQL locks tables
-* Table locking:: Table locking issues
-* DNS::
-@end menu
-
-@node Compile and link options, Disk issues, System, System
-@subsection How Compiling and Linking Affects the Speed of MySQL
-
-Most of the following tests are done on Linux with the
-@strong{MySQL} benchmarks, but they should give some indication for
-other operating systems and workloads.
-
-@cindex linking, speed
-@cindex compiling, speed
-@cindex speed, compiling
-@cindex speed, linking
-
-You get the fastest executable when you link with @code{-static}.
-
-On Linux, you will get the fastest code when compiling with @code{pgcc}
-and @code{-O3}. To compile @file{sql_yacc.cc} with these options, you
-need about 200M memory because @code{gcc/pgcc} needs a lot of memory to
-make all functions inline. You should also set @code{CXX=gcc} when
-configuring @strong{MySQL} to avoid inclusion of the @code{libstdc++}
-library (it is not needed). Note that with some versions of @code{pgcc},
-the resulting code will only run on true Pentium processors, even if you
-use the compiler option that you want the resulting code to be working on
-all x586 type processors (like AMD).
-
-By just using a better compiler and/or better compiler options you can
-get a 10-30 % speed increase in your application. This is particularly
-important if you compile the SQL server yourself!
-
-We have tested both the Cygnus CodeFusion and Fujitsu compilers, but
-when we tested them, neither was sufficiently bug free to allow
-@strong{MySQL} to be compiled with optimizations on.
-
-When you compile @strong{MySQL} you should only include support for the
-character sets that you are going to use. (Option @code{--with-charset=xxx}).
-The standard @strong{MySQL} binary distributions are compiled with support
-for all character sets.
-
-Here is a list of some measurements that we have done:
-@itemize @bullet
-@item
-If you use @code{pgcc} and compile everything with @code{-O6}, the
-@code{mysqld} server is 1% faster than with @code{gcc} 2.95.2.
-
-@item
-If you link dynamically (without @code{-static}), the result is 13%
-slower on Linux. Note that you still can use a dynamic linked
-@strong{MySQL} library. It is only the server that is critical for
-performance.
-
-@item
-If you strip your @code{mysqld} binary with @code{strip libexec/mysqld},
-the resulting binary can be up to 4 % faster.
-
-@item
-If you connect using TCP/IP rather than Unix sockets, the result is 7.5%
-slower on the same computer. (If you are connection to @code{localhost},
-@strong{MySQL} will, by default, use sockets).
-
-@item
-If you connect using TCP/IP from another computer over a 100M Ethernet,
-things will be 8-11 % slower.
-
-@item
-If you compile with @code{--with-debug=full}, then you will loose 20 %
-for most queries, but some queries may take substantially longer (The
-@strong{MySQL} benchmarks ran 35 % slower)
-If you use @code{--with-debug}, then you will only loose 15 %.
-By starting a @code{mysqld} version compiled with @code{--with-debug=full}
-with @code{--skip-safemalloc} the end result should be close to when
-configuring with @code{--with-debug}.
-
-@item
-On a Sun SPARCstation 20, SunPro C++ 4.2 is 5 % faster than @code{gcc} 2.95.2.
-
-@item
-Compiling with @code{gcc} 2.95.2 for ultrasparc with the option
-@code{-mcpu=v8 -Wa,-xarch=v8plusa} gives 4 % more performance.
-
-@item
-On Solaris 2.5.1, MIT-pthreads is 8-12% slower than Solaris native
-threads on a single processor. With more load/CPUs the difference should
-get bigger.
-
-@item
-Running with @code{--log-bin} makes @strong{[MySQL} 1 % slower.
-
-@item
-Compiling on Linux-x86 using gcc without frame pointers
-@code{-fomit-frame-pointer} or @code{-fomit-frame-pointer -ffixed-ebp}
-@code{mysqld} 1-4% faster.
-@end itemize
-
-The @strong{MySQL}-Linux distribution provided by @strong{MySQL AB} used
-to be compiled with @code{pgcc}, but we had to go back to regular gcc
-because of a bug in @code{pgcc} that would generate the code that does
-not run on AMD. We will continue using gcc until that bug is resolved.
-In the meantime, if you have a non-AMD machine, you can get a faster
-binary by compiling with @code{pgcc}. The standard @strong{MySQL}
-Linux binary is linked statically to get it faster and more portable.
-
-@cindex disk issues
-@cindex performance, disk issues
-@node Disk issues, Symbolic links, Compile and link options, System
-@subsection Disk Issues
-
-@itemize @bullet
-@item
-As mentioned before, disks seeks are a big performance bottleneck. This
-problems gets more and more apparent when the data starts to grow so
-large that effective caching becomes impossible. For large databases,
-where you access data more or less randomly, you can be sure that you
-will need at least one disk seek to read and a couple of disk seeks to
-write things. To minimize this problem, use disks with low seek times.
-@item
-Increase the number of available disk spindles (and thereby reduce
-the seek overhead) by either symlink files to different disks or striping
-the disks.
-@table @strong
-@item Using symbolic links
-This means that you symlink the index and/or data file(s) from the
-normal data directory to another disk (that may also be striped). This
-makes both the seek and read times better (if the disks are not used for
-other things). @xref{Symbolic links}.
-@cindex striping, defined
-@item Striping
-Striping means that you have many disks and put the first block on the
-first disk, the second block on the second disk, and the Nth on the
-(N mod number_of_disks) disk, and so on. This means if your normal data
-size is less than the stripe size (or perfectly aligned) you will get
-much better performance. Note that striping is very dependent on the OS
-and stripe-size. So benchmark your application with different
-stripe-sizes. @xref{Benchmarks}.
-
-Note that the speed difference for striping is @strong{very} dependent
-on the parameters. Depending on how you set the striping parameters and
-number of disks you may get a difference in orders of magnitude. Note that
-you have to choose to optimize for random or sequential access.
-@end table
-@item
-For reliability you may want to use RAID 0+1 (striping + mirroring), but
-in this case you will need 2*N drives to hold N drives of data. This is
-probably the best option if you have the money for it! You may, however,
-also have to invest in some volume-management software to handle it
-efficiently.
-@item
-A good option is to have semi-important data (that can be regenerated)
-on RAID 0 disk while storing really important data (like host information
-and logs) on a RAID 0+1 or RAID N disk. RAID N can be a problem if you
-have many writes because of the time to update the parity bits.
-@item
-You may also set the parameters for the file system that the database
-uses. One easy change is to mount the file system with the noatime
-option. That makes it skip the updating of the last access time in the
-inode and by this will avoid some disk seeks.
-@item
-On Linux, you can get much more performance (up to 100 % under load is
-not uncommon) by using hdpram to configure your disk's interface! The
-following should be quite good hdparm options for @strong{MySQL} (and
-probably many other applications):
-@example
-hdparm -m 16 -d 1
-
-@end example
-
-Note that the performance/reliability when using the above depends on
-your hardware, so we strongly suggest that you test your system
-thoroughly after using @code{hdparm}! Please consult the @code{hdparm}
-man page for more information! If @code{hdparm} is not used wisely,
-filesystem corruption may result. Backup everything before experimenting!
-@item
-On many operating systems you can mount the disks with the 'async' flag to set the file
-system to be updated asynchronously. If your computer is reasonable stable,
-this should give you more performance without sacrificing too much reliability.
-(This flag is on by default on Linux.)
-@item
-If you don't need to know when a file was last accessed (which is not
-really useful on a database server), you can mount your file systems
-with the noatime flag.
-@end itemize
-
-@cindex symbolic links
-@cindex links, symbolic
-@node Symbolic links, Server parameters, Disk issues, System
-@subsection Using Symbolic Links
-
-You can move tables and databases from the database directory to other
-locations and replace them with symbolic links to the new locations.
-You might want to do this, for example, to move a database to a file
-system with more free space or increase the speed of your system by
-spreading your tables to different disk.
+@node Clients, Extending MySQL, Table types, Top
+@chapter MySQL APIs
-The recommended may to do this, is to just symlink databases to different
-disk and only symlink tables as a last resort.
-.
+@cindex client tools
+@cindex APIs
+@cindex @code{mysqlclient} library
+@cindex buffer sizes, client
+@cindex library, @code{mysqlclient}
-@cindex databases, symbolic links
@menu
-* Symbolic links to database::
-* Symbolic links to tables::
+* PHP:: MySQL PHP API
+* Perl:: MySQL Perl API
+* ODBC:: MySQL ODBC Support
+* C:: MySQL C API
+* Cplusplus:: MySQL C++ APIs
+* Java:: MySQL Java connectivity (JDBC)
+* Python:: MySQL Python APIs
+* Tcl:: MySQL Tcl APIs
+* Eiffel:: MySQL Eiffel wrapper
@end menu
-@node Symbolic links to database, Symbolic links to tables, Symbolic links, Symbolic links
-@subsubsection Using Symbolic Links for Databases
-
-The way to symlink a database is to first create a directory on some
-disk where you have free space and then create a symlink to it from
-the @strong{MySQL} database directory.
-
-@example
-shell> mkdir /dr1/databases/test
-shell> ln -s /dr1/databases/test mysqld-datadir
-@end example
-
-@strong{MySQL} doesn't support that you link one directory to multiple
-databases. Replacing a database directory with a symbolic link will
-work fine as long as you don't make a symbolic link between databases.
-Suppose you have a database @code{db1} under the @strong{MySQL} data
-directory, and then make a symlink @code{db2} that points to @code{db1}:
-
-@example
-shell> cd /path/to/datadir
-shell> ln -s db1 db2
-@end example
-
-Now, for any table @code{tbl_a} in @code{db1}, there also appears to be
-a table @code{tbl_a} in @code{db2}. If one thread updates @code{db1.tbl_a}
-and another thread updates @code{db2.tbl_a}, there will be problems.
-
-If you really need this, you must change the following code in
-@file{mysys/mf_format.c}:
-
-@example
-if (flag & 32 || (!lstat(to,&stat_buff) && S_ISLNK(stat_buff.st_mode)))
-@end example
-
-to
-
-@example
-if (1)
-@end example
-
-On Windows you can use internal symbolic links to directories by compiling
-@strong{MySQL} with @code{-DUSE_SYMDIR}. This allows you to put different
-databases on different disks. @xref{Windows symbolic links}.
-
-@cindex databases, symbolic links
-@node Symbolic links to tables, , Symbolic links to database, Symbolic links
-@subsubsection Using Symbolic Links for Tables
-
-Before @strong{MySQL} 4.0 you should not symlink tables, if you are not
-very carefully with them. The problem is that if you run @code{ALTER
-TABLE}, @code{REPAIR TABLE} or @code{OPTIMIZE TABLE} on a symlinked
-table, the symlinks will be removed and replaced by the original
-files. This happens because the above command works by creating a
-temporary file in the database directory and when the command is
-complete, replace the original file with the temporary file.
-
-You should not symlink tables on system that doesn't have a fully
-working @code{realpath()} call. (At least Linux and Solaris support
-@code{realpath()})
-
-In @strong{MySQL} 4.0 symlinks is only fully supported for @code{MyISAM}
-tables. For other table types you will probably get strange problems
-when doing any of the above mentioned commands.
-
-The handling of symbolic links in @strong{MySQL} 4.0 works the following
-way (this is mostly relevant only for @code{MyISAM} tables).
-
-@itemize @bullet
-@item
-In the data directory you will always have the table definition file
-and the data/index files.
-@item
-You can symlink the index file and the data file to different directories
-independent of the other.
-@item
-The symlinking can be done from the operating system (if @code{mysqld} is
-not running) or with the @code{INDEX/DATA DIRECTORY="path-to-dir"} command
-in @code{CREATE TABLE}. @xref{CREATE TABLE}.
-@item
-@code{myisamchk} will not replace a symlink with the index/file but
-work directly on the files the symlinks points to. Any temporary files
-will be created in the same directory where the data/index file is.
-@item
-When you drop a table that is using symlinks, both the symlink and the
-file the symlink points to is dropped. This is a good reason to why you
-should NOT run @code{mysqld} as root and not allow persons to have write
-access to the @strong{MySQL} database directories.
-@item
-If you rename a table with @code{ALTER TABLE RENAME} and you don't change
-database, the symlink in the database directory will be renamed to the new
-name and the data/index file will be renamed accordingly.
-@item
-If you use @code{ALTER TABLE RENAME} to move a table to another database,
-then the table will be moved to the other database directory and the old
-symlinks and the files they pointed to will be deleted.
-@item
-If you are not using symlinks you should use the @code{--skip-symlink}
-option to @code{mysqld} to ensure that no one can drop or rename a file
-outside of the @code{mysqld} data directory.
-@end itemize
-
-Things that are not yet supported:
-
-@cindex TODO, symlinks
-@itemize @bullet
-@item
-@code{ALTER TABLE} ignores all @code{INDEX/DATA DIRECTORY="path"} options.
-@item
-@code{CREATE TABLE} doesn't report if the table has symbolic links.
-@item
-@code{mysqldump} doesn't include the symbolic links information in the output.
-@item
-@code{BACKUP TABLE} and @code{RESTORE TABLE} doesn't use symbolic links.
-@end itemize
-
-@cindex parameters, server
-@cindex @code{mysqld} server, buffer sizes
-@cindex buffer sizes, @code{mysqld} server
-@cindex startup parameters
-@node Server parameters, Table cache, Symbolic links, System
-@subsection Tuning Server Parameters
-
-You can get the default buffer sizes used by the @code{mysqld} server
-with this command:
-
-@example
-shell> mysqld --help
-@end example
-
-@cindex @code{mysqld} options
-@cindex variables, @code{mysqld}
-This command produces a list of all @code{mysqld} options and configurable
-variables. The output includes the default values and looks something
-like this:
-
-@example
-Possible variables for option --set-variable (-O) are:
-back_log current value: 5
-bdb_cache_size current value: 1048540
-binlog_cache_size current_value: 32768
-connect_timeout current value: 5
-delayed_insert_timeout current value: 300
-delayed_insert_limit current value: 100
-delayed_queue_size current value: 1000
-flush_time current value: 0
-interactive_timeout current value: 28800
-join_buffer_size current value: 131072
-key_buffer_size current value: 1048540
-lower_case_table_names current value: 0
-long_query_time current value: 10
-max_allowed_packet current value: 1048576
-max_binlog_cache_size current_value: 4294967295
-max_connections current value: 100
-max_connect_errors current value: 10
-max_delayed_threads current value: 20
-max_heap_table_size current value: 16777216
-max_join_size current value: 4294967295
-max_sort_length current value: 1024
-max_tmp_tables current value: 32
-max_write_lock_count current value: 4294967295
-myisam_sort_buffer_size current value: 8388608
-net_buffer_length current value: 16384
-net_retry_count current value: 10
-net_read_timeout current value: 30
-net_write_timeout current value: 60
-query_buffer_size current value: 0
-record_buffer current value: 131072
-slow_launch_time current value: 2
-sort_buffer current value: 2097116
-table_cache current value: 64
-thread_concurrency current value: 10
-tmp_table_size current value: 1048576
-thread_stack current value: 131072
-wait_timeout current value: 28800
-@end example
-
-If there is a @code{mysqld} server currently running, you can see what
-values it actually is using for the variables by executing this command:
-
-@example
-shell> mysqladmin variables
-@end example
-
-You can find a full description for all variables in the @code{SHOW VARIABLES}
-section in this manual. @xref{SHOW VARIABLES}.
-
-You can also see some statistics from a running server by issuing the command
-@code{SHOW STATUS}. @xref{SHOW STATUS}.
-
-@strong{MySQL} uses algorithms that are very scalable, so you can usually
-run with very little memory. If you, however, give @strong{MySQL} more
-memory, you will normally also get better performance.
-
-When tuning a @strong{MySQL} server, the two most important variables to use
-are @code{key_buffer_size} and @code{table_cache}. You should first feel
-confident that you have these right before trying to change any of the
-other variables.
-
-If you have much memory (>=256M) and many tables and want maximum performance
-with a moderate number of clients, you should use something like this:
-
-@example
-shell> safe_mysqld -O key_buffer=64M -O table_cache=256 \
- -O sort_buffer=4M -O record_buffer=1M &
-@end example
-
-If you have only 128M and only a few tables, but you still do a lot of
-sorting, you can use something like:
-
-@example
-shell> safe_mysqld -O key_buffer=16M -O sort_buffer=1M
-@end example
-
-If you have little memory and lots of connections, use something like this:
-
-@example
-shell> safe_mysqld -O key_buffer=512k -O sort_buffer=100k \
- -O record_buffer=100k &
-@end example
-
-or even:
-
-@example
-shell> safe_mysqld -O key_buffer=512k -O sort_buffer=16k \
- -O table_cache=32 -O record_buffer=8k -O net_buffer=1K &
-@end example
-
-When you have installed @strong{MySQL}, the @file{support-files} directory will
-contain some different @code{my.cnf} example files, @file{my-huge.cnf},
-@file{my-large.cnf}, @file{my-medium.cnf}, and @file{my-small.cnf}, you can
-use as a base to optimize your system.
-
-If there are very many connections, ``swapping problems'' may occur unless
-@code{mysqld} has been configured to use very little memory for each
-connection. @code{mysqld} performs better if you have enough memory for all
-connections, of course.
-
-Note that if you change an option to @code{mysqld}, it remains in effect only
-for that instance of the server.
-
-To see the effects of a parameter change, do something like this:
-
-@example
-shell> mysqld -O key_buffer=32m --help
-@end example
-
-Make sure that the @code{--help} option is last; otherwise, the effect of any
-options listed after it on the command line will not be reflected in the
-output.
-
-@cindex tables, opening
-@cindex tables, closing
-@cindex opening, tables
-@cindex closing, tables
-@cindex table cache
-@findex table_cache
-@node Table cache, Creating many tables, Server parameters, System
-@subsection How MySQL Opens and Closes Tables
-
-@code{table_cache}, @code{max_connections}, and @code{max_tmp_tables}
-affect the maximum number of files the server keeps open. If you
-increase one or both of these values, you may run up against a limit
-imposed by your operating system on the per-process number of open file
-descriptors. However, you can increase the limit on many systems.
-Consult your OS documentation to find out how to do this, because the
-method for changing the limit varies widely from system to system.
-
-@code{table_cache} is related to @code{max_connections}. For example,
-for 200 concurrent running connections, you should have a table cache of
-at least @code{200 * n}, where @code{n} is the maximum number of tables
-in a join. You also need to reserve some extra file descriptors for
-temporary tables and files.
-
-The cache of open tables can grow to a maximum of @code{table_cache}
-(default 64; this can be changed with the @code{-O table_cache=#}
-option to @code{mysqld}). A table is never closed, except when the
-cache is full and another thread tries to open a table or if you use
-@code{mysqladmin refresh} or @code{mysqladmin flush-tables}.
-
-When the table cache fills up, the server uses the following procedure
-to locate a cache entry to use:
-
-@itemize @bullet
-@item
-Tables that are not currently in use are released, in least-recently-used
-order.
-
-@item
-If the cache is full and no tables can be released, but a new table needs to
-be opened, the cache is temporarily extended as necessary.
-
-@item
-If the cache is in a temporarily-extended state and a table goes from in-use
-to not-in-use state, the table is closed and released from the cache.
-@end itemize
-
-A table is opened for each concurrent access. This means that
-if you have two threads accessing the same table or access the table
-twice in the same query (with @code{AS}) the table needs to be opened twice.
-The first open of any table takes two file descriptors; each additional
-use of the table takes only one file descriptor. The extra descriptor
-for the first open is used for the index file; this descriptor is shared
-among all threads.
-
-You can check if your table cache is too small by checking the mysqld
-variable @code{opened_tables}. If this is quite big, even if you
-haven't done a lot of @code{FLUSH TABLES}, you should increase your table
-cache. @xref{SHOW STATUS}.
-
-@cindex tables, too many
-@node Creating many tables, Open tables, Table cache, System
-@subsection Drawbacks to Creating Large Numbers of Tables in the Same Database
-
-If you have many files in a directory, open, close, and create operations will
-be slow. If you execute @code{SELECT} statements on many different tables,
-there will be a little overhead when the table cache is full, because for
-every table that has to be opened, another must be closed. You can reduce
-this overhead by making the table cache larger.
-
-@cindex tables, open
-@cindex open tables
-@node Open tables, Memory use, Creating many tables, System
-@subsection Why So Many Open tables?
-
-When you run @code{mysqladmin status}, you'll see something like this:
-
-@example
-Uptime: 426 Running threads: 1 Questions: 11082 Reloads: 1 Open tables: 12
-@end example
-
-This can be somewhat perplexing if you only have 6 tables.
-
-@strong{MySQL} is multithreaded, so it may have many queries on the same
-table simultaneously. To minimize the problem with two threads having
-different states on the same file, the table is opened independently by
-each concurrent thread. This takes some memory and one extra file
-descriptor for the data file. The index file descriptor is shared
-between all threads.
-
-@cindex memory use
-@node Memory use, Internal locking, Open tables, System
-@subsection How MySQL Uses Memory
-
-The list below indicates some of the ways that the @code{mysqld} server
-uses memory. Where applicable, the name of the server variable relevant
-to the memory use is given:
-
-@itemize @bullet
-@item
-The key buffer (variable @code{key_buffer_size}) is shared by all
-threads; Other buffers used by the server are allocated as
-needed. @xref{Server parameters}.
-
-@item
-Each connection uses some thread-specific space: A stack (default 64K,
-variable @code{thread_stack}), a connection buffer (variable
-@code{net_buffer_length}), and a result buffer (variable
-@code{net_buffer_length}). The connection buffer and result buffer are
-dynamically enlarged up to @code{max_allowed_packet} when needed. When
-a query is running, a copy of the current query string is also allocated.
-
-@item
-All threads share the same base memory.
-
-@item
-Only the compressed ISAM / MyISAM tables are memory mapped. This is
-because the 32-bit memory space of 4GB is not large enough for most
-big tables. When systems with a 64-bit address space become more
-common we may add general support for memory mapping.
-
-@item
-Each request doing a sequential scan over a table allocates a read buffer
-(variable @code{record_buffer}).
-
-@item
-All joins are done in one pass, and most joins can be done without even
-using a temporary table. Most temporary tables are memory-based (HEAP)
-tables. Temporary tables with a big record length (calculated as the
-sum of all column lengths) or that contain @code{BLOB} columns are
-stored on disk.
-
-One problem in @strong{MySQL} versions before Version 3.23.2 is that if a HEAP table
-exceeds the size of @code{tmp_table_size}, you get the error @code{The
-table tbl_name is full}. In newer versions this is handled by
-automatically changing the in-memory (HEAP) table to a disk-based
-(MyISAM) table as necessary. To work around this problem, you can
-increase the temporary table size by setting the @code{tmp_table_size}
-option to @code{mysqld}, or by setting the SQL option
-@code{SQL_BIG_TABLES} in the client program. @xref{SET OPTION, ,
-@code{SET OPTION}}. In @strong{MySQL} Version 3.20, the maximum size of the
-temporary table was @code{record_buffer*16}, so if you are using this
-version, you have to increase the value of @code{record_buffer}. You can
-also start @code{mysqld} with the @code{--big-tables} option to always
-store temporary tables on disk. However, this will affect the speed of
-many complicated queries.
-
-@item
-Most requests doing a sort allocates a sort buffer and 0-2 temporary
-files depending on the result set size. @xref{Temporary files}.
-
-@item
-Almost all parsing and calculating is done in a local memory store. No
-memory overhead is needed for small items and the normal slow memory
-allocation and freeing is avoided. Memory is allocated only for
-unexpectedly large strings (this is done with @code{malloc()} and
-@code{free()}).
-
-@item
-Each index file is opened once and the data file is opened once for each
-concurrently running thread. For each concurrent thread, a table structure,
-column structures for each column, and a buffer of size @code{3 * n} is
-allocated (where @code{n} is the maximum row length, not counting @code{BLOB}
-columns). A @code{BLOB} uses 5 to 8 bytes plus the length of the @code{BLOB}
-data. The @code{ISAM}/@code{MyISAM} table handlers will use one extra row
-buffer for internal usage.
-
-@item
-For each table having @code{BLOB} columns, a buffer is enlarged dynamically
-to read in larger @code{BLOB} values. If you scan a table, a buffer as large
-as the largest @code{BLOB} value is allocated.
-
-@item
-Table handlers for all in-use tables are saved in a cache and managed as a
-FIFO. Normally the cache has 64 entries. If a table has been used by two
-running threads at the same time, the cache contains two entries for the
-table. @xref{Table cache}.
-
-@item
-A @code{mysqladmin flush-tables} command closes all tables that are not in
-use and marks all in-use tables to be closed when the currently executing
-thread finishes. This will effectively free most in-use memory.
-@end itemize
-
-@code{ps} and other system status programs may report that @code{mysqld}
-uses a lot of memory. This may be caused by thread-stacks on different
-memory addresses. For example, the Solaris version of @code{ps} counts
-the unused memory between stacks as used memory. You can verify this by
-checking available swap with @code{swap -s}. We have tested
-@code{mysqld} with commercial memory-leakage detectors, so there should
-be no memory leaks.
-
-@cindex internal locking
-@cindex locking, tables
-@cindex tables, locking
-@node Internal locking, Table locking, Memory use, System
-@subsection How MySQL Locks Tables
-
-You can find a discussion about different locking methods in the appendix.
-@xref{Locking methods}.
-
-All locking in @strong{MySQL} is deadlock-free. This is managed by always
-requesting all needed locks at once at the beginning of a query and always
-locking the tables in the same order.
-
-The locking method @strong{MySQL} uses for @code{WRITE} locks works as follows:
-
-@itemize @bullet
-@item
-If there are no locks on the table, put a write lock on it.
-@item
-Otherwise, put the lock request in the write lock queue.
-@end itemize
-
-The locking method @strong{MySQL} uses for @code{READ} locks works as follows:
-
-@itemize @bullet
-@item
-If there are no write locks on the table, put a read lock on it.
-@item
-Otherwise, put the lock request in the read lock queue.
-@end itemize
-
-When a lock is released, the lock is made available to the threads
-in the write lock queue, then to the threads in the read lock queue.
-
-This means that if you have many updates on a table, @code{SELECT}
-statements will wait until there are no more updates.
-
-To work around this for the case where you want to do many @code{INSERT} and
-@code{SELECT} operations on a table, you can insert rows in a temporary
-table and update the real table with the records from the temporary table
-once in a while.
-
-This can be done with the following code:
-@example
-mysql> LOCK TABLES real_table WRITE, insert_table WRITE;
-mysql> insert into real_table select * from insert_table;
-mysql> TRUNCATE TABLE insert_table;
-mysql> UNLOCK TABLES;
-@end example
-
-You can use the @code{LOW_PRIORITY} options with @code{INSERT},
-@code{UPDATE} or @code{DELETE} or @code{HIGH_PRIORITY} with
-@code{SELECT} if you want to prioritize retrieval in some specific
-cases. You can also start @code{mysqld} with @code{--low-priority-updates}
-to get the same behaveour.
-
-Using @code{SQL_BUFFER_RESULT} can also help making table locks shorter.
-@xref{SELECT}.
-
-You could also change the locking code in @file{mysys/thr_lock.c} to use a
-single queue. In this case, write locks and read locks would have the same
-priority, which might help some applications.
-
-@cindex problems, table locking
-@node Table locking, DNS, Internal locking, System
-@subsection Table Locking Issues
-
-The table locking code in @strong{MySQL} is deadlock free.
-
-@strong{MySQL} uses table locking (instead of row locking or column
-locking) on all table types, except @code{BDB} tables, to achieve a very
-high lock speed. For large tables, table locking is MUCH better than
-row locking for most applications, but there are, of course, some
-pitfalls.
-
-For @code{BDB} and @code{InnoDB} tables, @strong{MySQL} only uses table
-locking if you explicitely lock the table with @code{LOCK TABLES} or
-execute a command that will modify every row in the table, like
-@code{ALTER TABLE}. For these table types we recommend you to not use
-@code{LOCK TABLES} at all.
-
-In @strong{MySQL} Version 3.23.7 and above, you can insert rows into
-@code{MyISAM} tables at the same time other threads are reading from the
-table. Note that currently this only works if there are no holes after
-deleted rows in the table at the time the insert is made. When all holes
-has been filled with new data, concurrent inserts will automatically be
-enabled again.
-
-Table locking enables many threads to read from a table at the same
-time, but if a thread wants to write to a table, it must first get
-exclusive access. During the update, all other threads that want to
-access this particular table will wait until the update is ready.
-
-As updates on tables normally are considered to be more important than
-@code{SELECT}, all statements that update a table have higher priority
-than statements that retrieve information from a table. This should
-ensure that updates are not 'starved' because one issues a lot of heavy
-queries against a specific table. (You can change this by using
-LOW_PRIORITY with the statement that does the update or
-@code{HIGH_PRIORITY} with the @code{SELECT} statement.)
-
-Starting from @strong{MySQL} Version 3.23.7 one can use the
-@code{max_write_lock_count} variable to force @strong{MySQL} to
-temporary give all @code{SELECT} statements, that wait for a table, a
-higher priority after a specific number of inserts on a table.
-
-Table locking is, however, not very good under the following senario:
-
-@itemize @bullet
-@item
-A client issues a @code{SELECT} that takes a long time to run.
-@item
-Another client then issues an @code{UPDATE} on a used table. This client
-will wait until the @code{SELECT} is finished.
-@item
-Another client issues another @code{SELECT} statement on the same table. As
-@code{UPDATE} has higher priority than @code{SELECT}, this @code{SELECT}
-will wait for the @code{UPDATE} to finish. It will also wait for the first
-@code{SELECT} to finish!
-@item
-A thread is waiting for something like @code{full disk}, in which case all
-threads that wants to access the problem table will also be put in a waiting
-state until more disk space is made available.
-@end itemize
-
-Some possible solutions to this problem are:
-
-@itemize @bullet
-@item
-Try to get the @code{SELECT} statements to run faster. You may have to create
-some summary tables to do this.
-
-@item
-Start @code{mysqld} with @code{--low-priority-updates}. This will give
-all statements that update (modify) a table lower priority than a @code{SELECT}
-statement. In this case the last @code{SELECT} statement in the previous
-scenario would execute before the @code{INSERT} statement.
-
-@item
-You can give a specific @code{INSERT}, @code{UPDATE}, or @code{DELETE}
-statement lower priority with the @code{LOW_PRIORITY} attribute.
-
-@item
-Start @code{mysqld} with a low value for @strong{max_write_lock_count} to give
-@code{READ} locks after a certain number of @code{WRITE} locks.
-
-@item
-You can specify that all updates from a specific thread should be done with
-low priority by using the SQL command: @code{SET SQL_LOW_PRIORITY_UPDATES=1}.
-@xref{SET OPTION, , @code{SET OPTION}}.
-
-@item
-You can specify that a specific @code{SELECT} is very important with the
-@code{HIGH_PRIORITY} attribute. @xref{SELECT, , @code{SELECT}}.
-
-@item
-If you have problems with @code{INSERT} combined with @code{SELECT},
-switch to use the new @code{MyISAM} tables as these support concurrent
-@code{SELECT}s and @code{INSERT}s.
-
-@item
-If you mainly mix @code{INSERT} and @code{SELECT} statements, the
-@code{DELAYED} attribute to @code{INSERT} will probably solve your problems.
-@xref{INSERT, , @code{INSERT}}.
-
-@item
-If you have problems with @code{SELECT} and @code{DELETE}, the @code{LIMIT}
-option to @code{DELETE} may help. @xref{DELETE, , @code{DELETE}}.
-@end itemize
-
-@cindex DNS
-@cindex hostname caching
-@node DNS, , Table locking, System
-@subsection How MySQL uses DNS
-
-When a new thread connects to @code{mysqld}, @code{mysqld} will span a
-new thread to handle the request. This thread will first check if the
-hostname is in the hostname cache. If not the thread will call
-@code{gethostbyaddr_r()} and @code{gethostbyname_r()} to resolve the
-hostname.
-
-If the operating system doesn't support the above thread-safe calls, the
-thread will lock a mutex and call @code{gethostbyaddr()} and
-@code{gethostbyname()} instead. Note that in this case no other thread
-can resolve other hostnames that is not in the hostname cache until the
-first thread is ready.
-
-You can disable DNS host lookup by starting @code{mysqld} with
-@code{--skip-name-resolve}. In this case you can however only use IP
-names in the @strong{MySQL} privilege tables.
-
-If you have a very slow DNS and many hosts, you can get more performance by
-either disabling DNS lookop with @code{--skip-name-resolve} or by
-increasing the @code{HOST_CACHE_SIZE} define (default: 128) and recompile
-@code{mysqld}.
-
-You can disable the hostname cache with @code{--skip-host-cache}. You
-can clear the hostname cache with @code{FLUSH HOSTS} or @code{mysqladmin
-flush-hosts}.
-
-If you don't want to allow connections over @code{TCP/IP}, you can do this
-by starting @code{mysqld} with @code{--skip-networking}.
-
-@cindex data, size
-@cindex reducing, data size
-@cindex storage space, minimizing
-@cindex tables, improving performance
-@cindex performance, improving
-@node Data size, MySQL indexes, System, Performance
-@section Get Your Data as Small as Possible
-
-One of the most basic optimization is to get your data (and indexes) to
-take as little space on the disk (and in memory) as possible. This can
-give huge improvements because disk reads are faster and normally less
-main memory will be used. Indexing also takes less resources if
-done on smaller columns.
-
-@strong{MySQL} supports a lot of different table types and row formats.
-Choosing the right table format may give you a big performance gain.
-@xref{Table types}.
-
-You can get better performance on a table and minimize storage space
-using the techniques listed below:
-
-@itemize @bullet
-@item
-Use the most efficient (smallest) types possible. @strong{MySQL} has
-many specialized types that save disk space and memory.
-@item
-Use the smaller integer types if possible to get smaller tables. For
-example, @code{MEDIUMINT} is often better than @code{INT}.
-@item
-Declare columns to be @code{NOT NULL} if possible. It makes everything
-faster and you save one bit per column. Note that if you really need
-@code{NULL} in your application you should definitely use it. Just avoid
-having it on all columns by default.
-@item
-If you don't have any variable-length columns (@code{VARCHAR},
-@code{TEXT}, or @code{BLOB} columns), a fixed-size record format is
-used. This is faster but unfortunately may waste some space.
-@xref{MyISAM table formats}.
-@item
-The primary index of a table should be as short as possible. This makes
-identification of one row easy and efficient.
-@item
-For each table, you have to decide which storage/index method to
-use. @xref{Table types}.
-@item
-Only create the indexes that you really need. Indexes are good for
-retrieval but bad when you need to store things fast. If you mostly
-access a table by searching on a combination of columns, make an index
-on them. The first index part should be the most used column. If you are
-ALWAYS using many columns, you should use the column with more duplicates
-first to get better compression of the index.
-@item
-If it's very likely that a column has a unique prefix on the first number
-of characters, it's better to only index this prefix. @strong{MySQL}
-supports an index on a part of a character column. Shorter indexes are
-faster not only because they take less disk space but also because they
-will give you more hits in the index cache and thus fewer disk
-seeks. @xref{Server parameters}.
-@item
-In some circumstances it can be beneficial to split into two a table that is
-scanned very often. This is especially true if it is a dynamic
-format table and it is possible to use a smaller static format table that
-can be used to find the relevant rows when scanning the table.
-@end itemize
-
-@cindex indexes, uses for
-@node MySQL indexes, Query Speed, Data size, Performance
-@section How MySQL Uses Indexes
-
-Indexes are used to find rows with a specific value of one column
-fast. Without an index @strong{MySQL} has to start with the first record
-and then read through the whole table until it finds the relevant
-rows. The bigger the table, the more this costs. If the table has an index
-for the columns in question, @strong{MySQL} can quickly get a position to
-seek to in the middle of the data file without having to look at all the
-data. If a table has 1000 rows, this is at least 100 times faster than
-reading sequentially. Note that if you need to access almost all 1000
-rows it is faster to read sequentially because we then avoid disk seeks.
-
-All @strong{MySQL} indexes (@code{PRIMARY}, @code{UNIQUE}, and
-@code{INDEX}) are stored in B-trees. Strings are automatically prefix-
-and end-space compressed. @xref{CREATE INDEX, , @code{CREATE INDEX}}.
-
-Indexes are used to:
-@itemize @bullet
-@item
-Quickly find the rows that match a @code{WHERE} clause.
-
-@item
-Retrieve rows from other tables when performing joins.
-
-@item
-Find the @code{MAX()} or @code{MIN()} value for a specific indexed
-column. This is optimized by a preprocessor that checks if you are
-using @code{WHERE} key_part_# = constant on all key parts < N. In this case
-@strong{MySQL} will do a single key lookup and replace the @code{MIN()}
-expression with a constant. If all expressions are replaced with
-constants, the query will return at once:
-
-@example
-SELECT MIN(key_part2),MAX(key_part2) FROM table_name where key_part1=10
-@end example
-
-@item
-Sort or group a table if the sorting or grouping is done on a leftmost
-prefix of a usable key (for example, @code{ORDER BY key_part_1,key_part_2 }). The
-key is read in reverse order if all key parts are followed by @code{DESC}.
-
-The index can also be used even if the @code{ORDER BY} doesn't match the index
-exactly, as long as all the unused index parts and all the extra
-are @code{ORDER BY} columns are constants in the @code{WHERE} clause. The
-following queries will use the index to resolve the @code{ORDER BY} part:
-
-@example
-SELECT * FROM foo ORDER BY key_part1,key_part2,key_part3;
-SELECT * FROM foo WHERE column=constant ORDER BY column, key_part1;
-SELECT * FROM foo WHERE key_part1=const GROUP BY key_part2;
-@end example
-
-@item
-In some cases a query can be optimized to retrieve values without
-consulting the data file. If all used columns for some table are numeric
-and form a leftmost prefix for some key, the values may be retrieved
-from the index tree for greater speed:
-
-@example
-SELECT key_part3 FROM table_name WHERE key_part1=1
-@end example
-
-@end itemize
-
-Suppose you issue the following @code{SELECT} statement:
-
-@example
-mysql> SELECT * FROM tbl_name WHERE col1=val1 AND col2=val2;
-@end example
-
-If a multiple-column index exists on @code{col1} and @code{col2}, the
-appropriate rows can be fetched directly. If separate single-column
-indexes exist on @code{col1} and @code{col2}, the optimizer tries to
-find the most restrictive index by deciding which index will find fewer
-rows and using that index to fetch the rows.
-
-@cindex indexes, leftmost prefix of
-@cindex leftmost prefix of indexes
-If the table has a multiple-column index, any leftmost prefix of the
-index can be used by the optimizer to find rows. For example, if you
-have a three-column index on @code{(col1,col2,col3)}, you have indexed
-search capabilities on @code{(col1)}, @code{(col1,col2)}, and
-@code{(col1,col2,col3)}.
-
-@strong{MySQL} can't use a partial index if the columns don't form a
-leftmost prefix of the index. Suppose you have the @code{SELECT}
-statements shown below:
-
-@example
-mysql> SELECT * FROM tbl_name WHERE col1=val1;
-mysql> SELECT * FROM tbl_name WHERE col2=val2;
-mysql> SELECT * FROM tbl_name WHERE col2=val2 AND col3=val3;
-@end example
-
-If an index exists on @code{(col1,col2,col3)}, only the first query
-shown above uses the index. The second and third queries do involve
-indexed columns, but @code{(col2)} and @code{(col2,col3)} are not
-leftmost prefixes of @code{(col1,col2,col3)}.
-
-@findex LIKE, and indexes
-@findex LIKE, and wildcards
-@cindex indexes, and @code{LIKE}
-@cindex wildcards, and @code{LIKE}
-@strong{MySQL} also uses indexes for @code{LIKE} comparisons if the argument
-to @code{LIKE} is a constant string that doesn't start with a wild-card
-character. For example, the following @code{SELECT} statements use indexes:
-
-@example
-mysql> select * from tbl_name where key_col LIKE "Patrick%";
-mysql> select * from tbl_name where key_col LIKE "Pat%_ck%";
-@end example
-
-In the first statement, only rows with @code{"Patrick" <= key_col <
-"Patricl"} are considered. In the second statement, only rows with
-@code{"Pat" <= key_col < "Pau"} are considered.
-
-The following @code{SELECT} statements will not use indexes:
-@example
-mysql> select * from tbl_name where key_col LIKE "%Patrick%";
-mysql> select * from tbl_name where key_col LIKE other_col;
-@end example
-
-In the first statement, the @code{LIKE} value begins with a wild-card
-character. In the second statement, the @code{LIKE} value is not a
-constant.
-
-@findex IS NULL, and indexes
-@cindex indexes, and @code{IS NULL}
-Searching using @code{column_name IS NULL} will use indexes if column_name
-is an index.
-
-@strong{MySQL} normally uses the index that finds the least number of rows. An
-index is used for columns that you compare with the following operators:
-@code{=}, @code{>}, @code{>=}, @code{<}, @code{<=}, @code{BETWEEN}, and a
-@code{LIKE} with a non-wild-card prefix like @code{'something%'}.
-
-Any index that doesn't span all @code{AND} levels in the @code{WHERE} clause
-is not used to optimize the query. In other words: To be able to use an
-index, a prefix of the index must be used in every @code{AND} group.
-
-The following @code{WHERE} clauses use indexes:
-@example
-... WHERE index_part1=1 AND index_part2=2 AND other_column=3
-... WHERE index=1 OR A=10 AND index=2 /* index = 1 OR index = 2 */
-... WHERE index_part1='hello' AND index_part_3=5
- /* optimized like "index_part1='hello'" */
-... WHERE index1=1 and index2=2 or index1=3 and index3=3;
- /* Can use index on index1 but not on index2 or index 3 */
-@end example
-
-These @code{WHERE} clauses do @strong{NOT} use indexes:
-@example
-... WHERE index_part2=1 AND index_part3=2 /* index_part_1 is not used */
-... WHERE index=1 OR A=10 /* Index is not used in both AND parts */
-... WHERE index_part1=1 OR index_part2=10 /* No index spans all rows */
-@end example
-
-Note that in some cases @strong{MySQL} will not use an index, even if one
-would be available. Some of the cases where this happens are:
-
-@itemize @bullet
-@item
-If the use of the index would require @strong{MySQL} to access more
-than 30 % of the rows in the table. (In this case a table scan is
-probably much faster, as this will require us to do much fewer seeks).
-Note that if such a query uses @code{LIMIT} to only retrieve
-part of the rows, @strong{MySQL} will use an index anyway, as it can
-much more quickly find the few rows to return in the result.
-@end itemize
-
-@cindex queries, speed of
-@cindex permission checks, effect on speed
-@cindex speed, of queries
-@node Query Speed, Tips, MySQL indexes, Performance
-@section Speed of Queries that Access or Update Data
-
-First, one thing that affects all queries: The more complex permission
-system setup you have, the more overhead you get.
+This chapter describes the APIs available for MySQL, where to get
+them, and how to use them. The C API is the most extensively covered, as it
+was developed by the MySQL team, and is the basis for most of the
+other APIs.
-If you do not have any @code{GRANT} statements done, @strong{MySQL} will
-optimize the permission checking somewhat. So if you have a very high
-volume it may be worth the time to avoid grants. Otherwise more
-permission check results in a larger overhead.
-If your problem is with some explicit @strong{MySQL} function, you can
-always time this in the @strong{MySQL} client:
+@node PHP, Perl, Clients, Clients
+@section MySQL PHP API
-@example
-mysql> select benchmark(1000000,1+1);
-+------------------------+
-| benchmark(1000000,1+1) |
-+------------------------+
-| 0 |
-+------------------------+
-1 row in set (0.32 sec)
-@end example
+@cindex PHP API
-The above shows that @strong{MySQL} can execute 1,000,000 @code{+}
-expressions in 0.32 seconds on a @code{PentiumII 400MHz}.
+PHP is a server-side, HTML-embedded scripting language that may be used to
+create dynamic Web pages. It contains support for accessing several
+databases, including MySQL. PHP may be run as a separate program
+or compiled as a module for use with the Apache Web server.
-All @strong{MySQL} functions should be very optimized, but there may be
-some exceptions, and the @code{benchmark(loop_count,expression)} is a
-great tool to find out if this is a problem with your query.
+The distribution and documentation are available at the
+@uref{http://www.php.net/, PHP web site}.
@menu
-* Estimating performance:: Estimating query performance
-* SELECT speed:: Speed of @code{SELECT} queries
-* Where optimizations:: How MySQL optimizes @code{WHERE} clauses
-* DISTINCT optimization:: How MySQL Optimizes @code{DISTINCT}
-* LEFT JOIN optimization:: How MySQL optimizes @code{LEFT JOIN}
-* LIMIT optimization:: How MySQL optimizes @code{LIMIT}
-* Insert speed:: Speed of @code{INSERT} queries
-* Update speed:: Speed of @code{UPDATE} queries
-* Delete speed:: Speed of @code{DELETE} queries
+* PHP problems:: Common problems with MySQL and PHP
@end menu
-@cindex estimating, query performance
-@cindex queries, estimating performance
-@cindex performance, estimating
-@node Estimating performance, SELECT speed, Query Speed, Query Speed
-@subsection Estimating Query Performance
-
-In most cases you can estimate the performance by counting disk seeks.
-For small tables, you can usually find the row in 1 disk seek (as the
-index is probably cached). For bigger tables, you can estimate that
-(using B++ tree indexes) you will need: @code{log(row_count) /
-log(index_block_length / 3 * 2 / (index_length + data_pointer_length)) +
-1} seeks to find a row.
-
-In @strong{MySQL} an index block is usually 1024 bytes and the data
-pointer is usually 4 bytes. A 500,000 row table with an
-index length of 3 (medium integer) gives you:
-@code{log(500,000)/log(1024/3*2/(3+4)) + 1} = 4 seeks.
-
-As the above index would require about 500,000 * 7 * 3/2 = 5.2M,
-(assuming that the index buffers are filled to 2/3, which is typical)
-you will probably have much of the index in memory and you will probably
-only need 1-2 calls to read data from the OS to find the row.
-
-For writes, however, you will need 4 seek requests (as above) to find
-where to place the new index and normally 2 seeks to update the index
-and write the row.
-
-Note that the above doesn't mean that your application will slowly
-degenerate by N log N! As long as everything is cached by the OS or SQL
-server things will only go marginally slower while the table gets
-bigger. After the data gets too big to be cached, things will start to
-go much slower until your applications is only bound by disk-seeks
-(which increase by N log N). To avoid this, increase the index cache as
-the data grows. @xref{Server parameters}.
-
-@cindex speed, of queries
-@findex SELECT speed
-
-@node SELECT speed, Where optimizations, Estimating performance, Query Speed
-@subsection Speed of @code{SELECT} Queries
-
-In general, when you want to make a slow @code{SELECT ... WHERE} faster, the
-first thing to check is whether or not you can add an index. @xref{MySQL
-indexes, , @strong{MySQL} indexes}. All references between different tables
-should usually be done with indexes. You can use the @code{EXPLAIN} command
-to determine which indexes are used for a @code{SELECT}.
-@xref{EXPLAIN, , @code{EXPLAIN}}.
-
-Some general tips:
-
-@itemize @bullet
-@item
-To help @strong{MySQL} optimize queries better, run @code{myisamchk
---analyze} on a table after it has been loaded with relevant data. This
-updates a value for each index part that indicates the average number of
-rows that have the same value. (For unique indexes, this is always 1,
-of course.). @strong{MySQL} will use this to decide which index to
-choose when you connect two tables with 'a non-constant expression'.
-You can check the result from the @code{analyze} run by doing @code{SHOW
-INDEX FROM table_name} and examining the @code{Cardinality} column.
-
-@item
-To sort an index and data according to an index, use @code{myisamchk
---sort-index --sort-records=1} (if you want to sort on index 1). If you
-have a unique index from which you want to read all records in order
-according to that index, this is a good way to make that faster. Note,
-however, that this sorting isn't written optimally and will take a long
-time for a large table!
-@end itemize
-
-@cindex optimizations
-@findex WHERE
-@node Where optimizations, DISTINCT optimization, SELECT speed, Query Speed
-@subsection How MySQL Optimizes @code{WHERE} Clauses
-
-The @code{WHERE} optimizations are put in the @code{SELECT} part here because
-they are mostly used with @code{SELECT}, but the same optimizations apply for
-@code{WHERE} in @code{DELETE} and @code{UPDATE} statements.
-
-Also note that this section is incomplete. @strong{MySQL} does many
-optimizations, and we have not had time to document them all.
-
-Some of the optimizations performed by @strong{MySQL} are listed below:
-
-@itemize @bullet
-@item
-Removal of unnecessary parentheses:
-@example
- ((a AND b) AND c OR (((a AND b) AND (c AND d))))
--> (a AND b AND c) OR (a AND b AND c AND d)
-@end example
-@item
-Constant folding:
-@example
- (a<b AND b=c) AND a=5
--> b>5 AND b=c AND a=5
-@end example
-@item
-Constant condition removal (needed because of constant folding):
-@example
- (B>=5 AND B=5) OR (B=6 AND 5=5) OR (B=7 AND 5=6)
--> B=5 OR B=6
-@end example
-@item
-Constant expressions used by indexes are evaluated only once.
-@item
-@code{COUNT(*)} on a single table without a @code{WHERE} is retrieved
-directly from the table information. This is also done for any @code{NOT NULL}
-expression when used with only one table.
-@item
-Early detection of invalid constant expressions. @strong{MySQL} quickly
-detects that some @code{SELECT} statements are impossible and returns no rows.
-@item
-@code{HAVING} is merged with @code{WHERE} if you don't use @code{GROUP BY}
-or group functions (@code{COUNT()}, @code{MIN()}...).
-@item
-For each sub-join, a simpler @code{WHERE} is constructed to get a fast
-@code{WHERE} evaluation for each sub-join and also to skip records as
-soon as possible.
-@cindex constant table
-@cindex tables, constant
-@item
-All constant tables are read first, before any other tables in the query.
-A constant table is:
-@itemize @minus
-@item
-An empty table or a table with 1 row.
-@item
-A table that is used with a @code{WHERE} clause on a @code{UNIQUE}
-index, or a @code{PRIMARY KEY}, where all index parts are used with constant
-expressions and the index parts are defined as @code{NOT NULL}.
-@end itemize
-All the following tables are used as constant tables:
-@example
-mysql> SELECT * FROM t WHERE primary_key=1;
-mysql> SELECT * FROM t1,t2
- WHERE t1.primary_key=1 AND t2.primary_key=t1.id;
-@end example
-
-@item
-The best join combination to join the tables is found by trying all
-possibilities. If all columns in @code{ORDER BY} and in @code{GROUP
-BY} come from the same table, then this table is preferred first when
-joining.
-@item
-If there is an @code{ORDER BY} clause and a different @code{GROUP BY}
-clause, or if the @code{ORDER BY} or @code{GROUP BY} contains columns
-from tables other than the first table in the join queue, a temporary
-table is created.
-@item
-If you use @code{SQL_SMALL_RESULT}, @strong{MySQL} will use an in-memory
-temporary table.
-@item
-Each table index is queried, and the best index that spans fewer than 30% of
-the rows is used. If no such index can be found, a quick table scan is used.
-@item
-In some cases, @strong{MySQL} can read rows from the index without even
-consulting the data file. If all columns used from the index are numeric,
-then only the index tree is used to resolve the query.
-@item
-Before each record is output, those that do not match the @code{HAVING} clause
-are skipped.
-@end itemize
-
-Some examples of queries that are very fast:
-
-@example
-mysql> SELECT COUNT(*) FROM tbl_name;
-mysql> SELECT MIN(key_part1),MAX(key_part1) FROM tbl_name;
-mysql> SELECT MAX(key_part2) FROM tbl_name
- WHERE key_part_1=constant;
-mysql> SELECT ... FROM tbl_name
- ORDER BY key_part1,key_part2,... LIMIT 10;
-mysql> SELECT ... FROM tbl_name
- ORDER BY key_part1 DESC,key_part2 DESC,... LIMIT 10;
-@end example
-
-The following queries are resolved using only the index tree (assuming
-the indexed columns are numeric):
-
-@example
-mysql> SELECT key_part1,key_part2 FROM tbl_name WHERE key_part1=val;
-mysql> SELECT COUNT(*) FROM tbl_name
- WHERE key_part1=val1 AND key_part2=val2;
-mysql> SELECT key_part2 FROM tbl_name GROUP BY key_part1;
-@end example
-
-The following queries use indexing to retrieve the rows in sorted
-order without a separate sorting pass:
-
-@example
-mysql> SELECT ... FROM tbl_name ORDER BY key_part1,key_part2,... ;
-mysql> SELECT ... FROM tbl_name ORDER BY key_part1 DESC,key_part2 DESC,... ;
-@end example
-
-@findex DISTINCT
-@cindex optimizing, DISTINCT
-@node DISTINCT optimization, LEFT JOIN optimization, Where optimizations, Query Speed
-@subsection How MySQL Optimizes @code{DISTINCT}
-
-@code{DISTINCT} is converted to a @code{GROUP BY} on all columns,
-@code{DISTINCT} combined with @code{ORDER BY} will in many cases also
-need a temporary table.
-
-When combining @code{LIMIT #} with @code{DISTINCT}, @strong{MySQL} will stop
-as soon as it finds @code{#} unique rows.
-
-If you don't use columns from all used tables, @strong{MySQL} will stop
-the scanning of the not used tables as soon as it has found the first match.
-
-@example
-SELECT DISTINCT t1.a FROM t1,t2 where t1.a=t2.a;
-@end example
-
-In the case, assuming t1 is used before t2 (check with @code{EXPLAIN}), then
-@strong{MySQL} will stop reading from t2 (for that particular row in t1)
-when the first row in t2 is found.
-
-@findex LEFT JOIN
-@cindex optimizing, LEFT JOIN
-@node LEFT JOIN optimization, LIMIT optimization, DISTINCT optimization, Query Speed
-@subsection How MySQL Optimizes @code{LEFT JOIN} and @code{RIGHT JOIN}
-
-@code{A LEFT JOIN B} in @strong{MySQL} is implemented as follows:
-
-@itemize @bullet
-@item
-The table @code{B} is set to be dependent on table @code{A} and all tables
-that @code{A} is dependent on.
-@item
-The table @code{A} is set to be dependent on all tables (except @code{B})
-that are used in the @code{LEFT JOIN} condition.
-@item
-All @code{LEFT JOIN} conditions are moved to the @code{WHERE} clause.
-@item
-All standard join optimizations are done, with the exception that a table is
-always read after all tables it is dependent on. If there is a circular
-dependence then @strong{MySQL} will issue an error.
-@item
-All standard @code{WHERE} optimizations are done.
-@item
-If there is a row in @code{A} that matches the @code{WHERE} clause, but there
-wasn't any row in @code{B} that matched the @code{LEFT JOIN} condition,
-then an extra @code{B} row is generated with all columns set to @code{NULL}.
-@item
-If you use @code{LEFT JOIN} to find rows that don't exist in some
-table and you have the following test: @code{column_name IS NULL} in the
-@code{WHERE} part, where column_name is a column that is declared as
-@code{NOT NULL}, then @strong{MySQL} will stop searching after more rows
-(for a particular key combination) after it has found one row that
-matches the @code{LEFT JOIN} condition.
-@end itemize
-
-@code{RIGHT JOIN} is implemented analogously as @code{LEFT JOIN}.
-
-The table read order forced by @code{LEFT JOIN} and @code{STRAIGHT JOIN}
-will help the join optimizer (which calculates in which order tables
-should be joined) to do its work much more quickly, as there are fewer
-table permutations to check.
-
-Note that the above means that if you do a query of type:
-
-@example
-SELECT * FROM a,b LEFT JOIN c ON (c.key=a.key) LEFT JOIN d (d.key=a.key) WHERE b.key=d.key
-@end example
-
-@strong{MySQL} will do a full scan on @code{b} as the @code{LEFT
-JOIN} will force it to be read before @code{d}.
-
-The fix in this case is to change the query to:
-
-@example
-SELECT * FROM b,a LEFT JOIN c ON (c.key=a.key) LEFT JOIN d (d.key=a.key) WHERE b.key=d.key
-@end example
-
-@cindex optimizing, LIMIT
-@findex LIMIT
-@node LIMIT optimization, Insert speed, LEFT JOIN optimization, Query Speed
-@subsection How MySQL Optimizes @code{LIMIT}
-
-In some cases @strong{MySQL} will handle the query differently when you are
-using @code{LIMIT #} and not using @code{HAVING}:
-
-@itemize @bullet
-@item
-If you are selecting only a few rows with @code{LIMIT}, @strong{MySQL}
-will use indexes in some cases when it normally would prefer to do a
-full table scan.
-@item
-If you use @code{LIMIT #} with @code{ORDER BY}, @strong{MySQL} will end the
-sorting as soon as it has found the first @code{#} lines instead of sorting
-the whole table.
-@item
-When combining @code{LIMIT #} with @code{DISTINCT}, @strong{MySQL} will stop
-as soon as it finds @code{#} unique rows.
-@item
-In some cases a @code{GROUP BY} can be resolved by reading the key in order
-(or do a sort on the key) and then calculate summaries until the
-key value changes. In this case @code{LIMIT #} will not calculate any
-unnecessary @code{GROUP BY}'s.
-@item
-As soon as @strong{MySQL} has sent the first @code{#} rows to the client, it
-will abort the query.
-@item
-@code{LIMIT 0} will always quickly return an empty set. This is useful
-to check the query and to get the column types of the result columns.
-@item
-The size of temporary tables uses the @code{LIMIT #} to calculate how much
-space is needed to resolve the query.
-@end itemize
-
-@cindex speed, inserting
-@cindex inserting, speed of
-@node Insert speed, Update speed, LIMIT optimization, Query Speed
-@subsection Speed of @code{INSERT} Queries
-
-The time to insert a record consists approximately of:
-
-@itemize @bullet
-@item
-Connect: (3)
-@item
-Sending query to server: (2)
-@item
-Parsing query: (2)
-@item
-Inserting record: (1 x size of record)
-@item
-Inserting indexes: (1 x number of indexes)
-@item
-Close: (1)
-@end itemize
-
-where the numbers are somewhat proportional to the overall time. This
-does not take into consideration the initial overhead to open tables
-(which is done once for each concurrently running query).
-
-The size of the table slows down the insertion of indexes by N log N
-(B-trees).
-
-Some ways to speed up inserts:
-
-@itemize @bullet
-@item
-If you are inserting many rows from the same client at the same time, use
-multiple value lists @code{INSERT} statements. This is much faster (many
-times in some cases) than using separate @code{INSERT} statements.
-Tune up @code{myisam_bulk_insert_tree_size} variable to make it even
-faster. @xref{SHOW VARIABLES}.
-@item
-If you are inserting a lot of rows from different clients, you can get
-higher speed by using the @code{INSERT DELAYED} statement. @xref{INSERT,
-, @code{INSERT}}.
-@item
-Note that with @code{MyISAM} you can insert rows at the same time
-@code{SELECT}s are running if there are no deleted rows in the tables.
-@item
-When loading a table from a text file, use @code{LOAD DATA INFILE}. This
-is usually 20 times faster than using a lot of @code{INSERT} statements.
-@xref{LOAD DATA, , @code{LOAD DATA}}.
-@item
-It is possible with some extra work to make @code{LOAD DATA INFILE} run even
-faster when the table has many indexes. Use the following procedure:
-
-@enumerate
-@item
-Optionally create the table with @code{CREATE TABLE}. For example, using
-@code{mysql} or Perl-DBI.
-
-@item
-Execute a @code{FLUSH TABLES} statement or the shell command @code{mysqladmin
-flush-tables}.
-
-@item
-Use @code{myisamchk --keys-used=0 -rq /path/to/db/tbl_name}. This will
-remove all usage of all indexes from the table.
-
-@item
-Insert data into the table with @code{LOAD DATA INFILE}. This will not
-update any indexes and will therefore be very fast.
-
-@item
-If you are going to only read the table in the future, run @code{myisampack}
-on it to make it smaller. @xref{Compressed format}.
-
-@item
-Re-create the indexes with @code{myisamchk -r -q
-/path/to/db/tbl_name}. This will create the index tree in memory before
-writing it to disk, which is much faster because it avoids lots of disk
-seeks. The resulting index tree is also perfectly balanced.
-
-@item
-Execute a @code{FLUSH TABLES} statement or the shell command @code{mysqladmin
-flush-tables}.
-@end enumerate
-
-Since @strong{MySQL 4.0} you can also use
-@code{ALTER TABLE tbl_name DISABLE KEYS} instead of
-@code{myisamchk --keys-used=0 -rq /path/to/db/tbl_name} and
-@code{ALTER TABLE tbl_name ENABLE KEYS} instead of
-@code{myisamchk -r -q /path/to/db/tbl_name}. This way you can also skip
-@code{FLUSH TABLES} steps.
-@item
-You can speed up insertions by locking your tables:
-
-@example
-mysql> LOCK TABLES a WRITE;
-mysql> INSERT INTO a VALUES (1,23),(2,34),(4,33);
-mysql> INSERT INTO a VALUES (8,26),(6,29);
-mysql> UNLOCK TABLES;
-@end example
-
-The main speed difference is that the index buffer is flushed to disk only
-once, after all @code{INSERT} statements have completed. Normally there would
-be as many index buffer flushes as there are different @code{INSERT}
-statements. Locking is not needed if you can insert all rows with a single
-statement.
-
-Locking will also lower the total time of multi-connection tests, but the
-maximum wait time for some threads will go up (because they wait for
-locks). For example:
-
-@example
-thread 1 does 1000 inserts
-thread 2, 3, and 4 does 1 insert
-thread 5 does 1000 inserts
-@end example
-
-If you don't use locking, 2, 3, and 4 will finish before 1 and 5. If you
-use locking, 2, 3, and 4 probably will not finish before 1 or 5, but the
-total time should be about 40% faster.
-
-As @code{INSERT}, @code{UPDATE}, and @code{DELETE} operations are very
-fast in @strong{MySQL}, you will obtain better overall performance by
-adding locks around everything that does more than about 5 inserts or
-updates in a row. If you do very many inserts in a row, you could do a
-@code{LOCK TABLES} followed by an @code{UNLOCK TABLES} once in a while
-(about each 1000 rows) to allow other threads access to the table. This
-would still result in a nice performance gain.
-
-Of course, @code{LOAD DATA INFILE} is much faster for loading data.
-@end itemize
-
-To get some more speed for both @code{LOAD DATA INFILE} and
-@code{INSERT}, enlarge the key buffer. @xref{Server parameters}.
-
-@node Update speed, Delete speed, Insert speed, Query Speed
-@subsection Speed of @code{UPDATE} Queries
-
-Update queries are optimized as a @code{SELECT} query with the additional
-overhead of a write. The speed of the write is dependent on the size of
-the data that is being updated and the number of indexes that are
-updated. Indexes that are not changed will not be updated.
-
-Also, another way to get fast updates is to delay updates and then do
-many updates in a row later. Doing many updates in a row is much quicker
-than doing one at a time if you lock the table.
-
-Note that, with dynamic record format, updating a record to
-a longer total length may split the record. So if you do this often,
-it is very important to @code{OPTIMIZE TABLE} sometimes.
-@xref{OPTIMIZE TABLE, , @code{OPTIMIZE TABLE}}.
-
-@node Delete speed, , Update speed, Query Speed
-@subsection Speed of @code{DELETE} Queries
-
-If you want to delete all rows in the table, you should use
-@code{TRUNCATE TABLE table_name}. @xref{TRUNCATE}.
-
-The time to delete a record is exactly proportional to the number of
-indexes. To delete records more quickly, you can increase the size of
-the index cache. @xref{Server parameters}.
-
-@cindex optimization, tips
-@cindex tips, optimization
-@node Tips, Benchmarks, Query Speed, Performance
-@section Other Optimization Tips
-
-Unsorted tips for faster systems:
-
-@itemize @bullet
-@item
-Use persistent connections to the database to avoid the connection
-overhead. If you can't use persistent connections and you are doing a
-lot of new connections to the database, you may want to change the value
-of the @code{thread_cache_size} variable. @xref{Server parameters}.
-@item
-Always check that all your queries really use the indexes you have created
-in the tables. In @strong{MySQL} you can do this with the @code{EXPLAIN}
-command. @xref{EXPLAIN, Explain, Explain, manual}.
-@item
-Try to avoid complex @code{SELECT} queries on tables that are updated a
-lot. This is to avoid problems with table locking.
-@item
-The new @code{MyISAM} tables can insert rows in a table without deleted
-rows at the same time another table is reading from it. If this is important
-for you, you should consider methods where you don't have to delete rows
-or run @code{OPTIMIZE TABLE} after you have deleted a lot of rows.
-@item
-Use @code{ALTER TABLE ... ORDER BY expr1,expr2...} if you mostly
-retrieve rows in expr1,expr2.. order. By using this option after big
-changes to the table, you may be able to get higher performance.
-@item
-In some cases it may make sense to introduce a column that is 'hashed'
-based on information from other columns. If this column is short and
-reasonably unique it may be much faster than a big index on many
-columns. In @strong{MySQL} it's very easy to use this extra column:
-@code{SELECT * FROM table_name WHERE hash=MD5(concat(col1,col2))
-AND col_1='constant' AND col_2='constant'}
-@item
-For tables that change a lot you should try to avoid all @code{VARCHAR}
-or @code{BLOB} columns. You will get dynamic row length as soon as you
-are using a single @code{VARCHAR} or @code{BLOB} column. @xref{Table
-types}.
-@item
-It's not normally useful to split a table into different tables just
-because the rows gets 'big'. To access a row, the biggest performance
-hit is the disk seek to find the first byte of the row. After finding
-the data most new disks can read the whole row fast enough for most
-applications. The only cases where it really matters to split up a table is if
-it's a dynamic row size table (see above) that you can change to a fixed
-row size, or if you very often need to scan the table and don't need
-most of the columns. @xref{Table types}.
-@item
-If you very often need to calculate things based on information from a
-lot of rows (like counts of things), it's probably much better to
-introduce a new table and update the counter in real time. An update of
-type @code{UPDATE table set count=count+1 where index_column=constant}
-is very fast!
-
-This is really important when you use databases like @strong{MySQL} that
-only have table locking (multiple readers / single writers). This will
-also give better performance with most databases, as the row locking
-manager in this case will have less to do.
-@item
-If you need to collect statistics from big log tables, use summary tables
-instead of scanning the whole table. Maintaining the summaries should be
-much faster than trying to do statistics 'live'. It's much faster to
-regenerate new summary tables from the logs when things change
-(depending on business decisions) than to have to change the running
-application!
-@item
-If possible, one should classify reports as 'live' or 'statistical',
-where data needed for statistical reports are only generated based on
-summary tables that are generated from the actual data.
-@item
-Take advantage of the fact that columns have default values. Insert
-values explicitly only when the value to be inserted differs from the
-default. This reduces the parsing that @strong{MySQL} need to do and
-improves the insert speed.
-@item
-In some cases it's convenient to pack and store data into a blob. In this
-case you have to add some extra code in your application to pack/unpack
-things in the blob, but this may save a lot of accesses at some stage.
-This is practical when you have data that doesn't conform to a static
-table structure.
-@item
-Normally you should try to keep all data non-redundant (what
-is called 3rd normal form in database theory), but you should not be
-afraid of duplicating things or creating summary tables if you need these
-to gain more speed.
-@item
-Stored procedures or UDF (user-defined functions) may be a good way to
-get more performance. In this case you should, however, always have a way
-to do this some other (slower) way if you use some database that doesn't
-support this.
-@item
-You can always gain something by caching queries/answers in your
-application and trying to do many inserts/updates at the same time. If
-your database supports lock tables (like @strong{MySQL} and Oracle),
-this should help to ensure that the index cache is only flushed once
-after all updates.
-@item
-Use @code{INSERT /*! DELAYED */} when you do not need to know when your
-data is written. This speeds things up because many records can be written
-with a single disk write.
-@item
-Use @code{INSERT /*! LOW_PRIORITY */} when you want your selects to be
-more important.
-@item
-Use @code{SELECT /*! HIGH_PRIORITY */} to get selects that jump the
-queue. That is, the select is done even if there is somebody waiting to
-do a write.
-@item
-Use the multi-line @code{INSERT} statement to store many rows with one
-SQL command (many SQL servers supports this).
-@item
-Use @code{LOAD DATA INFILE} to load bigger amounts of data. This is
-faster than normal inserts and will be even faster when @code{myisamchk}
-is integrated in @code{mysqld}.
-@item
-Use @code{AUTO_INCREMENT} columns to make unique values.
-@item
-Use @code{OPTIMIZE TABLE} once in a while to avoid fragmentation when
-using dynamic table format. @xref{OPTIMIZE TABLE, , @code{OPTIMIZE TABLE}}.
-
-@item
-Use @code{HEAP} tables to get more speed when possible. @xref{Table
-types}.
-@item
-When using a normal Web server setup, images should be stored as
-files. That is, store only a file reference in the database. The main
-reason for this is that a normal Web server is much better at caching
-files than database contents. So it it's much easier to get a fast
-system if you are using files.
-@item
-Use in memory tables for non-critical data that are accessed often (like
-information about the last shown banner for users that don't have
-cookies).
-@item
-Columns with identical information in different tables should be
-declared identical and have identical names. Before Version 3.23 you
-got slow joins otherwise.
-
-Try to keep the names simple (use @code{name} instead of
-@code{customer_name} in the customer table). To make your names portable
-to other SQL servers you should keep them shorter than 18 characters.
-@item
-If you need REALLY high speed, you should take a look at the low-level
-interfaces for data storage that the different SQL servers support! For
-example, by accessing the @strong{MySQL} @code{MyISAM} directly, you could
-get a speed increase of 2-5 times compared to using the SQL interface.
-To be able to do this the data must be on the same server as
-the application, and usually it should only be accessed by one process
-(because external file locking is really slow). One could eliminate the
-above problems by introducing low-level @code{MyISAM} commands in the
-@strong{MySQL} server (this could be one easy way to get more
-performance if needed). By carefully designing the database interface,
-it should be quite easy to support this types of optimization.
-@item
-In many cases it's faster to access data from a database (using a live
-connection) than accessing a text file, just because the database is
-likely to be more compact than the text file (if you are using numerical
-data), and this will involve fewer disk accesses. You will also save
-code because you don't have to parse your text files to find line and
-column boundaries.
-@item
-You can also use replication to speed things up. @xref{Replication}.
-@item
-Declaring a table with @code{DELAY_KEY_WRITE=1} will make the updating of
-indexes faster, as these are not logged to disk until the file is closed.
-The downside is that you should run @code{myisamchk} on these tables before
-you start @code{mysqld} to ensure that they are okay if something killed
-@code{mysqld} in the middle. As the key information can always be generated
-from the data, you should not lose anything by using @code{DELAY_KEY_WRITE}.
-@end itemize
-
-@cindex benchmarks
-@cindex performance, benchmarks
-@node Benchmarks, Design, Tips, Performance
-@section Using Your Own Benchmarks
-
-You should definitely benchmark your application and database to find
-out where the bottlenecks are. By fixing it (or by replacing the
-bottleneck with a 'dummy module') you can then easily identify the next
-bottleneck (and so on). Even if the overall performance for your
-application is sufficient, you should at least make a plan for each
-bottleneck, and decide how to solve it if someday you really need the
-extra performance.
-
-For an example of portable benchmark programs, look at the @strong{MySQL}
-benchmark suite. @xref{MySQL Benchmarks, , @strong{MySQL} Benchmarks}. You
-can take any program from this suite and modify it for your needs. By doing this,
-you can try different solutions to your problem and test which is really the
-fastest solution for you.
-
-It is very common that some problems only occur when the system is very
-heavily loaded. We have had many customers who contact us when they
-have a (tested) system in production and have encountered load problems. In
-every one of these cases so far, it has been problems with basic design
-(table scans are NOT good at high load) or OS/Library issues. Most of
-this would be a @strong{LOT} easier to fix if the systems were not
-already in production.
-
-To avoid problems like this, you should put some effort into benchmarking
-your whole application under the worst possible load! You can use Sasha's
-recent hack for this -
-@uref{http://www.mysql.com/Downloads/super-smack/super-smack-1.0.tar.gz,
-super-smack}.
-As the name suggests, it can bring your system down to its knees if you ask it,
-so make sure to use it only on your development systems.
-
-@cindex design, choices
-@cindex database design
-@cindex storage of data
-@node Design, Design Limitations, Benchmarks, Performance
-@section Design Choices
-
-@strong{MySQL} keeps row data and index data in separate files. Many (almost
-all) other databases mix row and index data in the same file. We believe that
-the @strong{MySQL} choice is better for a very wide range of modern systems.
-
-Another way to store the row data is to keep the information for each
-column in a separate area (examples are SDBM and Focus). This will cause a
-performance hit for every query that accesses more than one column. Because
-this degenerates so quickly when more than one column is accessed,
-we believe that this model is not good for general purpose databases.
-
-The more common case is that the index and data are stored together
-(like in Oracle/Sybase et al). In this case you will find the row
-information at the leaf page of the index. The good thing with this
-layout is that it, in many cases, depending on how well the index is
-cached, saves a disk read. The bad things with this layout are:
+@node PHP problems, , PHP, PHP
+@subsection Common Problems with MySQL and PHP
@itemize @bullet
-@item
-Table scanning is much slower because you have to read through the indexes
-to get at the data.
-@item
-You can't use only the index table to retrieve data for a query.
-@item
-You lose a lot of space, as you must duplicate indexes from the nodes
-(as you can't store the row in the nodes).
-@item
-Deletes will degenerate the table over time (as indexes in nodes are
-usually not updated on delete).
-@item
-It's harder to cache ONLY the index data.
+@item Error: "Maximum Execution Time Exceeded"
+This is a PHP limit; Go into the @file{php3.ini} file and set the maximum
+execution time up from 30 seconds to something higher, as needed.
+It is also not a bad idea to double the ram allowed per script to 16MB instead of
+8 MB.
+@item Error: "Fatal error: Call to unsupported or undefined function mysql_connect() in .."
+This means that your PHP version isn't compiled with MySQL support.
+You can either compile a dynamic MySQL module and load it into PHP or
+recompile PHP with built-in MySQL support. This is described in
+detail in the PHP manual.
+@item Error: "undefined reference to `uncompress'"
+This means that the client library is compiled with support for a compressed
+client/server protocol. The fix is to add @code{-lz} last when linking
+with @code{-lmysqlclient}.
@end itemize
-@cindex design, limitations
-@node Design Limitations, Portability, Design, Performance
-@section MySQL Design Limitations/Tradeoffs
-
-Because @strong{MySQL} uses extremely fast table locking (multiple readers /
-single writers) the biggest remaining problem is a mix of a steady stream of
-inserts and slow selects on the same table.
-
-We believe that for a huge number of systems the extremely fast
-performance in other cases make this choice a win. This case is usually
-also possible to solve by having multiple copies of the table, but it
-takes more effort and hardware.
-
-We are also working on some extensions to solve this problem for some
-common application niches.
-
-@cindex portability
-@cindex crash-me program
-@cindex programs, crash-me
-@node Portability, Internal use, Design Limitations, Performance
-@section Portability
-
-Because all SQL servers implement different parts of SQL, it takes work to
-write portable SQL applications. For very simple selects/inserts it is
-very easy, but the more you need the harder it gets. If you want an
-application that is fast with many databases it becomes even harder!
-
-To make a complex application portable you need to choose a number of
-SQL servers that it should work with.
-
-You can use the @strong{MySQL} crash-me program/web-page
-@uref{http://www.mysql.com/information/crash-me.php} to find functions,
-types, and limits you can use with a selection of database
-servers. Crash-me now tests far from everything possible, but it
-is still comprehensive with about 450 things tested.
-
-For example, you shouldn't have column names longer than 18 characters
-if you want to be able to use Informix or DB2.
-
-Both the @strong{MySQL} benchmarks and crash-me programs are very
-database-independent. By taking a look at how we have handled this, you
-can get a feeling for what you have to do to write your application
-database-independent. The benchmarks themselves can be found in the
-@file{sql-bench} directory in the @strong{MySQL} source
-distribution. They are written in Perl with DBI database interface
-(which solves the access part of the problem).
-
-See @uref{http://www.mysql.com/information/benchmarks.html} for the results
-from this benchmark.
-
-As you can see in these results, all databases have some weak points. That
-is, they have different design compromises that lead to different
-behavior.
-
-If you strive for database independence, you need to get a good feeling
-for each SQL server's bottlenecks. @strong{MySQL} is VERY fast in
-retrieving and updating things, but will have a problem in mixing slow
-readers/writers on the same table. Oracle, on the other hand, has a big
-problem when you try to access rows that you have recently updated
-(until they are flushed to disk). Transaction databases in general are
-not very good at generating summary tables from log tables, as in this
-case row locking is almost useless.
-
-To get your application @emph{really} database-independent, you need to define
-an easy extendable interface through which you manipulate your data. As
-C++ is available on most systems, it makes sense to use a C++ classes
-interface to the databases.
-
-If you use some specific feature for some database (like the
-@code{REPLACE} command in @strong{MySQL}), you should code a method for
-the other SQL servers to implement the same feature (but slower). With
-@strong{MySQL} you can use the @code{/*! */} syntax to add
-@strong{MySQL}-specific keywords to a query. The code inside
-@code{/**/} will be treated as a comment (ignored) by most other SQL
-servers.
-
-If REAL high performance is more important than exactness, as in some
-Web applications, a possibility is to create an application layer that
-caches all results to give you even higher performance. By letting
-old results 'expire' after a while, you can keep the cache reasonably
-fresh. This is quite nice in case of extremely high load, in which case
-you can dynamically increase the cache and set the expire timeout higher
-until things get back to normal.
-
-In this case the table creation information should contain information
-of the initial size of the cache and how often the table should normally
-be refreshed.
-
-@cindex uses, of MySQL
-@cindex customers, of MySQL
-@node Internal use, , Portability, Performance
-@section What Have We Used MySQL For?
-
-During @strong{MySQL} initial development, the features of @strong{MySQL} were made to fit
-our largest customer. They handle data warehousing for a couple of the
-biggest retailers in Sweden.
-From all stores, we get weekly summaries of all bonus card transactions,
-and we are expected to provide useful information for the store owners
-to help them find how their advertisement campaigns are affecting their
-customers.
-
-The data is quite huge (about 7 million summary transactions per month),
-and we have data for 4-10 years that we need to present to the users.
-We got weekly requests from the customers that they want to get
-'instant' access to new reports from this data.
-
-We solved this by storing all information per month in compressed
-'transaction' tables. We have a set of simple macros (script) that
-generates summary tables grouped by different criteria (product group,
-customer id, store ...) from the transaction tables. The reports are
-Web pages that are dynamically generated by a small Perl script that
-parses a Web page, executes the SQL statements in it, and inserts the
-results. We would have used PHP or mod_perl instead but they were
-not available at that time.
-
-For graphical data we wrote a simple tool in @code{C} that can produce
-GIFs based on the result of a SQL query (with some processing of the
-result). This is also dynamically executed from the Perl script that
-parses the @code{HTML} files.
-
-In most cases a new report can simply be done by copying an existing
-script and modifying the SQL query in it. In some cases, we will need to
-add more fields to an existing summary table or generate a new one, but
-this is also quite simple, as we keep all transactions tables on disk.
-(Currently we have at least 50G of transactions tables and 200G of other
-customer data.)
-
-We also let our customers access the summary tables directly with ODBC
-so that the advanced users can themselves experiment with the data.
-
-We haven't had any problems handling this with quite modest Sun Ultra
-SPARCstation (2x200 Mhz). We recently upgraded one of our servers to a 2
-CPU 400 Mhz UltraSPARC, and we are now planning to start handling
-transactions on the product level, which would mean a ten-fold increase
-of data. We think we can keep up with this by just adding more disk to
-our systems.
-
-We are also experimenting with Intel-Linux to be able to get more CPU
-power cheaper. Now that we have the binary portable database format (new
-in Version 3.23), we will start to use this for some parts of the application.
-
-Our initial feelings are that Linux will perform much better on
-low-to-medium load and Solaris will perform better when you start to get a
-high load because of extreme disk IO, but we don't yet have anything
-conclusive about this. After some discussion with a Linux Kernel
-developer, this might be a side effect of Linux giving so much resources
-to the batch job that the interactive performance gets very low. This
-makes the machine feel very slow and unresponsive while big batches are
-going. Hopefully this will be better handled in future Linux Kernels.
-
-@cindex benchmark suite
-@cindex crash-me program
-@node MySQL Benchmarks, Tools, Performance, Top
-@chapter The MySQL Benchmark Suite
-
-This should contain a technical description of the @strong{MySQL}
-benchmark suite (and @code{crash-me}), but that description is not
-written yet. Currently, you can get a good idea of the benchmark by
-looking at the code and results in the @file{sql-bench} directory in any
-@strong{MySQL} source distributions.
-
-This benchmark suite is meant to be a benchmark that will tell any user
-what things a given SQL implementation performs well or poorly at.
-
-Note that this benchmark is single threaded, so it measures the minimum
-time for the operations. We plan to in the future add a lot of
-multi-threaded tests to the benchmark suite.
-
-For example, (run on the same NT 4.0 machine):
-
-@multitable @columnfractions .6 .2 .2
-@strong{Reading 2000000 rows by index} @tab @strong{Seconds} @tab @strong{Seconds}
-@item mysql @tab 367 @tab 249
-@item mysql_odbc @tab 464
-@item db2_odbc @tab 1206
-@item informix_odbc @tab 121126
-@item ms-sql_odbc @tab 1634
-@item oracle_odbc @tab 20800
-@item solid_odbc @tab 877
-@item sybase_odbc @tab 17614
-@end multitable
-
-@multitable @columnfractions .6 .2 .2
-@strong{Inserting (350768) rows} @tab @strong{Seconds} @tab @strong{Seconds}
-@item mysql @tab 381 @tab 206
-@item mysql_odbc @tab 619
-@item db2_odbc @tab 3460
-@item informix_odbc @tab 2692
-@item ms-sql_odbc @tab 4012
-@item oracle_odbc @tab 11291
-@item solid_odbc @tab 1801
-@item sybase_odbc @tab 4802
-@end multitable
-
-In the above test @strong{MySQL} was run with a 8M index cache.
-
-We have gather some more benchmark results at
-@uref{http://www.mysql.com/information/benchmarks.html}.
-
-Note that Oracle is not included because they asked to be removed. All
-Oracle benchmarks have to be passed by Oracle! We believe that makes
-Oracle benchmarks @strong{VERY} biased because the above benchmarks are
-supposed to show what a standard installation can do for a single
-client.
-
-To run the benchmark suite, you have to download a @strong{MySQL} source
-distribution, install the perl DBI driver, the perl DBD driver for the
-database you want to test and then do:
-
-@example
-cd sql-bench
-perl run-all-tests --server=#
-@end example
-
-where # is one of supported servers. You can get a list of all options
-and supported servers by doing @code{run-all-tests --help}.
-
-@cindex crash-me
-@code{crash-me} tries to determine what features a database supports and
-what its capabilities and limitations are by actually running
-queries. For example, it determines:
-
-@itemize @bullet
-@item
-What column types are supported
-@item
-How many indexes are supported
-@item
-What functions are supported
-@item
-How big a query can be
-@item
-How big a @code{VARCHAR} column can be
-@end itemize
+@node Perl, ODBC, PHP, Clients
+@section MySQL Perl API
-We can find the result from crash-me on a lot of different databases at
-@uref{http://www.mysql.com/information/crash-me.php}.
+@cindex APIs, Perl
+@cindex Perl API
-@cindex utilities
-@node Tools, Maintenance, MySQL Benchmarks, Top
-@chapter MySQL Utilites
+This section documents the Perl @code{DBI} interface. The former interface
+was called @code{mysqlperl}. @code{DBI}/@code{DBD} now is the
+recommended Perl interface, so @code{mysqlperl} is obsolete and is not
+documented here.
@menu
-* Programs:: What do the executables do?
-* mysqld-max:: mysqld-max, An extended mysqld server
-* safe_mysqld:: safe_mysqld, the wrapper around mysqld
-* mysqld_multi:: Program for managing multiple @strong{MySQL} servers
-* mysql:: The command line tool
-* mysqladmin:: Administering a @strong{MySQL} server
-* mysqldump:: Dumping the structure and data from @strong{MySQL} databases and tables
-* mysqlhotcopy:: Copying @strong{MySQL} Databases and Tables
-* mysqlimport:: Importing data from text files
-* perror:: Displaying error messages
-* mysqlshow:: Showing databases, tables and columns
-* myisampack:: The @strong{MySQL} compressed read-only table generator
+* DBI with DBD:: @code{DBI} with @code{DBD::mysql}
+* Perl DBI Class:: The @code{DBI} interface
+* DBI-info:: More @code{DBI}/@code{DBD} information
@end menu
-In this chapter you will learn about the @strong{MySQL} Utilities that
-come in a given distribution. You will learn what each of them does, how
-to use it, and what you should use it for.
-
-@cindex environment variables
-@cindex programs, list of
-@node Programs, mysqld-max, Tools, Tools
-@section Overview of the Different MySQL Programs
-
-All @strong{MySQL} clients that communicate with the server using the
-@code{mysqlclient} library use the following environment variables:
-
-@tindex MYSQL_UNIX_PORT environment variable
-@tindex Environment variable, MYSQL_UNIX_PORT
-@tindex MYSQL_TCP_PORT environment variable
-@tindex Environment variable, MYSQL_TCP_PORT
-@tindex MYSQL_PWD environment variable
-@tindex Environment variable, MYSQL_PWD
-@tindex MYSQL_DEBUG environment variable
-@tindex Environment variable, MYSQL_DEBUG
-@multitable @columnfractions .25 .75
-@item @strong{Name} @tab @strong{Description}
-@item @code{MYSQL_UNIX_PORT} @tab The default socket; used for connections to @code{localhost}
-@item @code{MYSQL_TCP_PORT} @tab The default TCP/IP port
-@item @code{MYSQL_PWD} @tab The default password
-@item @code{MYSQL_DEBUG} @tab Debug-trace options when debugging
-@item @code{TMPDIR} @tab The directory where temporary tables/files are created
-@end multitable
-
-Use of @code{MYSQL_PWD} is insecure.
-@xref{Connecting}.
-
-@tindex MYSQL_HISTFILE environment variable
-@tindex Environment variable, MYSQL_HISTFILE
-@tindex HOME environment variable
-@tindex Environment variable, HOME
-@cindex history file
-@cindex command line history
-@tindex .mysql_history file
-The @file{mysql} client uses the file named in the @code{MYSQL_HISTFILE}
-environment variable to save the command-line history. The default value for
-the history file is @file{$HOME/.mysql_history}, where @code{$HOME} is the
-value of the @code{HOME} environment variable. @xref{Environment variables}.
-
-All @strong{MySQL} programs take many different options. However, every
-@strong{MySQL} program provides a @code{--help} option that you can use
-to get a full description of the program's different options. For example, try
-@code{mysql --help}.
-
-You can override default options for all standard client programs with an
-option file. @ref{Option files}.
-
-The list below briefly describes the @strong{MySQL} programs:
-
-@table @code
-
-@cindex @code{myisamchk}
-@item myisamchk
-Utility to describe, check, optimize, and repair @strong{MySQL} tables.
-Because @code{myisamchk} has many functions, it is described in its own
-chapter. @xref{Maintenance}.
-
-@cindex @code{make_binary_distribution}
-@item make_binary_distribution
-Makes a binary release of a compiled @strong{MySQL}. This could be sent
-by FTP to @file{/pub/mysql/Incoming} on @code{support.mysql.com} for the
-convenience of other @strong{MySQL} users.
-
-@cindex @code{msql2mysql}
-@item msql2mysql
-A shell script that converts @code{mSQL} programs to @strong{MySQL}. It doesn't
-handle all cases, but it gives a good start when converting.
-
-@cindex @code{mysqlaccess}
-@item mysqlaccess
-A script that checks the access privileges for a host, user, and database
-combination.
-
-@cindex @code{mysqladmin}
-@item mysqladmin
-Utility for performing administrative operations, such as creating or
-dropping databases, reloading the grant tables, flushing tables to disk, and
-reopening log files. @code{mysqladmin} can also be used to retrieve version,
-process, and status information from the server.
-@xref{mysqladmin, , @code{mysqladmin}}.
-
-@cindex @code{mysqlbug}
-@item mysqlbug
-The @strong{MySQL} bug report script. This script should always be used when
-filing a bug report to the @strong{MySQL} list.
-
-@cindex @code{mysqld}
-@item mysqld
-The SQL daemon. This should always be running.
-
-@cindex @code{mysqldump}
-@item mysqldump
-Dumps a @strong{MySQL} database into a file as SQL statements or
-as tab-separated text files. Enhanced freeware originally by Igor Romanenko.
-@xref{mysqldump, , @code{mysqldump}}.
-
-@cindex @code{mysqlimport}
-@item mysqlimport
-Imports text files into their respective tables using @code{LOAD DATA
-INFILE}. @xref{mysqlimport, , @code{mysqlimport}}.
-
-@cindex @code{mysqlshow}
-@item mysqlshow
-Displays information about databases, tables, columns, and indexes.
-
-@cindex @code{mysql_install_db}
-@item mysql_install_db
-Creates the @strong{MySQL} grant tables with default privileges. This is
-usually executed only once, when first installing @strong{MySQL}
-on a system.
-
-@cindex @code{replace}
-@item replace
-A utility program that is used by @code{msql2mysql}, but that has more
-general applicability as well. @code{replace} changes strings in place in
-files or on the standard input. Uses a finite state machine to match longer
-strings first. Can be used to swap strings. For example, this command
-swaps @code{a} and @code{b} in the given files:
-
-@example
-shell> replace a b b a -- file1 file2 ...
-@end example
-@end table
-
-@cindex @code{mysqld-max}
-@node mysqld-max, safe_mysqld, Programs, Tools
-@section mysqld-max, An extended mysqld server
-
-@code{mysqld-max} is the MySQL server (@code{mysqld}) configured with
-the following configure options:
-
-@multitable @columnfractions .3 .7
-@item @strong{Option} @tab @strong{Comment}
-@item --with-server-suffix=-max @tab Add a suffix to the @code{mysqld} version string.
-@item --with-bdb @tab Support for Berkeley DB (BDB) tables
-@item --with-innodb @tab Support for InnoDB tables.
-@item CFLAGS=-DUSE_SYMDIR @tab Symbolic links support for Windows.
-@end multitable
-
-You can find the @strong{MySQL}-max binaries at
-@uref{http://www.mysql.com/downloads/mysql-max-3.23.html}.
-
-The Windows @strong{MySQL} 3.23 binary distribution includes both the
-standard @strong{mysqld.exe} binary and the @code{mysqld-max.exe} binary.
-@uref{http://www.mysql.com/downloads/mysql-3.23.html}.
-@xref{Windows installation}.
-
-Note that as Berkeley DB and InnoDB are not available for all platforms,
-some of the @code{Max} binaries may not have support for both of these.
-You can check which table types are supported by doing the following
-query:
-
-@example
-mysql> show variables like "have_%";
-+---------------+-------+
-| Variable_name | Value |
-+---------------+-------+
-| have_bdb | YES |
-| have_gemini | NO |
-| have_innodb | NO |
-| have_isam | YES |
-| have_raid | YES |
-| have_ssl | NO |
-+---------------+-------+
-@end example
-
-The meaning of the values are:
-
-@multitable @columnfractions .3 .7
-@item @strong{Value} @tab @strong{Meaning}.
-@item YES @tab The option is activated and usable.
-@item NO @tab @strong{MySQL} is not compiled with support for this option.
-@item DISABLED @tab The xxxx option is disabled because one started @code{mysqld} with @code{--skip-xxxx} or because one didn't start @code{mysqld} with all needed options to enable the option. In this case the @code{hostname.err} file should contain a reason for why the option is disabled.
-@end multitable
-
-@strong{NOTE}: To be able to create InnoDB tables you @strong{MUST} edit
-your startup options to include at least the @code{innodb_data_file_path}
-option. @xref{InnoDB start}.
-
-To get better performance for BDB tables, you should add some configuration
-options for these too. @xref{BDB start}.
-@code{safe_mysqld} will automatically try to start any @code{mysqld} binary
-with the @code{-max} prefix. This makes it very easy to test out a
-another @code{mysqld} binary in an existing installation. Just
-run @code{configure} with the options you want and then install the
-new @code{mysqld} binary as @code{mysqld-max} in the same directory
-where your old @code{mysqld} binary is. @xref{safe_mysqld, , @code{safe_mysqld}}.
-
-The @code{mysqld-max} RPM uses the above mentioned @code{safe_mysqld}
-feature. It just installs the @code{mysqld-max} executable and
-@code{safe_mysqld} will automatically use this executable when
-@code{safe_mysqld} is restarted.
-
-The following table shows which table types our standard @strong{MySQL-Max}
-binaries includes:
-
-@multitable @columnfractions .4 .3 .3
-@item @strong{System} @tab @strong{BDB} @tab @strong{InnoDB}
-@item AIX 4.3 @tab N @tab Y
-@item HP-UX 11.0 @tab N @tab Y
-@item Linux-Alpha @tab N @tab Y
-@item Linux-Intel @tab Y @tab Y
-@item Linux-Ia64 @tab N @tab Y
-@item Solaris-intel @tab N @tab Y
-@item Solaris-sparc @tab Y @tab Y
-@item SCO OSR5 @tab Y @tab Y
-@item UnixWare @tab Y @tab Y
-@item Windows/NT @tab Y @tab Y
-@end multitable
-
-@cindex tools, safe_mysqld
-@cindex scripts
-@cindex @code{safe_mysqld}
-@node safe_mysqld, mysqld_multi, mysqld-max, Tools
-@section safe_mysqld, the wrapper around mysqld
-
-@code{safe_mysqld} is the recommended way to start a @code{mysqld}
-daemon on Unix. @code{safe_mysqld} adds some safety features such as
-restarting the server when an error occurs and logging run-time
-information to a log file.
-
-If you don't use @code{--mysqld=#} or @code{--mysqld-version=#}
-@code{safe_mysqld} will use an executable named @code{mysqld-max} if it
-exists. If not, @code{safe_mysqld} will start @code{mysqld}.
-This makes it very easy to test to use @code{mysqld-max} instead of
-@code{mysqld}; Just copy @code{mysqld-max} to where you have
-@code{mysqld} and it will be used.
-
-Normally one should never edit the @code{safe_mysqld} script, but
-instead put the options to @code{safe_mysqld} in the
-@code{[safe_mysqld]} section in the @code{my.cnf}
-file. @code{safe_mysqld} will read all options from the @code{[mysqld]},
-@code{[server]} and @code{[safe_mysqld]} sections from the option files.
-@xref{Option files}.
-
-Note that all options on the command line to @code{safe_mysqld} are passed
-to @code{mysqld}. If you wants to use any options in @code{safe_mysqld} that
-@code{mysqld} doesn't support, you must specify these in the option file.
-
-Most of the options to @code{safe_mysqld} are the same as the options to
-@code{mysqld}. @xref{Command-line options}.
-
-@code{safe_mysqld} supports the following options:
-
-@table @code
-@item --basedir=path
-@item --core-file-size=#
-Size of the core file @code{mysqld} should be able to create. Passed to @code{ulimit -c}.
-@item --datadir=path
-@item --defaults-extra-file=path
-@item --defaults-file=path
-@item --err-log=path
-@item --ledir=path
-Path to @code{mysqld}
-@item --log=path
-@item --mysqld=mysqld-version
-Name of the @code{mysqld} version in the @code{ledir} directory you want to start.
-@item --mysqld-version=version
-Similar to @code{--mysqld=} but here you only give the suffix for @code{mysqld}.
-For example if you use @code{--mysqld-version=max}, @code{safe_mysqld} will
-start the @code{ledir/mysqld-max} version. If the argument to
-@code{--mysqld-version} is empty, @code{ledir/mysqld} will be used.
-@item --no-defaults
-@item --open-files-limit=#
-Number of files @code{mysqld} should be able to open. Passed to @code{ulimit -n}. Note that you need to start @code{safe_mysqld} as root for this to work properly!
-@item --pid-file=path
-@item --port=#
-@item --socket=path
-@item --timezone=#
-Set the timezone (the @code{TZ}) variable to the value of this parameter.
-@item --user=#
-@end table
-
-The @code{safe_mysqld} script is written so that it normally is able to start
-a server that was installed from either a source or a binary version of
-@strong{MySQL}, even if these install the server in slightly different
-locations. @code{safe_mysqld} expects one of these conditions to be true:
-
-@itemize @bullet
-@item
-The server and databases can be found relative to the directory from which
-@code{safe_mysqld} is invoked. @code{safe_mysqld} looks under its working
-directory for @file{bin} and @file{data} directories (for binary
-distributions) or for @file{libexec} and @file{var} directories (for source
-distributions). This condition should be met if you execute
-@code{safe_mysqld} from your @strong{MySQL} installation directory (for
-example, @file{/usr/local/mysql} for a binary distribution).
-
-@item
-If the server and databases cannot be found relative to the working directory,
-@code{safe_mysqld} attempts to locate them by absolute pathnames. Typical
-locations are @file{/usr/local/libexec} and @file{/usr/local/var}.
-The actual locations are determined when the distribution was built from which
-@code{safe_mysqld} comes. They should be correct if
-@strong{MySQL} was installed in a standard location.
-@end itemize
-
-Because @code{safe_mysqld} will try to find the server and databases relative
-to its own working directory, you can install a binary distribution of
-@strong{MySQL} anywhere, as long as you start @code{safe_mysqld} from the
-@strong{MySQL} installation directory:
-
-@example
-shell> cd mysql_installation_directory
-shell> bin/safe_mysqld &
-@end example
-
-If @code{safe_mysqld} fails, even when invoked from the @strong{MySQL}
-installation directory, you can modify it to use the path to @code{mysqld}
-and the pathname options that are correct for your system. Note that if you
-upgrade @strong{MySQL} in the future, your modified version of
-@code{safe_mysqld} will be overwritten, so you should make a copy of your
-edited version that you can reinstall.
-
-@cindex tools, mysqld_multi
-@cindex scripts
-@cindex multi mysqld
-@cindex @code{mysqld_multi}
-@node mysqld_multi, mysql, safe_mysqld, Tools
-@section mysqld_multi, program for managing multiple @strong{MySQL} servers
-
-@code{mysqld_multi} is meant for managing several @code{mysqld}
-processes running in different UNIX sockets and TCP/IP ports.
-
-The program will search for group(s) named [mysqld#] from my.cnf (or the
-given --config-file=...), where # can be any positive number starting
-from 1. These groups should be the same as the usual @code{[mysqld]}
-group (e.g. options to mysqld, see @strong{MySQL} manual for detailed
-information about this group), but with those port, socket etc. options
-that are wanted for each separate @code{mysqld} processes. The number in
-the group name has another function; it can be used for starting,
-stopping, or reporting some specific @code{mysqld} servers with this
-program. See the usage and options below for more information.
-
-@example
-Usage: mysqld_multi [OPTIONS] @{start|stop|report@} [GNR,GNR,GNR...]
-or mysqld_multi [OPTIONS] @{start|stop|report@} [GNR-GNR,GNR,GNR-GNR,...]
-@end example
-
-The GNR above means the group number. You can start, stop or report
-any GNR, or several of them at the same time. (See --example) The GNRs
-list can be comma separated, or a dash combined, of which the latter
-means that all the GNRs between GNR1-GNR2 will be affected. Without
-GNR argument all the found groups will be either started, stopped, or
-reported. Note that you must not have any white spaces in the GNR
-list. Anything after a white space is ignored.
-
-@code{mysqld_multi} supports the following options:
-
-@table @code
-@cindex config-file option
-@item --config-file=...
-Alternative config file. NOTE: This will not affect this program's own
-options (group @code{[mysqld_multi]}), but only groups
-[mysqld#]. Without this option everything will be searched from the
-ordinary my.cnf file.
-@cindex example option
-@item --example
-Give an example of a config file.
-@cindex help option
-@item --help
-Print this help and exit.
-@cindex log option
-@item --log=...
-Log file. Full path to and the name for the log file. NOTE: If the file
-exists, everything will be appended.
-@cindex mysqladmin option
-@item --mysqladmin=...
-@code{mysqladmin} binary to be used for a server shutdown.
-@cindex mysqld option
-@item --mysqld=...
-@code{mysqld} binary to be used. Note that you can give
-@code{safe_mysqld} to this option also. The options are passed to
-@code{mysqld}. Just make sure you have @code{mysqld} in your environment
-variable @code{PATH} or fix @code{safe_mysqld}.
-@cindex no-log option
-@item --no-log
-Print to stdout instead of the log file. By default the log file is
-turned on.
-@cindex password option
-@item --password=...
-Password for user for @code{mysqladmin}.
-@cindex tcp-ip option
-@item --tcp-ip
-Connect to the @strong{MySQL} server(s) via the TCP/IP port instead of
-the UNIX socket. This affects stopping and reporting. If a socket file
-is missing, the server may still be running, but can be accessed only
-via the TCP/IP port. By default connecting is done via the UNIX socket.
-@cindex user option
-@item --user=...
-@strong{MySQL} user for @code{mysqladmin}.
-@cindex version option
-@item --version
-Print the version number and exit.
-@end table
-
-Some notes about @code{mysqld_multi}:
-
-@itemize @bullet
-@item
-Make sure that the @strong{MySQL} user, who is stopping the
-@code{mysqld} services (e.g using the @code{mysqladmin}) have the same
-password and username for all the data directories accessed (to the
-'mysql' database) And make sure that the user has the 'Shutdown_priv'
-privilege! If you have many data- directories and many different 'mysql'
-databases with different passwords for the @strong{MySQL} 'root' user,
-you may want to create a common 'multi_admin' user for each using the
-same password (see below). Example how to do it:
-@example
-shell> mysql -u root -S /tmp/mysql.sock -proot_password -e
-"GRANT SHUTDOWN ON *.* TO multi_admin@@localhost IDENTIFIED BY 'multipass'"
-@xref{Privileges}.
-@end example
-You will have to do the above for each @code{mysqld} running in each
-data directory, that you have (just change the socket, -S=...)
-@item
-@code{pid-file} is very important, if you are using @code{safe_mysqld}
-to start @code{mysqld} (e.g. --mysqld=safe_mysqld) Every @code{mysqld}
-should have its own @code{pid-file}. The advantage using
-@code{safe_mysqld} instead of @code{mysqld} directly here is, that
-@code{safe_mysqld} 'guards' every @code{mysqld} process and will restart
-it, if a @code{mysqld} process fails due to signal kill -9, or
-similar. (Like segmentation fault, which @strong{MySQL} should never do,
-of course ;) Please note that @code{safe_mysqld} script may require that
-you start it from a certain place. This means that you may have to CD to
-a certain directory, before you start the @code{mysqld_multi}. If
-you have problems starting, please see the @code{safe_mysqld}
-script. Check especially the lines:
-@example
---------------------------------------------------------------------------
-MY_PWD=`pwd` Check if we are starting this relative (for the binary
-release) if test -d /data/mysql -a -f ./share/mysql/english/errmsg.sys
--a -x ./bin/mysqld
---------------------------------------------------------------------------
-@xref{safe_mysqld, , @code{safe_mysqld}}.
-@end example
-The above test should be successful, or you may encounter problems.
-@item
-Beware of the dangers starting multiple @code{mysqlds} in the same data
-directory. Use separate data directories, unless you @strong{KNOW} what
-you are doing!
-@item
-The socket file and the TCP/IP port must be different for every @code{mysqld}.
-@item
-The first and fifth @code{mysqld} group were intentionally left out from
-the example. You may have 'gaps' in the config file. This gives you
-more flexibility. The order in which the @code{mysqlds} are started or
-stopped depends on the order in which they appear in the config file.
-@item
-When you want to refer to a certain group using GNR with this program,
-just use the number in the end of the group name ( [mysqld# <== ).
-@item
-You may want to use option '--user' for @code{mysqld}, but in order to
-do this you need to be root when you start the @code{mysqld_multi}
-script. Having the option in the config file doesn't matter; you will
-just get a warning, if you are not the superuser and the @code{mysqlds}
-are started under @strong{YOUR} UNIX account. @strong{IMPORTANT}: Make
-sure that the @code{pid-file} and the data directory are
-read+write(+execute for the latter one) accessible for @strong{THAT}
-UNIX user, who the specific @code{mysqld} process is started
-as. @strong{DON'T} use the UNIX root account for this, unless you
-@strong{KNOW} what you are doing!
-@item
-@strong{MOST IMPORTANT}: Make sure that you understand the meanings of
-the options that are passed to the @code{mysqlds} and why @strong{WOULD
-YOU WANT} to have separate @code{mysqld} processes. Starting multiple
-@code{mysqlds} in one data directory @strong{WILL NOT} give you extra
-performance in a threaded system!
-@end itemize
-
-@xref{Multiple servers}.
-
-This is an example of the config file on behalf of @code{mysqld_multi}.
-
-@example
-# This file should probably be in your home dir (~/.my.cnf) or /etc/my.cnf
-# Version 2.1 by Jani Tolonen
-
-[mysqld_multi]
-mysqld = /usr/local/bin/safe_mysqld
-mysqladmin = /usr/local/bin/mysqladmin
-user = multi_admin
-password = multipass
-
-[mysqld2]
-socket = /tmp/mysql.sock2
-port = 3307
-pid-file = /usr/local/mysql/var2/hostname.pid2
-datadir = /usr/local/mysql/var2
-language = /usr/local/share/mysql/english
-user = john
-
-[mysqld3]
-socket = /tmp/mysql.sock3
-port = 3308
-pid-file = /usr/local/mysql/var3/hostname.pid3
-datadir = /usr/local/mysql/var3
-language = /usr/local/share/mysql/swedish
-user = monty
-
-[mysqld4]
-socket = /tmp/mysql.sock4
-port = 3309
-pid-file = /usr/local/mysql/var4/hostname.pid4
-datadir = /usr/local/mysql/var4
-language = /usr/local/share/mysql/estonia
-user = tonu
-
-[mysqld6]
-socket = /tmp/mysql.sock6
-port = 3311
-pid-file = /usr/local/mysql/var6/hostname.pid6
-datadir = /usr/local/mysql/var6
-language = /usr/local/share/mysql/japanese
-user = jani
-@end example
-
-@xref{Option files}.
-
-@cindex command line tool
-@cindex tools, command line
-@cindex scripts
-@cindex @code{mysql}
-@node mysql, mysqladmin, mysqld_multi, Tools
-@section The Command-line Tool
-
-@code{mysql} is a simple SQL shell (with GNU @code{readline} capabilities).
-It supports interactive and non-interactive use. When used interactively,
-query results are presented in an ASCII-table format. When used
-non-interactively (for example, as a filter), the result is presented in
-tab-separated format. (The output format can be changed using command-line
-options.) You can run scripts simply like this:
-
-@example
-shell> mysql database < script.sql > output.tab
-@end example
-
-If you have problems due to insufficient memory in the client, use the
-@code{--quick} option! This forces @code{mysql} to use
-@code{mysql_use_result()} rather than @code{mysql_store_result()} to
-retrieve the result set.
-
-Using @code{mysql} is very easy. Just start it as follows:
-@code{mysql database} or @code{mysql --user=user_name --password=your_password database}. Type a SQL statement, end it with @samp{;}, @samp{\g}, or @samp{\G}
-and press RETURN/ENTER.
-
-@cindex command line options
-@cindex options, command line
-@cindex startup parameters
-@code{mysql} supports the following options:
-
-@table @code
-@cindex help option
-@item -?, --help
-Display this help and exit.
-@cindex automatic rehash option
-@item -A, --no-auto-rehash
-No automatic rehashing. One has to use 'rehash' to get table and field
-completion. This gives a quicker start of mysql.
-@cindex batch option
-@item -B, --batch
-Print results with a tab as separator, each row on a new line. Doesn't use
-history file.
-@cindex character sets option
-@item --character-sets-dir=...
-Directory where character sets are located.
-@cindex compress option.
-@item -C, --compress
-Use compression in server/client protocol.
-@cindex debug option
-@item -#, --debug[=...]
-Debug log. Default is 'd:t:o,/tmp/mysql.trace'.
-@cindex database option
-@item -D, --database=...
-Database to use. This is mainly useful in the @code{my.cnf} file.
-@cindex default character set option
-@item --default-character-set=...
-Set the default character set.
-@cindex execute option
-@item -e, --execute=...
-Execute command and quit. (Output like with --batch)
-@cindex vertical option
-@item -E, --vertical
-Print the output of a query (rows) vertically. Without this option you
-can also force this output by ending your statements with @code{\G}.
-@cindex force option
-@item -f, --force
-Continue even if we get a SQL error.
-@cindex no-named-commands option
-@item -g, --no-named-commands
-Named commands are disabled. Use \* form only, or use named commands
-only in the beginning of a line ending with a semicolon (;). Since
-Version 10.9, the client now starts with this option ENABLED by default!
-With the -g option, long format commands will still work from the first
-line, however.
-@cindex enable-named-commands option
-@item -G, --enable-named-commands
-Named commands are @strong{enabled}. Long format commands are allowed as
-well as shortened \* commands.
-@cindex ignore space option.
-@item -i, --ignore-space
-Ignore space after function names.
-@cindex host option
-@item -h, --host=...
-Connect to the given host.
-@cindex html option
-@item -H, --html
-Produce HTML output.
-@cindex skip line numbers option
-@item -L, --skip-line-numbers
-Don't write line number for errors. Useful when one wants to compare result
-files that includes error messages
-@cindex no pager option
-@item --no-pager
-Disable pager and print to stdout. See interactive help (\h) also.
-@cindex no tee option
-@item --no-tee
-Disable outfile. See interactive help (\h) also.
-@cindex unbuffered option.
-@item -n, --unbuffered
-Flush buffer after each query.
-@cindex skip column names option
-@item -N, --skip-column-names
-Don't write column names in results.
-@cindex set variable option
-@item -O, --set-variable var=option
-Give a variable a value. @code{--help} lists variables.
-@cindex one database option
-@item -o, --one-database
-Only update the default database. This is useful for skipping updates to
-other database in the update log.
-@cindex pager option
-@item @code{--pager[=...]}
-Output type. Default is your @code{ENV} variable @code{PAGER}. Valid
-pagers are less, more, cat [> filename], etc. See interactive help (\h)
-also. This option does not work in batch mode. Pager works only in UNIX.
-@cindex password option
-@item -p[password], --password[=...]
-Password to use when connecting to server. If a password is not given on
-the command line, you will be prompted for it. Note that if you use the
-short form @code{-p} you can't have a space between the option and the
-password.
-@item -P --port=...
-TCP/IP port number to use for connection.
-@cindex quick option
-@item -q, --quick
-Don't cache result, print it row-by-row. This may slow down the server
-if the output is suspended. Doesn't use history file.
-@cindex raw option
-@item -r, --raw
-Write column values without escape conversion. Used with @code{--batch}
-@cindex silent option
-@item -s, --silent
-Be more silent.
-@item -S --socket=...
-Socket file to use for connection.
-@cindex table option
-@item -t --table
-Output in table format. This is default in non-batch mode.
-@item -T, --debug-info
-Print some debug information at exit.
-@cindex tee option
-@item --tee=...
-Append everything into outfile. See interactive help (\h) also. Does not
-work in batch mode.
-@cindex user option
-@item -u, --user=#
-User for login if not current user.
-@cindex safe updates option
-@item -U, --safe-updates[=#], --i-am-a-dummy[=#]
-Only allow @code{UPDATE} and @code{DELETE} that uses keys. See below for
-more information about this option. You can reset this option if you have
-it in your @code{my.cnf} file by using @code{--safe-updates=0}.
-@cindex verbose option
-@item -v, --verbose
-More verbose output (-v -v -v gives the table output format).
-@cindex version option
-@item -V, --version
-Output version information and exit.
-@cindex wait option
-@item -w, --wait
-Wait and retry if connection is down instead of aborting.
-@end table
-
-You can also set the following variables with @code{-O} or
-@code{--set-variable}:
-
-@cindex timeout
-@multitable @columnfractions .3 .2 .5
-@item Variablename @tab Default @tab Description
-@item connect_timeout @tab 0 @tab Number of seconds before timeout connection.
-@item max_allowed_packet @tab 16777216 @tab Max packetlength to send/receive from to server
-@item net_buffer_length @tab 16384 @tab Buffer for TCP/IP and socket communication
-@item select_limit @tab 1000 @tab Automatic limit for SELECT when using --i-am-a-dummy
-@item max_join_size @tab 1000000 @tab Automatic limit for rows in a join when using --i-am-a-dummy.
-@end multitable
-
-If you type 'help' on the command line, @code{mysql} will print out the
-commands that it supports:
-
-@cindex commands, list of
-@example
-mysql> help
-
-MySQL commands:
-help (\h) Display this text.
-? (\h) Synonym for `help'.
-clear (\c) Clear command.
-connect (\r) Reconnect to the server. Optional arguments are db and host.
-edit (\e) Edit command with $EDITOR.
-ego (\G) Send command to mysql server, display result vertically.
-exit (\q) Exit mysql. Same as quit.
-go (\g) Send command to mysql server.
-nopager (\n) Disable pager, print to stdout.
-notee (\t) Don't write into outfile.
-pager (\P) Set PAGER [to_pager]. Print the query results via PAGER.
-print (\p) Print current command.
-quit (\q) Quit mysql.
-rehash (\#) Rebuild completion hash.
-source (\.) Execute a SQL script file. Takes a file name as an argument.
-status (\s) Get status information from the server.
-tee (\T) Set outfile [to_outfile]. Append everything into given outfile.
-use (\u) Use another database. Takes database name as argument.
-@end example
-
-From the above, pager only works in UNIX.
-
-@cindex status command
-The @code{status} command gives you some information about the
-connection and the server you are using. If you are running in the
-@code{--safe-updates} mode, @code{status} will also print the values for
-the @code{mysql} variables that affect your queries.
-
-@cindex @code{safe-mode} command
-A useful startup option for beginners (introduced in @strong{MySQL}
-Version 3.23.11) is @code{--safe-updates} (or @code{--i-am-a-dummy} for
-users that has at some time done a @code{DELETE FROM table_name} but
-forgot the @code{WHERE} clause). When using this option, @code{mysql}
-sends the following command to the @strong{MySQL} server when opening
-the connection:
-
-@example
-SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=#select_limit#,
- SQL_MAX_JOIN_SIZE=#max_join_size#"
-@end example
-
-where @code{#select_limit#} and @code{#max_join_size#} are variables that
-can be set from the @code{mysql} command line. @xref{SET OPTION, @code{SET}}.
-
-The effect of the above is:
-
-@itemize @bullet
-@item
-You are not allowed to do an @code{UPDATE} or @code{DELETE} statement
-if you don't have a key constraint in the @code{WHERE} part. One can,
-however, force an @code{UPDATE/DELETE} by using @code{LIMIT}:
-@example
-UPDATE table_name SET not_key_column=# WHERE not_key_column=# LIMIT 1;
-@end example
-@item
-All big results are automatically limited to @code{#select_limit#} rows.
-@item
-@code{SELECT}'s that will probably need to examine more than
-@code{#max_join_size} row combinations will be aborted.
-@end itemize
-
-Some useful hints about the @code{mysql} client:
-
-Some data is much more readable when displayed vertically, instead of
-the usual horizontal box type output. For example longer text, which
-includes new lines, is often much easier to be read with vertical
-output.
-
-@example
-mysql> select * from mails where length(txt) < 300 limit 300,1\G
-*************************** 1. row ***************************
- msg_nro: 3068
- date: 2000-03-01 23:29:50
-time_zone: +0200
-mail_from: Monty
- reply: monty@@no.spam.com
- mail_to: "Thimble Smith" <tim@@no.spam.com>
- sbj: UTF-8
- txt: >>>>> "Thimble" == Thimble Smith writes:
-
-Thimble> Hi. I think this is a good idea. Is anyone familiar with UTF-8
-Thimble> or Unicode? Otherwise I'll put this on my TODO list and see what
-Thimble> happens.
+@node DBI with DBD, Perl DBI Class, Perl, Perl
+@subsection @code{DBI} with @code{DBD::mysql}
-Yes, please do that.
+@cindex @code{DBI} interface
-Regards,
-Monty
- file: inbox-jani-1
- hash: 190402944
-1 row in set (0.09 sec)
-@end example
+@code{DBI} is a generic interface for many databases. That means that
+you can write a script that works with many different database engines
+without change. You need a DataBase Driver (DBD) defined for each
+database type. For MySQL, this driver is called
+@code{DBD::mysql}.
-@itemize @bullet
-@item
-For logging, you can use the @code{tee} option. The @code{tee} can be
-started with option @code{--tee=...}, or from the command line
-interactively with command @code{tee}. All the data displayed on the
-screen will also be appended into a given file. This can be very useful
-for debugging purposes also. The @code{tee} can be disabled from the
-command line with command @code{notee}. Executing @code{tee} again
-starts logging again. Without a parameter the previous file will be
-used. Note that @code{tee} will flush the results into the file after
-each command, just before the command line appears again waiting for the
-next command.
-@item
-Browsing, or searching the results in the interactive mode in UNIX less,
-more, or any other similar program, is now possible with option
-@code{--pager[=...]}. Without argument, @code{mysql} client will look
-for environment variable PAGER and set @code{pager} to that.
-@code{pager} can be started from the interactive command line with
-command @code{pager} and disabled with command @code{nopager}. The
-command takes an argument optionally and the @code{pager} will be set to
-that. Command @code{pager} can be called without an argument, but this
-requires that the option @code{--pager} was used, or the @code{pager}
-will default to stdout. @code{pager} works only in UNIX, since it uses
-the popen() function, which doesn't exist in Windows. In Windows, the
-@code{tee} option can be used instead, although it may not be as handy
-as @code{pager} can be in some situations.
-@item
-A few tips about @code{pager}: You can use it to write to a file:
-@example
-mysql> pager cat > /tmp/log.txt
-@end example
-and the results will only go to a file. You can also pass any options
-for the programs that you want to use with the @code{pager}:
+For more information on the Perl5 DBI, please visit the @code{DBI} Web
+page and read the documentation:
@example
-mysql> pager less -n -i -S
+@uref{http://www.symbolstone.org/technology/perl/DBI/index.html}
@end example
-From the above do note the option '-S'. You may find it very useful when
-browsing the results; try the option with horizontal output (end
-commands with '\g', or ';') and with vertical output (end commands with
-'\G'). Sometimes a very wide result set is hard to be read from the screen,
-with option -S to less you can browse the results within the interactive
-less from left to right, preventing lines longer than your screen from
-being continued to the next line. This can make the result set much more
-readable. You can swith the mode between on and off within the interactive
-less with '-S'. See the 'h' for more help about less.
-@item
-Last (unless you already understood this from the above examples ;) you
-can combine very complex ways to handle the results, for example the
-following would send the results to two files in two different
-directories, on two different hard-disks mounted on /dr1 and /dr2, yet
-let the results still be seen on the screen via less:
+For more information on Object Oriented Programming
+(OOP) as defined in Perl5, see the Perl OOP page:
@example
-mysql> pager cat | tee /dr1/tmp/res.txt | tee /dr2/tmp/res2.txt | less -n -i -S
+@uref{http://language.perl.com/info/documentation.html}
@end example
-@item
-You can also combine the two functions above; have the @code{tee}
-enabled, @code{pager} set to 'less' and you will be able to browse the
-results in unix 'less' and still have everything appended into a file
-the same time. The difference between @code{UNIX tee} used with the
-@code{pager} and the @code{mysql} client in-built @code{tee}, is that
-the in-built @code{tee} works even if you don't have the @code{UNIX tee}
-available. The in-built @code{tee} also logs everything that is printed
-on the screen, where the @code{UNIX tee} used with @code{pager} doesn't
-log quite that much. Last, but not least, the interactive @code{tee} is
-more handy to switch on and off, when you want to log something into a
-file, but want to be able to turn the feature off sometimes.
-@end itemize
+Note that if you want to use transactions with Perl, you need to have
+@code{Msql-Mysql-modules} version 1.2216 or newer.
-@cindex administration, server
-@cindex server administration
-@cindex @code{mysladmn}
-@node mysqladmin, mysqldump, mysql, Tools
-@section Administering a MySQL Server
+Installation instructions for MySQL Perl support are given in
+@ref{Perl support}.
-A utility for performing administrative operations. The syntax is:
-@example
-shell> mysqladmin [OPTIONS] command [command-option] command ...
-@end example
+@node Perl DBI Class, DBI-info, DBI with DBD, Perl
+@subsection The @code{DBI} Interface
-You can get a list of the options your version of @code{mysqladmin} supports
-by executing @code{mysqladmin --help}.
+@cindex @code{DBI} Perl module
-The current @code{mysqladmin} supports the following commands:
+@noindent
+@strong{Portable DBI Methods}
@multitable @columnfractions .3 .7
-@item create databasename @tab Create a new database.
-@item drop databasename @tab Delete a database and all its tables.
-@item extended-status @tab Gives an extended status message from the server.
-@item flush-hosts @tab Flush all cached hosts.
-@item flush-logs @tab Flush all logs.
-@item flush-tables @tab Flush all tables.
-@item flush-privileges @tab Reload grant tables (same as reload).
-@item kill id,id,... @tab Kill mysql threads.
-@item password @tab New-password. Change old password to new-password.
-@item ping @tab Check if @code{mysqld} is alive.
-@item processlist @tab Show list of active threads in server.
-@item reload @tab Reload grant tables.
-@item refresh @tab Flush all tables and close and open logfiles.
-@item shutdown @tab Take server down.
-@item slave-start @tab Start slave replication thread.
-@item slave-stop @tab Stop slave replication thread.
-@item status @tab Gives a short status message from the server.
-@item variables @tab Prints variables available.
-@item version @tab Get version info from server.
+@item @code{connect} @tab Establishes a connection to a database server.
+@item @code{disconnect} @tab Disconnects from the database server.
+@item @code{prepare} @tab Prepares a SQL statement for execution.
+@item @code{execute} @tab Executes prepared statements.
+@item @code{do} @tab Prepares and executes a SQL statement.
+@item @code{quote} @tab Quotes string or @code{BLOB} values to be inserted.
+@item @code{fetchrow_array} @tab Fetches the next row as an array of fields.
+@item @code{fetchrow_arrayref} @tab Fetches next row as a reference array of fields.
+@item @code{fetchrow_hashref} @tab Fetches next row as a reference to a hashtable.
+@item @code{fetchall_arrayref} @tab Fetches all data as an array of arrays.
+@item @code{finish} @tab Finishes a statement and lets the system free resources.
+@item @code{rows} @tab Returns the number of rows affected.
+@item @code{data_sources} @tab Returns an array of databases available on localhost.
+@item @code{ChopBlanks} @tab Controls whether @code{fetchrow_*} methods trim spaces.
+@item @code{NUM_OF_PARAMS} @tab The number of placeholders in the prepared statement.
+@item @code{NULLABLE} @tab Which columns can be @code{NULL}.
+@item @code{trace} @tab Perform tracing for debugging.
@end multitable
-All commands can be shortened to their unique prefix. For example:
-
-@example
-shell> mysqladmin proc stat
-+----+-------+-----------+----+-------------+------+-------+------+
-| Id | User | Host | db | Command | Time | State | Info |
-+----+-------+-----------+----+-------------+------+-------+------+
-| 6 | monty | localhost | | Processlist | 0 | | |
-+----+-------+-----------+----+-------------+------+-------+------+
-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
-@end example
-
-@cindex status command, results
-The @code{mysqladmin status} command result has the following columns:
+@noindent
+@strong{MySQL-specific Methods}
-@cindex uptime
@multitable @columnfractions .3 .7
-@item Uptime @tab Number of seconds the @strong{MySQL} server has been up.
-@cindex threads
-@item Threads @tab Number of active threads (clients).
-@cindex questions
-@item Questions @tab Number of questions from clients since @code{mysqld} was started.
-@cindex slow queries
-@item Slow queries @tab Queries that have taken more than @code{long_query_time} seconds. @xref{Slow query log}.
-@cindex opens
-@item Opens @tab How many tables @code{mysqld} has opened.
-@cindex flush tables
-@cindex tables, flush
-@item Flush tables @tab Number of @code{flush ...}, @code{refresh}, and @code{reload} commands.
-@cindex open tables
-@item Open tables @tab Number of tables that are open now.
-@cindex memory use
-@item Memory in use @tab Memory allocated directly by the @code{mysqld} code (only available when @strong{MySQL} is compiled with --with-debug=full).
-@cindex max memory used
-@item Max memory used @tab Maximum memory allocated directly by the @code{mysqld} code (only available when @strong{MySQL} is compiled with --with-debug=full).
+@item @code{insertid} @tab The latest @code{AUTO_INCREMENT} value.
+@item @code{is_blob} @tab Which columns are @code{BLOB} values.
+@item @code{is_key} @tab Which columns are keys.
+@item @code{is_num} @tab Which columns are numeric.
+@item @code{is_pri_key} @tab Which columns are primary keys.
+@item @code{is_not_null} @tab Which columns CANNOT be @code{NULL}. See @code{NULLABLE}.
+@item @code{length} @tab Maximum possible column sizes.
+@item @code{max_length} @tab Maximum column sizes actually present in result.
+@item @code{NAME} @tab Column names.
+@item @code{NUM_OF_FIELDS} @tab Number of fields returned.
+@item @code{table} @tab Table names in returned set.
+@item @code{type} @tab All column types.
@end multitable
-If you do @code{myslqadmin shutdown} on a socket (in other words, on a
-the computer where @code{mysqld} is running), @code{mysqladmin} will
-wait until the @strong{MySQL} @code{pid-file} is removed to ensure that
-the @code{mysqld} server has stopped properly.
-
-@cindex dumping, databases
-@cindex databases, dumping
-@cindex tables, dumping
-@cindex backing up, databases
-@node mysqldump, mysqlhotcopy, mysqladmin, Tools
-@section Dumping the Structure and Data from MySQL Databases and Tables
-
-@cindex @code{mysqldump}
-Utility to dump a database or a collection of database for backup or for
-transferring the data to another SQL server (not necessarily a @strong{MySQL}
-server). The dump will contain SQL statements to create the table
-and/or populate the table.
-
-If you are doing a backup on the server, you should consider using
-the @code{mysqlhotcopy} instead. @xref{mysqlhotcopy, , @code{mysqlhotcopy}}.
-
-@example
-shell> mysqldump [OPTIONS] database [tables]
-OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
-OR mysqldump [OPTIONS] --all-databases [OPTIONS]
-@end example
-
-If you don't give any tables or use the @code{--databases} or
-@code{--all-databases}, the whole database(s) will be dumped.
-
-You can get a list of the options your version of @code{mysqldump} supports
-by executing @code{mysqldump --help}.
-
-Note that if you run @code{mysqldump} without @code{--quick} or
-@code{--opt}, @code{mysqldump} will load the whole result set into
-memory before dumping the result. This will probably be a problem if
-you are dumping a big database.
-
-Note that if you are using a new copy of the @code{mysqldump} program
-and you are going to do a dump that will be read into a very old @strong{MySQL}
-server, you should not use the @code{--opt} or @code{-e} options.
-
-@code{mysqldump} supports the following options:
-
-@table @code
-@item --add-locks
-Add @code{LOCK TABLES} before and @code{UNLOCK TABLE} after each table dump.
-(To get faster inserts into @strong{MySQL}.)
-@item --add-drop-table
-Add a @code{drop table} before each create statement.
-@item -A, --all-databases
-Dump all the databases. This will be same as @code{--databases} with all
-databases selected.
-@item -a, --all
-Include all @strong{MySQL}-specific create options.
-@item --allow-keywords
-Allow creation of column names that are keywords. This works by
-prefixing each column name with the table name.
-@item -c, --complete-insert
-Use complete insert statements (with column names).
-@item -C, --compress
-Compress all information between the client and the server if both support
-compression.
-@item -B, --databases
-To dump several databases. Note the difference in usage. In this case
-no tables are given. All name arguments are regarded as database names.
-@code{USE db_name;} will be included in the output before each new database.
-@item --delayed
-Insert rows with the @code{INSERT DELAYED} command.
-@item -e, --extended-insert
-Use the new multiline @code{INSERT} syntax. (Gives more compact and
-faster inserts statements.)
-@item -#, --debug[=option_string]
-Trace usage of the program (for debugging).
-@item --help
-Display a help message and exit.
-@item --fields-terminated-by=...
-@itemx --fields-enclosed-by=...
-@itemx --fields-optionally-enclosed-by=...
-@itemx --fields-escaped-by=...
-@itemx --lines-terminated-by=...
-These options are used with the @code{-T} option and have the same
-meaning as the corresponding clauses for @code{LOAD DATA INFILE}.
-@xref{LOAD DATA, , @code{LOAD DATA}}.
-@item -F, --flush-logs
-Flush log file in the @strong{MySQL} server before starting the dump.
-@item -f, --force,
-Continue even if we get a SQL error during a table dump.
-@item -h, --host=..
-Dump data from the @strong{MySQL} server on the named host. The default host
-is @code{localhost}.
-@item -l, --lock-tables.
-Lock all tables before starting the dump. The tables are locked with
-@code{READ LOCAL} to allow concurrent inserts in the case of @code{MyISAM}
-tables.
-@item -n, --no-create-db
-'CREATE DATABASE /*!32312 IF NOT EXISTS*/ db_name;' will not be put in the
-output. The above line will be added otherwise, if --databases or
---all-databases option was given.
-@item -t, --no-create-info
-Don't write table creation information (The @code{CREATE TABLE} statement.)
-@item -d, --no-data
-Don't write any row information for the table. This is very useful if you
-just want to get a dump of the structure for a table!
-@item --opt
-Same as @code{--quick --add-drop-table --add-locks --extended-insert
---lock-tables}. Should give you the fastest possible dump for reading
-into a @strong{MySQL} server.
-@item -pyour_pass, --password[=your_pass]
-The password to use when connecting to the server. If you specify
-no @samp{=your_pass} part,
-@code{mysqldump} you will be prompted for a password.
-@item -P port_num, --port=port_num
-The TCP/IP port number to use for connecting to a host. (This is used for
-connections to hosts other than @code{localhost}, for which Unix sockets are
-used.)
-@item -q, --quick
-Don't buffer query, dump directly to stdout. Uses @code{mysql_use_result()}
-to do this.
-@item -r, --result-file=...
-Direct output to a given file. This option should be used in MSDOS,
-because it prevents new line '\n' from being converted to '\n\r' (new
-line + carriage return).
-@item -S /path/to/socket, --socket=/path/to/socket
-The socket file to use when connecting to @code{localhost} (which is the
-default host).
-@item --tables
-Overrides option --databases (-B).
-@item -T, --tab=path-to-some-directory
-Creates a @code{table_name.sql} file, that contains the SQL CREATE commands,
-and a @code{table_name.txt} file, that contains the data, for each give table.
-@strong{NOTE}: This only works if @code{mysqldump} is run on the same
-machine as the @code{mysqld} daemon. The format of the @code{.txt} file
-is made according to the @code{--fields-xxx} and @code{--lines--xxx} options.
-@item -u user_name, --user=user_name
-The @strong{MySQL} user name to use when connecting to the server. The
-default value is your Unix login name.
-@item -O var=option, --set-variable var=option
-Set the value of a variable. The possible variables are listed below.
-@item -v, --verbose
-Verbose mode. Print out more information on what the program does.
-@item -V, --version
-Print version information and exit.
-@item -w, --where='where-condition'
-Dump only selected records. Note that QUOTES are mandatory:
-
-@example
-"--where=user='jimf'" "-wuserid>1" "-wuserid<1"
-@end example
-@item -O net_buffer_length=#, where # < 16M
-When creating multi-row-insert statements (as with option
-@code{--extended-insert} or @code{--opt}), @code{mysqldump} will create
-rows up to @code{net_buffer_length} length. If you increase this
-variable, you should also ensure that the @code{max_allowed_packet}
-variable in the @strong{MySQL} server is bigger than the
-@code{net_buffer_length}.
-@end table
-
-The most normal use of @code{mysqldump} is probably for making a backup of
-whole databases. @xref{Backup}.
-
-@example
-mysqldump --opt database > backup-file.sql
-@end example
-
-You can read this back into @strong{MySQL} with:
-
-@example
-mysql database < backup-file.sql
-@end example
-
-or
-
-@example
-mysql -e "source /patch-to-backup/backup-file.sql" database
-@end example
-
-However, it's also very useful to populate another @strong{MySQL} server with
-information from a database:
-
-@example
-mysqldump --opt database | mysql ---host=remote-host -C database
-@end example
-
-It is possible to dump several databases with one command:
-
-@example
-mysqldump --databases database1 [database2 database3...] > my_databases.sql
-@end example
-
-If all the databases are wanted, one can use:
-
-@example
-mysqldump --all-databases > all_databases.sql
-@end example
-
-@cindex dumping, databases
-@cindex databases, dumping
-@cindex tables, dumping
-@cindex backing up, databases
-@node mysqlhotcopy, mysqlimport, mysqldump, Tools
-@section Copying MySQL Databases and Tables
-
-@code{mysqlhotcopy} is a perl script that uses @code{LOCK TABLES},
-@code{FLUSH TABLES} and @code{cp} or @code{scp} to quickly make a backup
-of a database. It's the fastest way to make a backup of the database,
-of single tables but it can only be run on the same machine where the
-database directories are.
-
-@example
-mysqlhotcopy db_name [/path/to/new_directory]
-
-mysqlhotcopy db_name_1 ... db_name_n /path/to/new_directory
-
-mysqlhotcopy db_name./regex/
-@end example
-
-@code{mysqlhotcopy} supports the following options:
-
-@table @code
-@item -?, --help
-Display a help screen and exit
-@item -u, --user=#
-User for database login
-@item -p, --password=#
-Password to use when connecting to server
-@item -P, --port=#
-Port to use when connecting to local server
-@item -S, --socket=#
-Socket to use when connecting to local server
-@item --allowold
-Don't abort if target already exists (rename it _old)
-@item --keepold
-Don't delete previous (now renamed) target when done
-@item --noindices
-Don't include full index files in copy to make the backup smaller and faster
-The indexes can later be reconstructed with @code{myisamchk -rq.}.
-@item --method=#
-Method for copy (@code{cp} or @code{scp}).
-@item -q, --quiet
-Be silent except for errors
-@item --debug
-Enable debug
-@item -n, --dryrun
-Report actions without doing them
-@item --regexp=#
-Copy all databases with names matching regexp
-@item --suffix=#
-Suffix for names of copied databases
-@item --checkpoint=#
-Insert checkpoint entry into specified db.table
-@item --flushlog
-Flush logs once all tables are locked.
-@item --tmpdir=#
-Temporary directory (instead of /tmp).
-@end table
-
-You can use @code{perldoc mysqlhotcopy} to get a more complete
-documentation for @code{mysqlhotcopy}.
-
-@code{mysqlhotcopy} reads the groups @code{[client]} and @code{[mysqlhotcopy]}
-from the option files.
-
-To be able to execute @code{mysqlhotcopy} you need write access to the
-backup directory, @code{SELECT} privilege to the tables you are about to
-copy and the @strong{MySQL} @code{Reload} privilege (to be able to
-execute @code{FLUSH TABLES}).
-
-@cindex importing, data
-@cindex data, importing
-@cindex files, text
-@cindex text files, importing
-@cindex @code{mysqlimport}
-@node mysqlimport, perror, mysqlhotcopy, Tools
-@section Importing Data from Text Files
-
-@code{mysqlimport} provides a command-line interface to the @code{LOAD DATA
-INFILE} SQL statement. Most options to @code{mysqlimport} correspond
-directly to the same options to @code{LOAD DATA INFILE}.
-@xref{LOAD DATA, , @code{LOAD DATA}}.
-
-@code{mysqlimport} is invoked like this:
-
-@example
-shell> mysqlimport [options] database textfile1 [textfile2....]
-@end example
-
-For each text file named on the command line,
-@code{mysqlimport} strips any extension from the filename and uses the result
-to determine which table to import the file's contents into. For example,
-files named @file{patient.txt}, @file{patient.text}, and @file{patient} would
-all be imported into a table named @code{patient}.
-
-@code{mysqlimport} supports the following options:
+The Perl methods are described in more detail in the following sections.
+Variables used for method return values have these meanings:
@table @code
-@item -c, --columns=...
-This option takes a comma-separated list of field names as an argument.
-The field list is used to create a proper @code{LOAD DATA INFILE} command,
-which is then passed to @strong{MySQL}. @xref{LOAD DATA, , @code{LOAD DATA}}.
-
-@item -C, --compress
-Compress all information between the client and the server if both support
-compression.
-
-@item -#, --debug[=option_string]
-Trace usage of the program (for debugging).
-
-@item -d, --delete
-Empty the table before importing the text file.
-
-@item --fields-terminated-by=...
-@itemx --fields-enclosed-by=...
-@itemx --fields-optionally-enclosed-by=...
-@itemx --fields-escaped-by=...
-@itemx --lines-terminated-by=...
-These options have the same meaning as the corresponding clauses for
-@code{LOAD DATA INFILE}. @xref{LOAD DATA, , @code{LOAD DATA}}.
-
-@item -f, --force
-Ignore errors. For example, if a table for a text file doesn't exist,
-continue processing any remaining files. Without @code{--force},
-@code{mysqlimport} exits if a table doesn't exist.
-
-@item --help
-Display a help message and exit.
-
-@item -h host_name, --host=host_name
-Import data to the @strong{MySQL} server on the named host. The default host
-is @code{localhost}.
-
-@item -i, --ignore
-See the description for the @code{--replace} option.
-
-@item -l, --lock-tables
-Lock @strong{ALL} tables for writing before processing any text files. This
-ensures that all tables are synchronized on the server.
-
-@item -L, --local
-Read input files from the client. By default, text files are assumed to be on
-the server if you connect to @code{localhost} (which is the default host).
-
-@item -pyour_pass, --password[=your_pass]
-The password to use when connecting to the server. If you specify
-no @samp{=your_pass} part,
-@code{mysqlimport} you will be prompted for a password.
-
-@item -P port_num, --port=port_num
-The TCP/IP port number to use for connecting to a host. (This is used for
-connections to hosts other than @code{localhost}, for which Unix sockets are
-used.)
-
-@item -r, --replace
-The @code{--replace} and @code{--ignore} options control handling of input
-records that duplicate existing records on unique key values. If you specify
-@code{--replace}, new rows replace existing rows that have the same unique key
-value. If you specify @code{--ignore}, input rows that duplicate an existing
-row on a unique key value are skipped. If you don't specify either option, an
-error occurs when a duplicate key value is found, and the rest of the text
-file is ignored.
-
-@item -s, --silent
-Silent mode. Write output only when errors occur.
-
-@item -S /path/to/socket, --socket=/path/to/socket
-The socket file to use when connecting to @code{localhost} (which is the
-default host).
+@item $dbh
+Database handle
-@item -u user_name, --user=user_name
-The @strong{MySQL} user name to use when connecting to the server. The
-default value is your Unix login name.
+@item $sth
+Statement handle
-@item -v, --verbose
-Verbose mode. Print out more information what the program does.
+@item $rc
+Return code (often a status)
-@item -V, --version
-Print version information and exit.
+@item $rv
+Return value (often a row count)
@end table
-Here is a sample run using @code{mysqlimport}:
-
-@example
-$ mysql --version
-mysql Ver 9.33 Distrib 3.22.25, for pc-linux-gnu (i686)
-$ uname -a
-Linux xxx.com 2.2.5-15 #1 Mon Apr 19 22:21:09 EDT 1999 i586 unknown
-$ mysql -e 'CREATE TABLE imptest(id INT, n VARCHAR(30))' test
-$ ed
-a
-100 Max Sydow
-101 Count Dracula
-.
-w imptest.txt
-32
-q
-$ od -c imptest.txt
-0000000 1 0 0 \t M a x S y d o w \n 1 0
-0000020 1 \t C o u n t D r a c u l a \n
-0000040
-$ mysqlimport --local test imptest.txt
-test.imptest: Records: 2 Deleted: 0 Skipped: 0 Warnings: 0
-$ mysql -e 'SELECT * FROM imptest' test
-+------+---------------+
-| id | n |
-+------+---------------+
-| 100 | Max Sydow |
-| 101 | Count Dracula |
-+------+---------------+
-@end example
-
-@cindex error messages, displaying
-@cindex perror
-@node perror, mysqlshow, mysqlimport, Tools
-@section Converting an error code to the corresponding error message
-
-@code{perror} can be used to print error message(s). @code{perror} can
-be invoked like this:
-
-@example
-shell> perror [OPTIONS] [ERRORCODE [ERRORCODE...]]
-
-For example:
-
-shell> perror 64 79
-Error code 64: Machine is not on the network
-Error code 79: Can not access a needed shared library
-@end example
-
-@code{perror} can be used to display a description for a system error
-code, or an MyISAM/ISAM table handler error code. The error messages
-are mostly system dependent.
-
-@cindex databases, displaying
-@cindex displaying, database information
-@cindex tables, displaying
-@cindex columns, displaying
-@cindex showing, database information
-@node mysqlshow, myisampack, perror, Tools
-@section Showing Databases, Tables, and Columns
-
-@code{mysqlshow} can be used to quickly look at which databases exist,
-their tables, and the table's columns.
-
-With the @code{mysql} program you can get the same information with the
-@code{SHOW} commands. @xref{SHOW}.
-
-@code{mysqlshow} is invoked like this:
-
-@example
-shell> mysqlshow [OPTIONS] [database [table [column]]]
-@end example
-
-@itemize @bullet
-@item
-If no database is given, all matching databases are shown.
-@item
-If no table is given, all matching tables in the database are shown.
-@item
-If no column is given, all matching columns and column types in the table
-are shown.
-@end itemize
-
-Note that in newer @strong{MySQL} versions, you only see those
-database/tables/columns for which you have some privileges.
-
-If the last argument contains a shell or SQL wild-card (@code{*}, @code{?},
-@code{%} or @code{_}) then only what's matched by the wild card is shown.
-This may cause some confusion when you try to display the columns for a
-table with a @code{_} as in this case @code{mysqlshow} only shows you
-the table names that match the pattern. This is easily fixed by
-adding an extra @code{%} last on the command line (as a separate
-argument).
-
-@cindex compressed tables
-@cindex tables, compressed
-@cindex MyISAM, compressed tables
-@cindex @code{myisampack}
-@cindex @code{pack_isam}
-@node myisampack, , mysqlshow, Tools
-@section The MySQL Compressed Read-only Table Generator
-
-@code{myisampack} is used to compress MyISAM tables, and @code{pack_isam}
-is used to compress ISAM tables. Because ISAM tables are deprecated, we
-will only discuss @code{myisampack} here, but everything said about
-@code{myisampack} should also be true for @code{pack_isam}.
-
-@code{myisampack} works by compressing each column in the table separately.
-The information needed to decompress columns is read into memory when the
-table is opened. This results in much better performance when accessing
-individual records, because you only have to uncompress exactly one record, not
-a much larger disk block as when using Stacker on MS-DOS.
-Usually, @code{myisampack} packs the data file 40%-70%.
-
-@strong{MySQL} uses memory mapping (@code{mmap()}) on compressed tables and
-falls back to normal read/write file usage if @code{mmap()} doesn't work.
-
-There are currently two limitations with @code{myisampack}:
-@itemize @bullet
-@item
-After packing, the table is read-only.
-@item
-@code{myisampack} can also pack @code{BLOB} or @code{TEXT} columns. The
-older @code{pack_isam} could not do this.
-@end itemize
-
-Fixing these limitations is on our TODO list but with low priority.
-
-@code{myisampack} is invoked like this:
-
-@example
-shell> myisampack [options] filename ...
-@end example
-
-Each filename should be the name of an index (@file{.MYI}) file. If you
-are not in the database directory, you should specify the pathname to the
-file. It is permissible to omit the @file{.MYI} extension.
-
-@code{myisampack} supports the following options:
+@noindent
+@strong{Portable DBI Methods}
@table @code
-@item -b, --backup
-Make a backup of the table as @code{tbl_name.OLD}.
-
-@item -#, --debug=debug_options
-Output debug log. The @code{debug_options} string often is
-@code{'d:t:o,filename'}.
-
-@item -f, --force
-Force packing of the table even if it becomes bigger or if the temporary file
-exists. @code{myisampack} creates a temporary file named @file{tbl_name.TMD}
-while it compresses the table. If you kill @code{myisampack}, the @file{.TMD}
-file may not be deleted. Normally, @code{myisampack} exits with an error if
-it finds that @file{tbl_name.TMD} exists. With @code{--force},
-@code{myisampack} packs the table anyway.
-
-@item -?, --help
-Display a help message and exit.
-
-@item -j big_tbl_name, --join=big_tbl_name
-Join all tables named on the command line into a single table
-@code{big_tbl_name}. All tables that are to be combined
-MUST be identical (same column names and types, same indexes, etc.).
-
-@item -p #, --packlength=#
-Specify the record length storage size, in bytes. The value should be 1, 2,
-or 3. (@code{myisampack} stores all rows with length pointers of 1, 2, or 3
-bytes. In most normal cases, @code{myisampack} can determine the right length
-value before it begins packing the file, but it may notice during the packing
-process that it could have used a shorter length. In this case,
-@code{myisampack} will print a note that the next time you pack the same file,
-you could use a shorter record length.)
-
-@item -s, --silent
-Silent mode. Write output only when errors occur.
-
-@item -t, --test
-Don't actually pack table, just test packing it.
-
-@item -T dir_name, --tmp_dir=dir_name
-Use the named directory as the location in which to write the temporary table.
-
-@item -v, --verbose
-Verbose mode. Write information about progress and packing result.
-
-@item -V, --version
-Display version information and exit.
-
-@item -w, --wait
-
-Wait and retry if table is in use. If the @code{mysqld} server was
-invoked with the @code{--skip-locking} option, it is not a good idea to
-invoke @code{myisampack} if the table might be updated during the
-packing process.
-@end table
-
-@cindex examples, compressed tables
-The sequence of commands shown below illustrates a typical table compression
-session:
+@findex DBI->connect()
+@findex connect() DBI method
+@item connect($data_source, $username, $password)
+Use the @code{connect} method to make a database connection to the data
+source. The @code{$data_source} value should begin with
+@code{DBI:driver_name:}.
+Example uses of @code{connect} with the @code{DBD::mysql} driver:
@example
-shell> ls -l station.*
--rw-rw-r-- 1 monty my 994128 Apr 17 19:00 station.MYD
--rw-rw-r-- 1 monty my 53248 Apr 17 19:00 station.MYI
--rw-rw-r-- 1 monty my 5767 Apr 17 19:00 station.frm
-
-shell> myisamchk -dvv station
-
-MyISAM file: station
-Isam-version: 2
-Creation time: 1996-03-13 10:08:58
-Recover time: 1997-02-02 3:06:43
-Data records: 1192 Deleted blocks: 0
-Datafile: Parts: 1192 Deleted data: 0
-Datafile pointer (bytes): 2 Keyfile pointer (bytes): 2
-Max datafile length: 54657023 Max keyfile length: 33554431
-Recordlength: 834
-Record format: Fixed length
-
-table description:
-Key Start Len Index Type Root Blocksize Rec/key
-1 2 4 unique unsigned long 1024 1024 1
-2 32 30 multip. text 10240 1024 1
-
-Field Start Length Type
-1 1 1
-2 2 4
-3 6 4
-4 10 1
-5 11 20
-6 31 1
-7 32 30
-8 62 35
-9 97 35
-10 132 35
-11 167 4
-12 171 16
-13 187 35
-14 222 4
-15 226 16
-16 242 20
-17 262 20
-18 282 20
-19 302 30
-20 332 4
-21 336 4
-22 340 1
-23 341 8
-24 349 8
-25 357 8
-26 365 2
-27 367 2
-28 369 4
-29 373 4
-30 377 1
-31 378 2
-32 380 8
-33 388 4
-34 392 4
-35 396 4
-36 400 4
-37 404 1
-38 405 4
-39 409 4
-40 413 4
-41 417 4
-42 421 4
-43 425 4
-44 429 20
-45 449 30
-46 479 1
-47 480 1
-48 481 79
-49 560 79
-50 639 79
-51 718 79
-52 797 8
-53 805 1
-54 806 1
-55 807 20
-56 827 4
-57 831 4
-
-shell> myisampack station.MYI
-Compressing station.MYI: (1192 records)
-- Calculating statistics
-
-normal: 20 empty-space: 16 empty-zero: 12 empty-fill: 11
-pre-space: 0 end-space: 12 table-lookups: 5 zero: 7
-Original trees: 57 After join: 17
-- Compressing file
-87.14%
-
-shell> ls -l station.*
--rw-rw-r-- 1 monty my 127874 Apr 17 19:00 station.MYD
--rw-rw-r-- 1 monty my 55296 Apr 17 19:04 station.MYI
--rw-rw-r-- 1 monty my 5767 Apr 17 19:00 station.frm
-
-shell> myisamchk -dvv station
-
-MyISAM file: station
-Isam-version: 2
-Creation time: 1996-03-13 10:08:58
-Recover time: 1997-04-17 19:04:26
-Data records: 1192 Deleted blocks: 0
-Datafile: Parts: 1192 Deleted data: 0
-Datafilepointer (bytes): 3 Keyfile pointer (bytes): 1
-Max datafile length: 16777215 Max keyfile length: 131071
-Recordlength: 834
-Record format: Compressed
-
-table description:
-Key Start Len Index Type Root Blocksize Rec/key
-1 2 4 unique unsigned long 10240 1024 1
-2 32 30 multip. text 54272 1024 1
-
-Field Start Length Type Huff tree Bits
-1 1 1 constant 1 0
-2 2 4 zerofill(1) 2 9
-3 6 4 no zeros, zerofill(1) 2 9
-4 10 1 3 9
-5 11 20 table-lookup 4 0
-6 31 1 3 9
-7 32 30 no endspace, not_always 5 9
-8 62 35 no endspace, not_always, no empty 6 9
-9 97 35 no empty 7 9
-10 132 35 no endspace, not_always, no empty 6 9
-11 167 4 zerofill(1) 2 9
-12 171 16 no endspace, not_always, no empty 5 9
-13 187 35 no endspace, not_always, no empty 6 9
-14 222 4 zerofill(1) 2 9
-15 226 16 no endspace, not_always, no empty 5 9
-16 242 20 no endspace, not_always 8 9
-17 262 20 no endspace, no empty 8 9
-18 282 20 no endspace, no empty 5 9
-19 302 30 no endspace, no empty 6 9
-20 332 4 always zero 2 9
-21 336 4 always zero 2 9
-22 340 1 3 9
-23 341 8 table-lookup 9 0
-24 349 8 table-lookup 10 0
-25 357 8 always zero 2 9
-26 365 2 2 9
-27 367 2 no zeros, zerofill(1) 2 9
-28 369 4 no zeros, zerofill(1) 2 9
-29 373 4 table-lookup 11 0
-30 377 1 3 9
-31 378 2 no zeros, zerofill(1) 2 9
-32 380 8 no zeros 2 9
-33 388 4 always zero 2 9
-34 392 4 table-lookup 12 0
-35 396 4 no zeros, zerofill(1) 13 9
-36 400 4 no zeros, zerofill(1) 2 9
-37 404 1 2 9
-38 405 4 no zeros 2 9
-39 409 4 always zero 2 9
-40 413 4 no zeros 2 9
-41 417 4 always zero 2 9
-42 421 4 no zeros 2 9
-43 425 4 always zero 2 9
-44 429 20 no empty 3 9
-45 449 30 no empty 3 9
-46 479 1 14 4
-47 480 1 14 4
-48 481 79 no endspace, no empty 15 9
-49 560 79 no empty 2 9
-50 639 79 no empty 2 9
-51 718 79 no endspace 16 9
-52 797 8 no empty 2 9
-53 805 1 17 1
-54 806 1 3 9
-55 807 20 no empty 3 9
-56 827 4 no zeros, zerofill(2) 2 9
-57 831 4 no zeros, zerofill(1) 2 9
+$dbh = DBI->connect("DBI:mysql:$database", $user, $password);
+$dbh = DBI->connect("DBI:mysql:$database:$hostname",
+ $user, $password);
+$dbh = DBI->connect("DBI:mysql:$database:$hostname:$port",
+ $user, $password);
@end example
+If the user name and/or password are undefined, @code{DBI} uses the
+values of the @code{DBI_USER} and @code{DBI_PASS} environment variables,
+respectively. If you don't specify a hostname, it defaults to
+@code{'localhost'}. If you don't specify a port number, it defaults to the
+default MySQL port (@value{default_port}).
-The information printed by @code{myisampack} is described below:
-
-@table @code
-@item normal
-The number of columns for which no extra packing is used.
-
-@item empty-space
-The number of columns containing
-values that are only spaces; these will occupy 1 bit.
-
-@item empty-zero
-The number of columns containing
-values that are only binary 0's; these will occupy 1 bit.
-
-@item empty-fill
-The number of integer columns that don't occupy the full byte range of their
-type; these are changed to a smaller type (for example, an @code{INTEGER}
-column may be changed to @code{MEDIUMINT}).
-
-@item pre-space
-The number of decimal columns that are stored with leading spaces. In this
-case, each value will contain a count for the number of leading spaces.
-
-@item end-space
-The number of columns that have a lot of trailing spaces. In this case, each
-value will contain a count for the number of trailing spaces.
-
-@item table-lookup
-The column had only a small number of different values, which were
-converted to an @code{ENUM} before Huffman compression.
-
-@item zero
-The number of columns for which all values are zero.
-
-@item Original trees
-The initial number of Huffman trees.
-
-@item After join
-The number of distinct Huffman trees left after joining
-trees to save some header space.
-@end table
-
-After a table has been compressed, @code{myisamchk -dvv} prints additional
-information about each field:
-
-@table @code
-@item Type
-The field type may contain the following descriptors:
+As of @code{Msql-Mysql-modules} Version 1.2009,
+the @code{$data_source} value allows certain modifiers:
@table @code
-@item constant
-All rows have the same value.
-
-@item no endspace
-Don't store endspace.
-
-@item no endspace, not_always
-Don't store endspace and don't do end space compression for all values.
-
-@item no endspace, no empty
-Don't store endspace. Don't store empty values.
-
-@item table-lookup
-The column was converted to an @code{ENUM}.
+@item mysql_read_default_file=file_name
+Read @file{filename} as an option file. For information on option files,
+see @ref{Option files}.
-@item zerofill(n)
-The most significant @code{n} bytes in the value are always 0 and are not
-stored.
+@item mysql_read_default_group=group_name
+The default group when reading an option file is normally the
+@code{[client]} group. By specifying the @code{mysql_read_default_group}
+option, the default group becomes the @code{[group_name]} group.
-@item no zeros
-Don't store zeros.
+@item mysql_compression=1
+Use compressed communication between the client and server (MySQL
+Version 3.22.3 or later).
-@item always zero
-0 values are stored in 1 bit.
+@item mysql_socket=/path/to/socket
+Specify the pathname of the Unix socket that is used to connect
+to the server (MySQL Version 3.21.15 or later).
@end table
-@item Huff tree
-The Huffman tree associated with the field.
-
-@item Bits
-The number of bits used in the Huffman tree.
-@end table
+Multiple modifiers may be given; each must be preceded by a semicolon.
-After you have run @code{pack_isam}/@code{myisampack} you must run
-@code{isamchk}/@code{myisamchk} to re-create the index. At this time you
-can also sort the index blocks and create statistics needed for
-the @strong{MySQL} optimizer to work more efficiently:
+For example, if you want to avoid hardcoding the user name and password into
+a @code{DBI} script, you can take them from the user's @file{~/.my.cnf}
+option file instead by writing your @code{connect} call like this:
@example
-myisamchk -rq --analyze --sort-index table_name.MYI
-isamchk -rq --analyze --sort-index table_name.ISM
+$dbh = DBI->connect("DBI:mysql:$database"
+ . ";mysql_read_default_file=$ENV@{HOME@}/.my.cnf",
+ $user, $password);
@end example
-After you have installed the packed table into the @strong{MySQL} database
-directory you should do @code{mysqladmin flush-tables} to force @code{mysqld}
-to start using the new table.
-
-If you want to unpack a packed table, you can do this with the
-@code{--unpack} option to @code{isamchk} or @code{myisamchk}.
-
-
-@cindex installation maintenance
-@cindex maintaining, tables
-@cindex tables, maintaining
-@cindex databases, maintaining
-@cindex @code{myisamchk}
-@cindex @code{mysqlcheck}
-@cindex crash, recovery
-@cindex recovery, from crash
-@node Maintenance, Adding functions, Tools, Top
-@chapter Maintaining a MySQL Installation
-
-@menu
-* Table maintenance:: Table maintenance and crash recovery
-* Using mysqlcheck:: Using mysqlcheck for maintenance and recovery
-* Maintenance regimen:: Setting up a table maintenance regimen
-* Table-info:: Getting information about a table
-* Crash recovery:: Using @code{myisamchk} for crash recovery
-* Log file maintenance:: Log file maintenance
-@end menu
-
-This chapter covers what you should know about maintaining a @strong{MySQL}
-distribution. You will learn how to care for your tables on a regular
-basis, and what to do when disaster strikes.
-
-@node Table maintenance, Using mysqlcheck, Maintenance, Maintenance
-@section Using @code{myisamchk} for Table Maintenance and Crash Recovery
-
-Starting with @strong{MySQL} Version 3.23.13, you can check MyISAM
-tables with the @code{CHECK TABLE} command. @xref{CHECK TABLE}. You can
-repair tables with the @code{REPAIR TABLE} command. @xref{REPAIR TABLE}.
-
-To check/repair MyISAM tables (@code{.MYI} and @code{.MYD}) you should
-use the @code{myisamchk} utility. To check/repair ISAM tables
-(@code{.ISM} and @code{.ISD}) you should use the @code{isamchk}
-utility. @xref{Table types}.
-
-In the following text we will talk about @code{myisamchk}, but everything
-also applies to the old @code{isamchk}.
-
-You can use the @code{myisamchk} utility to get information about your
-database tables, check and repair them, or optimize them. The following
-sections describe how to invoke @code{myisamchk} (including a
-description of its options), how to set up a table maintenance schedule,
-and how to use @code{myisamchk} to perform its various functions.
-
-You can, in most cases, also use the command @code{OPTIMIZE TABLES} to
-optimize and repair tables, but this is not as fast or reliable (in case
-of real fatal errors) as @code{myisamchk}. On the other hand,
-@code{OPTIMIZE TABLE} is easier to use and you don't have to worry about
-flushing tables.
-@xref{OPTIMIZE TABLE, , @code{OPTIMIZE TABLE}}.
-
-Even that the repair in @code{myisamchk} is quite secure, it's always a
-good idea to make a backup BEFORE doing a repair (or anything that could
-make a lot of changes to a table)
-
-@menu
-* myisamchk syntax:: @code{myisamchk} invocation syntax
-* myisamchk memory:: @code{myisamchk} memory usage
-@end menu
-
-@node myisamchk syntax, myisamchk memory, Table maintenance, Table maintenance
-@subsection @code{myisamchk} Invocation Syntax
-
-@code{myisamchk} is invoked like this:
+This call will read options defined for the @code{[client]} group in the
+option file. If you wanted to do the same thing but use options specified
+for the @code{[perl]} group as well, you could use this:
@example
-shell> myisamchk [options] tbl_name
+$dbh = DBI->connect("DBI:mysql:$database"
+ . ";mysql_read_default_file=$ENV@{HOME@}/.my.cnf"
+ . ";mysql_read_default_group=perl",
+ $user, $password);
@end example
-The @code{options} specify what you want @code{myisamchk} to do. They are
-described below. (You can also get a list of options by invoking
-@code{myisamchk --help}.) With no options, @code{myisamchk} simply checks your
-table. To get more information or to tell @code{myisamchk} to take corrective
-action, specify options as described below and in the following sections.
-
-@code{tbl_name} is the database table you want to check/repair. If you run
-@code{myisamchk} somewhere other than in the database directory, you must
-specify the path to the file, because @code{myisamchk} has no idea where your
-database is located. Actually, @code{myisamchk} doesn't care whether or not
-the files you are working on are located in a database directory; you can
-copy the files that correspond to a database table into another location and
-perform recovery operations on them there.
-
-You can name several tables on the @code{myisamchk} command line if you
-wish. You can also specify a name as an index file
-name (with the @file{.MYI} suffix), which allows you to specify all
-tables in a directory by using the pattern @file{*.MYI}.
-For example, if you are in a database directory, you can check all the
-tables in the directory like this:
-
+@findex DBI->disconnect
+@findex disconnect DBI method
+@item disconnect
+The @code{disconnect} method disconnects the database handle from the database.
+This is typically called right before you exit from the program.
+Example:
@example
-shell> myisamchk *.MYI
+$rc = $dbh->disconnect;
@end example
-If you are not in the database directory, you can check all the tables there
-by specifying the path to the directory:
-
+@findex DBI->prepare()
+@findex prepare() DBI method
+@item prepare($statement)
+Prepares a SQL statement for execution by the database engine
+and returns a statement handle @code{($sth)}, which you can use to invoke
+the @code{execute} method.
+Typically you handle @code{SELECT} statements (and @code{SELECT}-like statements
+such as @code{SHOW}, @code{DESCRIBE}, and @code{EXPLAIN}) by means of
+@code{prepare} and @code{execute}.
+Example:
@example
-shell> myisamchk /path/to/database_dir/*.MYI
+$sth = $dbh->prepare($statement)
+ or die "Can't prepare $statement: $dbh->errstr\n";
@end example
-You can even check all tables in all databases by specifying a wild card
-with the path to the @strong{MySQL} data directory:
-
+@findex DBI->execute
+@findex execute DBI method
+@item execute
+The @code{execute} method executes a prepared statement. For
+non-@code{SELECT} statements, @code{execute} returns the number of rows
+affected. If no rows are affected, @code{execute} returns @code{"0E0"},
+which Perl treats as zero but regards as true. If an error occurs,
+@code{execute} returns @code{undef}. For @code{SELECT} statements,
+@code{execute} only starts the SQL query in the database; you need to use one
+of the @code{fetch_*} methods described below to retrieve the data.
+Example:
@example
-shell> myisamchk /path/to/datadir/*/*.MYI
+$rv = $sth->execute
+ or die "can't execute the query: $sth->errstr;
@end example
-The recommended way to quickly check all tables is:
-
+@findex DBI->do()
+@findex do() DBI method
+@item do($statement)
+The @code{do} method prepares and executes a SQL statement and returns the
+number of rows affected. If no rows are affected, @code{do} returns
+@code{"0E0"}, which Perl treats as zero but regards as true. This method is
+generally used for non-@code{SELECT} statements that cannot be prepared in
+advance (due to driver limitations) or that do not need to be executed more
+than once (inserts, deletes, etc.). Example:
@example
-myisamchk --silent --fast /path/to/datadir/*/*.MYI
-isamchk --silent /path/to/datadir/*/*.ISM
+$rv = $dbh->do($statement)
+ or die "Can't execute $statement: $dbh- >errstr\n";
@end example
-If you want to check all tables and repair all tables that are corrupted,
-you can use the following line:
+Generally the 'do' statement is MUCH faster (and is preferable)
+than prepare/execute for statements that don't contain parameters.
+@findex DBI->quote()
+@findex quote() DBI method
+@cindex quoting strings
+@cindex strings, quoting
+@item quote($string)
+The @code{quote} method is used to "escape" any special characters contained in
+the string and to add the required outer quotation marks.
+Example:
@example
-myisamchk --silent --force --fast --update-state -O key_buffer=64M -O sort_buffer=64M -O read_buffer=1M -O write_buffer=1M /path/to/datadir/*/*.MYI
-isamchk --silent --force -O key_buffer=64M -O sort_buffer=64M -O read_buffer=1M -O write_buffer=1M /path/to/datadir/*/*.ISM
+$sql = $dbh->quote($string)
@end example
-The above assumes that you have more than 64 M free.
-
-Note that if you get an error like:
-
+@findex DBI->fetchrow_array
+@findex fetchrow_array DBI method
+@item fetchrow_array
+This method fetches the next row of data and returns it as an array of
+field values. Example:
@example
-myisamchk: warning: 1 clients is using or hasn't closed the table properly
+while(@@row = $sth->fetchrow_array) @{
+ print qw($row[0]\t$row[1]\t$row[2]\n);
+@}
@end example
-This means that you are trying to check a table that has been updated by
-the another program (like the @code{mysqld} server) that hasn't yet closed
-the file or that has died without closing the file properly.
-
-If you @code{mysqld} is running, you must force a sync/close of all
-tables with @code{FLUSH TABLES} and ensure that no one is using the
-tables while you are running @code{myisamchk}. In @strong{MySQL} Version 3.23
-the easiest way to avoid this problem is to use @code{CHECK TABLE}
-instead of @code{myisamchk} to check tables.
-
-@menu
-* myisamchk general options::
-* myisamchk check options::
-* myisamchk repair options::
-* myisamchk other options::
-@end menu
-
-@cindex options, @code{myisamchk}
-@cindex @code{myisamchk}, options
-@node myisamchk general options, myisamchk check options, myisamchk syntax, myisamchk syntax
-@subsubsection General Options for @code{myisamchk}
-
-@code{myisamchk} supports the following options.
-
-@table @code
-@item -# or --debug=debug_options
-Output debug log. The @code{debug_options} string often is
-@code{'d:t:o,filename'}.
-@item -? or --help
-Display a help message and exit.
-@item -O var=option, --set-variable var=option
-Set the value of a variable. The possible variables and their default values
-for myisamchk can be examined with @code{myisamchk --help}:
-@multitable @columnfractions .3 .7
-@item key_buffer_size @tab 523264
-@item read_buffer_size @tab 262136
-@item write_buffer_size @tab 262136
-@item sort_buffer_size @tab 2097144
-@item sort_key_blocks @tab 16
-@item decode_bits @tab 9
-@end multitable
-
-@code{sort_buffer_size} is used when the keys are repaired by sorting
-keys, which is the normal case when you use @code{--recover}.
-
-@code{key_buffer_size} is used when you are checking the table with
-@code{--extended-check} or when the keys are repaired by inserting key
-row by row in to the table (like when doing normal inserts). Repairing
-through the key buffer is used in the following cases:
-
-@itemize @bullet
-@item
-If you use @code{--safe-recover}.
-@item
-If you are using a @code{FULLTEXT} index.
-@item
-If the temporary files needed to sort the keys would be more than twice
-as big as when creating the key file directly. This is often the case
-when you have big @code{CHAR}, @code{VARCHAR} or @code{TEXT} keys as the
-sort needs to store the whole keys during sorting. If you have lots
-of temporary space and you can force @code{myisamchk} to repair by sorting
-you can use the @code{--sort-recover} option.
-@end itemize
-
-Reparing through the key buffer takes much less disk space than using
-sorting, but is also much slower.
-
-If you want a faster repair, set the above variables to about 1/4 of your
-available memory. You can set both variables to big values, as only one
-of the above buffers will be used at a time.
-
-@item -s or --silent
-Silent mode. Write output only when errors occur. You can use @code{-s}
-twice (@code{-ss}) to make @code{myisamchk} very silent.
-@item -v or --verbose
-Verbose mode. Print more information. This can be used with @code{-d} and
-@code{-e}. Use @code{-v} multiple times (@code{-vv}, @code{-vvv}) for more
-verbosity!
-@item -V or --version
-Print the @code{myisamchk} version and exit.
-@item -w or, --wait
-Instead of giving an error if the table is locked, wait until the table
-is unlocked before continuing. Note that if you are running @code{mysqld}
-on the table with @code{--skip-locking}, the table can only be locked
-by another @code{myisamchk} command.
-@end table
-
-@cindex check options, myisamchk
-@cindex tables, checking
-@node myisamchk check options, myisamchk repair options, myisamchk general options, myisamchk syntax
-@subsubsection Check Options for @code{myisamchk}
-
-@table @code
-@item -c or --check
-Check table for errors. This is the default operation if you are not
-giving @code{myisamchk} any options that override this.
-
-@item -e or --extend-check
-Check the table VERY thoroughly (which is quite slow if you have many
-indexes). This option should only be used in extreme cases. Normally,
-@code{myisamchk} or @code{myisamchk --medium-check} should, in most
-cases, be able to find out if there are any errors in the table.
-
-If you are using @code{--extended-check} and have much memory, you should
-increase the value of @code{key_buffer_size} a lot!
-
-@item -F or --fast
-Check only tables that haven't been closed properly.
-@item -C or --check-only-changed
-Check only tables that have changed since the last check.
-@item -f or --force
-Restart @code{myisamchk} with @code{-r} (repair) on the table, if
-@code{myisamchk} finds any errors in the table.
-@item -i or --information
-Print informational statistics about the table that is checked.
-@item -m or --medium-check
-Faster than extended-check, but only finds 99.99% of all errors.
-Should, however, be good enough for most cases.
-@item -U or --update-state
-Store in the @file{.MYI} file when the table was checked and if the table crashed. This should be used to get full benefit of the
-@code{--check-only-changed} option, but you shouldn't use this
-option if the @code{mysqld} server is using the table and you are
-running @code{mysqld} with @code{--skip-locking}.
-@item -T or --read-only
-Don't mark table as checked. This is useful if you use @code{myisamchk}
-to check a table that is in use by some other application that doesn't
-use locking (like @code{mysqld --skip-locking}).
-@end table
-
-@cindex repair options, myisamchk
-@cindex files, repairing
-@node myisamchk repair options, myisamchk other options, myisamchk check options, myisamchk syntax
-@subsubsection Repair Options for myisamchk
-
-The following options are used if you start @code{myisamchk} with
-@code{-r} or @code{-o}:
-
-@table @code
-@item -D # or --data-file-length=#
-Max length of data file (when re-creating data file when it's 'full').
-@item -e or --extend-check
-Try to recover every possible row from the data file.
-Normally this will also find a lot of garbage rows. Don't use this option
-if you are not totally desperate.
-@item -f or --force
-Overwrite old temporary files (@code{table_name.TMD}) instead of aborting.
-@item -k # or keys-used=#
-If you are using ISAM, tells the ISAM table handler to update only the
-first @code{#} indexes. If you are using @code{MyISAM}, tells which keys
-to use, where each binary bit stands for one key (first key is bit 0).
-This can be used to get faster inserts! Deactivated indexes can be
-reactivated by using @code{myisamchk -r}. keys.
-@item -l or --no-symlinks
-Do not follow symbolic links. Normally @code{myisamchk} repairs the
-table a symlink points at. This option doesn't exist in MySQL 4.0,
-as MySQL 4.0 will not remove symlinks during repair.
-@item -r or --recover
-Can fix almost anything except unique keys that aren't unique
-(which is an extremely unlikely error with ISAM/MyISAM tables).
-If you want to recover a table, this is the option to try first. Only if
-myisamchk reports that the table can't be recovered by @code{-r}, you
-should then try @code{-o}. (Note that in the unlikely case that @code{-r}
-fails, the data file is still intact.)
-If you have lots of memory, you should increase the size of
-@code{sort_buffer_size}!
-@item -o or --safe-recover
-Uses an old recovery method (reads through all rows in order and updates
-all index trees based on the found rows); this is a magnitude slower
-than @code{-r}, but can handle a couple of very unlikely cases that
-@code{-r} cannot handle. This recovery method also uses much less disk
-space than @code{-r}. Normally one should always first repair with
-@code{-r}, and only if this fails use @code{-o}.
-
-If you have lots of memory, you should increase the size of
-@code{key_buffer_size}!
-@item -n or --sort-recover
-Force @code{myisamchk} to use sorting to resolve the keys even if the
-temporary files should be very big. This will not have any effect if you have
-fulltext keys in the table.
-
-@item --character-sets-dir=...
-Directory where character sets are stored.
-@item --set-character-set=name
-Change the character set used by the index
-@item .t or --tmpdir=path
-Path for storing temporary files. If this is not set, @code{myisamchk} will
-use the environment variable @code{TMPDIR} for this.
-@item -q or --quick
-Faster repair by not modifying the data file. One can give a second
-@code{-q} to force @code{myisamchk} to modify the original datafile in case
-of duplicate keys
-@item -u or --unpack
-Unpack file packed with myisampack.
-@end table
-
-@node myisamchk other options, , myisamchk repair options, myisamchk syntax
-@subsubsection Other Options for @code{myisamchk}
-
-Other actions that @code{myisamchk} can do, besides repair and check tables:
-
-@table @code
-@item -a or --analyze
-Analyze the distribution of keys. This improves join performance by
-enabling the join optimizer to better choose in which order it should
-join the tables and which keys it should use:
-@code{myisamchk --describe --verbose table_name'} or using @code{SHOW KEYS} in
-@strong{MySQL}.
-@item -d or --description
-Prints some information about table.
-@item -A or --set-auto-increment[=value]
-Force auto_increment to start at this or higher value. If no value is
-given, then sets the next auto_increment value to the highest used value
-for the auto key + 1.
-@item -S or --sort-index
-Sort the index tree blocks in high-low order.
-This will optimize seeks and will make table scanning by key faster.
-@item -R or --sort-records=#
-Sorts records according to an index. This makes your data much more localized
-and may speed up ranged @code{SELECT} and @code{ORDER BY} operations on
-this index. (It may be VERY slow to do a sort the first time!)
-To find out a table's index numbers, use @code{SHOW INDEX}, which shows a
-table's indexes in the same order that @code{myisamchk} sees them. Indexes are
-numbered beginning with 1.
-@end table
-
-@cindex memory usage, myisamchk
-@node myisamchk memory, , myisamchk syntax, Table maintenance
-@subsection @code{myisamchk} Memory Usage
-
-Memory allocation is important when you run @code{myisamchk}.
-@code{myisamchk} uses no more memory than you specify with the @code{-O}
-options. If you are going to use @code{myisamchk} on very large files,
-you should first decide how much memory you want it to use. The default
-is to use only about 3M to fix things. By using larger values, you can
-get @code{myisamchk} to operate faster. For example, if you have more
-than 32M RAM, you could use options such as these (in addition to any
-other options you might specify):
-
+@findex DBI->fetchrow_arrayref
+@findex fetchrow_arrayref DBI method
+@item fetchrow_arrayref
+This method fetches the next row of data and returns it as a reference
+to an array of field values. Example:
@example
-shell> myisamchk -O sort=16M -O key=16M -O read=1M -O write=1M ...
+while($row_ref = $sth->fetchrow_arrayref) @{
+ print qw($row_ref->[0]\t$row_ref->[1]\t$row_ref->[2]\n);
+@}
@end example
-Using @code{-O sort=16M} should probably be enough for most cases.
-
-Be aware that @code{myisamchk} uses temporary files in @code{TMPDIR}. If
-@code{TMPDIR} points to a memory file system, you may easily get out of
-memory errors. If this happens, set @code{TMPDIR} to point at some directory
-with more space and restart @code{myisamchk}.
-
-When repairing, @code{myisamchk} will also need a lot of disk space:
-
-@itemize @bullet
-@item
-Double the size of the record file (the original one and a copy). This
-space is not needed if one does a repair with @code{--quick}, as in this
-case only the index file will be re-created. This space is needed on the
-same disk as the original record file!
-@item
-Space for the new index file that replaces the old one. The old
-index file is truncated at start, so one usually ignore this space.
-This space is needed on the same disk as the original index file!
-@item
-When using @code{--recover} or @code{--sort-recover}
-(but not when using @code{--safe-recover}, you will need space for a
-sort buffer for:
-@code{(largest_key + row_pointer_length)*number_of_rows * 2}.
-You can check the length of the keys and the row_pointer_length with
-@code{myisamchk -dv table}.
-This space is allocated on the temporary disk (specified by @code{TMPDIR} or
-@code{--tmpdir=#}).
-@end itemize
-
-If you have a problem with disk space during repair, you can try to use
-@code{--safe-recover} instead of @code{--recover}.
-
-@node Using mysqlcheck, Maintenance regimen, Table maintenance, Maintenance
-@section Using @code{mysqlcheck} for Table Maintenance and Crash Recovery
-
-Since @strong{MySQL} version 3.23.38 you will be able to use a new
-checking and repairing tool for @code{MyISAM} tables. The difference to
-@code{myisamchk} is that @code{mysqlcheck} should be used when the
-@code{mysqld} server is running, where as @code{myisamchk} should be used
-when it is not. The benefit is that you no longer have to take the
-server down for checking or repairing your tables.
-
-@code{mysqlcheck} uses @strong{MySQL} server commands @code{CHECK},
-@code{REPAIR}, @code{ANALYZE} and @code{OPTIMIZE} in a convenient way
-for the user.
-
-There are three alternative ways to invoke @code{mysqlcheck}:
-
+@findex DBI->fetchrow_hashref
+@findex fetchrow_hashref DBI method
+@item fetchrow_hashref
+This method fetches a row of data and returns a reference to a hash
+table containing field name/value pairs. This method is not nearly as
+efficient as using array references as demonstrated above. Example:
@example
-shell> mysqlcheck [OPTIONS] database [tables]
-shell> mysqlcheck [OPTIONS] --databases DB1 [DB2 DB3...]
-shell> mysqlcheck [OPTIONS] --all-databases
+while($hash_ref = $sth->fetchrow_hashref) @{
+ print qw($hash_ref->@{firstname@}\t$hash_ref->@{lastname@}\t\
+ $hash_ref- > title@}\n);
+@}
@end example
-So it can be used in a similar way as @code{mysqldump} when it
-comes to what databases and tables you want to choose.
-
-@code{mysqlcheck} does have a special feature compared to the other
-clients; the default behavior, checking tables (-c), can be changed by
-renaming the binary. So if you want to have a tool that repairs tables
-by default, you should just copy @code{mysqlcheck} to your harddrive
-with a new name, @code{mysqlrepair}, or alternatively make a symbolic
-link to @code{mysqlrepair} and name the symbolic link as
-@code{mysqlrepair}. If you invoke @code{mysqlrepair} now, it will repair
-tables by default.
-
-The names that you can use to change @code{mysqlcheck} default behavior
-are here:
-
+@findex DBI->fetchall_arrayref
+@findex fetchall_arrayref DBI method
+@item fetchall_arrayref
+This method is used to get all the data (rows) to be returned from the
+SQL statement. It returns a reference to an array of references to arrays
+for each row. You access or print the data by using a nested
+loop. Example:
@example
-mysqlrepair: The default option will be -r
-mysqlanalyze: The default option will be -a
-mysqloptimize: The default option will be -o
+my $table = $sth->fetchall_arrayref
+ or die "$sth->errstr\n";
+my($i, $j);
+for $i ( 0 .. $#@{$table@} ) @{
+ for $j ( 0 .. $#@{$table->[$i]@} ) @{
+ print "$table->[$i][$j]\t";
+ @}
+ print "\n";
+@}
@end example
-The options available for @code{mysqlcheck} are listed here, please
-check what your version supports with @code{mysqlcheck --help}.
-
-@table @code
-@item -A, --all-databases
-Check all the databases. This will be same as --databases with all
-databases selected
-@item -1, --all-in-1
-Instead of making one query for each table, execute all queries in 1
-query separately for each database. Table names will be in a comma
-separated list.
-@item -a, --analyze
-Analyze given tables.
-@item --auto-repair
-If a checked table is corrupted, automatically fix it. Repairing will be
-done after all tables have been checked, if corrupted ones were found.
-@item -#, --debug=...
-Output debug log. Often this is 'd:t:o,filename'
-@item --character-sets-dir=...
-Directory where character sets are
-@item -c, --check
-Check table for errors
-@item -C, --check-only-changed
-Check only tables that have changed since last check or haven't been
-closed properly.
-@item --compress
-Use compression in server/client protocol.
-@item -?, --help
-Display this help message and exit.
-@item -B, --databases
-To check several databases. Note the difference in usage; In this case
-no tables are given. All name arguments are regarded as database names.
-@item --default-character-set=...
-Set the default character set
-@item -F, --fast
-Check only tables that hasn't been closed properly
-@item -f, --force
-Continue even if we get an sql-error.
-@item -e, --extended
-If you are using this option with CHECK TABLE, it will ensure that the
-table is 100 percent consistent, but will take a long time.
-
-If you are using this option with REPAIR TABLE, it will run an extended
-repair on the table, which may not only take a long time to execute, but
-may produce a lot of garbage rows also!
-@item -h, --host=...
-Connect to host.
-@item -m, --medium-check
-Faster than extended-check, but only finds 99.99 percent of all
-errors. Should be good enough for most cases.
-@item -o, --optimize
-Optimize table
-@item -p, --password[=...]
-Password to use when connecting to server. If password is not given
-it's solicited on the tty.
-@item -P, --port=...
-Port number to use for connection.
-@item -q, --quick
-If you are using this option with CHECK TABLE, it prevents the check
-from scanning the rows to check for wrong links. This is the fastest
-check.
-
-If you are using this option with REPAIR TABLE, it will try to repair
-only the index tree. This is the fastest repair method for a table.
-@item -r, --repair
-Can fix almost anything except unique keys that aren't unique.
-@item -s, --silent
-Print only error messages.
-@item -S, --socket=...
-Socket file to use for connection.
-@item --tables
-Overrides option --databases (-B).
-@item -u, --user=#
-User for login if not current user.
-@item -v, --verbose
-Print info about the various stages.
-@item -V, --version
-Output version information and exit.
-@end table
-
-@cindex maintaining, tables
-@cindex tables, maintenance regimen
-@node Maintenance regimen, Table-info, Using mysqlcheck, Maintenance
-@section Setting Up a Table Maintenance Regimen
-
-Starting with @strong{MySQL} Version 3.23.13, you can check MyISAM
-tables with the @code{CHECK TABLE} command. @xref{CHECK TABLE}. You can
-repair tables with the @code{REPAIR TABLE} command. @xref{REPAIR TABLE}.
-
-It is a good idea to perform table checks on a regular basis rather than
-waiting for problems to occur. For maintenance purposes, you can use
-@code{myisamchk -s} to check tables. The @code{-s} option (short for
-@code{--silent}) causes @code{myisamchk} to run in silent mode, printing
-messages only when errors occur.
-
-@tindex .pid (process ID) file
-It's also a good idea to check tables when the server starts up.
-For example, whenever the machine has done a reboot in the middle of an
-update, you usually need to check all the tables that could have been
-affected. (This is an ``expected crashed table''.) You could add a test to
-@code{safe_mysqld} that runs @code{myisamchk} to check all tables that have
-been modified during the last 24 hours if there is an old @file{.pid}
-(process ID) file left after a reboot. (The @file{.pid} file is created by
-@code{mysqld} when it starts up and removed when it terminates normally. The
-presence of a @file{.pid} file at system startup time indicates that
-@code{mysqld} terminated abnormally.)
-
-An even better test would be to check any table whose last-modified time
-is more recent than that of the @file{.pid} file.
-
-You should also check your tables regularly during normal system
-operation. At @strong{MySQL AB}, we run a @code{cron} job to check all
-our important tables once a week, using a line like this in a @file{crontab}
-file:
-
+@findex DBI->finish
+@findex finish DBI method
+@item finish
+Indicates that no more data will be fetched from this statement
+handle. You call this method to free up the statement handle and any
+system resources associated with it. Example:
@example
-35 0 * * 0 /path/to/myisamchk --fast --silent /path/to/datadir/*/*.MYI
+$rc = $sth->finish;
@end example
-This prints out information about crashed tables so we can examine and repair
-them when needed.
-
-As we haven't had any unexpectedly crashed tables (tables that become
-corrupted for reasons other than hardware trouble)
-for a couple of years now (this is really true), once a week is
-more than enough for us.
-
-We recommend that to start with, you execute @code{myisamchk -s} each
-night on all tables that have been updated during the last 24 hours,
-until you come to trust @strong{MySQL} as much as we do.
-
-@cindex tables, defragment
-Normally you don't need to maintain @strong{MySQL} tables that much. If
-you are changing tables with dynamic size rows (tables with @code{VARCHAR},
-@code{BLOB} or @code{TEXT} columns) or have tables with many deleted rows
-you may want to from time to time (once a month?) defragment/reclaim space
-from the tables.
-
-You can do this by using @code{OPTIMIZE TABLE} on the tables in question or
-if you can take the @code{mysqld} server down for a while do:
-
+@findex DBI->rows
+@findex rows DBI method
+@item rows
+Returns the number of rows changed (updated, deleted, etc.) by the last
+command. This is usually used after a non-@code{SELECT} @code{execute}
+statement. Example:
@example
-isamchk -r --silent --sort-index -O sort_buffer_size=16M */*.ISM
-myisamchk -r --silent --sort-index -O sort_buffer_size=16M */*.MYI
+$rv = $sth->rows;
@end example
-@cindex tables, information
-@node Table-info, Crash recovery, Maintenance regimen, Maintenance
-@section Getting Information About a Table
-
-To get a description of a table or statistics about it, use the commands shown
-below. We explain some of the information in more detail later:
-
-@table @code
-@item myisamchk -d tbl_name
-Runs @code{myisamchk} in ``describe mode'' to produce a description of
-your table. If you start the @strong{MySQL} server using the
-@code{--skip-locking} option, @code{myisamchk} may report an error for a
-table that is updated while it runs. However, because @code{myisamchk}
-doesn't change the table in describe mode, there isn't any risk of
-destroying data.
-
-@item myisamchk -d -v tbl_name
-To produce more information about what @code{myisamchk} is doing, add @code{-v}
-to tell it to run in verbose mode.
-
-@item myisamchk -eis tbl_name
-Shows only the most important information from a table. It is slow because it
-must read the whole table.
-
-@item myisamchk -eiv tbl_name
-This is like @code{-eis}, but tells you what is being done.
-@end table
-
-@cindex examples, @code{myisamchk} output
-@cindex @code{myisamchk}, example output
-Example of @code{myisamchk -d} output:
+@findex DBI->@{NULLABLE@}
+@findex NULLABLE DBI method
+@item NULLABLE
+Returns a reference to an array of boolean values; for each element of
+the array, a value of TRUE indicates that this
+column may contain @code{NULL} values.
+Example:
@example
-MyISAM file: company.MYI
-Record format: Fixed length
-Data records: 1403698 Deleted blocks: 0
-Recordlength: 226
-
-table description:
-Key Start Len Index Type
-1 2 8 unique double
-2 15 10 multip. text packed stripped
-3 219 8 multip. double
-4 63 10 multip. text packed stripped
-5 167 2 multip. unsigned short
-6 177 4 multip. unsigned long
-7 155 4 multip. text
-8 138 4 multip. unsigned long
-9 177 4 multip. unsigned long
- 193 1 text
+$null_possible = $sth->@{NULLABLE@};
@end example
-Example of @code{myisamchk -d -v} output:
+@findex DBI->@{NUM_OF_FIELDS@}
+@findex NUM_OF_FIELDS DBI method
+@item NUM_OF_FIELDS
+This attribute indicates
+the number of fields returned by a @code{SELECT} or @code{SHOW FIELDS}
+statement. You may use this for checking whether a statement returned a
+result: A zero value indicates a non-@code{SELECT} statement like
+@code{INSERT}, @code{DELETE}, or @code{UPDATE}.
+Example:
@example
-MyISAM file: company
-Record format: Fixed length
-File-version: 1
-Creation time: 1999-10-30 12:12:51
-Recover time: 1999-10-31 19:13:01
-Status: checked
-Data records: 1403698 Deleted blocks: 0
-Datafile parts: 1403698 Deleted data: 0
-Datafilepointer (bytes): 3 Keyfile pointer (bytes): 3
-Max datafile length: 3791650815 Max keyfile length: 4294967294
-Recordlength: 226
-
-table description:
-Key Start Len Index Type Rec/key Root Blocksize
-1 2 8 unique double 1 15845376 1024
-2 15 10 multip. text packed stripped 2 25062400 1024
-3 219 8 multip. double 73 40907776 1024
-4 63 10 multip. text packed stripped 5 48097280 1024
-5 167 2 multip. unsigned short 4840 55200768 1024
-6 177 4 multip. unsigned long 1346 65145856 1024
-7 155 4 multip. text 4995 75090944 1024
-8 138 4 multip. unsigned long 87 85036032 1024
-9 177 4 multip. unsigned long 178 96481280 1024
- 193 1 text
+$nr_of_fields = $sth->@{NUM_OF_FIELDS@};
@end example
-Example of @code{myisamchk -eis} output:
+@findex DBI->data_sources()
+@findex data_sources() DBI method
+@item data_sources($driver_name)
+This method returns an array containing names of databases available to the
+MySQL server on the host @code{'localhost'}.
+Example:
@example
-Checking MyISAM file: company
-Key: 1: Keyblocks used: 97% Packed: 0% Max levels: 4
-Key: 2: Keyblocks used: 98% Packed: 50% Max levels: 4
-Key: 3: Keyblocks used: 97% Packed: 0% Max levels: 4
-Key: 4: Keyblocks used: 99% Packed: 60% Max levels: 3
-Key: 5: Keyblocks used: 99% Packed: 0% Max levels: 3
-Key: 6: Keyblocks used: 99% Packed: 0% Max levels: 3
-Key: 7: Keyblocks used: 99% Packed: 0% Max levels: 3
-Key: 8: Keyblocks used: 99% Packed: 0% Max levels: 3
-Key: 9: Keyblocks used: 98% Packed: 0% Max levels: 4
-Total: Keyblocks used: 98% Packed: 17%
-
-Records: 1403698 M.recordlength: 226 Packed: 0%
-Recordspace used: 100% Empty space: 0% Blocks/Record: 1.00
-Record blocks: 1403698 Delete blocks: 0
-Recorddata: 317235748 Deleted data: 0
-Lost space: 0 Linkdata: 0
-
-User time 1626.51, System time 232.36
-Maximum resident set size 0, Integral resident set size 0
-Non physical pagefaults 0, Physical pagefaults 627, Swaps 0
-Blocks in 0 out 0, Messages in 0 out 0, Signals 0
-Voluntary context switches 639, Involuntary context switches 28966
+@@dbs = DBI->data_sources("mysql");
@end example
-Example of @code{myisamchk -eiv} output:
+@findex DBI->@{ChopBlanks@}
+@findex ChopBlanks DBI method
+@item ChopBlanks
+This attribute determines whether the @code{fetchrow_*} methods will chop
+leading and trailing blanks from the returned values.
+Example:
@example
-Checking MyISAM file: company
-Data records: 1403698 Deleted blocks: 0
-- check file-size
-- check delete-chain
-block_size 1024:
-index 1:
-index 2:
-index 3:
-index 4:
-index 5:
-index 6:
-index 7:
-index 8:
-index 9:
-No recordlinks
-- check index reference
-- check data record references index: 1
-Key: 1: Keyblocks used: 97% Packed: 0% Max levels: 4
-- check data record references index: 2
-Key: 2: Keyblocks used: 98% Packed: 50% Max levels: 4
-- check data record references index: 3
-Key: 3: Keyblocks used: 97% Packed: 0% Max levels: 4
-- check data record references index: 4
-Key: 4: Keyblocks used: 99% Packed: 60% Max levels: 3
-- check data record references index: 5
-Key: 5: Keyblocks used: 99% Packed: 0% Max levels: 3
-- check data record references index: 6
-Key: 6: Keyblocks used: 99% Packed: 0% Max levels: 3
-- check data record references index: 7
-Key: 7: Keyblocks used: 99% Packed: 0% Max levels: 3
-- check data record references index: 8
-Key: 8: Keyblocks used: 99% Packed: 0% Max levels: 3
-- check data record references index: 9
-Key: 9: Keyblocks used: 98% Packed: 0% Max levels: 4
-Total: Keyblocks used: 9% Packed: 17%
-
-- check records and index references
-[LOTS OF ROW NUMBERS DELETED]
-
-Records: 1403698 M.recordlength: 226 Packed: 0%
-Recordspace used: 100% Empty space: 0% Blocks/Record: 1.00
-Record blocks: 1403698 Delete blocks: 0
-Recorddata: 317235748 Deleted data: 0
-Lost space: 0 Linkdata: 0
-
-User time 1639.63, System time 251.61
-Maximum resident set size 0, Integral resident set size 0
-Non physical pagefaults 0, Physical pagefaults 10580, Swaps 0
-Blocks in 4 out 0, Messages in 0 out 0, Signals 0
-Voluntary context switches 10604, Involuntary context switches 122798
+$sth->@{'ChopBlanks'@} =1;
@end example
-Here are the sizes of the data and index files for the table used in the
-preceding examples:
-
+@findex DBI->trace
+@findex trace DBI method
+@item trace($trace_level)
+@itemx trace($trace_level, $trace_filename)
+The @code{trace} method enables or disables tracing. When invoked as a
+@code{DBI} class method, it affects tracing for all handles. When invoked as
+a database or statement handle method, it affects tracing for the given
+handle (and any future children of the handle). Setting @code{$trace_level}
+to 2 provides detailed trace information. Setting @code{$trace_level} to 0
+disables tracing. Trace output goes to the standard error output by
+default. If @code{$trace_filename} is specified, the file is opened in
+append mode and output for @emph{all} traced handles is written to that
+file. Example:
@example
--rw-rw-r-- 1 monty tcx 317235748 Jan 12 17:30 company.MYD
--rw-rw-r-- 1 davida tcx 96482304 Jan 12 18:35 company.MYM
+DBI->trace(2); # trace everything
+DBI->trace(2,"/tmp/dbi.out"); # trace everything to
+ # /tmp/dbi.out
+$dth->trace(2); # trace this database handle
+$sth->trace(2); # trace this statement handle
@end example
-Explanations for the types of information @code{myisamchk} produces are
-given below. The ``keyfile'' is the index file. ``Record'' and ``row''
-are synonymous:
-
-@table @code
-@item ISAM file
-Name of the ISAM (index) file.
-
-@item Isam-version
-Version of ISAM format. Currently always 2.
-
-@item Creation time
-When the data file was created.
-
-@item Recover time
-When the index/data file was last reconstructed.
-
-@item Data records
-How many records are in the table.
-
-@item Deleted blocks
-How many deleted blocks still have reserved space.
-You can optimize your table to minimize this space.
-@xref{Optimization}.
-
-@item Datafile: Parts
-For dynamic record format, this indicates how many data blocks there are. For
-an optimized table without fragmented records, this is the same as @code{Data
-records}.
-
-@item Deleted data
-How many bytes of non-reclaimed deleted data there are.
-You can optimize your table to minimize this space.
-@xref{Optimization}.
-
-@item Datafile pointer
-The size of the data file pointer, in bytes. It is usually 2, 3, 4, or 5
-bytes. Most tables manage with 2 bytes, but this cannot be controlled
-from @strong{MySQL} yet. For fixed tables, this is a record address. For
-dynamic tables, this is a byte address.
-
-@item Keyfile pointer
-The size of the index file pointer, in bytes. It is usually 1, 2, or 3
-bytes. Most tables manage with 2 bytes, but this is calculated
-automatically by @strong{MySQL}. It is always a block address.
-
-@item Max datafile length
-How long the table's data file (@code{.MYD} file) can become, in bytes.
-
-@item Max keyfile length
-How long the table's key file (@code{.MYI} file) can become, in bytes.
-
-@item Recordlength
-How much space each record takes, in bytes.
-
-@item Record format
-The format used to store table rows.
-The examples shown above use @code{Fixed length}.
-Other possible values are @code{Compressed} and @code{Packed}.
-
-@item table description
-A list of all keys in the table. For each key, some low-level information
-is presented:
-
-@table @code
-@item Key
-This key's number.
-
-@item Start
-Where in the record this index part starts.
-
-@item Len
-How long this index part is. For packed numbers, this should always be
-the full length of the column. For strings, it may be shorter than the full
-length of the indexed column, because you can index a prefix of a string
-column.
-
-@item Index
-@code{unique} or @code{multip.} (multiple). Indicates whether or not one value
-can exist multiple times in this index.
-
-@item Type
-What data-type this index part has. This is an ISAM data-type
-with the options @code{packed}, @code{stripped} or @code{empty}.
-
-@item Root
-Address of the root index block.
-
-@item Blocksize
-The size of each index block. By default this is 1024, but the value may be
-changed at compile time.
-
-@item Rec/key
-This is a statistical value used by the optimizer. It tells how many
-records there are per value for this key. A unique key always has a
-value of 1. This may be updated after a table is loaded (or greatly
-changed) with @code{myisamchk -a}. If this is not updated at all, a default
-value of 30 is given.
-@end table
-
-@item
-In the first example above, the 9th key is a multi-part key with two parts.
-
-@item Keyblocks used
-What percentage of the keyblocks are used. Because the table used in the
-examples had just been reorganized with @code{myisamchk}, the values are very
-high (very near the theoretical maximum).
-
-@item Packed
-@strong{MySQL} tries to pack keys with a common suffix. This can only be used
-for @code{CHAR}/@code{VARCHAR}/@code{DECIMAL} keys. For long strings like
-names, this can significantly reduce the space used. In the third example
-above, the 4th key is 10 characters long and a 60% reduction in space is
-achieved.
-
-@item Max levels
-How deep the B-tree for this key is. Large tables with long keys get high
-values.
-
-@item Records
-How many rows are in the table.
-
-@item M.recordlength
-The average record length. For tables with fixed-length records, this is the
-exact record length.
-
-@item Packed
-@strong{MySQL} strips spaces from the end of strings. The @code{Packed}
-value indicates the percentage of savings achieved by doing this.
-
-@item Recordspace used
-What percentage of the data file is used.
-
-@item Empty space
-What percentage of the data file is unused.
-
-@item Blocks/Record
-Average number of blocks per record (that is, how many links a fragmented
-record is composed of). This is always 1 for fixed-format tables. This value
-should stay as close to 1.0 as possible. If it gets too big, you can
-reorganize the table with @code{myisamchk}.
-@xref{Optimization}.
-
-@item Recordblocks
-How many blocks (links) are used. For fixed format, this is the same as the number
-of records.
-
-@item Deleteblocks
-How many blocks (links) are deleted.
-
-@item Recorddata
-How many bytes in the data file are used.
-
-@item Deleted data
-How many bytes in the data file are deleted (unused).
-
-@item Lost space
-If a record is updated to a shorter length, some space is lost. This is
-the sum of all such losses, in bytes.
-
-@item Linkdata
-When the dynamic table format is used, record fragments are linked with
-pointers (4 to 7 bytes each). @code{Linkdata} is the sum of the amount of
-storage used by all such pointers.
-@end table
-
-If a table has been compressed with @code{myisampack}, @code{myisamchk
--d} prints additional information about each table column. See
-@ref{myisampack, , @code{myisampack}}, for an example of this
-information and a description of what it means.
-
-@cindex crash, recovery
-@cindex recovery, from crash
-@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
-some systems, like Linux), you can't reliably use @code{myisamchk} to
-check a table when @code{mysqld} is using the same table. If you
-can be sure that no one is accessing the tables through @code{mysqld}
-while you run @code{myisamchk}, you only have to do @code{mysqladmin
-flush-tables} before you start checking the tables. If you can't
-guarantee the above, then you must take down @code{mysqld} while you
-check the tables. If you run @code{myisamchk} while @code{mysqld} is updating
-the tables, you may get a warning that a table is corrupt even if it
-isn't.
-
-If you are not using @code{--skip-locking}, you can use @code{myisamchk}
-to check tables at any time. While you do this, all clients that try
-to update the table will wait until @code{myisamchk} is ready before
-continuing.
-
-If you use @code{myisamchk} to repair or optimize tables, you
-@strong{MUST} always ensure that the @code{mysqld} server is not using
-the table (this also applies if you are using @code{--skip-locking}).
-If you don't take down @code{mysqld} you should at least do a
-@code{mysqladmin flush-tables} before you run @code{myisamchk}.
-
-This chapter describes how to check for and deal with data corruption
-in @strong{MySQL} databases. If your tables get corrupted a lot you should
-try to find the reason for this! @xref{Crashing}.
-
-The @code{MyISAM} table section contains reason for why a table could be
-corrupted. @xref{MyISAM table problems}.
-
-When performing crash recovery, it is important to understand that each table
-@code{tbl_name} in a database corresponds to three files in the database
-directory:
-
-@multitable @columnfractions .2 .8
-@item @strong{File} @tab @strong{Purpose}
-@item @file{tbl_name.frm} @tab Table definition (form) file
-@item @file{tbl_name.MYD} @tab Data file
-@item @file{tbl_name.MYI} @tab Index file
-@end multitable
-
-Each of these three file types is subject to corruption in various ways, but
-problems occur most often in data files and index files.
-
-@code{myisamchk} works by creating a copy of the @file{.MYD} (data) file
-row by row. It ends the repair stage by removing the old @file{.MYD}
-file and renaming the new file to the original file name. If you use
-@code{--quick}, @code{myisamchk} does not create a temporary @file{.MYD}
-file, but instead assumes that the @file{.MYD} file is correct and only
-generates a new index file without touching the @file{.MYD} file. This
-is safe, because @code{myisamchk} automatically detects if the
-@file{.MYD} file is corrupt and aborts the repair in this case. You can
-also give two @code{--quick} options to @code{myisamchk}. In this case,
-@code{myisamchk} does not abort on some errors (like duplicate key) but
-instead tries to resolve them by modifying the @file{.MYD}
-file. Normally the use of two @code{--quick} options is useful only if
-you have too little free disk space to perform a normal repair. In this
-case you should at least make a backup before running @code{myisamchk}.
-
-@menu
-* Check:: How to check tables for errors
-* Repair:: How to repair tables
-* Optimization:: Table optimization
-@end menu
-
-@cindex checking, tables for errors
-@cindex tables, error checking
-@cindex errors, checking tables for
-@node Check, Repair, Crash recovery, Crash recovery
-@subsection How to Check Tables for Errors
-
-To check a MyISAM table, use the following commands:
-
-@table @code
-@item myisamchk tbl_name
-This finds 99.99% of all errors. What it can't find is corruption that
-involves @strong{ONLY} the data file (which is very unusual). If you want
-to check a table, you should normally run @code{myisamchk} without options or
-with either the @code{-s} or @code{--silent} option.
-
-@item myisamchk -m tbl_name
-This finds 99.999% of all errors. It checks first all index entries for errors and
-then it reads through all rows. It calculates a checksum for all keys in
-the rows and verifies that they checksum matches the checksum for the keys
-in the index tree.
-
-@item myisamchk -e tbl_name
-This does a complete and thorough check of all data (@code{-e} means
-``extended check''). It does a check-read of every key for each row to verify
-that they indeed point to the correct row. This may take a LONG time on a
-big table with many keys. @code{myisamchk} will normally stop after the first
-error it finds. If you want to obtain more information, you can add the
-@code{--verbose} (@code{-v}) option. This causes @code{myisamchk} to keep
-going, up through a maximum of 20 errors. In normal usage, a simple
-@code{myisamchk} (with no arguments other than the table name) is sufficient.
+@tindex @code{DBI_TRACE} environment variable
+@tindex environment variable, @code{DBI_TRACE}
+You can also enable @code{DBI} tracing by setting the @code{DBI_TRACE}
+environment variable. Setting it to a numeric value is equivalent to calling
+@code{DBI->(value)}. Setting it to a pathname is equivalent to calling
+@code{DBI->(2,value)}.
-@item myisamchk -e -i tbl_name
-Like the previous command, but the @code{-i} option tells @code{myisamchk} to
-print some informational statistics, too.
@end table
-@cindex tables, repairing
-@cindex repairing, tables
-@node Repair, Optimization, Check, Crash recovery
-@subsection How to Repair Tables
-
-In the following section we only talk about using @code{myisamchk} on
-@code{MyISAM} tables (extensions @code{.MYI} and @code{.MYD}). If you
-are using @code{ISAM} tables (extensions @code{.ISM} and @code{.ISD}),
-you should use @code{isamchk} instead.
-
-Starting with @strong{MySQL} Version 3.23.14, you can repair MyISAM
-tables with the @code{REPAIR TABLE} command. @xref{REPAIR TABLE}.
-
-The symptoms of a corrupted table include queries that abort unexpectedly
-and observable errors such as these:
-
-@itemize @bullet
-@item
-@file{tbl_name.frm} is locked against change
-@item
-Can't find file @file{tbl_name.MYI} (Errcode: ###)
-@item
-Unexpected end of file
-@item
-Record file is crashed
-@item
-Got error ### from table handler
-
-To get more information about the error you can run @code{perror ###}. Here
-is the most common errors that indicates a problem with the table:
-
-@example
-shell> perror 126 127 132 134 135 136 141 144 145
-126 = Index file is crashed / Wrong file format
-127 = Record-file is crashed
-132 = Old database file
-134 = Record was already deleted (or record file crashed)
-135 = No more room in record file
-136 = No more room in index file
-141 = Duplicate unique key or constraint on write or update
-144 = Table is crashed and last repair failed
-145 = Table was marked as crashed and should be repaired
-@end example
-
-Note that error 135, no more room in record file, is not an error that
-can be fixed by a simple repair. In this case you have to do:
-
-@example
-ALTER TABLE table MAX_ROWS=xxx AVG_ROW_LENGTH=yyy;
-@end example
-
-@end itemize
-
-In the other cases, you must repair your tables. @code{myisamchk}
-can usually detect and fix most things that go wrong.
-
-The repair process involves up to four stages, described below. Before you
-begin, you should @code{cd} to the database directory and check the
-permissions of the table files. Make sure they are readable by the Unix user
-that @code{mysqld} runs as (and to you, because you need to access the files
-you are checking). If it turns out you need to modify files, they must also
-be writable by you.
-
-If you are using @strong{MySQL} Version 3.23.16 and above, you can (and
-should) use the @code{CHECK} and @code{REPAIR} commands to check and repair
-@code{MyISAM} tables. @xref{CHECK TABLE}. @xref{REPAIR TABLE}.
-
-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
-if you want to use the extended features that @code{isamchk}/@code{myisamchk} provides.
-
-If you are going to repair a table from the command line, you must first
-take down the @code{mysqld} server. Note that when you do
-@code{mysqladmin shutdown} on a remote server, the @code{mysqld} server
-will still be alive for a while after @code{mysqladmin} returns, until
-all queries are stopped and all keys have been flushed to disk.
-
@noindent
-@strong{Stage 1: Checking your tables}
-
-Run @code{myisamchk *.MYI} or @code{myisamchk -e *.MYI} if you have
-more time. Use the @code{-s} (silent) option to suppress unnecessary
-information.
-
-If the @code{mysqld} server is done you should use the --update option to tell
-@code{myisamchk} to mark the table as 'checked'.
-
-You have to repair only those tables for which @code{myisamchk} announces an
-error. For such tables, proceed to Stage 2.
-
-If you get weird errors when checking (such as @code{out of
-memory} errors), or if @code{myisamchk} crashes, go to Stage 3.
-
-@noindent
-@strong{Stage 2: Easy safe repair}
-
-NOTE: If you want repairing to go much faster, you should add: @code{-O
-sort_buffer=# -O key_buffer=#} (where # is about 1/4 of the available
-memory) to all @code{isamchk/myisamchk} commands.
-
-First, try @code{myisamchk -r -q tbl_name} (@code{-r -q} means ``quick
-recovery mode''). This will attempt to repair the index file without
-touching the data file. If the data file contains everything that it
-should and the delete links point at the correct locations within the
-data file, this should work, and the table is fixed. Start repairing the
-next table. Otherwise, use the following procedure:
-
-@enumerate
-@item
-Make a backup of the data file before continuing.
-
-@item
-Use @code{myisamchk -r tbl_name} (@code{-r} means ``recovery mode''). This will
-remove incorrect records and deleted records from the data file and
-reconstruct the index file.
-
-@item
-If the preceding step fails, use @code{myisamchk --safe-recover tbl_name}.
-Safe recovery mode uses an old recovery method that handles a few cases that
-regular recovery mode doesn't (but is slower).
-@end enumerate
-
-If you get weird errors when repairing (such as @code{out of
-memory} errors), or if @code{myisamchk} crashes, go to Stage 3.
-
-@noindent
-@strong{Stage 3: Difficult repair}
-
-You should only reach this stage if the first 16K block in the index file is
-destroyed or contains incorrect information, or if the index file is
-missing. In this case, it's necessary to create a new index file. Do so as
-follows:
-
-@enumerate
-@item
-Move the data file to some safe place.
-
-@item
-Use the table description file to create new (empty) data and index files:
-
-@example
-shell> mysql db_name
-mysql> SET AUTOCOMMIT=1;
-mysql> TRUNCATE TABLE table_name;
-mysql> quit
-@end example
-
-If your SQL version doesn't have @code{TRUNCATE TABLE}, use @code{DELETE FROM
-table_name} instead.
-
-@item
-Copy the old data file back onto the newly created data file.
-(Don't just move the old file back onto the new file; you want to retain
-a copy in case something goes wrong.)
-@end enumerate
-
-Go back to Stage 2. @code{myisamchk -r -q} should work now. (This shouldn't
-be an endless loop.)
-
-@noindent
-@strong{Stage 4: Very difficult repair}
-
-You should reach this stage only if the description file has also
-crashed. That should never happen, because the description file isn't changed
-after the table is created:
-
-@enumerate
-@item
-Restore the description file from a backup and go back to Stage 3. You can
-also restore the index file and go back to Stage 2. In the latter case, you
-should start with @code{myisamchk -r}.
-
-@item
-If you don't have a backup but know exactly how the table was created, create
-a copy of the table in another database. Remove the new data file, then move
-the description and index files from the other database to your crashed
-database. This gives you new description and index files, but leaves
-the data file alone. Go back to Stage 2 and attempt to reconstruct
-the index file.
-@end enumerate
-
-@cindex tables, optimizing
-@cindex optimizing, tables
-@node Optimization, , Repair, Crash recovery
-@subsection Table Optimization
-
-To coalesce fragmented records and eliminate wasted space resulting from
-deleting or updating records, run @code{myisamchk} in recovery mode:
-
-@example
-shell> myisamchk -r tbl_name
-@end example
-
-You can optimize a table in the same way using the SQL @code{OPTIMIZE TABLE}
-statement. @code{OPTIMIZE TABLE} does a repair of the table, a key
-analyzes and also sorts the index tree to give faster key lookups.
-There is also no possibility of unwanted interaction between a utility
-and the server, because the server does all the work when you use
-@code{OPTIMIZE TABLE}. @xref{OPTIMIZE TABLE}.
+@strong{MySQL-specific Methods}
-@code{myisamchk} also has a number of other options you can use to improve
-the performance of a table:
+The methods shown below are MySQL-specific and not part of the
+@code{DBI} standard. Several of them are now deprecated:
+@code{is_blob}, @code{is_key}, @code{is_num}, @code{is_pri_key},
+@code{is_not_null}, @code{length}, @code{max_length}, and @code{table}.
+Where @code{DBI}-standard alternatives exist, they are noted below:
@table @code
-@item -S, --sort-index
-@item -R index_num, --sort-records=index_num
-@item -a, --analyze
-@end table
-
-For a full description of the option. @xref{myisamchk syntax}.
-
-@cindex files, log
-@cindex maintaining, log files
-@cindex log files, maintaining
-@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 don'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{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. 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.
-
-You can force @strong{MySQL} to start using new log files by using
-@code{mysqladmin flush-logs} or by using the SQL command @code{FLUSH LOGS}.
-If you are using @strong{MySQL} Version 3.21 you must use @code{mysqladmin refresh}.
-
-The above command does the following:
-
-@itemize @bullet
-@item
-If standard logging (@code{--log}) or slow query logging
-(@code{--log-slow-queries}) is used, closes and reopens the log file.
-(@file{mysql.log} and @file{`hostname`-slow.log} as default).
-@item
-If update logging (@code{--log-update}) is used, closes the update log and
-opens a new log file with a higher sequence number.
-@end itemize
-
-If you are using only an update log, you only have to flush the logs and then
-move away the old update log files to a backup.
-If you are using the normal logging, you can do something like:
-
-@example
-shell> cd mysql-data-directory
-shell> mv mysql.log mysql.old
-shell> mysqladmin flush-logs
-@end example
-
-and then take a backup and remove @file{mysql.old}.
-
-@cindex functions, new
-@cindex adding, new functions
-@cindex user-defined functions, adding
-@cindex UDFs, defined
-@cindex functions, user-defined
-@node Adding functions, Adding procedures, Maintenance, Top
-@chapter Adding New Functions to MySQL
-
-There are two ways to add new functions to @strong{MySQL}:
-
-@itemize @bullet
-@item You can add the function through the user-definable function (UDF)
-interface. User-definable functions are added and removed dynamically using
-the @code{CREATE FUNCTION} and @code{DROP FUNCTION} statements.
-@xref{CREATE FUNCTION, , @code{CREATE FUNCTION}}.
-
-@item You can add the function as a native (built in) @strong{MySQL} function.
-Native functions are compiled into the @code{mysqld} server and become
-available on a permanent basis.
-@end itemize
-
-Each method has advantages and disadvantages:
-
-@itemize @bullet
-@item
-If you write a user-definable function, you must install the object file
-in addition to the server itself. If you compile your function into the
-server, you don't need to do that.
-@item
-You can add UDFs to a binary @strong{MySQL} distribution. Native functions
-require you to modify a source distribution.
-@item
-If you upgrade your @strong{MySQL} distribution, you can continue to use your
-previously installed UDFs. For native functions, you must repeat your
-modifications each time you upgrade.
-@end itemize
-
-Whichever method you use to add new functions, they may be used just like
-native functions such as @code{ABS()} or @code{SOUNDEX()}.
-
-@menu
-* Adding UDF:: Adding a new user-definable function
-* Adding native function:: Adding a new native function
-@end menu
-
-@cindex adding, user-definable functions
-@cindex user-defined functions, adding
-@cindex functions, user-definable, adding
-@node Adding UDF, Adding native function, Adding functions, Adding functions
-@section Adding a New User-definable Function
-
-@menu
-* UDF calling sequences:: UDF calling sequences
-* UDF arguments:: Argument processing
-* UDF return values:: Return values and error handling
-* UDF compiling:: Compiling and installing user-definable functions
-@end menu
-
-For the UDF mechanism to work, functions must be written in C or C++ and your
-operating system must support dynamic loading. The @strong{MySQL} source
-distribution includes a file @file{sql/udf_example.cc} that defines 5 new
-functions. Consult this file to see how UDF calling conventions work.
-
-For @code{mysqld} to be able to use UDF functions, you should configure MySQL
-with @code{--with-mysqld-ldflags=-rdynamic} The reason is that to on
-many platforms (including Linux) you can load a dynamic library (with
-@code{dlopen()}) from a static linked program, which you would get if
-you are using @code{--with-mysqld-ldflags=-all-static} If you want to
-use an UDF that needs to access symbols from @code{mysqld} (like the
-@code{methaphone} example in @file{sql/udf_example.cc} that uses
-@code{default_charset_info}), you must link the program with
-@code{-rdynamic}. (see @code{man dlopen}).
-
-For each function that you want to use in SQL statements, you should define
-corresponding C (or C++) functions. In the discussion below, the name
-``xxx'' is used for an example function name. To distinquish between SQL and
-C/C++ usage, @code{XXX()} (uppercase) indicates a SQL function call, and
-@code{xxx()} (lowercase) indicates a C/C++ function call.
-
-The C/C++ functions that you write to implement the interface for
-@code{XXX()} are:
-
-@table @asis
-@item @code{xxx()} (required)
-The main function. This is where the function result is computed.
-The correspondence between the SQL type and return type of your C/C++
-function is shown below:
-
-@multitable @columnfractions .2 .8
-@item @strong{SQL type} @tab @strong{C/C++ type}
-@item @code{STRING} @tab @code{char *}
-@item @code{INTEGER} @tab @code{long long}
-@item @code{REAL} @tab @code{double}
-@end multitable
-
-@item @code{xxx_init()} (optional)
-The initialization function for @code{xxx()}. It can be used to:
-
-@itemize @bullet
-@item
-Check the number of arguments to @code{XXX()}.
-@item
-Check that the arguments are of a required type or, alternatively,
-tell @strong{MySQL} to coerce arguments to the types you want when
-the main function is called.
-@item
-Allocate any memory required by the main function.
-@item
-Specify the maximum length of the result.
-@item
-Specify (for @code{REAL} functions) the maximum number of decimals.
-@item
-Specify whether or not the result can be @code{NULL}.
-@end itemize
-
-@item @code{xxx_deinit()} (optional)
-The deinitialization function for @code{xxx()}. It should deallocate any
-memory allocated by the initialization function.
-@end table
-
-When a SQL statement invokes @code{XXX()}, @strong{MySQL} calls the
-initialization function @code{xxx_init()} to let it perform any required
-setup, such as argument checking or memory allocation. If @code{xxx_init()}
-returns an error, the SQL statement is aborted with an error message and the
-main and deinitialization functions are not called. Otherwise, the main
-function @code{xxx()} is called once for each row. After all rows have been
-processed, the deinitialization function @code{xxx_deinit()} is called so it
-can perform any required cleanup.
-
-All functions must be thread safe (not just the main function,
-but the initialization and deinitialization functions as well). This means
-that you are not allowed to allocate any global or static variables that
-change! If you need memory, you should allocate it in @code{xxx_init()}
-and free it in @code{xxx_deinit()}.
-
-@cindex calling sequences, UDF
-@node UDF calling sequences, UDF arguments, Adding UDF, Adding UDF
-@subsection UDF Calling Sequences
-
-The main function should be declared as shown below. Note that the return
-type and parameters differ, depending on whether you will declare the SQL
-function @code{XXX()} to return @code{STRING}, @code{INTEGER}, or @code{REAL}
-in the @code{CREATE FUNCTION} statement:
-
-@noindent
-For @code{STRING} functions:
-
+@findex DBI->@{insertid@}
+@findex insertid DBI method
+@tindex AUTO_INCREMENT, using with DBI
+@item insertid
+If you use the @code{AUTO_INCREMENT} feature of MySQL, the new
+auto-incremented values will be stored here.
+Example:
@example
-char *xxx(UDF_INIT *initid, UDF_ARGS *args,
- char *result, unsigned long *length,
- char *is_null, char *error);
+$new_id = $sth->@{insertid@};
@end example
-@noindent
-For @code{INTEGER} functions:
+As an alternative, you can use @code{$dbh->@{'mysql_insertid'@}}.
+@findex DBI->@{is_blob@}
+@findex is_blob DBI method
+@item is_blob
+Returns a reference to an array of boolean values; for each element of the
+array, a value of TRUE indicates that the
+respective column is a @code{BLOB}.
+Example:
@example
-long long xxx(UDF_INIT *initid, UDF_ARGS *args,
- char *is_null, char *error);
+$keys = $sth->@{is_blob@};
@end example
-@noindent
-For @code{REAL} functions:
-
+@findex DBI->@{is_key@}
+@findex is_key DBI method
+@item is_key
+Returns a reference to an array of boolean values; for each element of the
+array, a value of TRUE indicates that the
+respective column is a key.
+Example:
@example
-double xxx(UDF_INIT *initid, UDF_ARGS *args,
- char *is_null, char *error);
+$keys = $sth->@{is_key@};
@end example
-The initialization and deinitialization functions are declared like this:
-
+@findex DBI->@{is_num@}
+@findex is_num DBI method
+@item is_num
+Returns a reference to an array of boolean values; for each element of the
+array, a value of TRUE indicates that the
+respective column contains numeric values.
+Example:
@example
-my_bool xxx_init(UDF_INIT *initid, UDF_ARGS *args, char *message);
-
-void xxx_deinit(UDF_INIT *initid);
+$nums = $sth->@{is_num@};
@end example
-The @code{initid} parameter is passed to all three functions. It points to a
-@code{UDF_INIT} structure that is used to communicate information between
-functions. The @code{UDF_INIT} structure members are listed below. The
-initialization function should fill in any members that it wishes to change.
-(To use the default for a member, leave it unchanged.):
-
-@table @code
-@item my_bool maybe_null
-@code{xxx_init()} should set @code{maybe_null} to @code{1} if @code{xxx()}
-can return @code{NULL}. The default value is @code{1} if any of the
-arguments are declared @code{maybe_null}.
-
-@item unsigned int decimals
-Number of decimals. The default value is the maximum number of decimals in
-the arguments passed to the main function. (For example, if the function is
-passed @code{1.34}, @code{1.345}, and @code{1.3}, the default would be 3,
-because @code{1.345} has 3 decimals.
-
-@item unsigned int max_length
-The maximum length of the string result. The default value differs depending
-on the result type of the function. For string functions, the default is the
-length of the longest argument. For integer functions, the default is 21
-digits. For real functions, the default is 13 plus the number of decimals
-indicated by @code{initid->decimals}. (For numeric functions, the length
-includes any sign or decimal point characters.)
-
-@item char *ptr
-A pointer that the function can use for its own purposes. For example,
-functions can use @code{initid->ptr} to communicate allocated memory
-between functions. In @code{xxx_init()}, allocate the memory and assign it
-to this pointer:
-
+@findex DBI->@{is_pri_key@}
+@findex is_pri_key DBI method
+@item is_pri_key
+Returns a reference to an array of boolean values; for each element of the
+array, a value of TRUE indicates that the respective column is a primary key.
+Example:
@example
-initid->ptr = allocated_memory;
+$pri_keys = $sth->@{is_pri_key@};
@end example
-In @code{xxx()} and @code{xxx_deinit()}, refer to @code{initid->ptr} to use
-or deallocate the memory.
-@end table
-
-@cindex argument processing
-@cindex processing, arguments
-@node UDF arguments, UDF return values, UDF calling sequences, Adding UDF
-@subsection Argument Processing
-
-The @code{args} parameter points to a @code{UDF_ARGS} structure that thas the
-members listed below:
-
-@table @code
-@item unsigned int arg_count
-The number of arguments. Check this value in the initialization function
-if you want your function to be called with a particular number of arguments.
-For example:
-
+@findex DBI->@{is_not_null@}
+@findex is_not_null DBI method
+@item is_not_null
+Returns a reference to an array of boolean values; for each element of the
+array, a value of FALSE indicates that this column may contain @code{NULL}
+values.
+Example:
@example
-if (args->arg_count != 2)
-@{
- strcpy(message,"XXX() requires two arguments");
- return 1;
-@}
+$not_nulls = $sth->@{is_not_null@};
@end example
+@code{is_not_null} is deprecated; it is preferable to use the
+@code{NULLABLE} attribute (described above), because that is a DBI standard.
-@item enum Item_result *arg_type
-The types for each argument. The possible type values are
-@code{STRING_RESULT}, @code{INT_RESULT}, and @code{REAL_RESULT}.
-
-To make sure that arguments are of a given type and return an
-error if they are not, check the @code{arg_type} array in the initialization
-function. For example:
+@findex DBI->@{length@}
+@findex length DBI method
+@findex DBI->@{max_length@}
+@findex max_length DBI method
+@item length
+@itemx max_length
+Each of these methods returns a reference to an array of column sizes. The
+@code{length} array indicates the maximum possible sizes that each column may
+be (as declared in the table description). The @code{max_length} array
+indicates the maximum sizes actually present in the result table. Example:
@example
-if (args->arg_type[0] != STRING_RESULT ||
- args->arg_type[1] != INT_RESULT)
-@{
- strcpy(message,"XXX() requires a string and an integer");
- return 1;
-@}
+$lengths = $sth->@{length@};
+$max_lengths = $sth->@{max_length@};
@end example
-As an alternative to requiring your function's arguments to be of particular
-types, you can use the initialization function to set the @code{arg_type}
-elements to the types you want. This causes @strong{MySQL} to coerce
-arguments to those types for each call to @code{xxx()}. For example, to
-specify coercion of the first two arguments to string and integer, do this in
-@code{xxx_init()}:
-
+@findex DBI->@{NAME@}
+@findex NAME DBI method
+@item NAME
+Returns a reference to an array of column names.
+Example:
@example
-args->arg_type[0] = STRING_RESULT;
-args->arg_type[1] = INT_RESULT;
+$names = $sth->@{NAME@};
@end example
-@item char **args
-@code{args->args} communicates information to the initialization function
-about the general nature of the arguments your function was called with. For a
-constant argument @code{i}, @code{args->args[i]} points to the argument
-value. (See below for instructions on how to access the value properly.)
-For a non-constant argument, @code{args->args[i]} is @code{0}.
-A constant argument is an expression that uses only constants, such as
-@code{3} or @code{4*7-2} or @code{SIN(3.14)}. A non-constant argument is an
-expression that refers to values that may change from row to row, such as
-column names or functions that are called with non-constant arguments.
-
-For each invocation of the main function, @code{args->args} contains the
-actual arguments that are passed for the row currently being processed.
-
-Functions can refer to an argument @code{i} as follows:
-
-@itemize @bullet
-@item
-An argument of type @code{STRING_RESULT} is given as a string pointer plus a
-length, to allow handling of binary data or data of arbitrary length. The
-string contents are available as @code{args->args[i]} and the string length
-is @code{args->lengths[i]}. You should not assume that strings are
-null-terminated.
-
-@item
-For an argument of type @code{INT_RESULT}, you must cast
-@code{args->args[i]} to a @code{long long} value:
-
+@findex DBI->@{table@}
+@findex table DBI method
+@item table
+Returns a reference to an array of table names.
+Example:
@example
-long long int_val;
-int_val = *((long long*) args->args[i]);
+$tables = $sth->@{table@};
@end example
-@item
-For an argument of type @code{REAL_RESULT}, you must cast
-@code{args->args[i]} to a @code{double} value:
-
+@findex DBI->@{type@}
+@findex type DBI method
+@item type
+Returns a reference to an array of column types.
+Example:
@example
-double real_val;
-real_val = *((double*) args->args[i]);
+$types = $sth->@{type@};
@end example
-@end itemize
-@item unsigned long *lengths
-For the initialization function, the @code{lengths} array indicates the
-maximum string length for each argument. For each invocation of the main
-function, @code{lengths} contains the actual lengths of any string arguments
-that are passed for the row currently being processed. For arguments of
-types @code{INT_RESULT} or @code{REAL_RESULT}, @code{lengths} still contains
-the maximum length of the argument (as for the initialization function).
@end table
-@cindex UDFs, return values
-@cindex return values, UDFs
-@cindex errors, handling for UDFs
-@cindex handling, errors
-@node UDF return values, UDF compiling, UDF arguments, Adding UDF
-@subsection Return Values and Error Handling
-
-The initialization function should return @code{0} if no error occurred and
-@code{1} otherwise. If an error occurs, @code{xxx_init()} should store a
-null-terminated error message in the @code{message} parameter. The message
-will be returned to the client. The message buffer is
-@code{MYSQL_ERRMSG_SIZE} characters long, but you should try to keep the
-message to less than 80 characters so that it fits the width of a standard
-terminal screen.
-
-The return value of the main function @code{xxx()} is the function value, for
-@code{long long} and @code{double} functions. A string functions should
-return a pointer to the result and store the length of the string in the
-@code{length} arguments. @code{result} is a buffer at least 255 bytes long.
-Set these to the contents and length of the return value. For example:
-
-@example
-memcpy(result, "result string", 13);
-*length = 13;
-@end example
-
-If your string functions that needs to return a string longer than 255
-bytes, you must allocate the space for it with @code{malloc()} in your
-@code{xxx_init()} function or your @code{xxx()} function and free it in
-your @code{xxx_deinit()} function. You can store the allocated memory
-in the @code{ptr} slot in the @code{UDF_INIT} structure for reuse by
-future @code{xxx()} calls. @xref{UDF calling sequences}.
-
-To indicate a return value of @code{NULL} in the main function, set
-@code{is_null} to @code{1}:
-
-@example
-*is_null = 1;
-@end example
-
-To indicate an error return in the main function, set the @code{error}
-parameter to @code{1}:
-
-@example
-*error = 1;
-@end example
-
-If @code{xxx()} sets @code{*error} to @code{1} for any row, the function
-value is @code{NULL} for the current row and for any subsequent rows
-processed by the statement in which @code{XXX()} was invoked. (@code{xxx()}
-will not even be called for subsequent rows.) @strong{NOTE:} In
-@strong{MySQL} versions prior to 3.22.10, you should set both @code{*error}
-and @code{*is_null}:
-
-@example
-*error = 1;
-*is_null = 1;
-@end example
-
-@cindex compiling, user-defined functions
-@cindex UDFs, compiling
-@cindex installing, user-defined functions
-@node UDF compiling, , UDF return values, Adding UDF
-@subsection Compiling and Installing User-definable Functions
-
-Files implementing UDFs must be compiled and installed on the host where the
-server runs. This process is described below for the example UDF file
-@file{udf_example.cc} that is included in the @strong{MySQL} source
-distribution. This file contains the following functions:
-
-@itemize @bullet
-@item
-@code{metaphon()} returns a metaphon string of the string argument.
-This is something like a soundex string, but it's more tuned for English.
-@item
-@code{myfunc_double()} returns the sum of the ASCII values of the
-characters in its arguments, divided by the sum of the length of its arguments.
-@item
-@code{myfunc_int()} returns the sum of the length of its arguments.
-@item
-@code{sequence([const int])} returns an sequence starting from the given
-number or 1 if no number has been given.
-@item
-@code{lookup()} returns the IP number for a hostname.
-@item
-@code{reverse_lookup()} returns the hostname for an IP number.
-The function may be called with a string @code{"xxx.xxx.xxx.xxx"} or
-four numbers.
-@end itemize
-
-A dynamically loadable file should be compiled as a sharable object file,
-using a command something like this:
-@example
-shell> gcc -shared -o udf_example.so myfunc.cc
-@end example
-
-You can easily find out the correct compiler options for your system by
-running this command in the @file{sql} directory of your @strong{MySQL}
-source tree:
-
-@example
-shell> make udf_example.o
-@end example
-
-You should run a compile command similar to the one that @code{make} displays,
-except that you should remove the @code{-c} option near the end of the line
-and add @code{-o udf_example.so} to the end of the line. (On some systems,
-you may need to leave the @code{-c} on the command.)
-
-Once you compile a shared object containing UDFs, you must install it
-and tell @strong{MySQL} about it. Compiling a shared object from
-@file{udf_example.cc} produces a file named something like
-@file{udf_example.so} (the exact name may vary from platform to platform).
-Copy this file to some directory searched by @code{ld}, such as
-@file{/usr/lib}. On many systems, you can set the @code{LD_LIBRARY} or
-@code{LD_LIBRARY_PATH} environment variable to point at the directory where
-you have your UDF function files. The @code{dlopen} manual page tells you
-which variable you should use on your system. You should set this in
-@code{mysql.server} or @code{safe_mysqld} and restart @code{mysqld}.
-
-After the library is installed, notify @code{mysqld} about the new
-functions with these commands:
-
-@example
-mysql> CREATE FUNCTION metaphon RETURNS STRING SONAME "udf_example.so";
-mysql> CREATE FUNCTION myfunc_double RETURNS REAL SONAME "udf_example.so";
-mysql> CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "udf_example.so";
-mysql> CREATE FUNCTION lookup RETURNS STRING SONAME "udf_example.so";
-mysql> CREATE FUNCTION reverse_lookup RETURNS STRING SONAME "udf_example.so";
-@end example
-
-Functions can be deleted using @code{DROP FUNCTION}:
-
-@example
-mysql> DROP FUNCTION metaphon;
-mysql> DROP FUNCTION myfunc_double;
-mysql> DROP FUNCTION myfunc_int;
-mysql> DROP FUNCTION lookup;
-mysql> DROP FUNCTION reverse_lookup;
-@end example
-
-The @code{CREATE FUNCTION} and @code{DROP FUNCTION} statements update the
-system table @code{func} in the @code{mysql} database. The function's name,
-type and shared library name are saved in the table. You must have the
-@strong{insert} and @strong{delete} privileges for the @code{mysql} database
-to create and drop functions.
-
-You should not use @code{CREATE FUNCTION} to add a function that has already
-been created. If you need to reinstall a function, you should remove it with
-@code{DROP FUNCTION} and then reinstall it with @code{CREATE FUNCTION}. You
-would need to do this, for example, if you recompile a new version of your
-function, so that @code{mysqld} gets the new version. Otherwise the server
-will continue to use the old version.
-
-Active functions are reloaded each time the server starts, unless you start
-@code{mysqld} with the @code{--skip-grant-tables} option. In this case, UDF
-initialization is skipped and UDFs are unavailable. (An active function is
-one that has been loaded with @code{CREATE FUNCTION} and not removed with
-@code{DROP FUNCTION}.)
-
-@cindex adding, native functions
-@cindex native functions, adding
-@cindex functions, native, adding
-@node Adding native function, , Adding UDF, Adding functions
-@section Adding a New Native Function
-
-The procedure for adding a new native function is described below. Note
-that you cannot add native functions to a binary distribution because
-the procedure involves modifying @strong{MySQL} source code. You must
-compile @strong{MySQL} yourself from a source distribution. Also note
-that if you migrate to another version of @strong{MySQL} (for example,
-when a new version is released), you will need to repeat the procedure
-with the new version.
-
-To add a new native @strong{MySQL} function, follow these steps:
-
-@enumerate
-@item
-Add one line to @file{lex.h} that defines the function name in the
-@code{sql_functions[]} array.
-@item
-If the function prototype is simple (just takes zero, one, two or three
-arguments), you should in lex.h specify SYM(FUNC_ARG#) (where # is the
-number of arguments) as the second argument in the
-@code{sql_functions[]} array and add a function that creates a function
-object in @file{item_create.cc}. Take a look at @code{"ABS"} and
-@code{create_funcs_abs()} for an example of this.
+@node DBI-info, , Perl DBI Class, Perl
+@subsection More @code{DBI}/@code{DBD} Information
-If the function prototype is complicated (for example takes a variable number
-of arguments), you should add two lines to @file{sql_yacc.yy}. One
-indicates the preprocessor symbol that @code{yacc} should define (this
-should be added at the beginning of the file). Then define the function
-parameters and add an ``item'' with these parameters to the
-@code{simple_expr} parsing rule. For an example, check all occurrences
-of @code{ATAN} in @file{sql_yacc.yy} to see how this is done.
-@item
-In @file{item_func.h}, declare a class inheriting from @code{Item_num_func} or
-@code{Item_str_func}, depending on whether your function returns a number or a
-string.
-@item
-In @file{item_func.cc}, add one of the following declarations, depending
-on whether you are defining a numeric or string function:
-@example
-double Item_func_newname::val()
-longlong Item_func_newname::val_int()
-String *Item_func_newname::Str(String *str)
-@end example
+@cindex @code{DBI/DBD}
-If you inherit your object from any of the standard items (like
-@code{Item_num_func} you probably only have to define one of the above
-functions and let the parent object take care of the other functions.
-For example, the @code{Item_str_func} class defines a @code{val()} function
-that executes @code{atof()} on the value returned by @code{::str()}.
+You can use the @code{perldoc} command to get more information about
+@code{DBI}.
-@item
-You should probably also define the following object function:
@example
-void Item_func_newname::fix_length_and_dec()
+perldoc DBI
+perldoc DBI::FAQ
+perldoc DBD::mysql
@end example
-This function should at least calculate @code{max_length} based on the
-given arguments. @code{max_length} is the maximum number of characters
-the function may return. This function should also set @code{maybe_null
-= 0} if the main function can't return a @code{NULL} value. The
-function can check if any of the function arguments can return
-@code{NULL} by checking the arguments @code{maybe_null} variable. You
-can take a look at @code{Item_func_mod::fix_length_and_dec} for a
-typical example of how to do this.
-@end enumerate
-
-All functions must be thread safe (In other words, don't use any global or
-static variables in the functions without protecting them with mutexes).
-
-If you want to return @code{NULL}, from @code{::val()}, @code{::val_int()}
-or @code{::str()} you should set @code{null_value} to 1 and return 0.
-
-For @code{::str()} object functions, there are some additional
-considerations to be aware of:
-
-@itemize @bullet
-@item
-The @code{String *str} argument provides a string buffer that may be
-used to hold the result. (For more information about the @code{String} type,
-take a look at the @file{sql_string.h} file.)
-@item
-The @code{::str()} function should return the string that holds the result or
-@code{(char*) 0} if the result is @code{NULL}.
-@item
-All current string functions try to avoid allocating any memory unless
-absolutely necessary!
-@end itemize
-
-@cindex procedures, adding
-@cindex adding, procedures
-@cindex new procedures, adding
-@node Adding procedures, ODBC, Adding functions, Top
-@chapter Adding New Procedures to MySQL
-
-In @strong{MySQL}, you can define a procedure in C++ that can access and
-modify the data in a query before it is sent to the client. The modification
-can be done on row-by-row or @code{GROUP BY} level.
-
-We have created an example procedure in @strong{MySQL} Version 3.23 to
-show you what can be done.
-
-Additionally we recommend you to take a look at 'mylua', which you can find in the Contrib directory. @xref{Contrib}. Which this you can use the LUA
-language to load a procedure at runtime into @code{mysqld}.
-
-@menu
-* procedure analyse:: Procedure analyse
-* Writing a procedure:: Writing a procedure.
-@end menu
-
-@node procedure analyse, Writing a procedure, Adding procedures, Adding procedures
-@section Procedure Analyse
-@code{analyse([max elements,[max memory]])}
-
-This procedure is defined in the @file{sql/sql_analyse.cc}. This
-examines the result from your query and returns an analysis of the
-results:
-
-@itemize @bullet
-@item
-@code{max elements} (default 256) is the maximum number of distinct values
-@code{analyse} will notice per column. This is used by @code{analyse} to check if
-the optimal column type should be of type @code{ENUM}.
-@item
-@code{max memory} (default 8192) is the maximum memory @code{analyse} should
-allocate per column while trying to find all distinct values.
-@end itemize
+You can also use the @code{pod2man}, @code{pod2html}, etc., tools to
+translate to other formats.
+You can find the latest @code{DBI} information at
+the @code{DBI} Web page:
@example
-SELECT ... FROM ... WHERE ... PROCEDURE ANALYSE([max elements,[max memory]])
+@uref{http://www.symbolstone.org/technology/perl/DBI/index.html}
@end example
-@node Writing a procedure, , procedure analyse, Adding procedures
-@section Writing a Procedure
-
-For the moment, the only documentation for this is the source.
-You can find all information about procedures by examining the following files:
-
-@itemize @bullet
-@item @file{sql/sql_analyse.cc}
-@item @file{sql/procedure.h}
-@item @file{sql/procedure.cc}
-@item @file{sql/sql_select.cc}
-@end itemize
+@node ODBC, C, Perl, Clients
+@section MySQL ODBC Support
@cindex ODBC
@cindex Windows
@cindex MyODBC
-@node ODBC, Common programs, Adding procedures, Top
-@chapter MySQL ODBC Support
@menu
* Installing MyODBC:: How to install MyODBC
* ODBC administrator:: How to fill in the various fields in the ODBC administrator program
-* MyODBC connect parameters::
-* ODBC Problems:: How to report problems with @strong{MySQL} ODBC
+* MyODBC connect parameters:: Connect parameters for MyODBC
+* ODBC Problems:: How to report problems with MySQL ODBC
* MyODBC clients:: Programs known to work with @strong{MyODBC}
* ODBC and last_insert_id:: How to get the value of an @code{AUTO_INCREMENT} column in ODBC
* MyODBC bug report:: Reporting problems with MyODBC
@end menu
-@strong{MySQL} provides support for ODBC by means of the @strong{MyODBC}
+
+MySQL provides support for ODBC by means of the @strong{MyODBC}
program. This chapter will teach you how to install @strong{MyODBC},
and how to use it. Here, you will also find a list of common programs that
are known to work with @strong{MyODBC}.
+
@node Installing MyODBC, ODBC administrator, ODBC, ODBC
-@section How To Install MyODBC
+@subsection How To Install MyODBC
@strong{MyODBC} is a 32-bit ODBC (2.50) level 0 (with level 1 and level
2 features) driver for connecting an ODBC-aware application to
-@strong{MySQL}. @strong{MyODBC} works on Windows95, Windows98, NT, and
+MySQL. @strong{MyODBC} works on Windows95, Windows98, NT, and
on most Unix platforms.
@strong{MyODBC} is in public domain, and you can find the newest version
@@ -36309,7 +38361,7 @@ to the databases.
If you want to install @strong{MyODBC} on a Unix box, you will also need
an @strong{ODBC} manager. @strong{MyODBC} is known to work with
most of the Unix ODBC managers. You can find a list at these in the
-@strong{ODBC}-related links section on the @strong{MySQL} useful links page.
+@strong{ODBC}-related links section on the MySQL useful links page.
@xref{Useful Links}.
To install @strong{MyODBC} on Windows, you should download the
@@ -36339,11 +38391,11 @@ mode.
@itemize @bullet
@item
To make a connection to a Unix box from a Windows box, with an ODBC
-application (one that doesn't support @strong{MySQL} natively), you must
+application (one that doesn't support MySQL natively), you must
first install @strong{MyODBC} on the Windows machine.
@item
The user and Windows machine must have the access privileges to the
-@strong{MySQL} server on the Unix machine. This is set up with the
+MySQL server on the Unix machine. This is set up with the
@code{GRANT} command. @xref{GRANT,,@code{GRANT}}.
@item
You must create an ODBC DSN entry as follows:
@@ -36358,10 +38410,10 @@ Click the tab User DSN.
@item
Click the button Add.
@item
-Select @strong{MySQL} in the screen Create New Data Source and click
+Select MySQL in the screen Create New Data Source and click
the Finish button.
@item
-The @strong{MySQL} Driver default configuration screen is shown.
+The MySQL Driver default configuration screen is shown.
@xref{ODBC administrator}.
@end itemize
@@ -36371,12 +38423,14 @@ specified in the ODBC administrator.
@end itemize
Notice that there are other configuration options on the screen of
-@strong{MySQL} (trace, don't prompt on connect, etc) that you can try if
+MySQL (trace, don't prompt on connect, etc) that you can try if
you run into problems.
-@cindex ODBC, administrator
+
@node ODBC administrator, MyODBC connect parameters, Installing MyODBC, ODBC
-@section How to Fill in the Various Fields in the ODBC Administrator Program
+@subsection How to Fill in the Various Fields in the ODBC Administrator Program
+
+@cindex ODBC, administrator
There are three possibilities for specifying the server name on
Windows95:
@@ -36429,8 +38483,9 @@ If you specify the option @code{Read options from C:\my.cnf}, the groups
You can use all options that are usable by @code{mysql_options()}.
@xref{mysql_options, , @code{mysql_options}}.
+
@node MyODBC connect parameters, ODBC Problems, ODBC administrator, ODBC
-@section Connect parameters for MyODBC
+@subsection Connect parameters for MyODBC
One can specify the following parameters for @strong{MyODBC} on
the @code{[Servername]} section of an @code{ODBC.INI} file or
@@ -36439,8 +38494,8 @@ through the @code{InConnectionString} argument in the
@multitable @columnfractions .2 .2 .6
@item @strong{Parameter} @tab @strong{Default value} @tab @strong{Comment}
-@item user @tab ODBC (on Windows) @tab The username used to connect to @strong{MySQL}.
-@item server @tab localhost @tab The hostname of the @strong{MySQL} server.
+@item user @tab ODBC (on Windows) @tab The username used to connect to MySQL.
+@item server @tab localhost @tab The hostname of the MySQL server.
@item database @tab @tab The default database
@item option @tab 0 @tab A integer by which you can specify how @strong{MyODBC} should work. See below.
@item port @tab 3306 @tab The TCP/IP port to use if @code{server} is not @code{localhost}.
@@ -36486,8 +38541,9 @@ you want to to debug @strong{MyODBC} (for example to enable tracing),
you should instead use @code{MYODBCD.DLL}. To install this file, copy
@file{MYODBCD.DLL} over the installed @code{MYODBC.DLL} file.
+
@node ODBC Problems, MyODBC clients, MyODBC connect parameters, ODBC
-@section How to Report Problems with MyODBC
+@subsection How to Report Problems with MyODBC
@strong{MyODBC} has been tested with Access, Admndemo.exe, C++-Builder,
Borland Builder 4, Centura Team Developer (formerly Gupta SQL/Windows),
@@ -36516,8 +38572,9 @@ single floats.
If the above doesn't help, you should do a @code{MyODBC} trace file and
try to figure out why things go wrong.
+
@node MyODBC clients, ODBC and last_insert_id, ODBC Problems, ODBC
-@section Programs Known to Work with MyODBC
+@subsection Programs Known to Work with MyODBC
Most programs should work with @strong{MyODBC}, but for each of those
listed below, we have tested it ourselves or received confirmation from
@@ -36533,19 +38590,25 @@ To make Access work:
@itemize @bullet
@item
If you are using Access 2000, you should get and install the newest
-Microsoft MDAC (@code{Microsoft Data Access Components}) from
-@uref{http://www.microsoft.com/data}. This will fix the following bug
-in Access: when you export data to @strong{MySQL}, the table and column
-names aren't specified. Another way to around this bug is to upgrade to
-MyODBC Version 2.50.33 and @strong{MySQL} Version 3.23.x, which together
-provide a workaround for this bug!
-
-Note that if you are using @strong{MySQL} Version 3.22, you must to apply the
+(version 2.6 or above) Microsoft MDAC (@code{Microsoft Data Access
+Components}) from @uref{http://www.microsoft.com/data}. This will fix
+the following bug in Access: when you export data to MySQL, the
+table and column names aren't specified. Another way to around this bug
+is to upgrade to MyODBC Version 2.50.33 and MySQL Version
+3.23.x, which together provide a workaround for this bug!
+
+You should also get and apply the Microsoft Jet 4.0 Service Pack 5 (SP5)
+which can be found here
+@uref{http://support.microsoft.com/support/kb/articles/Q 239/1/14.ASP}.
+This will fix some cases where columns are marked as @code{#deleted#}
+in Access.
+
+Note that if you are using MySQL Version 3.22, you must to apply the
MDAC patch and use MyODBC 2.50.32 or 2.50.34 and above to go around
this problem.
@item
Set the ``Return matching rows'' MyODBC option field when connecting to
-@strong{MySQL}.
+MySQL.
@item
You should have a primary key in the table. If not, new or updated rows
may show up as @code{#Deleted#}.
@@ -36575,7 +38638,7 @@ Access can't always handle @code{DATE} columns properly. If you have a problem
with these, change the columns to @code{DATETIME}.
@item
In some cases, Access may generate illegal SQL queries that
-@strong{MySQL} can't understand. You can fix this by selecting
+MySQL can't understand. You can fix this by selecting
@code{"Query|SQLSpecific|Pass-Through"} from the Access menu.
@item
If you have in Access a column defined as BYTE, Access will try to export this
@@ -36593,7 +38656,7 @@ matching rows} and @code{Simulate ODBC 1.0}.
@item ADO
When you are coding with the ADO API and @strong{MyODBC} you need to put
attention in some default properties that aren't supported by the
-@strong{MySQL} server. For example, using the @code{CursorLocation
+MySQL server. For example, using the @code{CursorLocation
Property} as @code{adUseServer} will return for the @code{RecordCount
Property} a result of -1. To have the right value, you need to set this
property to @code{adUseClient}, like is showing in the VB code below:
@@ -36626,7 +38689,7 @@ You should use the option flag @code{Return matching rows}.
To get these to work, you should set the option flags
@code{Don't optimize column widths} and @code{Return matching rows}.
-@cindex Borland Buidler 4 program
+@cindex Borland Builder 4 program
@item Borland Builder 4
When you start a query you can use the property @code{Active} or use the
method @code{Open}. Note that @code{Active} will start by automatically
@@ -36636,16 +38699,16 @@ your tables are big!
The following information is taken from the ColdFusion documentation:
Use the following information to configure ColdFusion Server for Linux
-to use the unixODBC driver with @strong{MyODBC} for @strong{MySQL} data
+to use the unixODBC driver with @strong{MyODBC} for MySQL data
sources. Allaire has verified that @strong{MyODBC} Version 2.50.26
-works with @strong{MySQL} Version 3.22.27 and ColdFusion for Linux. (Any
+works with MySQL Version 3.22.27 and ColdFusion for Linux. (Any
newer version should also work.) You can download @strong{MyODBC} at
@uref{http://www.mysql.com/downloads/api-myodbc.html}
@cindex ColdFusion program
ColdFusion Version 4.5.1 allows you to us the ColdFusion Administrator
-to add the @strong{MySQL} data source. However, the driver is not
-included with ColdFusion Version 4.5.1. Before the @strong{MySQL} driver
+to add the MySQL data source. However, the driver is not
+included with ColdFusion Version 4.5.1. Before the MySQL driver
will appear in the ODBC datasources drop-down list, you must build and
copy the @strong{MyODBC} driver to
@file{/opt/coldfusion/lib/libmyodbc.so}.
@@ -36657,7 +38720,7 @@ on Coldfusion applications.
@cindex DataJunction
@item DataJunction
You have to change it to output @code{VARCHAR} rather than @code{ENUM}, as
-it exports the latter in a manner that causes @strong{MySQL} grief.
+it exports the latter in a manner that causes MySQL grief.
@cindex Excel
@item Excel
Works. Some tips:
@@ -36684,7 +38747,7 @@ exact types for each column.
@cindex Word program
@item Word
-To retrieve data from @strong{MySQL} to Word/Excel documents, you need to
+To retrieve data from MySQL to Word/Excel documents, you need to
use the @code{MyODBC} driver and the Add-in Microsoft Query help.
For example, create a db with a table containing 2 columns of text:
@@ -36730,7 +38793,7 @@ Test program for ODBC.
@cindex Delphi program
@item Delphi
You must use BDE Version 3.2 or newer. Set the `Don't optimize column width'
-option field when connecting to @strong{MySQL}.
+option field when connecting to MySQL.
Also, here is some potentially useful Delphi code that sets up both an
ODBC entry and a BDE entry for @strong{MyODBC} (the BDE entry requires a BDE
@@ -36774,8 +38837,8 @@ fReg:= TRegistry.Create;
AliasEditor.Add('DocumentsFab','MySQL',Memo1.Lines);
@end example
-@cindex C++Builder
-@item C++Builder
+@cindex C++ Builder
+@item C++ Builder
Tested with BDE Version 3.0. The only known problem is that when the table
schema changes, query fields are not updated. BDE, however, does not seem
to recognize primary keys, only the index PRIMARY, though this has not
@@ -36804,9 +38867,11 @@ columns to INT} option in the MyODBC connect screen.
You should use the option flag @code{Don't optimize column widths}.
@end table
-@cindex AUTO-INCREMENT, ODBC
+
@node ODBC and last_insert_id, MyODBC bug report, MyODBC clients, ODBC
-@section How to Get the Value of an @code{AUTO_INCREMENT} Column in ODBC
+@subsection How to Get the Value of an @code{AUTO_INCREMENT} Column in ODBC
+
+@cindex AUTO-INCREMENT, ODBC
A common problem is how to get the value of an automatically generated ID
from an @code{INSERT}. With ODBC, you can do something like this (assuming
@@ -36832,11 +38897,13 @@ the following query can be used to find a newly inserted row:
SELECT * FROM tbl_name WHERE auto IS NULL;
@end example
+
+@node MyODBC bug report, , ODBC and last_insert_id, ODBC
+@subsection Reporting Problems with MyODBC
+
@cindex reporting, MyODBC problems
@cindex problems, ODBC
@cindex MyODBC, reporting problems
-@node MyODBC bug report, , ODBC and last_insert_id, ODBC
-@section Reporting Problems with MyODBC
If you encounter difficulties with @strong{MyODBC}, you should start by
making a log file from the ODBC manager (the log you get when requesting
@@ -36869,7 +38936,7 @@ You should be able to find out the issued queries by searching after
the string @code{>mysql_real_query} in the @file{myodbc.log} file.
You should also try duplicating the queries in the @code{mysql} monitor
-or @code{admndemo} to find out if the error is MyODBC or @strong{MySQL}.
+or @code{admndemo} to find out if the error is MyODBC or MySQL.
If you find out something is wrong, please only send the relevant rows
(max 40 rows) to @email{myodbc@@lists.mysql.com}. Please never
@@ -36879,7 +38946,7 @@ If you are unable to find out what's wrong, the last option is to
make an archive (tar or zip) that contains a MyODBC trace file, the ODBC
log file, and a README file that explains the problem. You can send this
to @uref{ftp://support.mysql.com/pub/mysql/secret}. Only we at
-@strong{MySQL AB} will have access to the files you upload, and we will
+MySQL AB will have access to the files you upload, and we will
be very discrete with the data!
If you can create a program that also shows this problem, please
@@ -36891,2331 +38958,35 @@ file where you do exactly the same thing in the other SQL server.
Remember that the more information you can supply to us, the more
likely it is that we can fix the problem!
-@node Common programs, Problems, ODBC, Top
-@chapter Using MySQL with Some Common Programs
-
-@menu
-* Apache:: Using @strong{MySQL} with Apache
-* Borland C++::
-@end menu
-
-This chapter describes how to use @strong{MySQL} with some common programs.
-
-In this chapter you will:
-
-@itemize @bullet
-@item
-Learn how to easily store your Apache log files in a @strong{MySQL}
-database.
-@item
-Find some tips on how to compile @strong{MySQL} and @strong{MySQL}-based
-programs using Borland C++.
-@end itemize
-
-@cindex Apache
-@node Apache, Borland C++, Common programs, Common programs
-@section Using MySQL with Apache
-
-The Contrib section includes programs that let you authenticate your
-users from a @strong{MySQL} database and also let you log your log files
-into a @strong{MySQL} table. @xref{Contrib}.
-
-You can change the Apache logging format to be easily readable by
-@strong{MySQL} by putting the following into the Apache configuration file:
-
-@example
-LogFormat \
- "\"%h\",%@{%Y%m%d%H%M%S@}t,%>s,\"%b\",\"%@{Content-Type@}o\", \
- \"%U\",\"%@{Referer@}i\",\"%@{User-Agent@}i\""
-@end example
-
-In @strong{MySQL} you can do something like this:
-
-@example
-LOAD DATA INFILE '/local/access_log' INTO TABLE table_name
-FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\'
-@end example
-
-@cindex Borland C++ compiler
-@node Borland C++, , Apache, Common programs
-@section Borland C++
-
-You can compile the @strong{MySQL} Windows source with Borland C++ 5.02.
-(The Windows source includes only projects for Microsoft VC++, for
-Borland C++ you have to do the project files yourself).
-
-One known problem with Borland C++ is that it uses a different structure
-alignment than VC++. This means that you will run into problems if you
-try to use the default @code{libmysql.dll} libraries (that was compiled
-with VC++) with Borland C++. You can do one of the following to avoid
-this problem.
-
-@itemize @bullet
-@item
-You can use the static @strong{MySQL} libraries for Borland C++ that you
-can find on @uref{http://www.mysql.com/downloads/os-win32.html}.
-@item
-Only call @code{mysql_init()} with @code{NULL} as an argument, not a
-pre-allocated MYSQL struct.
-@end itemize
-
-@cindex problems, common errors
-@cindex errors, common
-@node Problems, Common problems, Common programs, Top
-@chapter Problems and Common Errors
-
-@menu
-* What is crashing:: How to determine what is causing problems
-* Crashing:: What to do if @strong{MySQL} keeps crashing
-* Link errors:: Problems when linking with the @strong{MySQL} client library
-* Common errors:: Some common errors when using @strong{MySQL}
-* Full disk:: How @strong{MySQL} handles a full disk
-* Multiple sql commands:: How to run SQL commands from a text file
-* Temporary files:: Where @strong{MySQL} stores temporary files
-* Problems with mysql.sock:: How to protect @file{/tmp/mysql.sock}
-* Changing MySQL user:: How to run @strong{MySQL} as a normal user
-* Resetting permissions:: How to reset a forgotten password.
-* File permissions :: Problems with file permissions
-* Not enough file handles:: File not found
-* Using DATE:: Problems using @code{DATE} columns
-* Timezone problems:: Timezone problems
-* Case sensitivity:: Case sensitivity in searches
-* Problems with NULL:: Problems with @code{NULL} values
-* Problems with alias:: Problems with @code{alias}
-* Deleting from related tables:: Deleting rows from related tables
-* No matching rows:: Solving problems with no matching rows
-* ALTER TABLE problems:: Problems with @code{ALTER TABLE}.
-* Change column order:: How to change the order of columns in a table
-* Temporary table problems::
-@end menu
-
-This chapter lists some common problems and error messages that users have
-run into. You will learn how to figure out what the problem is, and what
-to do to solve it. You will also find proper solutions to some common
-problems.
-
-@node What is crashing, Crashing, Problems, Problems
-@section How to Determine What Is Causing Problems
-
-When you run into problems, the first thing you should do is to find out
-which program / piece of equipment is causing problems:
-
-@itemize @bullet
-@item
-If you have one of the following symptoms, then it is probably a hardware
-(like memory, motherboard, CPU, or hard disk) or kernel problem:
-@itemize @minus
-@item
-The keyboard doesn't work. This can normally be checked by pressing
-Caps Lock. If the Caps Lock light doesn't change you have to replace
-your keyboard. (Before doing this, you should try to reboot
-your computer and check all cables to the keyboard.)
-@item
-The mouse pointer doesn't move.
-@item
-The machine doesn't answer to a remote machine's pings.
-@item
-Different, unrelated programs don't behave correctly.
-@item
-If your system rebooted unexpectedly (a faulty user level program should
-NEVER be able to take down your system).
-@end itemize
-
-In this case you should start by checking all your cables and run some
-diagnostic tool to check your hardware!
-You should also check if there are any patches, updates, or service
-packs for your operating system that could likely solve your problems.
-Check also that all your libraries (like glibc) are up to date.
-
-It's always good to use a machine with ECC memory to discover
-memory problems early!
-@item
-If your keyboard is locked up, you may be able to fix this by
-logging into your machine from another machine and execute
-@code{kbd_mode -a} on it.
-
-@item
-Please examine your system log file (/var/log/messages or similar) for
-reasons for your problems. If you think the problem is in @strong{MySQL}
-then you should also examine @strong{MySQL}'s log files. @xref{Update log}.
-
-@item
-If you don't think you have hardware problems, you should try to find
-out which program is causing problems.
-
-Try using @code{top}, @code{ps}, @code{taskmanager}, or some similar program,
-to check which program is taking all CPU or is locking the machine.
-
-@item
-Check with @code{top}, @code{df}, or a similar program if you are out of
-memory, disk space, open files, or some other critical resource.
-
-@item
-If the problem is some runaway process, you can always try to kill it. If it
-doesn't want to die, there is probably a bug in the operating system.
-@end itemize
-
-If after you have examined all other possibilities and you have
-concluded that it's the @strong{MySQL} server or a @strong{MySQL} client
-that is causing the problem, it's time to do a bug report for our
-mailing list or our support team. In the bug report, try to give a
-very detailed description of how the system is behaving and what you think is
-happening. You should also state why you think it's @strong{MySQL} that
-is causing the problems. Take into consideration all the situations in
-this chapter. State any problems exactly how they appear when you
-examine your system. Use the 'cut and paste' method for any output
-and/or error messages from programs and/or log files!
-
-Try to describe in detail which program is not working and all
-symptoms you see! We have in the past received many bug reports that just
-state "the system doesn't work". This doesn't provide us with any
-information about what could be the problem.
-
-If a program fails, it's always useful to know:
-
-@itemize @bullet
-@item
-Has the program in question made a segmentation fault (core dumped)?
-@item
-Is the program taking the whole CPU? Check with @code{top}. Let the
-program run for a while, it may be evaluating something heavy.
-@item
-If it's the @code{mysqld} server that is causing problems, can you
-do @code{mysqladmin -u root ping} or @code{mysqladmin -u root processlist}?
-@item
-What does a client program say (try with @code{mysql}, for example)
-when you try to connect to the @strong{MySQL} server?
-Does the client jam? Do you get any output from the program?
-@end itemize
-
-When sending a bug report, you should of follow the outlines
-described in this manual. @xref{Asking questions}.
-
-@cindex crash, repeated
-@node Crashing, Link errors, What is crashing, Problems
-@section What to Do if MySQL Keeps Crashing
-
-All @strong{MySQL} versions are tested on many platforms before they are
-released. This doesn't mean that there aren't any bugs in
-@strong{MySQL}, but it means if there are bugs, they are very few and can be
-hard to find. If you have a problem, it will always help if you try to
-find out exactly what crashes your system, as you will have a much better
-chance of getting this fixed quickly.
-
-First, you should try to find out whether the problem is that the
-@code{mysqld} daemon dies or whether your problem has to do with your
-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}. @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
-@code{write()} system call, after every SQL statement and before the
-client is notified about the result. (This is not true if you are running
-with @code{delayed_key_writes}, in which case only the data is written.)
-This means that the data is safe even if @code{mysqld} crashes, as the OS will
-ensure that the not flushed data is written to disk. You can force
-@strong{MySQL} to sync everything to disk after every SQL command by
-starting @code{mysqld} with @code{--flush}.
-
-The above means that normally you shouldn't get corrupted tables unless:
-
-@itemize @bullet
-@item
-Someone/something killed @code{mysqld} or the machine in the middle
-of an update.
-@item
-You have found a bug in @code{mysqld} that caused it to die in the
-middle of an update.
-@item
-Someone is manipulating the data/index files outside of @strong{mysqld}
-without locking the table properly.
-@item
-If you are running many @code{mysqld} servers on the same data on a
-system that doesn't support good file system locks (normally handled by
-the @code{lockd} daemon ) or if you are running
-multiple servers with @code{--skip-locking}
-@item
-You have a crashed index/data file that contains very wrong data that
-got @code{mysqld} confused.
-@item
-You have found a bug in the data storage code. This isn't that likely,
-but it's at least possible. In this case you can try to change the file
-type to another database handler by using @code{ALTER TABLE} on a
-repaired copy of the table!
-@end itemize
-
-Because it is very difficult to know why something is crashing, first try to
-check whether or not things that work for others crash for you. Please try
-the following things:
-
-@itemize @bullet
-@item
-Take down the @code{mysqld} daemon with @code{mysqladmin shutdown}, run
-@code{myisamchk --silent --force */*.MYI} on all tables, and restart the
-@code{mysqld} daemon. This will ensure that you are running from a clean
-state. @xref{Maintenance}.
-
-@item
-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. @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
-Try to make a test case that we can use to reproduce the problem.
-@xref{Reproduceable test case}.
-
-@item
-Try running the included mysql-test test and the @strong{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
-If you configure @strong{MySQL} for debugging, it will be much easier to
-gather information about possible errors if something goes wrong.
-Reconfigure @strong{MySQL} with the @code{--with-debug} option or
-@code{--with-debug=full} to @code{configure} and then recompile.
-@xref{Debugging server}.
-
-@item
-Configuring @strong{MySQL} for debugging causes a safe memory allocator to be
-included that can find some errors. It also provides a lot of output about
-what is happening.
-
-@item
-Have you applied the latest patches for your operating system?
-
-@item
-Use the @code{--skip-locking} option to @code{mysqld}. On some systems, the
-@code{lockd} lock manager does not work properly; the @code{--skip-locking}
-option tells @code{mysqld} not to use external locking. (This means that you
-cannot run 2 @code{mysqld} servers on the same data and that you must be
-careful if you use @code{myisamchk}, but it may be instructive to try the
-option as a test.)
-
-@item
-Have you tried @code{mysqladmin -u root processlist} when @code{mysqld}
-appears to be running but not responding? Sometimes @code{mysqld} is not
-comatose even though you might think so. The problem may be that all
-connections are in use, or there may be some internal lock problem.
-@code{mysqladmin processlist} will usually be able to make a connection even
-in these cases, and can provide useful information about the current number
-of connections and their status.
-
-@item
-Run the command @code{mysqladmin -i 5 status} or @code{mysqladmin -i 5
--r status} or in a separate window to produce statistics while you run
-your other queries.
-
-@item
-Try the following:
-@enumerate
-@item
-Start @code{mysqld} from @code{gdb} (or in another debugger).
-@xref{Using gdb on mysqld}.
-
-@item
-Run your test scripts.
-
-@item
-Print the backtrace and the local variables at the 3 lowest levels. In gdb you
-can do this with the following commands when @code{mysqld} has crashed inside
-gdb:
-
-@example
-backtrace
-info local
-up
-info local
-up
-info local
-@end example
-
-With gdb you can also examine which threads exist with @code{info
-threads} and switch to a specific thread with @code{thread #}, where
-@code{#} is the thread id.
-@end enumerate
-
-@item
-Try to simulate your application with a Perl script to force
-@strong{MySQL} to crash or misbehave.
-
-@item
-Send a normal bug report. @xref{Bug reports}. Be even more detailed
-than usual. Because @strong{MySQL} works for many people, it may be that the
-crash results from something that exists only on your computer (for example,
-an error that is related to your particular system libraries).
-@item
-If you have a problem with tables with dynamic-length rows and you are
-not using @code{BLOB/TEXT} columns (but only @code{VARCHAR} columns), you
-can try to change all @code{VARCHAR} to @code{CHAR} with @code{ALTER
-TABLE}. This will force @strong{MySQL} to use fixed-size rows.
-Fixed-size rows take a little extra space, but are much more tolerant to
-corruption!
-
-The current dynamic row code has been in use at @strong{MySQL AB} for at
-least 3 years without any problems, but by nature dynamic-length rows are
-more prone to errors, so it may be a good idea to try the above to see if
-it helps!
-@end itemize
-
-@cindex linking, errors
-@cindex errors, linking
-@cindex problems, linking
-@node Link errors, Common errors, Crashing, Problems
-@section Problems When Linking with the MySQL Client Library
-
-If you are linking your program and you get errors for unreferenced
-symbols that start with @code{mysql_}, like the following:
-
-@example
-/tmp/ccFKsdPa.o: In function `main':
-/tmp/ccFKsdPa.o(.text+0xb): undefined reference to `mysql_init'
-/tmp/ccFKsdPa.o(.text+0x31): undefined reference to `mysql_real_connect'
-/tmp/ccFKsdPa.o(.text+0x57): undefined reference to `mysql_real_connect'
-/tmp/ccFKsdPa.o(.text+0x69): undefined reference to `mysql_error'
-/tmp/ccFKsdPa.o(.text+0x9a): undefined reference to `mysql_close'
-@end example
-
-you should be able to solve this by adding @code{-Lpath-to-the-mysql-library
--lmysqlclient} @strong{LAST} on your link line.
-
-If you get @code{undefined reference} errors for the @code{uncompress}
-or @code{compress} function, add @code{-lgz} @strong{LAST} on your link
-line and try again!
-
-If you get @code{undefined reference} errors for functions that should
-exist on your system, like @code{connect}, check the man page for the
-function in question, for which libraries you should add to the link
-line!
-
-If you get @code{undefined reference} errors for functions that don't
-exist on your system, like the following:
-
-@example
-mf_format.o(.text+0x201): undefined reference to `__lxstat'
-@end example
-
-it usually means that your library is compiled on a system that is not
-100 % compatible with yours. In this case you should download the
-latest @strong{MySQL} source distribution and compile this yourself.
-@xref{Installing source}.
-
-If you are trying to run a program and you then get errors for
-unreferenced symbols that start with @code{mysql_} or that the
-@code{mysqlclient} library can't be found, this means that your system
-can't find the share @code{libmysqlclient.so} library.
-
-The fix for this is to tell your system to search after shared
-libraries where the library is located by one of the following methods:
-
-@itemize @bullet
-@item
-Add the path to the directory where you have @code{libmysqlclient.so} the
-@code{LD_LIBRARY_PATH} environment variable.
-@item
-Add the path to the directory where you have @code{libmysqlclient.so} the
-@code{LD_LIBRARY} environment variable.
-@item
-Copy @code{libmysqlclient.so} to some place that is searched by your system,
-like @file{/lib}, and update the shared library information by executing
-@code{ldconfig}.
-@end itemize
-
-Another way to solve this problem is to link your program statically, with
-@code{-static}, or by removing the dynamic @strong{MySQL} libraries
-before linking your code. In the second case you should be
-sure that no other programs are using the dynamic libraries!
-
-@cindex errors, list of
-@node Common errors, Full disk, Link errors, Problems
-@section Some Common Errors When Using MySQL
-
-@menu
-* Error Access denied:: @code{Access denied} Error
-* Gone away:: @code{MySQL server has gone away} error
-* Can not connect to server:: @code{Can't connect to [local] MySQL server} error
-* Blocked host:: @code{Host '...' is blocked} error
-* Too many connections:: @code{Too many connections} error
-* Non-transactional tables:: @code{Some non-transactional changed tables couldn't be rolled back} Error
-* Out of memory:: @code{Out of memory} error
-* Packet too large:: @code{Packet too large} error
-* Communication errors:: Communication errors / Aborted connection
-* Full table:: @code{The table is full} error
-* Cannot create:: @code{Can't create/write to file} Error
-* Commands out of sync:: @code{Commands out of sync} error in client
-* Ignoring user:: @code{Ignoring user} error
-* Cannot find table:: @code{Table 'xxx' doesn't exist} error
-* Cannot initialize character set::
-@end menu
-
-This section lists some errors that users frequently get. You will find
-descriptions of the errors, and how to solve the problem here.
-
-@cindex errors, access denied
-@cindex problems, access denied errors
-@cindex access denied errors
-@node Error Access denied, Gone away, Common errors, Common errors
-@subsection @code{Access denied} Error
-
-@xref{Privileges}, and especially. @xref{Access denied}.
-
-@node Gone away, Can not connect to server, Error Access denied, Common errors
-@subsection @code{MySQL server has gone away} Error
-
-This section also covers the related @code{Lost connection to server
-during query} error.
-
-The most common reason for the @code{MySQL server has gone away} error
-is that the server timed out and closed the connection. By default, the
-server closes the connection after 8 hours if nothing has happened. You
-can change the time limit by setting the @code{wait_timeout} variable when
-you start @code{mysqld}.
-
-Another common reason to receive the @code{MySQL server has gone away} error
-is because you have issued a ``close'' on your @strong{MySQL} connection
-and then tried to run a query on the closed connection.
-
-You can check that the @strong{MySQL} hasn't died by executing
-@code{mysqladmin version} and examining the uptime.
-
-If you have a script, you just have to issue the query again for the client
-to do an automatic reconnection.
-
-You normally can get the following error codes in this case
-(which one you get is OS-dependent):
-
-@multitable @columnfractions .3 .7
-@item @code{CR_SERVER_GONE_ERROR} @tab The client couldn't send a question to the
-server.
-@item @code{CR_SERVER_LOST} @tab The client didn't get an error when writing
-to the server, but it didn't get a full answer (or any answer) to the question.
-@end multitable
-
-You can also get these errors if you send a query to the server that is
-incorrect or too large. If @code{mysqld} gets a packet that is too large
-or out of order, it assumes that something has gone wrong with the client and
-closes the connection. If you need big queries (for example, if you are
-working with big @code{BLOB} columns), you can increase the query limit by
-starting @code{mysqld} with the @code{-O max_allowed_packet=#} option
-(default 1M). The extra memory is allocated on demand, so @code{mysqld} will
-use more memory only when you issue a big query or when @code{mysqld} must
-return a big result row!
-
-@node Can not connect to server, Blocked host, Gone away, Common errors
-@subsection @code{Can't connect to [local] MySQL server} error
-
-A @strong{MySQL} client on Unix can connect to the @code{mysqld} server in two
-different ways: Unix sockets, which connect through a file in the file
-system (default @file{/tmp/mysqld.sock}) or TCP/IP, which connects
-through a port number. Unix sockets are faster than TCP/IP but can only
-be used when connecting to a server on the same computer. Unix sockets
-are used if you don't specify a hostname or if you specify the special
-hostname @code{localhost}.
-
-On Windows you can connect only with TCP/IP if the @code{mysqld} server
-is running on Win95/Win98. If it's running on NT, you can also connect
-with named pipes. The name of the named pipe is @strong{MySQL}. If you
-don't give a hostname when connecting to @code{mysqld}, a @strong{MySQL} client
-will first try to connect to the named pipe, and if this doesn't work it
-will connect to the TCP/IP port. You can force the use of named pipes
-on Windows by using @code{.} as the hostname.
-
-The error (2002) @code{Can't connect to ...} normally means that there
-isn't a @strong{MySQL} server running on the system or that you are
-using a wrong socket file or TCP/IP port when trying to connect to the
-@code{mysqld} server.
-
-Start by checking (using @code{ps} or the task manager on Windows) that
-there is a process running named @code{mysqld} on your server! If there
-isn't any @code{mysqld} process, you should start one. @xref{Starting
-server}.
-
-If a @code{mysqld} process is running, you can check the server by
-trying these different connections (the port number and socket pathname
-might be different in your setup, of course):
-
-@example
-shell> mysqladmin version
-shell> mysqladmin variables
-shell> mysqladmin -h `hostname` version variables
-shell> mysqladmin -h `hostname` --port=3306 version
-shell> mysqladmin -h 'ip for your host' version
-shell> mysqladmin --socket=/tmp/mysql.sock version
-@end example
-
-Note the use of backquotes rather than forward quotes with the @code{hostname}
-command; these cause the output of @code{hostname} (that is, the current
-hostname) to be substituted into the @code{mysqladmin} command.
-
-Here are some reasons the @code{Can't connect to local MySQL server}
-error might occur:
-
-@itemize @bullet
-@item
-@code{mysqld} is not running.
-@item
-You are running on a system that uses MIT-pthreads.
-If you are running on a system that doesn't have native threads,
-@code{mysqld} uses the MIT-pthreads package. @xref{Which OS}. However,
-all MIT-pthreads versions doesn't support Unix sockets. On a system
-without sockets support you must always specify the hostname explicitly
-when connecting to the server. Try using this command to check the
-connection to the server:
-@example
-shell> mysqladmin -h `hostname` version
-@end example
-@item
-Someone has removed the Unix socket that @code{mysqld} uses (default
-@file{/tmp/mysqld.sock}). You might have a @code{cron} job that removes
-the @strong{MySQL} socket (for example, a job that removes old files
-from the @file{/tmp} directory). You can always run @code{mysqladmin
-version} and check that the socket @code{mysqladmin} is trying to use
-really exists. The fix in this case is to change the @code{cron} job to
-not remove @file{mysqld.sock} or to place the socket somewhere else. You
-can specify a different socket location at @strong{MySQL} configuration
-time with this command:
-@example
-shell> ./configure --with-unix-socket-path=/path/to/socket
-@end example
-You can also start @code{safe_mysqld} with the
-@code{--socket=/path/to/socket} option and set the environment variable
-@code{MYSQL_UNIX_PORT} to the socket pathname before starting your
-@strong{MySQL} clients.
-@item
-You have started the @code{mysqld} server with
-the @code{--socket=/path/to/socket} option. If you change the socket
-pathname for the server, you must also notify the @strong{MySQL} clients
-about the new path. You can do this by setting the environment variable
-@code{MYSQL_UNIX_PORT} to the socket pathname or by providing the socket path
-as an argument to the clients. You can test the socket with this command:
-
-@example
-shell> mysqladmin --socket=/path/to/socket version
-@end example
-@item
-You are using Linux and one thread has died (core dumped). In this case
-you must kill the other @code{mysqld} threads (for example, with the
-@code{mysql_zap} script before you can start a new @strong{MySQL}
-server. @xref{Crashing}.
-@item
-You may not have read and write privilege to either the directory that holds
-the socket file or privilege to the socket file itself. In this case you
-have to either change the privilege for the directory / file or restart
-@code{mysqld} so that it uses a directory that you can access.
-@end itemize
-
-If you get the error message @code{Can't connect to MySQL server on
-some_hostname}, you can try the following things to find out what the
-problem is :
-
-@itemize @bullet
-@item
-Check if the server is up by doing @code{telnet your-host-name
-tcp-ip-port-number} and press @code{RETURN} a couple of times. If there
-is a @strong{MySQL} server running on this port you should get a
-responses that includes the version number of the running @strong{MySQL}
-server. If you get an error like @code{telnet: Unable to connect to
-remote host: Connection refused}, then there is no server running on the
-given port.
-@item
-Try connecting to the @code{mysqld} daemon on the local machine and check
-the TCP/IP port that @code{mysqld} it's configured to use (variable @code{port}) with
-@code{mysqladmin variables}.
-@item
-Check that your @code{mysqld} server is not started with the
-@code{--skip-networking} option.
-@end itemize
-
-@node Blocked host, Too many connections, Can not connect to server, Common errors
-@subsection @code{Host '...' is blocked} Error
-
-If you get an error like this:
-
-@example
-Host 'hostname' is blocked because of many connection errors.
-Unblock with 'mysqladmin flush-hosts'
-@end example
-
-this means that @code{mysqld} has gotten a lot (@code{max_connect_errors})
-of connect requests from the host @code{'hostname'} that have been interrupted
-in the middle. After @code{max_connect_errors} failed requests, @code{mysqld}
-assumes that something is wrong (like an attack from a cracker), and
-blocks the site from further connections until someone executes the command
-@code{mysqladmin flush-hosts}.
-
-By default, @code{mysqld} blocks a host after 10 connection errors.
-You can easily adjust this by starting the server like this:
-
-@example
-shell> safe_mysqld -O max_connect_errors=10000 &
-@end example
-
-Note that if you get this error message for a given host, you should first
-check that there isn't anything wrong with TCP/IP connections from that
-host. If your TCP/IP connections aren't working, it won't do you any good to
-increase the value of the @code{max_connect_errors} variable!
-
-@node Too many connections, Non-transactional tables, Blocked host, Common errors
-@subsection @code{Too many connections} Error
-
-If you get the error @code{Too many connections} when you try to connect
-to @strong{MySQL}, this means that there is already @code{max_connections}
-clients connected to the @code{mysqld} server.
-
-If you need more connections than the default (100), then you should restart
-@code{mysqld} with a bigger value for the @code{max_connections} variable.
-
-Note that @code{mysqld} actually allows (@code{max_connections}+1)
-clients to connect. The last connection is reserved for a user with the
-@strong{process} privilege. By not giving this privilege to normal
-users (they shouldn't need this), an administrator with this privilege
-can log in and use @code{SHOW PROCESSLIST} to find out what could be
-wrong. @xref{SHOW}.
-
-The maximum number of connects @strong{MySQL} is depending on how good
-the thread library is on a given platform. Linux or Solaris should be
-able to support 500-1000 simultaneous connections, depending on how much
-RAM you have and what your clients are doing.
-
-@cindex Non-transactional tables
-@node Non-transactional tables, Out of memory, Too many connections, Common errors
-@subsection @code{Some non-transactional changed tables couldn't be rolled back} Error
-
-If you get the error/warning: @code{Warning: Some non-transactional
-changed tables couldn't be rolled back} when trying to do a
-@code{ROLLBACK}, this means that some of the tables you used in the
-transaction didn't support transactions. These non-transactional tables
-will not be affected by the @code{ROLLBACK} statement.
-
-The most typical case when this happens is when you have tried to create
-a table of a type that is not supported by your @code{mysqld} binary.
-If @code{mysqld} doesn't support a table type (or if the table type is
-disabled by a startup option) , it will instead create the table type
-with the table type that is most resembles to the one you requested,
-probably @code{MyISAM}.
-
-You can check the table type for a table by doing:
-
-@code{SHOW TABLE STATUS LIKE 'table_name'}. @xref{SHOW TABLE STATUS}.
-
-You can check the extensions your @code{mysqld} binary supports by doing:
-
-@code{show variables like 'have_%'}. @xref{SHOW VARIABLES}.
-
-@node Out of memory, Packet too large, Non-transactional tables, Common errors
-@subsection @code{Out of memory} Error
-
-If you issue a query and get something like the following error:
-
-@example
-mysql: Out of memory at line 42, 'malloc.c'
-mysql: needed 8136 byte (8k), memory in use: 12481367 bytes (12189k)
-ERROR 2008: MySQL client ran out of memory
-@end example
-
-note that the error refers to the @strong{MySQL} client @code{mysql}. The
-reason for this error is simply that the client does not have enough memory to
-store the whole result.
-
-To remedy the problem, first check that your query is correct. Is it
-reasonable that it should return so many rows? If so,
-you can use @code{mysql --quick}, which uses @code{mysql_use_result()}
-to retrieve the result set. This places less of a load on the client (but
-more on the server).
-
-@node Packet too large, Communication errors, Out of memory, Common errors
-@subsection @code{Packet too large} Error
-
-When a @strong{MySQL} client or the @code{mysqld} server gets a packet bigger
-than @code{max_allowed_packet} bytes, it issues a @code{Packet too large}
-error and closes the connection.
-
-If you are using the @code{mysql} client, you may specify a bigger buffer by
-starting the client with @code{mysql --set-variable=max_allowed_packet=8M}.
-
-If you are using other clients that do not allow you to specify the maximum
-packet size (such as @code{DBI}), you need to set the packet size when you
-start the server. You cau use a command-line option to @code{mysqld} to set
-@code{max_allowed_packet} to a larger size. For example, if you are
-expecting to store the full length of a @code{BLOB} into a table, you'll need
-to start the server with the @code{--set-variable=max_allowed_packet=16M}
-option.
-
-@cindex aborted clients
-@cindex aborted connection
-@cindex connection, aborted
-@node Communication errors, Full table, Packet too large, Common errors
-@subsection Communication Errors / Aborted Connection
-
-Starting with @code{MySQL 3.23.40} you only get the @code{Aborted
-connection} error of you start @code{mysqld} with @code{--warnings}.
-
-If you find errors like the following in your error log.
-
-@example
-010301 14:38:23 Aborted connection 854 to db: 'users' user: 'josh'
-@end example
-
-@xref{Error log}.
-
-This means that something of the following has happened:
-
-@itemize @bullet
-@item
-The client program did not call @code{mysql_close()} before exit.
-@item
-The client had been sleeping more than @code{wait_timeout} or
-@code{interactive_timeout} without doing any requests. @xref{SHOW
-VARIABLES}.
-@item
-The client program ended abruptly in the middle of the transfer.
-@end itemize
-
-When the above happens, the server variable @code{Aborted_clients} is
-incremented.
-
-The server variable @code{Aborted_connects} is incremented when:
-
-@itemize @bullet
-@item
-When a connection packet doesn't contain the right information.
-@item
-When the user didn't have privileges to connect to a database.
-@item
-When a user uses a wrong password.
-@item
-When it takes more than @code{connect_timeout} seconds to get
-a connect package.
-@end itemize
-
-Note that the above could indicate that someone is trying to break into
-your database!
-
-@xref{SHOW VARIABLES}.
-
-Other reasons for problems with Aborted clients / Aborted connections.
-@itemize @bullet
-@item
-Usage of duplex Ethernet protocol, both half and full with
-Linux. Many Linux Ethernet drivers have this bug. You should test
-for this bug by transferring a huge file via ftp between these two
-machines. If a transfer goes in burst-pause-burst-pause ... mode then
-you are experiencing a Linux duplex syndrome. The only solution to
-this problem is switching of both half and full duplexing on hubs
-and switches.
-@item
-Some problem with the thread library that causes interrupts on reads.
-@item
-Badly configured TCP/IP.
-@item
-Faulty Ethernets or hubs or switches, cables ... This can be diagnosed
-properly only by replacing hardware.
-@end itemize
-
-
-@cindex table is full
-@node Full table, Cannot create, Communication errors, Common errors
-@subsection @code{The table is full} Error
-
-This error occurs in older @strong{MySQL} versions when an in-memory temporary
-table becomes larger than @code{tmp_table_size} bytes. To avoid this
-problem, you can use the @code{-O tmp_table_size=#} option to
-@code{mysqld} to increase the temporary table size or use the SQL
-option @code{SQL_BIG_TABLES} before you issue the problematic
-query. @xref{SET OPTION, , @code{SET OPTION}}.
-
-You can also start @code{mysqld} with the @code{--big-tables} option.
-This is exactly the same as using @code{SQL_BIG_TABLES} for all queries.
-
-In @strong{MySQL} Version 3.23, in-memory temporary tables will automatically be
-converted to a disk-based @code{MyISAM} table after the table size gets
-bigger than @code{tmp_table_size}.
-
-@cindex can't create/write to file
-@node Cannot create, Commands out of sync, Full table, Common errors
-@subsection @code{Can't create/write to file} Error
-
-If you get an error for some queries of type:
-
-@example
-Can't create/write to file '\\sqla3fe_0.ism'.
-@end example
-
-this means that @strong{MySQL} can't create a temporary file for the
-result set in the given temporary directory. (The above error is a
-typical error message on Windows, and the Unix error message is similar.)
-The fix is to start @code{mysqld} with @code{--tmpdir=path} or to add to your option
-file:
-
-@example
-[mysqld]
-tmpdir=C:/temp
-@end example
-
-assuming that the @file{c:\\temp} directory exists. @xref{Option files}.
-
-Check also the error code that you get with @code{perror}. One reason
-may also be a disk full error;
-
-@example
-shell> perror 28
-Error code 28: No space left on device
-@end example
-
-@cindex commands out of sync
-@node Commands out of sync, Ignoring user, Cannot create, Common errors
-@subsection @code{Commands out of sync} Error in Client
-
-If you get @code{Commands out of sync; You can't run this command now}
-in your client code, you are calling client functions in the wrong order!
-
-This can happen, for example, if you are using @code{mysql_use_result()} and
-try to execute a new query before you have called @code{mysql_free_result()}.
-It can also happen if you try to execute two queries that return data without
-a @code{mysql_use_result()} or @code{mysql_store_result()} in between.
-
-@node Ignoring user, Cannot find table, Commands out of sync, Common errors
-@subsection @code{Ignoring user} Error
-
-If you get the following error:
-
-@code{Found wrong password for user: 'some_user@@some_host'; Ignoring user}
-
-this means that when @code{mysqld} was started or when it reloaded the
-permissions tables, it found an entry in the @code{user} table with
-an invalid password. As a result, the entry is simply ignored by the
-permission system.
-
-Possible causes of and fixes for this problem:
-
-@itemize @bullet
-@item
-You may be running a new version of @code{mysqld} with an old
-@code{user} table.
-You can check this by executing @code{mysqlshow mysql user} to see if
-the password field is shorter than 16 characters. If so, you can correct this
-condition by running the @code{scripts/add_long_password} script.
-
-@item
-The user has an old password (8 characters long) and you didn't start
-@code{mysqld} with the @code{--old-protocol} option.
-Update the user in the @code{user} table with a new password or
-restart @code{mysqld} with @code{--old-protocol}.
-
-@item
-@findex PASSWORD()
-You have specified a password in the @code{user} table without using the
-@code{PASSWORD()} function. Use @code{mysql} to update the user in the
-@code{user} table with a new password. Make sure to use the @code{PASSWORD()}
-function:
-
-@example
-mysql> update user set password=PASSWORD('your password')
- where user='XXX';
-@end example
-@end itemize
-
-@node Cannot find table, Cannot initialize character set, Ignoring user, Common errors
-@subsection @code{Table 'xxx' doesn't exist} Error
-
-If you get the error @code{Table 'xxx' doesn't exist} or @code{Can't
-find file: 'xxx' (errno: 2)}, this means that no table exists
-in the current database with the name @code{xxx}.
-
-Note that as @strong{MySQL} uses directories and files to store databases and
-tables, the database and table names are @strong{case sensitive}!
-(On Windows the databases and tables names are not case sensitive, but all
-references to a given table within a query must use the same case!)
-
-You can check which tables you have in the current database with
-@code{SHOW TABLES}. @xref{SHOW, , @code{SHOW}}.
-
-@cindex multibyte character sets
-@node Cannot initialize character set, , Cannot find table, Common errors
-@subsection @code{Can@'t initialize character set xxx} error.
-
-If you get an error like:
-
-@example
-MySQL Connection Failed: Can't initialize character set xxx
-@end example
-
-This means one of the following things:
-
-@itemize @bullet
-@item
-The character set is a multi-byte character set and you have not support
-for the character set in the client.
-
-In this case you need to recompile the client with
-@code{--with-charset=xxx} or with @code{--with-extra-charsets=xxx}.
-@xref{configure options}.
-
-All standard @strong{MySQL} binaries are compiled with
-@code{--with-extra-character-sets=complex} which will enable support for
-all multi-byte character sets. @xref{Character sets}.
-
-@item
-The character set is a simple character set which is not compiled into
-@code{mysqld} and the character set definition files is not in the place
-where the client expect to find them.
-
-In this case you need to:
-
-@itemize @bullet
-@item
-Recompile the client with support for the character set.
-@xref{configure options}.
-@item
-Specify to the client where the character set definition files are. For many
-client you can do this with the
-@code{--character-sets-dir=path-to-charset-dir} option.
-@item
-Copy the character definition files to the path where the client expect them
-to be.
-@end itemize
-@end itemize
-
-@cindex full disk
-@cindex disk full
-@node Full disk, Multiple sql commands, Common errors, Problems
-@section How MySQL Handles a Full Disk
-
-@noindent
-When a disk-full condition occurs, @strong{MySQL} does the following:
-
-@itemize @bullet
-@item
-It checks once every minute to see whether or not there is enough space to
-write the current row. If there is enough space, it continues as if nothing had
-happened.
-@item
-Every 6 minutes it writes an entry to the log file warning about the disk
-full condition.
-@end itemize
-
-@noindent
-To alleviate the problem, you can take the following actions:
-
-@itemize @bullet
-@item
-To continue, you only have to free enough disk space to insert all records.
-@item
-To abort the thread, you must send a @code{mysqladmin kill} to the thread.
-The thread will be aborted the next time it checks the disk (in 1 minute).
-@item
-Note that other threads may be waiting for the table that caused the disk
-full condition. If you have several ``locked'' threads, killing the one
-thread that is waiting on the disk-full condition will allow the other
-threads to continue.
-@end itemize
-
-Exceptions to the above behaveour is when you use @code{REPAIR} or
-@code{OPTIMIZE} or when the indexes are created in a batch after an
-@code{LOAD DATA INFILE} or after an @code{ALTER TABLE} statement.
-
-All of the above commands may use big temporary files that left to
-themself would cause big problems for the rest of the system. If
-@strong{MySQL} gets disk full while doing any of the above operations,
-it will remove the big temporary files and mark the table as crashed
-(except for @code{ALTER TABLE}, in which the old table will be left
-unchanged).
-
-@node Multiple sql commands, Temporary files, Full disk, Problems
-@section How to Run SQL Commands from a Text File
-
-The @code{mysql} client typically is used interactively, like this:
-
-@example
-shell> mysql database
-@end example
-
-However, it's also possible to put your SQL commands in a file and tell
-@code{mysql} to read its input from that file. To do so, create a text
-file @file{text_file} that contains the commands you wish to execute.
-Then invoke @code{mysql} as shown below:
-
-@example
-shell> mysql database < text_file
-@end example
-
-You can also start your text file with a @code{USE db_name} statement. In
-this case, it is unnecessary to specify the database name on the command
-line:
-
-@example
-shell> mysql < text_file
-@end example
-
-@xref{Programs}.
-
-@node Temporary files, Problems with mysql.sock, Multiple sql commands, Problems
-@section Where MySQL Stores Temporary Files
-
-@strong{MySQL} uses the value of the @code{TMPDIR} environment variable as
-the pathname of the directory in which to store temporary files. If you don't
-have @code{TMPDIR} set, @strong{MySQL} uses the system default, which is
-normally @file{/tmp} or @file{/usr/tmp}. If the file system containing your
-temporary file directory is too small, you should edit @code{safe_mysqld} to
-set @code{TMPDIR} to point to a directory in a file system where you have
-enough space! You can also set the temporary directory using the
-@code{--tmpdir} option to @code{mysqld}.
-
-@strong{MySQL} creates all temporary files as hidden files. This ensures
-that the temporary files will be removed if @code{mysqld} is terminated. The
-disadvantage of using hidden files is that you will not see a big temporary
-file that fills up the file system in which the temporary file directory is
-located.
-
-When sorting (@code{ORDER BY} or @code{GROUP BY}), @strong{MySQL} normally
-uses one or two temporary files. The maximum disk-space needed is:
-
-@example
-(length of what is sorted + sizeof(database pointer))
-* number of matched rows
-* 2
-@end example
-
-@code{sizeof(database pointer)} is usually 4, but may grow in the future for
-really big tables.
-
-For some @code{SELECT} queries, @strong{MySQL} also creates temporary SQL
-tables. These are not hidden and have names of the form @file{SQL_*}.
-
-@code{ALTER TABLE} creates a temporary table in the same directory as
-the original table.
-
-@cindex @code{mysql.sock}, protection
-@cindex deletion, @code{mysql.sock}
-@node Problems with mysql.sock, Changing MySQL user, Temporary files, Problems
-@section How to Protect @file{/tmp/mysql.sock} from Being Deleted
-
-If you have problems with the fact that anyone can delete the
-@strong{MySQL} communication socket @file{/tmp/mysql.sock}, you can,
-on most versions of Unix, protect your @file{/tmp} file system by setting
-the @code{sticky} bit on it. Log in as @code{root} and do the following:
-
-@example
-shell> chmod +t /tmp
-@end example
-
-This will protect your @file{/tmp} file system so that files can be deleted
-only by their owners or the superuser (@code{root}).
-
-You can check if the @code{sticky} bit is set by executing @code{ls -ld /tmp}.
-If the last permission bit is @code{t}, the bit is set.
-
-@cindex starting, @code{mysqld}
-@cindex @code{mysqld}, starting
-@node Changing MySQL user, Resetting permissions, Problems with mysql.sock, Problems
-@section How to Run MySQL As a Normal User
-
-The @strong{MySQL} server @code{mysqld} can be started and run by any user.
-In order to change @code{mysqld} to run as a Unix user @code{user_name}, you must
-do the following:
-
-@enumerate
-@item
-Stop the server if it's running (use @code{mysqladmin shutdown}).
-
-@item
-Change the database directories and files so that @code{user_name} has
-privileges to read and write files in them (you may need to do this as
-the Unix @code{root} user):
-
-@example
-shell> chown -R user_name /path/to/mysql/datadir
-@end example
-
-If directories or files within the @strong{MySQL} data directory are
-symlinks, you'll also need to follow those links and change the directories
-and files they point to. @code{chown -R} may not follow symlinks for
-you.
-
-@item
-Start the server as user @code{user_name}, or, if you are using
-@strong{MySQL} Version 3.22 or later, start @code{mysqld} as the Unix @code{root}
-user and use the @code{--user=user_name} option. @code{mysqld} will switch
-to run as the Unix user @code{user_name} before accepting any connections.
-
-@item
-To start the server as the given user name automatically at system
-startup time, add a @code{user} line that specifies the user name to
-the @code{[mysqld]} group of the @file{/etc/my.cnf} option file or the
-@file{my.cnf} option file in the server's data directory. For example:
-
-@example
-[mysqld]
-user=user_name
-@end example
-@end enumerate
-
-At this point, your @code{mysqld} process should be running fine and dandy as
-the Unix user @code{user_name}. One thing hasn't changed, though: the
-contents of the permissions tables. By default (right after running the
-permissions table install script @code{mysql_install_db}), the @strong{MySQL}
-user @code{root} is the only user with permission to access the @code{mysql}
-database or to create or drop databases. Unless you have changed those
-permissions, they still hold. This shouldn't stop you from accessing
-@strong{MySQL} as the @strong{MySQL} @code{root} user when you're logged in
-as a Unix user other than @code{root}; just specify the @code{-u root} option
-to the client program.
-
-Note that accessing @strong{MySQL} as @code{root}, by supplying @code{-u
-root} on the command line, has @emph{nothing} to do with @strong{MySQL} running
-as the Unix @code{root} user, or, indeed, as another Unix user. The access
-permissions and user names of @strong{MySQL} are completely separate from
-Unix user names. The only connection with Unix user names is that if you
-don't provide a @code{-u} option when you invoke a client program, the client
-will try to connect using your Unix login name as your @strong{MySQL} user
-name.
-
-If your Unix box itself isn't secured, you should probably at least put a
-password on the @strong{MySQL} @code{root} users in the access tables.
-Otherwise, any user with an account on that machine can run @code{mysql -u
-root db_name} and do whatever he likes.
-
-@cindex passwords, forgotten
-@cindex passwords, resetting
-@cindex root user, password resetting
-@node Resetting permissions, File permissions , Changing MySQL user, Problems
-@section How to Reset a Forgotten Password
-
-If you have forgotten the @code{root} user password for @strong{MySQL}, you
-can restore it with the following procedure:
-
-@enumerate
-@item
-Take down the @code{mysqld} server by sending a @code{kill} (not @code{kill
--9}) to the @code{mysqld} server. The pid is stored in a @code{.pid}
-file, which is normally in the @strong{MySQL} database directory:
-
-@example
-kill `cat /mysql-data-directory/hostname.pid`
-@end example
-
-You must be either the Unix @code{root} user or the same user the server
-runs as to do this.
-
-@item
-Restart @code{mysqld} with the @code{--skip-grant-tables} option.
-@item
-Connect to the @code{mysqld} server with @code{mysql -h hostname mysql} and change
-the password with a @code{GRANT} command. @xref{GRANT,,@code{GRANT}}.
-You can also do this with
-@code{mysqladmin -h hostname -u user password 'new password'}
-@item
-Load the privilege tables with: @code{mysqladmin -h hostname
-flush-privileges} or with the SQL command @code{FLUSH PRIVILEGES}.
-@end enumerate
-
-Note that after you started @code{mysqld} with @code{--skip-grant-tables},
-any usage of @code{GRANT} commands will give you an @code{Unknown command}
-error until you have executed @code{FLUSH PRIVILEGES}.
-
-@cindex files, permissions
-@cindex error mesaages, can't find file
-@cindex files, not found message
-@node File permissions , Not enough file handles, Resetting permissions, Problems
-@section Problems with File Permissions
-
-If you have problems with file permissions, for example, if @code{mysql}
-issues the following error message when you create a table:
-
-@example
-ERROR: Can't find file: 'path/with/filename.frm' (Errcode: 13)
-@end example
-
-@tindex UMASK environment variable
-@tindex Environment variable, UMASK
-then the environment variable @code{UMASK} might be set incorrectly when
-@code{mysqld} starts up. The default umask value is @code{0660}. You can
-change this behavior by starting @code{safe_mysqld} as follows:
-
-@example
-shell> UMASK=384 # = 600 in octal
-shell> export UMASK
-shell> /path/to/safe_mysqld &
-@end example
-
-@tindex UMASK_DIR environment variable
-@tindex Environment variable, UMASK_DIR
-By default @strong{MySQL} will create database and @code{RAID}
-directories with permission type 0700. You can modify this behavior by
-setting the @code{UMASK_DIR} variable. If you set this, new
-directories are created with the combined @code{UMASK} and
-@code{UMASK_DIR}. For example, if you want to give group access to
-all new directories, you can do:
-
-@example
-shell> UMASK_DIR=504 # = 770 in octal
-shell> export UMASK_DIR
-shell> /path/to/safe_mysqld &
-@end example
-
-In @strong{MySQL} Version 3.23.25 and above, @strong{MySQL} assumes that the
-value for @code{UMASK} and @code{UMASK_DIR} is in octal if it starts
-with a zero.
-
-@xref{Environment variables}.
-
-@node Not enough file handles, Using DATE, File permissions , Problems
-@section File Not Found
-
-If you get @code{ERROR '...' not found (errno: 23)}, @code{Can't open
-file: ... (errno: 24)}, or any other error with @code{errno 23} or
-@code{errno 24} from @strong{MySQL}, it means that you haven't allocated
-enough file descriptors for @strong{MySQL}. You can use the
-@code{perror} utility to get a description of what the error number
-means:
-
-@example
-shell> perror 23
-File table overflow
-shell> perror 24
-Too many open files
-shell> perror 11
-Resource temporarily unavailable
-@end example
-
-The problem here is that @code{mysqld} is trying to keep open too many
-files simultaneously. You can either tell @code{mysqld} not to open so
-many files at once or increase the number of file descriptors
-available to @code{mysqld}.
-
-To tell @code{mysqld} to keep open fewer files at a time, you can make
-the table cache smaller by using the @code{-O table_cache=32} option to
-@code{safe_mysqld} (the default value is 64). Reducing the value of
-@code{max_connections} will also reduce the number of open files (the
-default value is 90).
-
-@tindex ulimit
-To change the number of file descriptors available to @code{mysqld}, you
-can use the option @code{--open-files-limit=#} to @code{safe_mysqld} or
-@code{-O open-files-limit=#} to @code{mysqld}. @xref{SHOW VARIABLES}.
-The easiest way to do that is to add the option to your option file.
-@xref{Option files}. If you have an old @code{mysqld} version that
-doesn't support this, you can edit the @code{safe_mysqld} script. There
-is a commented-out line @code{ulimit -n 256} in the script. You can
-remove the @code{'#'} character to uncomment this line, and change the
-number 256 to affect the number of file descriptors available to
-@code{mysqld}.
-
-@code{ulimit} (and @code{open-files-limit}) can increase the number of
-file descriptors, but only up to the limit imposed by the operating
-system. There is also a 'hard' limit that can only be overrided if you
-start @code{safe_mysqld} or @code{mysqld} as root (Just remember that
-you need to also use the @code{--user=..} option in this case). If you
-need to increase the OS limit on the number of file descriptors
-available to each process, consult the documentation for your operating
-system.
-
-Note that if you run the @code{tcsh} shell, @code{ulimit} will not work!
-@code{tcsh} will also report incorrect values when you ask for the current
-limits! In this case you should start @code{safe_mysqld} with @code{sh}!
-
-@findex DATE
-@cindex DATE columns, problems
-@cindex problems, @code{DATE} columns
-@node Using DATE, Timezone problems, Not enough file handles, Problems
-@section Problems Using @code{DATE} Columns
-
-The format of a @code{DATE} value is @code{'YYYY-MM-DD'}. According to ANSI
-SQL, no other format is allowed. You should use this format in @code{UPDATE}
-expressions and in the WHERE clause of @code{SELECT} statements. For
-example:
-
-@example
-mysql> SELECT * FROM tbl_name WHERE date >= '1997-05-05';
-@end example
-
-As a convenience, @strong{MySQL} automatically converts a date to a number if
-the date is used in a numeric context (and vice versa). It is also smart
-enough to allow a ``relaxed'' string form when updating and in a @code{WHERE}
-clause that compares a date to a @code{TIMESTAMP}, @code{DATE}, or a
-@code{DATETIME} column. (Relaxed form means that any punctuation character
-may be used as the separator between parts. For example, @code{'1998-08-15'}
-and @code{'1998#08#15'} are equivalent.) @strong{MySQL} can also convert a
-string containing no separators (such as @code{'19980815'}), provided it
-makes sense as a date.
-
-The special date @code{'0000-00-00'} can be stored and retrieved as
-@code{'0000-00-00'.} When using a @code{'0000-00-00'} date through
-@strong{MyODBC}, it will automatically be converted to @code{NULL} in
-@strong{MyODBC} Version 2.50.12 and above, because ODBC can't handle this kind of
-date.
-
-Because @strong{MySQL} performs the conversions described above, the following
-statements work:
-
-@example
-mysql> INSERT INTO tbl_name (idate) VALUES (19970505);
-mysql> INSERT INTO tbl_name (idate) VALUES ('19970505');
-mysql> INSERT INTO tbl_name (idate) VALUES ('97-05-05');
-mysql> INSERT INTO tbl_name (idate) VALUES ('1997.05.05');
-mysql> INSERT INTO tbl_name (idate) VALUES ('1997 05 05');
-mysql> INSERT INTO tbl_name (idate) VALUES ('0000-00-00');
-
-mysql> SELECT idate FROM tbl_name WHERE idate >= '1997-05-05';
-mysql> SELECT idate FROM tbl_name WHERE idate >= 19970505;
-mysql> SELECT mod(idate,100) FROM tbl_name WHERE idate >= 19970505;
-mysql> SELECT idate FROM tbl_name WHERE idate >= '19970505';
-@end example
-
-@noindent
-However, the following will not work:
-
-@example
-mysql> SELECT idate FROM tbl_name WHERE STRCMP(idate,'19970505')=0;
-@end example
-
-@code{STRCMP()} is a string function, so it converts @code{idate} to
-a string and performs a string comparison. It does not convert
-@code{'19970505'} to a date and perform a date comparison.
-
-Note that @strong{MySQL} does no checking whether or not the date is
-correct. If you store an incorrect date, such as @code{'1998-2-31'}, the
-wrong date will be stored. If the date cannot be converted to any reasonable
-value, a @code{0} is stored in the @code{DATE} field. This is mainly a speed
-issue and we think it is up to the application to check the dates, and not
-the server.
-
-@cindex timezone problems
-@cindex problems, timezone
-@tindex TZ environment variable
-@tindex Environment variable, TZ
-@node Timezone problems, Case sensitivity, Using DATE, Problems
-@section Time Zone Problems
-
-If you have a problem with @code{SELECT NOW()} returning values in GMT and
-not your local time, you have to set the @code{TZ} environment variable to
-your current time zone. This should be done for the environment in which
-the server runs, for example, in @code{safe_mysqld} or @code{mysql.server}.
-@xref{Environment variables}.
-
-@cindex case sensitivity, in searches
-@cindex searching, and case-sensitivity
-@cindex Chinese
-@cindex Big5 Chinese character encoding
-@node Case sensitivity, Problems with NULL, Timezone problems, Problems
-@section Case Sensitivity in Searches
-
-By default, @strong{MySQL} searches are case-insensitive (although there are
-some character sets that are never case insensitive, such as @code{czech}).
-That means that if you search with @code{col_name LIKE 'a%'}, you will get all
-column values that start with @code{A} or @code{a}. If you want to make this
-search case-sensitive, use something like @code{INDEX(col_name, "A")=0} to
-check a prefix. Or use @code{STRCMP(col_name, "A") = 0} if the column value
-must be exactly @code{"A"}.
-
-Simple comparison operations (@code{>=, >, = , < , <=}, sorting and
-grouping) are based on each character's ``sort value''. Characters with
-the same sort value (like E, e and é) are treated as the same character!
-
-In older @strong{MySQL} versions @code{LIKE} comparisons where done on
-the uppercase value of each character (E == e but E <> é). In newer
-@strong{MySQL} versions @code{LIKE} works just like the other comparison
-operators.
-
-If you want a column always to be treated in case-sensitive fashion,
-declare it as @code{BINARY}. @xref{CREATE TABLE, , @code{CREATE TABLE}}.
-
-If you are using Chinese data in the so-called big5 encoding, you want to
-make all character columns @code{BINARY}. This works because the sorting
-order of big5 encoding characters is based on the order of ASCII codes.
-
-@cindex @code{NULL} values, vs. empty values
-@tindex NULL
-@node Problems with NULL, Problems with alias, Case sensitivity, Problems
-@section Problems with @code{NULL} Values
-
-The concept of the @code{NULL} value is a common source of confusion for
-newcomers to SQL, who often think that @code{NULL} is the same thing as an
-empty string @code{''}. This is not the case! For example, the following
-statements are completely different:
-
-@example
-mysql> INSERT INTO my_table (phone) VALUES (NULL);
-mysql> INSERT INTO my_table (phone) VALUES ("");
-@end example
-
-Both statements insert a value into the @code{phone} column, but the first
-inserts a @code{NULL} value and the second inserts an empty string. The
-meaning of the first can be regarded as ``phone number is not known'' and the
-meaning of the second can be regarded as ``she has no phone''.
-
-In SQL, the @code{NULL} value is always false in comparison to any
-other value, even @code{NULL}. An expression that contains @code{NULL}
-always produces a @code{NULL} value unless otherwise indicated in
-the documentation for the operators and functions involved in the
-expression. All columns in the following example return @code{NULL}:
-
-@example
-mysql> SELECT NULL,1+NULL,CONCAT('Invisible',NULL);
-@end example
-
-If you want to search for column values that are @code{NULL}, you
-cannot use the @code{=NULL} test. The following statement returns no
-rows, because @code{expr = NULL} is FALSE, for any expression:
-
-@example
-mysql> SELECT * FROM my_table WHERE phone = NULL;
-@end example
-
-To look for @code{NULL} values, you must use the @code{IS NULL} test.
-The following shows how to find the @code{NULL} phone number and the
-empty phone number:
-
-@example
-mysql> SELECT * FROM my_table WHERE phone IS NULL;
-mysql> SELECT * FROM my_table WHERE phone = "";
-@end example
-
-In @strong{MySQL}, as in many other SQL servers, you can't index
-columns that can have @code{NULL} values. You must declare such columns
-@code{NOT NULL}. Conversely, you cannot insert @code{NULL} into an indexed
-column.
-
-@findex LOAD DATA INFILE
-When reading data with @code{LOAD DATA INFILE}, empty columns are updated
-with @code{''}. If you want a @code{NULL} value in a column, you should use
-@code{\N} in the text file. The literal word @code{'NULL'} may also be used
-under some circumstances.
-@xref{LOAD DATA, , @code{LOAD DATA}}.
-
-When using @code{ORDER BY}, @code{NULL} values are presented first. If you
-sort in descending order using @code{DESC}, @code{NULL} values are presented
-last. When using @code{GROUP BY}, all @code{NULL} values are regarded as
-equal.
-
-To help with @code{NULL} handling, you can use the @code{IS NULL} and
-@code{IS NOT NULL} operators and the @code{IFNULL()} function.
-
-@cindex @code{TIMESTAMP}, and @code{NULL} values
-@cindex @code{AUTO_INCREMENT}, and @code{NULL} values
-@cindex @code{NULL} values, and @code{TIMESTAMP} columns
-@cindex @code{NULL} values, and @code{AUTO_INCREMENT} columns
-For some column types, @code{NULL} values are handled specially. If you
-insert @code{NULL} into the first @code{TIMESTAMP} column of a table, the
-current date and time is inserted. If you insert @code{NULL} into an
-@code{AUTO_INCREMENT} column, the next number in the sequence is inserted.
-
-@tindex alias
-@node Problems with alias, Deleting from related tables, Problems with NULL, Problems
-@section Problems with @code{alias}
-
-You can use an alias to refer to a column in the @code{GROUP BY},
-@code{ORDER BY}, or in the @code{HAVING} part. Aliases can also be used
-to give columns better names:
-
-@example
-SELECT SQRT(a*b) as rt FROM table_name GROUP BY rt HAVING rt > 0;
-SELECT id,COUNT(*) AS cnt FROM table_name GROUP BY id HAVING cnt > 0;
-SELECT id AS "Customer identity" FROM table_name;
-@end example
-
-Note that ANSI SQL doesn't allow you to refer to an alias in a
-@code{WHERE} clause. This is because when the @code{WHERE} code is
-executed the column value may not yet be determined. For example, the
-following query is @strong{illegal}:
-
-@example
-SELECT id,COUNT(*) AS cnt FROM table_name WHERE cnt > 0 GROUP BY id;
-@end example
-
-The @code{WHERE} statement is executed to determine which rows should
-be included in the @code{GROUP BY} part while @code{HAVING} is used to
-decide which rows from the result set should be used.
-
-@cindex deleting, rows
-@cindex rows, deleting
-@cindex tables, deleting rows
-@node Deleting from related tables, No matching rows, Problems with alias, Problems
-@section Deleting Rows from Related Tables
-
-As @strong{MySQL} doesn't support sub-selects or use of more than one table
-in the @code{DELETE} statement, you should use the following approach to
-delete rows from 2 related tables:
-
-@enumerate
-@item
-@code{SELECT} the rows based on some @code{WHERE} condition in the main table.
-@item
-@code{DELETE} the rows in the main table based on the same condition.
-@item
-@code{DELETE FROM related_table WHERE related_column IN (selected_rows)}.
-@end enumerate
-
-If the total number of characters in the query with
-@code{related_column} is more than 1,048,576 (the default value of
-@code{max_allowed_packet}, you should split it into smaller parts and
-execute multiple @code{DELETE} statements. You will probably get the
-fastest @code{DELETE} by only deleting 100-1000 @code{related_column}
-id's per query if the @code{related_column} is an index. If the
-@code{related_column} isn't an index, the speed is independent of the
-number of arguments in the @code{IN} clause.
-
-@cindex no matching rows
-@cindex rows, matching problems
-@node No matching rows, ALTER TABLE problems, Deleting from related tables, Problems
-@section Solving Problems with No Matching Rows
-
-If you have a complicated query that has many tables and that doesn't
-return any rows, you should use the following procedure to find out what
-is wrong with your query:
-
-@enumerate
-@item
-Test the query with @code{EXPLAIN} and check if you can find something that is
-obviously wrong. @xref{EXPLAIN, , @code{EXPLAIN}}.
-
-@item
-Select only those fields that are used in the @code{WHERE} clause.
-
-@item
-Remove one table at a time from the query until it returns some rows.
-If the tables are big, it's a good idea to use @code{LIMIT 10} with the query.
-
-@item
-Do a @code{SELECT} for the column that should have matched a row against
-the table that was last removed from the query.
-
-@item
-If you are comparing @code{FLOAT} or @code{DOUBLE} columns with numbers that
-have decimals, you can't use @code{=}! This problem is common in most
-computer languages because floating-point values are not exact values:
-
-@example
-mysql> SELECT * FROM table_name WHERE float_column=3.5;
- ->
-mysql> SELECT * FROM table_name WHERE float_column between 3.45 and 3.55;
-@end example
-
-In most cases, changing the @code{FLOAT} to a @code{DOUBLE} will fix this!
-
-@item
-If you still can't figure out what's wrong, create a minimal test that can
-be run with @code{mysql test < query.sql} that shows your problems.
-You can create a test file with @code{mysqldump --quick database tables > query.sql}. Open the file in an editor, remove some insert lines (if there are
-too many of these), and add your select statement at the end of the file.
-
-Test that you still have your problem by doing:
-
-@example
-shell> mysqladmin create test2
-shell> mysql test2 < query.sql
-@end example
-
-Post the test file using @code{mysqlbug} to @email{mysql@@lists.mysql.com}.
-@end enumerate
-
-@tindex ALTER TABLE
-@node ALTER TABLE problems, Change column order, No matching rows, Problems
-@section Problems with @code{ALTER TABLE}.
-
-@code{ALTER TABLE} changes a table to the current character set.
-If you during @code{ALTER TABLE} get a duplicate key error, then the cause
-is either that the new character sets maps to keys to the same value
-or that the table is corrupted, in which case you should run
-@code{REPAIR TABLE} on the table.
-
-If @code{ALTER TABLE} dies with an error like this:
-
-@example
-Error on rename of './database/name.frm' to './database/B-a.frm' (Errcode: 17)
-@end example
-
-the problem may be that @strong{MySQL} has crashed in a previous @code{ALTER
-TABLE} and there is an old table named @file{A-something} or
-@file{B-something} lying around. In this case, go to the @strong{MySQL} data
-directory and delete all files that have names starting with @code{A-} or
-@code{B-}. (You may want to move them elsewhere instead of deleting them.)
-
-@code{ALTER TABLE} works the following way:
-
-@itemize @bullet
-@item Create a new table named @file{A-xxx} with the requested changes.
-@item All rows from the old table are copied to @file{A-xxx}.
-@item The old table is renamed @file{B-xxx}.
-@item @file{A-xxx} is renamed to your old table name.
-@item @file{B-xxx} is deleted.
-@end itemize
-
-If something goes wrong with the renaming operation, @strong{MySQL} tries to
-undo the changes. If something goes seriously wrong (this shouldn't happen,
-of course), @strong{MySQL} may leave the old table as @file{B-xxx}, but a
-simple rename on the system level should get your data back.
-
-@cindex reordering, columns
-@cindex columns, changing
-@cindex changing, column order
-@cindex tables, changing column order
-@node Change column order, Temporary table problems, ALTER TABLE problems, Problems
-@section How To Change the Order of Columns in a Table
-
-The whole point of SQL is to abstract the application from the data
-storage format. You should always specify the order in which you wish to
-retrieve your data. For example:
-
-@example
-SELECT col_name1, col_name2, col_name3 FROM tbl_name;
-@end example
-
-will return columns in the order @code{col_name1}, @code{col_name2}, @code{col_name3}, whereas:
-
-@example
-SELECT col_name1, col_name3, col_name2 FROM tbl_name;
-@end example
-
-will return columns in the order @code{col_name1}, @code{col_name3}, @code{col_name2}.
-
-You should @strong{NEVER}, in an application, use @code{SELECT *} and
-retrieve the columns based on their position, because the order in which
-columns are returned @strong{CANNOT} be guaranteed over time. A simple
-change to your database may cause your application to fail rather
-dramatically.
-
-If you want to change the order of columns anyway, you can do it as follows:
-
-@enumerate
-@item
-Create a new table with the columns in the right order.
-@item
-Execute
-@code{INSERT INTO new_table SELECT fields-in-new_table-order FROM old_table}.
-@item
-Drop or rename @code{old_table}.
-@item
-@code{ALTER TABLE new_table RENAME old_table}.
-@end enumerate
-
-@cindex temporary tables, problems
-@node Temporary table problems, , Change column order, Problems
-@section TEMPORARY TABLE problems
-
-The following are a list of the limitations with @code{TEMPORARY TABLES}.
-
-@itemize @bullet
-@item
-A temporary table can only be of type @code{HEAP}, @code{ISAM} or
-@code{MyISAM}.
-@item
-You can't use temporary tables more than once in the same query.
-For example, the following doesn't work.
-
-@example
-select * from temporary_table, temporary_table as t2;
-@end example
-
-We plan to fix the above in 4.0.
-@item
-You can't use @code{RENAME} on a @code{TEMPORARY} table.
-Note that @code{ALTER TABLE org_name RENAME new_name} works!
-
-We plan to fix the above in 4.0.
-@end itemize
-
-@cindex problems, solving
-@cindex solving, problems
-@cindex databases, replicating
-@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
-* Multiple servers:: Running multiple @strong{MySQL} servers on the same machine
-@end menu
-
-In this chapter, you will find information to solve some of the more common
-tasks with @strong{MySQL}. This includes making backups, running more than
-one @strong{MySQL} server daemon on a single machine, and replicating a
-database using the update or binary logs.
-
-@cindex database replication
-@cindex replication, database
-@node Log Replication, Backup, Common problems, Common problems
-@section Database Replication with Update Log
-
-Now that master-slave internal replication is available starting in
-Version 3.23.15, using the update log to implement replications is not
-recommended. @xref{Replication}.
-
-However, it is still possible to replicate a database by using the
-update log or the binary log. @xref{Update log}. This requires one
-database that acts as a master (to which data changes are made) and one
-or more other databases that act as slaves. To update a slave, just run
-@code{mysql < update_log.*} or @code{mysqlbinlog binary_log.* | mysql}.
-Supply host, user, and password options that are appropriate for the
-slave database, and use the update log from the master database as
-input.
-
-If you never delete anything from a table, you can use a @code{TIMESTAMP}
-column to find out which rows have been inserted or changed in the table
-since the last replication (by comparing the time when you did the
-replication last time) and only copy these rows to the mirror.
-
-It is possible to make a two-way updating system using both the update
-log (for deletes) and timestamps (on both sides). But in that case you
-must be able to handle conflicts when the same data have been changed in
-both ends. You probably want to keep the old version to help with
-deciding what has been updated.
-
-Because replication in this case is done with SQL statements, you should not
-use the following functions in statements that update the database; they may
-not return the same value as in the original database:
-
-@itemize @bullet
-@item @code{DATABASE()}
-@item @code{GET_LOCK()} and @code{RELEASE_LOCK()}
-@item @code{RAND()}
-@item @code{USER()}, @code{SYSTEM_USER()} or @code{SESSION_USER()}
-@item @code{VERSION()}, @code{CONNECT_ID()}
-@end itemize
-
-All time functions are safe to use, as the timestamp is sent to the
-mirror if needed. @code{LAST_INSERT_ID()} is also safe to use.
-
-@cindex databases, backups
-@cindex backups
-@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
-backup. To get a consistent backup, do a @code{LOCK TABLES} on the
-relevant tables followed by @code{FLUSH TABLES} for the tables.
-@xref{LOCK TABLES, , @code{LOCK TABLES}}.
-@xref{FLUSH, , @code{FLUSH}}.
-You only need a read lock; this allows other threads to continue to
-query the tables while you are making a copy of the files in the
-database directory. The @code{FLUSH TABLE} is needed to ensure that
-the all active index pages is written to disk before you start the backup.
-
-If you want to make a SQL level backup of a table, you can use
-@code{SELECT INTO OUTFILE} or @code{BACKUP TABLE}. @xref{SELECT}.
-@xref{BACKUP TABLE}.
-
-Another way to back up a database is to use the @code{mysqldump} program or
-the @code{mysqlhotcopy script}. @xref{mysqldump, , @code{mysqldump}}.
-@xref{mysqlhotcopy, , @code{mysqlhotcopy}}.
-
-@enumerate
-@item
-Do a full backup of your databases:
-
-@example
-shell> mysqldump --tab=/path/to/some/dir --opt --full
-
-or
-
-shell> mysqlhotcopy database /path/to/some/dir
-@end example
-
-You can also simply copy all table files (@file{*.frm}, @file{*.MYD}, and
-@file{*.MYI} files) as long as the server isn't updating anything.
-The script @code{mysqlhotcopy} does use this method.
-
-@item
-@cindex log files, names
-Stop @code{mysqld} if it's running, then start it with the
-@code{--log-update[=file_name]} option. @xref{Update log}. The update
-log file(s) provide you with the information you need to replicate
-changes to the database that are made subsequent to the point at which
-you executed @code{mysqldump}.
-@end enumerate
-
-If you have to restore something, try to recover your tables using
-@code{REPAIR TABLE} or @code{myisamchk -r} first. That should work in
-99.9% of all cases. If @code{myisamchk} fails, try the following
-procedure: (This will only work if you have started @strong{MySQL} with
-@code{--log-update}. @xref{Update log}.):
-
-@enumerate
-@item
-Restore the original @code{mysqldump} backup.
-@item
-Execute the following command to re-run the updates in the binary log:
-
-@example
-shell> mysqlbinlog hostname-bin.[0-9]* | mysql
-@end example
-
-If you are using the update log you can use:
-
-@example
-shell> ls -1 -t -r hostname.[0-9]* | xargs cat | mysql
-@end example
-@end enumerate
-
-@code{ls} is used to get all the update log files in the right order.
-
-You can also do selective backups with @code{SELECT * INTO OUTFILE 'file_name'
-FROM tbl_name} and restore with @code{LOAD DATA INFILE 'file_name' REPLACE
-...} To avoid duplicate records, you need a @code{PRIMARY KEY} or a
-@code{UNIQUE} key in the table. The @code{REPLACE} keyword causes old records
-to be replaced with new ones when a new record duplicates an old record on
-a unique key value.
-
-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}.
-
-If you are using a Veritas file system, you can do:
-
-@enumerate
-@item
-Execute in a client (perl ?) @code{FLUSH TABLES WITH READ LOCK}
-@item
-Fork a shell or execute in another client @code{mount vxfs snapshot}.
-@item
-Execute in the first client @code{UNLOCK TABLES}
-@item
-Copy files from snapshot
-@item
-Unmount snapshot
-@end enumerate
-
-@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, ,
-@code{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 used by any currently executing @strong{MySQL} server
-with this command:
-
-@example
-shell> mysqladmin -h hostname --port=port_number variables
-@end example
-
-Note that if you specify ``@code{localhost}'' as a hostname, @code{mysqladmin}
-will default to using Unix sockets instead of TCP/IP.
-
-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_number} to connect
-with TCP/IP, or @code{[--host localhost] --socket=file_name} to connect via
-a Unix socket.
-
-@item
-In your C or Perl programs, you can give the port or socket arguments
-when connecting to the @strong{MySQL} server.
-
-@item
-If your are using the Perl @code{DBD::mysql} 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;mysql_read_default_file=/usr/local/mysql/data/my.cnf"
-$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 several different log files that 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 @code{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 Deprecated: 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} data directory. You can
-force @code{mysqld} 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\data\mysql.err}).
-
-This contains information indicating when @code{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 automatically checked or repaired.
-
-On some operating systems, the error log will contain a stack trace
-for where @code{mysqld} died. This can be used to find out where
-@code{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 @file{'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 sent to it.
-
-By default, the @code{mysql.server} script starts the @strong{MySQL}
-server with the @code{-l} option. If you need better performance when
-you start using @strong{MySQL} in a production environment, you can
-remove the @code{-l} option from @code{mysql.server} or change it to
-@code{--log-binary}.
-
-The entries in this log are written as @code{mysqld} receives the questions.
-This may be different than the order in which the statements are executed.
-This is in contrast to the update log and the binary log which are written
-after the query is executed, but before any locks are released.
-
-@cindex update log
-@cindex files, update log
-@node Update log, Binary log, Query log, Log files
-@section The Update Log
-
-@strong{NOTE}: The update log is replaced by the binary
-log. @xref{Binary log}. With this you can do anything that you can do
-with the update log.
-
-When started with the @code{--log-update[=file_name]} option,
-@code{mysqld} writes a log file containing all SQL commands that update
-data. If no filename is given, it defaults to the name of the host
-machine. If a filename is given, but it doesn't contain a path, the file
-is written in the data directory. If @file{file_name} doesn't have an
-extension, @code{mysqld} will create log file names like so:
-@file{file_name.###}, where @code{###} is a number that is incremented each
-time you execute @code{mysqladmin refresh}, execute @code{mysqladmin
-flush-logs}, execute the @code{FLUSH LOGS} statement, or restart the server.
-
-@strong{NOTE:} For the above scheme to work, you should NOT create
-your own files with the same filename as the update log + some extensions
-that may be regarded as a number, in the directory used by the update log!
-
-If you use the @code{--log} or @code{-l} options, @code{mysqld} writes a
-general log with a filename of @file{hostname.log}, and restarts and
-refreshes do not cause a new log file to be generated (although it is closed
-and reopened). In this case you can copy it (on Unix) by doing:
-
-@example
-mv hostname.log hostname-old.log
-mysqladmin flush-logs
-cp hostname-old.log to-backup-directory
-rm hostname-old.log
-@end example
-
-Update logging is smart because it logs only statements that really update
-data. So an @code{UPDATE} or a @code{DELETE} with a @code{WHERE} that finds no
-rows is not written to the log. It even skips @code{UPDATE} statements that
-set a column to the value it already has.
-
-The update logging is done immediately after a query completes but before
-any locks are released or any commit is done. This ensures that the log
-will be logged in the execution order.
-
-If you want to update a database from update log files, you could do the
-following (assuming your update logs have names of the form
-@file{file_name.###}):
-
-@example
-shell> ls -1 -t -r file_name.[0-9]* | xargs cat | mysql
-@end example
-
-@code{ls} is used to get all the log files in the right order.
-
-This can be useful if you have to revert to backup files after a crash
-and you want to redo the updates that occurred between the time of the backup
-and the crash.
-
-@cindex binary log
-@cindex files, binary log
-@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
-recommend you to switch to this log format as soon as possible!
-
-The binary log contains all information that is available in the update
-log in a more efficient format. It also contains information about how long
-every query that updated the database took.
-
-The binary log is also used when you are replicating a slave from a master.
-@xref{Replication}.
-
-When started with the @code{--log-bin[=file_name]} option, @code{mysqld}
-writes a log file containing all SQL commands that update data. If no
-file name is given, it defaults to the name of the host machine followed
-by @code{-bin}. If file name is given, but it doesn't contain a path, the
-file is written in the data directory.
-
-You can use the following options to @code{mysqld} to affect what is logged
-to the binary log:
-
-@multitable @columnfractions .4 .6
-@item @code{binlog-do-db=database_name} @tab
-Tells the master it should log updates for the specified database, and
-exclude all others not explicitly mentioned.
-(Example: @code{binlog-do-db=some_database})
-
-@item @code{binlog-ignore-db=database_name} @tab
-Tells the master that updates to the given database should not be logged
-to the binary log (Example: @code{binlog-ignore-db=some_database})
-@end multitable
-
-To the binary log filename @code{mysqld} will append an extension that is a
-number that is incremented each time you execute @code{mysqladmin
-refresh}, execute @code{mysqladmin flush-logs}, execute the @code{FLUSH LOGS}
-statement or restart the server.
-
-To be able to know which different binary log files have been used,
-@code{mysqld} will also create a binary log index file that
-contains the name of all used binary log files. By default this has the
-same name as the binary log file, with the extension @code{'.index'}.
-You can change the name of the binary log index file with the
-@code{--log-bin-index=[filename]} option.
-
-If you are using replication, you should not delete old binary log
-files until you are sure that no slave will ever need to use them.
-One way to do this is to do @code{mysqladmin flush-logs} once a day and then
-remove any logs that are more than 3 days old.
-
-You can examine the binary log file with the @code{mysqlbinlog} command.
-For example, you can update a @strong{MySQL} server from the binary log
-as follows:
-
-@example
-mysqlbinlog log-file | mysql -h server_name
-@end example
-
-You can also use the @code{mysqlbinlog} program to read the binary log
-directly from a remote @strong{MySQL} server!
-
-@code{mysqlbinlog --help} will give you more information of how to use
-this program!
-
-If you are using @code{BEGIN [WORK]} or @code{SET AUTOCOMMIT=0}, you must
-use the @strong{MySQL} binary log for backups instead of the old update log.
-
-The binary logging is done immediately after a query completes but before
-any locks are released or any commit is done. This ensures that the log
-will be logged in the execution order.
-
-All updates (@code{UPDATE}, @code{DELETE} or @code{INSERT}) that change
-a transactional table (like BDB tables) are cached until a @code{COMMIT}.
-Any updates to a non-transactional table are stored in the binary log at
-once. Every thread will, on start, allocate a buffer of
-@code{binlog_cache_size} to buffer queries. If a query is bigger than
-this, the thread will open a temporary file to handle the bigger cache.
-The temporary file will be deleted when the thread ends.
-
-The @code{max_binlog_cache_size} can be used to restrict the total size used
-to cache a multi-transaction query.
-
-If you are using the update or binary log, concurrent inserts will
-not work together with @code{CREATE ... INSERT} and @code{INSERT ... SELECT}.
-This is to ensure that you can recreate an exact copy of your tables by
-applying the log on a backup.
-
-@cindex slow query log
-@cindex files, slow query log
-@node Slow query log, , Binary log, Log files
-@section The Slow Query Log
-
-When started with the @code{--log-slow-queries[=file_name]} option,
-@code{mysqld} writes a log file containing all SQL commands that took
-more than @code{long_query_time} to execute. The time to get the initial
-table locks are not counted as execution time.
-
-The slow query log is logged after the query is executed and after all
-locks has been released. This may be different than the order in which
-the statements are executed.
-
-If no file name is given, it defaults to the name of the host machine
-suffixed with @code{-slow.log}. If a filename is given, but doesn't
-contain a path, the file is written in the data directory.
-
-The slow query log can be used to find queries that take a long time to
-execute and are thus candidates for optimization.
-
-You are using @code{--log-long-format} then also queries that are not
-using indexes are printed. @xref{Command-line options}.
-@cindex database replication
-@cindex replication, database
-@cindex database mirroring
-@cindex mirroring, database
-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 client tools
-@cindex APIs
-@cindex @code{mysqlclient} library
-@cindex buffer sizes, client
-@cindex library, @code{mysqlclient}
-@node Clients, Comparisons, Log files, Top
-@chapter MySQL APIs
-
-@menu
-* C:: @strong{MySQL} C API
-* Perl:: @strong{MySQL} Perl API
-* Eiffel:: @strong{MySQL} Eiffel wrapper
-* Java:: @strong{MySQL} Java connectivity (JDBC)
-* PHP:: @strong{MySQL} PHP API
-* Cplusplus:: @strong{MySQL} C++ APIs
-* Python:: @strong{MySQL} Python APIs
-* Tcl:: @strong{MySQL} Tcl APIs
-@end menu
-
-This chapter describes the APIs available for @strong{MySQL}, where to get
-them, and how to use them. The C API is the most extensively covered, as it
-was developed by the @strong{MySQL} team, and is the basis for most of the
-other APIs.
+@node C, Cplusplus, ODBC, Clients
+@section MySQL C API
@cindex C API, datatypes
@cindex datatypes, C API
-@node C, Perl, Clients, Clients
-@section MySQL C API
@menu
* C API datatypes:: C API Datatypes
* C API function overview:: C API Function Overview
* C API functions:: C API Function Descriptions
-* C API problems::
-* Thread-safe clients::
+* C API problems:: Common questions and problems when using the C API
+* Building clients:: Building Client Programs
+* Thread-safe clients:: How to Make a Thread-safe Client
@end menu
-The C API code is distributed with @strong{MySQL}. It is included in the
+The C API code is distributed with MySQL. It is included in the
@code{mysqlclient} library and allows C programs to access a database.
-Many of the clients in the @strong{MySQL} source distribution are
+Many of the clients in the MySQL source distribution are
written in C. If you are looking for examples that demonstrate how to
use the C API, take a look at these clients. You can find these in the
-@code{clients} directory in the @strong{MySQL} source distribution.
+@code{clients} directory in the MySQL source distribution.
Most of the other client APIs (all except Java) use the @code{mysqlclient}
-library to communicate with the @strong{MySQL} server. This means that, for
+library to communicate with the MySQL server. This means that, for
example, you can take advantage of many of the same environment variables
that are used by other client programs, because they are referenced from the
-library. See @ref{Programs}, for a list of these variables.
+library. See @ref{Client-Side Scripts}, for a list of these variables.
The client has a maximum communication buffer size. The size of the buffer
that is allocated initially (16K bytes) is automatically increased up to the
@@ -39235,7 +39006,7 @@ client's default maximum is 16M, but the default maximum in the server is
@code{max_allowed_packet} parameter when the server is started. @xref{Server
parameters}.
-The @strong{MySQL} server shrinks each communication buffer to
+The MySQL server shrinks each communication buffer to
@code{net_buffer_length} bytes after each query. For clients, the size of
the buffer associated with a connection is not decreased until the connection
is closed, at which time client memory is reclaimed.
@@ -39243,14 +39014,15 @@ is closed, at which time client memory is reclaimed.
For programming with threads, consult the 'how to make a thread-safe
client' chapter. @xref{Thread-safe clients}.
+
@node C API datatypes, C API function overview, C, C
@subsection C API Datatypes
-@table @code
+@table @code
@tindex MYSQL C type
@item MYSQL
This structure represents a handle to one database connection. It is
-used for almost all @strong{MySQL} functions.
+used for almost all MySQL functions.
@tindex MYSQL_RES C type
@item MYSQL_RES
@@ -39278,7 +39050,7 @@ this structure; they are contained in a @code{MYSQL_ROW} structure.
@tindex MYSQL_FIELD_OFFSET C type
@item MYSQL_FIELD_OFFSET
-This is a type-safe representation of an offset into a @strong{MySQL} field
+This is a type-safe representation of an offset into a MySQL field
list. (Used by @code{mysql_field_seek()}.) Offsets are field numbers
within a row, beginning at zero.
@@ -39405,11 +39177,13 @@ status of the @code{flags} value:
The number of decimals for numeric fields.
@end table
-@cindex C API, functions
-@cindex functions, C API
+
@node C API function overview, C API functions, C API datatypes, C
@subsection C API Function Overview
+@cindex C API, functions
+@cindex functions, C API
+
The functions available in the C API are listed below and are described in
greater detail in the next section.
@xref{C API functions}.
@@ -39423,7 +39197,7 @@ Returns the number of rows changed/deleted/inserted by the last @code{UPDATE},
Closes a server connection.
@item @strong{mysql_connect()} @tab
-Connects to a @strong{MySQL} server. This function is deprecated; use
+Connects to a MySQL server. This function is deprecated; use
@code{mysql_real_connect()} instead.
@item @strong{mysql_change_user()} @tab
@@ -39455,10 +39229,10 @@ This function is deprecated; @code{mysql_errno()} or @code{mysql_error()}
may be used instead.
@item @strong{mysql_errno()} @tab
-Returns the error number for the most recently invoked @strong{MySQL} function.
+Returns the error number for the most recently invoked MySQL function.
@item @strong{mysql_error()} @tab
-Returns the error message for the most recently invoked @strong{MySQL} function.
+Returns the error message for the most recently invoked MySQL function.
@item @strong{mysql_real_escape_string()} @tab
Escapes special characters in a string for use in a SQL statement taking
@@ -39549,7 +39323,7 @@ as necessary.
Executes a SQL query specified as a null-terminated string.
@item @strong{mysql_real_connect()} @tab
-Connects to a @strong{MySQL} server.
+Connects to a MySQL server.
@item @strong{mysql_real_query()} @tab
Executes a SQL query specified as a counted string.
@@ -39679,12 +39453,13 @@ changed by calling @code{mysql_field_seek()}. Setting the field cursor
affects subsequent calls to @code{mysql_fetch_field()}. You can also get
information for fields all at once by calling @code{mysql_fetch_fields()}.
-For detecting and reporting errors, @strong{MySQL} provides access to error
+For detecting and reporting errors, MySQL provides access to error
information by means of the @code{mysql_errno()} and @code{mysql_error()}
functions. These return the error code or error message for the most
recently invoked function that can succeed or fail, allowing you to determine
when an error occurred and what it was.
+
@node C API functions, C API problems, C API function overview, C
@subsection C API Function Descriptions
@@ -39745,7 +39520,7 @@ when an error occurred and what it was.
In the descriptions below, a parameter or return value of @code{NULL} means
@code{NULL} in the sense of the C programming language, not a
-@strong{MySQL} @code{NULL} value.
+MySQL @code{NULL} value.
Functions that return a value generally return a pointer or an integer.
Unless specified otherwise, functions returning a pointer return a
@@ -39772,10 +39547,12 @@ find out which of these occurred by calling @code{mysql_errno()}.
A string representation of the error may be obtained by calling
@code{mysql_error()}.
-@findex @code{mysql_affected_rows()}
+
@node mysql_affected_rows, mysql_close, C API functions, C API functions
@subsubsection @code{mysql_affected_rows()}
+@findex @code{mysql_affected_rows()}
+
@code{my_ulonglong mysql_affected_rows(MYSQL *mysql)}
@subsubheading Description
@@ -39817,10 +39594,12 @@ Note that when one uses a @code{REPLACE} command,
old row. This is because in this case one row was inserted and then the
duplicate was deleted.
-@findex @code{mysql_close()}
+
@node mysql_close, mysql_connect, mysql_affected_rows, C API functions
@subsubsection @code{mysql_close()}
+@findex @code{mysql_close()}
+
@code{void mysql_close(MYSQL *mysql)}
@subsubheading Description
@@ -39836,10 +39615,12 @@ None.
None.
-@findex @code{mysql_connect()}
+
@node mysql_connect, mysql_change_user, mysql_close, C API functions
@subsubsection @code{mysql_connect()}
+@findex @code{mysql_connect()}
+
@code{MYSQL *mysql_connect(MYSQL *mysql, const char *host, const char *user, const char *passwd)}
@subsubheading Description
@@ -39847,7 +39628,7 @@ None.
This function is deprecated. It is preferable to use
@code{mysql_real_connect()} instead.
-@code{mysql_connect()} attempts to establish a connection to a @strong{MySQL}
+@code{mysql_connect()} attempts to establish a connection to a MySQL
database engine running on @code{host}. @code{mysql_connect()} must complete
successfully before you can execute any of the other API functions, with the
exception of @code{mysql_get_client_info()}.
@@ -39869,10 +39650,12 @@ Same as for @code{mysql_real_connect()}.
Same as for @code{mysql_real_connect()}.
-@findex @code{mysql_change_user()}
+
@node mysql_change_user, mysql_character_set_name, mysql_connect, C API functions
@subsubsection @code{mysql_change_user()}
+@findex @code{mysql_change_user()}
+
@code{my_bool mysql_change_user(MYSQL *mysql, const char *user, const
char *password, const char *db)}
@@ -39883,7 +39666,7 @@ become the default (current) database on the connection specified by
@code{mysql}. In subsequent queries, this database is the default for
table references that do not include an explicit database specifier.
-This function was introduced in @strong{MySQL} Version 3.23.3.
+This function was introduced in MySQL Version 3.23.3.
@code{mysql_change_user()} fails unless the connected user can be
authenticated or if he doesn't have permission to use the database. In
@@ -39904,13 +39687,13 @@ The same that you can get from @code{mysql_real_connect()}.
@item CR_COMMANDS_OUT_OF_SYNC
Commands were executed in an improper order.
@item CR_SERVER_GONE_ERROR
-The @strong{MySQL} server has gone away.
+The MySQL server has gone away.
@item CR_SERVER_LOST
The connection to the server was lost during the query.
@item CR_UNKNOWN_ERROR
An unknown error occurred.
@item ER_UNKNOWN_COM_ERROR
-The @strong{MySQL} server doesn't implement this command (probably an old server)
+The MySQL server doesn't implement this command (probably an old server)
@item ER_ACCESS_DENIED_ERROR
The user or password was wrong.
@item ER_BAD_DB_ERROR
@@ -39931,10 +39714,12 @@ if (mysql_change_user(&mysql, "user", "password", "new_database"))
@}
@end example
-@findex @code{mysql_character_set_name()}
+
@node mysql_character_set_name, mysql_create_db, mysql_change_user, C API functions
@subsubsection @code{mysql_character_set_name()}
+@findex @code{mysql_character_set_name()}
+
@code{const char *mysql_character_set_name(MYSQL *mysql)}
@subsubheading Description
@@ -39949,10 +39734,11 @@ The default character set
None.
-@findex @code{mysql_create_db()}
@node mysql_create_db, mysql_data_seek, mysql_character_set_name, C API functions
@subsubsection @code{mysql_create_db()}
+@findex @code{mysql_create_db()}
+
@code{int mysql_create_db(MYSQL *mysql, const char *db)}
@subsubheading Description
@@ -39973,7 +39759,7 @@ occurred.
Commands were executed in an improper order.
@item CR_SERVER_GONE_ERROR
-The @strong{MySQL} server has gone away.
+The MySQL server has gone away.
@item CR_SERVER_LOST
The connection to the server was lost during the query.
@@ -39992,10 +39778,12 @@ if(mysql_create_db(&mysql, "my_database"))
@}
@end example
-@findex @code{mysql_data_seek()}
+
@node mysql_data_seek, mysql_debug, mysql_create_db, C API functions
@subsubsection @code{mysql_data_seek()}
+@findex @code{mysql_data_seek()}
+
@code{void mysql_data_seek(MYSQL_RES *result, unsigned long long offset)}
@subsubheading Description
@@ -40014,10 +39802,12 @@ None.
@subsubheading Errors
None.
-@findex @code{mysql_debug()}
+
@node mysql_debug, mysql_drop_db, mysql_data_seek, C API functions
@subsubsection @code{mysql_debug()}
+@findex @code{mysql_debug()}
+
@code{void mysql_debug(char *debug)}
@subsubheading Description
@@ -40042,10 +39832,12 @@ The call shown below causes the client library to generate a trace file in
mysql_debug("d:t:O,/tmp/client.trace");
@end example
-@findex @code{mysql_drop_db()}
+
@node mysql_drop_db, mysql_dump_debug_info, mysql_debug, C API functions
@subsubsection @code{mysql_drop_db()}
+@findex @code{mysql_drop_db()}
+
@code{int mysql_drop_db(MYSQL *mysql, const char *db)}
@subsubheading Description
@@ -40065,7 +39857,7 @@ occurred.
@item CR_COMMANDS_OUT_OF_SYNC
Commands were executed in an improper order.
@item CR_SERVER_GONE_ERROR
-The @strong{MySQL} server has gone away.
+The MySQL server has gone away.
@item CR_SERVER_LOST
The connection to the server was lost during the query.
@item CR_UNKNOWN_ERROR
@@ -40080,10 +39872,12 @@ if(mysql_drop_db(&mysql, "my_database"))
mysql_error(&mysql));
@end example
-@findex @code{mysql_dump_debug_info()}
+
@node mysql_dump_debug_info, mysql_eof, mysql_drop_db, C API functions
@subsubsection @code{mysql_dump_debug_info()}
+@findex @code{mysql_dump_debug_info()}
+
@code{int mysql_dump_debug_info(MYSQL *mysql)}
@subsubheading Description
@@ -40100,17 +39894,19 @@ Zero if the command was successful. Non-zero if an error occurred.
@item CR_COMMANDS_OUT_OF_SYNC
Commands were executed in an improper order.
@item CR_SERVER_GONE_ERROR
-The @strong{MySQL} server has gone away.
+The MySQL server has gone away.
@item CR_SERVER_LOST
The connection to the server was lost during the query.
@item CR_UNKNOWN_ERROR
An unknown error occurred.
@end table
-@findex @code{mysql_eof()}
+
@node mysql_eof, mysql_errno, mysql_dump_debug_info, C API functions
@subsubsection @code{mysql_eof()}
+@findex @code{mysql_eof()}
+
@code{my_bool mysql_eof(MYSQL_RES *result)}
@subsubheading Description
@@ -40136,7 +39932,7 @@ was reached normally. In this case, you can use @code{mysql_eof()} to
determine what happened. @code{mysql_eof()} returns a non-zero value if the
end of the result set was reached and zero if an error occurred.
-Historically, @code{mysql_eof()} predates the standard @strong{MySQL} error
+Historically, @code{mysql_eof()} predates the standard MySQL error
functions @code{mysql_errno()} and @code{mysql_error()}. Because those error
functions provide the same information, their use is preferred over
@code{mysql_eof()}, which is now deprecated. (In fact, they provide more
@@ -40168,7 +39964,7 @@ if(!mysql_eof(result)) // mysql_fetch_row() failed due to an error
@}
@end example
-However, you can achieve the same effect with the standard @strong{MySQL}
+However, you can achieve the same effect with the standard MySQL
error functions:
@example
@@ -40184,10 +39980,12 @@ if(mysql_errno(&mysql)) // mysql_fetch_row() failed due to an error
@}
@end example
-@findex @code{mysql_errno()}
+
@node mysql_errno, mysql_error, mysql_eof, C API functions
@subsubsection @code{mysql_errno()}
+@findex @code{mysql_errno()}
+
@code{unsigned int mysql_errno(MYSQL *mysql)}
@subsubheading Description
@@ -40195,9 +39993,9 @@ if(mysql_errno(&mysql)) // mysql_fetch_row() failed due to an error
For the connection specified by @code{mysql}, @code{mysql_errno()} returns
the error code for the most recently invoked API function that can succeed
or fail. A return value of zero means that no error occurred. Client error
-message numbers are listed in the @strong{MySQL} @file{errmsg.h} header file.
+message numbers are listed in the MySQL @file{errmsg.h} header file.
Server error message numbers are listed in @file{mysqld_error.h}. In the
-@strong{MySQL} source distribution you can find a complete list of
+MySQL source distribution you can find a complete list of
error messages and error numbers in the file @file{Docs/mysqld_error.txt}.
@subsubheading Return Values
@@ -40207,10 +40005,12 @@ An error code value. Zero if no error occurred.
@subsubheading Errors
None.
-@findex @code{mysql_error()}
+
@node mysql_error, mysql_escape_string, mysql_errno, C API functions
@subsubsection @code{mysql_error()}
+@findex @code{mysql_error()}
+
@code{char *mysql_error(MYSQL *mysql)}
@subsubheading Description
@@ -40233,7 +40033,7 @@ if(mysql_error(&mysql)[0] != '\0')
@end example
The language of the client error messages may be changed by
-recompiling the @strong{MySQL} client library. Currently you can choose
+recompiling the MySQL client library. Currently you can choose
error messages in several different languages.
@xref{Languages}.
@@ -40245,10 +40045,12 @@ occurred.
@subsubheading Errors
None.
-@findex @code{mysql_escape_string()}
+
@node mysql_escape_string, mysql_fetch_field, mysql_error, C API functions
@subsubsection @code{mysql_escape_string()}
+@findex @code{mysql_escape_string()}
+
You should use @code{mysql_real_escape_string()} instead!
This is identical to @code{mysql_real_escape_string()} except that it
@@ -40258,10 +40060,12 @@ according to the current character set while
@code{mysql_escape_string()} does not respect the current charset
setting.
-@findex @code{mysql_fetch_field()}
+
@node mysql_fetch_field, mysql_fetch_fields, mysql_escape_string, C API functions
@subsubsection @code{mysql_fetch_field()}
+@findex @code{mysql_fetch_field()}
+
@code{MYSQL_FIELD *mysql_fetch_field(MYSQL_RES *result)}
@subsubheading Description
@@ -40277,10 +40081,10 @@ field each time you execute a new @code{SELECT} query. The field returned by
@code{mysql_field_seek()}.
If you've called @code{mysql_query()} to perform a @code{SELECT} on a table
-but have not called @code{mysql_store_result()}, @strong{MySQL} returns the
+but have not called @code{mysql_store_result()}, MySQL returns the
default blob length (8K bytes) if you call @code{mysql_fetch_field()} to ask
for the length of a @code{BLOB} field. (The 8K size is chosen because
-@strong{MySQL} doesn't know the maximum length for the @code{BLOB}. This
+MySQL doesn't know the maximum length for the @code{BLOB}. This
should be made configurable sometime.) Once you've retrieved the result set,
@code{field->max_length} contains the length of the largest value for this
column in the specific query.
@@ -40304,10 +40108,12 @@ while((field = mysql_fetch_field(result)))
@}
@end example
-@findex @code{mysql_fetch_fields()}
+
@node mysql_fetch_fields, mysql_fetch_field_direct, mysql_fetch_field, C API functions
@subsubsection @code{mysql_fetch_fields()}
+@findex @code{mysql_fetch_fields()}
+
@code{MYSQL_FIELD *mysql_fetch_fields(MYSQL_RES *result)}
@subsubheading Description
@@ -40338,10 +40144,12 @@ for(i = 0; i < num_fields; i++)
@}
@end example
-@findex @code{mysql_fetch_field_direct()}
+
@node mysql_fetch_field_direct, mysql_fetch_lengths, mysql_fetch_fields, C API functions
@subsubsection @code{mysql_fetch_field_direct()}
+@findex @code{mysql_fetch_field_direct()}
+
@code{MYSQL_FIELD *mysql_fetch_field_direct(MYSQL_RES *result, unsigned int fieldnr)}
@subsubheading Description
@@ -40374,10 +40182,12 @@ for(i = 0; i < num_fields; i++)
@}
@end example
-@findex @code{mysql_fetch_lengths()}
+
@node mysql_fetch_lengths, mysql_fetch_row, mysql_fetch_field_direct, C API functions
@subsubsection @code{mysql_fetch_lengths()}
+@findex @code{mysql_fetch_lengths()}
+
@code{unsigned long *mysql_fetch_lengths(MYSQL_RES *result)}
@subsubheading Description
@@ -40424,10 +40234,12 @@ if (row)
@}
@end example
-@findex @code{mysql_fetch_row()}
+
@node mysql_fetch_row, mysql_field_count, mysql_fetch_lengths, C API functions
@subsubsection @code{mysql_fetch_row()}
+@findex @code{mysql_fetch_row()}
+
@code{MYSQL_ROW mysql_fetch_row(MYSQL_RES *result)}
@subsubheading Description
@@ -40484,13 +40296,15 @@ while ((row = mysql_fetch_row(result)))
@}
@end example
-@findex @code{mysql_field_count()}
+
@node mysql_field_count, mysql_field_seek, mysql_fetch_row, C API functions
@subsubsection @code{mysql_field_count()}
+@findex @code{mysql_field_count()}
+
@code{unsigned int mysql_field_count(MYSQL *mysql)}
-If you are using a version of @strong{MySQL} earlier than Version 3.22.24, you
+If you are using a version of MySQL earlier than Version 3.22.24, you
should use @code{unsigned int mysql_num_fields(MYSQL *mysql)} instead.
@subsubheading Description
@@ -40556,12 +40370,15 @@ error from @code{mysql_store_result()} rather than inferring from the value
of @code{mysql_field_count()} whether or not the statement was a
@code{SELECT}.
-@findex @code{mysql_field_seek()}
+
@node mysql_field_seek, mysql_field_tell, mysql_field_count, C API functions
@subsubsection @code{mysql_field_seek()}
+@findex @code{mysql_field_seek()}
+
@code{MYSQL_FIELD_OFFSET mysql_field_seek(MYSQL_RES *result, MYSQL_FIELD_OFFSET offset)}
+* Thread-safe clients:: How to Make a Thread-safe Client
@subsubheading Description
Sets the field cursor to the given offset. The next call to
@@ -40577,10 +40394,12 @@ The previous value of the field cursor.
@subsubheading Errors
None.
-@findex @code{mysql_field_tell()}
+
@node mysql_field_tell, mysql_free_result, mysql_field_seek, C API functions
@subsubsection @code{mysql_field_tell()}
+@findex @code{mysql_field_tell()}
+
@code{MYSQL_FIELD_OFFSET mysql_field_tell(MYSQL_RES *result)}
@subsubheading Description
@@ -40596,10 +40415,12 @@ The current offset of the field cursor.
@subsubheading Errors
None.
-@findex @code{mysql_free_result()}
+
@node mysql_free_result, mysql_get_client_info, mysql_field_tell, C API functions
@subsubsection @code{mysql_free_result()}
+@findex @code{mysql_free_result()}
+
@code{void mysql_free_result(MYSQL_RES *result)}
@subsubheading Description
@@ -40616,10 +40437,12 @@ None.
@subsubheading Errors
None.
-@findex @code{mysql_get_client_info()}
+
@node mysql_get_client_info, mysql_get_host_info, mysql_free_result, C API functions
@subsubsection @code{mysql_get_client_info()}
+@findex @code{mysql_get_client_info()}
+
@code{char *mysql_get_client_info(void)}
@subsubheading Description
@@ -40628,15 +40451,17 @@ Returns a string that represents the client library version.
@subsubheading Return Values
-A character string that represents the @strong{MySQL} client library version.
+A character string that represents the MySQL client library version.
@subsubheading Errors
None.
-@findex @code{mysql_get_host_info()}
+
@node mysql_get_host_info, mysql_get_proto_info, mysql_get_client_info, C API functions
@subsubsection @code{mysql_get_host_info()}
+@findex @code{mysql_get_host_info()}
+
@code{char *mysql_get_host_info(MYSQL *mysql)}
@subsubheading Description
@@ -40651,10 +40476,12 @@ A character string representing the server host name and the connection type.
@subsubheading Errors
None.
-@findex @code{mysql_get_proto_info()}
+
@node mysql_get_proto_info, mysql_get_server_info, mysql_get_host_info, C API functions
@subsubsection @code{mysql_get_proto_info()}
+@findex @code{mysql_get_proto_info()}
+
@code{unsigned int mysql_get_proto_info(MYSQL *mysql)}
@subsubheading Description
@@ -40669,10 +40496,12 @@ connection.
@subsubheading Errors
None.
-@findex @code{mysql_get_server_info()}
+
@node mysql_get_server_info, mysql_info, mysql_get_proto_info, C API functions
@subsubsection @code{mysql_get_server_info()}
+@findex @code{mysql_get_server_info()}
+
@code{char *mysql_get_server_info(MYSQL *mysql)}
@subsubheading Description
@@ -40686,10 +40515,12 @@ A character string that represents the server version number.
@subsubheading Errors
None.
-@findex @code{mysql_info()}
+
@node mysql_info, mysql_init, mysql_get_server_info, C API functions
@subsubsection @code{mysql_info()}
+@findex @code{mysql_info()}
+
@code{char *mysql_info(MYSQL *mysql)}
@subsubheading Description
@@ -40726,10 +40557,12 @@ query.
@subsubheading Errors
None.
-@findex @code{mysql_init()}
+
@node mysql_init, mysql_insert_id, mysql_info, C API functions
@subsubsection @code{mysql_init()}
+@findex @code{mysql_init()}
+
@code{MYSQL *mysql_init(MYSQL *mysql)}
@subsubheading Description
@@ -40749,10 +40582,12 @@ insufficient memory to allocate a new object.
@subsubheading Errors
In case of insufficient memory, @code{NULL} is returned.
-@findex @code{mysql_insert_id()}
+
@node mysql_insert_id, mysql_kill, mysql_init, C API functions
@subsubsection @code{mysql_insert_id()}
+@findex @code{mysql_insert_id()}
+
@code{my_ulonglong mysql_insert_id(MYSQL *mysql)}
@subsubheading Description
@@ -40780,10 +40615,12 @@ the query did not update an @code{AUTO_INCREMENT} value.
@subsubheading Errors
None.
-@findex @code{mysql_kill()}
+
@node mysql_kill, mysql_list_dbs, mysql_insert_id, C API functions
@subsubsection @code{mysql_kill()}
+@findex @code{mysql_kill()}
+
@code{int mysql_kill(MYSQL *mysql, unsigned long pid)}
@subsubheading Description
@@ -40800,17 +40637,19 @@ Zero for success. Non-zero if an error occurred.
@item CR_COMMANDS_OUT_OF_SYNC
Commands were executed in an improper order.
@item CR_SERVER_GONE_ERROR
-The @strong{MySQL} server has gone away.
+The MySQL server has gone away.
@item CR_SERVER_LOST
The connection to the server was lost during the query.
@item CR_UNKNOWN_ERROR
An unknown error occurred.
@end table
-@findex @code{mysql_list_dbs()}
+
@node mysql_list_dbs, mysql_list_fields, mysql_kill, C API functions
@subsubsection @code{mysql_list_dbs()}
+@findex @code{mysql_list_dbs()}
+
@code{MYSQL_RES *mysql_list_dbs(MYSQL *mysql, const char *wild)}
@subsubheading Description
@@ -40836,17 +40675,19 @@ Commands were executed in an improper order.
@item CR_OUT_OF_MEMORY
Out of memory.
@item CR_SERVER_GONE_ERROR
-The @strong{MySQL} server has gone away.
+The MySQL server has gone away.
@item CR_SERVER_LOST
The connection to the server was lost during the query.
@item CR_UNKNOWN_ERROR
An unknown error occurred.
@end table
-@findex @code{mysql_list_fields()}
+
@node mysql_list_fields, mysql_list_processes, mysql_list_dbs, C API functions
@subsubsection @code{mysql_list_fields()}
+@findex @code{mysql_list_fields()}
+
@code{MYSQL_RES *mysql_list_fields(MYSQL *mysql, const char *table, const char *wild)}
@subsubheading Description
@@ -40873,17 +40714,19 @@ A @code{MYSQL_RES} result set for success. @code{NULL} if an error occurred.
@item CR_COMMANDS_OUT_OF_SYNC
Commands were executed in an improper order.
@item CR_SERVER_GONE_ERROR
-The @strong{MySQL} server has gone away.
+The MySQL server has gone away.
@item CR_SERVER_LOST
The connection to the server was lost during the query.
@item CR_UNKNOWN_ERROR
An unknown error occurred.
@end table
-@findex @code{mysql_list_processes()}
+
@node mysql_list_processes, mysql_list_tables, mysql_list_fields, C API functions
@subsubsection @code{mysql_list_processes()}
+@findex @code{mysql_list_processes()}
+
@code{MYSQL_RES *mysql_list_processes(MYSQL *mysql)}
@subsubheading Description
@@ -40904,17 +40747,19 @@ A @code{MYSQL_RES} result set for success. @code{NULL} if an error occurred.
@item CR_COMMANDS_OUT_OF_SYNC
Commands were executed in an improper order.
@item CR_SERVER_GONE_ERROR
-The @strong{MySQL} server has gone away.
+The MySQL server has gone away.
@item CR_SERVER_LOST
The connection to the server was lost during the query.
@item CR_UNKNOWN_ERROR
An unknown error occurred.
@end table
-@findex @code{mysql_list_tables()}
+
@node mysql_list_tables, mysql_num_fields, mysql_list_processes, C API functions
@subsubsection @code{mysql_list_tables()}
+@findex @code{mysql_list_tables()}
+
@code{MYSQL_RES *mysql_list_tables(MYSQL *mysql, const char *wild)}
@subsubheading Description
@@ -40938,25 +40783,27 @@ A @code{MYSQL_RES} result set for success. @code{NULL} if an error occurred.
@item CR_COMMANDS_OUT_OF_SYNC
Commands were executed in an improper order.
@item CR_SERVER_GONE_ERROR
-The @strong{MySQL} server has gone away.
+The MySQL server has gone away.
@item CR_SERVER_LOST
The connection to the server was lost during the query.
@item CR_UNKNOWN_ERROR
An unknown error occurred.
@end table
-@findex @code{mysql_num_fields()}
-@findex @code{mysql_field_count()}
+
@node mysql_num_fields, mysql_num_rows, mysql_list_tables, C API functions
@subsubsection @code{mysql_num_fields()}
+@findex @code{mysql_num_fields()}
+@findex @code{mysql_field_count()}
+
@code{unsigned int mysql_num_fields(MYSQL_RES *result)}
or
@code{unsigned int mysql_num_fields(MYSQL *mysql)}
-The second form doesn't work on @strong{MySQL} Version 3.22.24 or newer. To pass a
+The second form doesn't work on MySQL Version 3.22.24 or newer. To pass a
@code{MYSQL*} argument, you must use
@code{unsigned int mysql_field_count(MYSQL *mysql)} instead.
@@ -41023,10 +40870,12 @@ is to replace the @code{mysql_errno(&mysql)} call with a check if
@code{mysql_field_count(&mysql)} is = 0. This will only happen if something
went wrong.
-@findex @code{mysql_num_rows()}
+
@node mysql_num_rows, mysql_options, mysql_num_fields, C API functions
@subsubsection @code{mysql_num_rows()}
+@findex @code{mysql_num_rows()}
+
@code{my_ulonglong mysql_num_rows(MYSQL_RES *result)}
@subsubheading Description
@@ -41047,10 +40896,12 @@ The number of rows in the result set.
@subsubheading Errors
None.
-@findex @code{mysql_options()}
+
@node mysql_options, mysql_ping, mysql_num_rows, C API functions
@subsubsection @code{mysql_options()}
+@findex @code{mysql_options()}
+
@code{int mysql_options(MYSQL *mysql, enum mysql_option option, const char *arg)}
@subsubheading Description
@@ -41071,8 +40922,8 @@ Possible options values:
@item @strong{Option} @tab @strong{Argument type} @tab @strong{Function}
@item @code{MYSQL_OPT_CONNECT_TIMEOUT} @tab @code{unsigned int *} @tab Connect timeout in seconds.
@item @code{MYSQL_OPT_COMPRESS} @tab Not used @tab Use the compressed client/server protocol.
-@item @code{MYSQL_OPT_NAMED_PIPE} @tab Not used @tab Use named pipes to connect to a @strong{MySQL} server on NT.
-@item @code{MYSQL_INIT_COMMAND} @tab @code{char *} @tab Command to execute when connecting to the @strong{MySQL} server. Will automatically be re-executed when reconnecting.
+@item @code{MYSQL_OPT_NAMED_PIPE} @tab Not used @tab Use named pipes to connect to a MySQL server on NT.
+@item @code{MYSQL_INIT_COMMAND} @tab @code{char *} @tab Command to execute when connecting to the MySQL server. Will automatically be re-executed when reconnecting.
@item @code{MYSQL_READ_DEFAULT_FILE} @tab @code{char *} @tab Read options from the named option file instead of from @file{my.cnf}.
@item @code{MYSQL_READ_DEFAULT_GROUP} @tab @code{char *} @tab Read options from the named group from @file{my.cnf} or the file specified with @code{MYSQL_READ_DEFAULT_FILE}.
@end multitable
@@ -41088,10 +40939,10 @@ The specified group in the option file may contain the following options:
@item @code{database} @tab Connect to this database if no database was specified in the connect command.
@item @code{debug} @tab Debug options.
@item @code{host} @tab Default host name.
-@item @code{init-command} @tab Command to execute when connecting to @strong{MySQL} server. Will automatically be re-executed when reconnecting.
+@item @code{init-command} @tab Command to execute when connecting to MySQL server. Will automatically be re-executed when reconnecting.
@item @code{interactive-timeout} @tab Same as specifying @code{CLIENT_INTERACTIVE} to @code{mysql_real_connect()}. @xref{mysql_real_connect}.
@item @code{password} @tab Default password.
-@item @code{pipe} @tab Use named pipes to connect to a @strong{MySQL} server on NT.
+@item @code{pipe} @tab Use named pipes to connect to a MySQL server on NT.
@item @code{port} @tab Default port number.
@item @code{return-found-rows} @tab Tell @code{mysql_info()} to return found rows instead of updated rows when using @code{UPDATE}.
@item @code{socket} @tab Default socket number.
@@ -41127,10 +40978,12 @@ The above requests the client to use the compressed client/server protocol and
read the additional options from the @code{odbc} section in the @code{my.cnf}
file.
-@findex @code{mysql_ping()}
+
@node mysql_ping, mysql_query, mysql_options, C API functions
@subsubsection @code{mysql_ping()}
+@findex @code{mysql_ping()}
+
@code{int mysql_ping(MYSQL *mysql)}
@subsubheading Description
@@ -41152,15 +41005,17 @@ Zero if the server is alive. Non-zero if an error occurred.
@item CR_COMMANDS_OUT_OF_SYNC
Commands were executed in an improper order.
@item CR_SERVER_GONE_ERROR
-The @strong{MySQL} server has gone away.
+The MySQL server has gone away.
@item CR_UNKNOWN_ERROR
An unknown error occurred.
@end table
-@findex @code{mysql_query()}
+
@node mysql_query, mysql_real_connect, mysql_ping, C API functions
@subsubsection @code{mysql_query()}
+@findex @code{mysql_query()}
+
@code{int mysql_query(MYSQL *mysql, const char *query)}
@subsubheading Description
@@ -41187,17 +41042,19 @@ Zero if the query was successful. Non-zero if an error occurred.
@item CR_COMMANDS_OUT_OF_SYNC
Commands were executed in an improper order.
@item CR_SERVER_GONE_ERROR
-The @strong{MySQL} server has gone away.
+The MySQL server has gone away.
@item CR_SERVER_LOST
The connection to the server was lost during the query.
@item CR_UNKNOWN_ERROR
An unknown error occurred.
@end table
-@findex @code{mysql_real_connect()}
+
@node mysql_real_connect, mysql_real_escape_string, mysql_query, C API functions
@subsubsection @code{mysql_real_connect()}
+@findex @code{mysql_real_connect()}
+
@code{MYSQL *mysql_real_connect(MYSQL *mysql, const char *host,
const char *user, const char *passwd, const char *db,
unsigned int port, const char *unix_socket,
@@ -41206,7 +41063,7 @@ An unknown error occurred.
@subsubheading Description
@code{mysql_real_connect()} attempts to establish a connection to a
-@strong{MySQL} database engine running on @code{host}.
+MySQL database engine running on @code{host}.
@code{mysql_real_connect()} must complete successfully before you can execute
any of the other API functions, with the exception of
@code{mysql_get_client_info()}.
@@ -41228,7 +41085,7 @@ the local host is assumed. If the OS supports sockets (Unix) or named pipes
(Windows), they are used instead of TCP/IP to connect to the server.
@item
-The @code{user} parameter contains the user's @strong{MySQL} login ID. If
+The @code{user} parameter contains the user's MySQL login ID. If
@code{user} is @code{NULL}, the current user is assumed. Under Unix, this is
the current login name. Under Windows ODBC, the current user name must be
specified explicitly.
@@ -41238,7 +41095,7 @@ specified explicitly.
The @code{passwd} parameter contains the password for @code{user}. If
@code{passwd} is @code{NULL}, only entries in the @code{user} table for the
user that have a blank (empty) password field will be checked for a match. This
-allows the database administrator to set up the @strong{MySQL} privilege
+allows the database administrator to set up the MySQL privilege
system in such a way that users get different privileges depending on whether
or not they have specified a password.
@@ -41289,10 +41146,10 @@ pass @code{NULL} for that parameter.
@table @code
@item CR_CONN_HOST_ERROR
-Failed to connect to the @strong{MySQL} server.
+Failed to connect to the MySQL server.
@item CR_CONNECTION_ERROR
-Failed to connect to the local @strong{MySQL} server.
+Failed to connect to the local MySQL server.
@item CR_IPSOCK_ERROR
Failed to create an IP socket.
@@ -41342,20 +41199,22 @@ if (!mysql_real_connect(&mysql,"host","user","passwd","database",0,NULL,0))
@}
@end example
-By using @code{mysql_options()} the @strong{MySQL} library will read the
+By using @code{mysql_options()} the MySQL library will read the
@code{[client]} and @code{your_prog_name} sections in the @code{my.cnf}
file which will ensure that your program will work, even if someone has
-set up @strong{MySQL} in some non-standard way.
+set up MySQL in some non-standard way.
Note that upon connection, @code{mysql_real_connect()} sets the @code{reconnect}
flag (part of the MYSQL structure) to a value of @code{1}. This flag indicates,
in the event that a query cannot be performed because of a lost connection, to
try reconnecting to the server before giving up.
-@findex @code{mysql_real_escape_string()}
+
@node mysql_real_escape_string, mysql_real_query, mysql_real_connect, C API functions
@subsubsection @code{mysql_real_escape_string()}
+@findex @code{mysql_real_escape_string()}
+
@code{unsigned int mysql_real_escape_string(MYSQL *mysql, char *to, const char *from, unsigned int length)}
@subsubheading Description
@@ -41411,10 +41270,12 @@ terminating null character.
@subsubheading Errors
None.
-@findex @code{mysql_real_query()}
+
@node mysql_real_query, mysql_reload, mysql_real_escape_string, C API functions
@subsubsection @code{mysql_real_query()}
+@findex @code{mysql_real_query()}
+
@code{int mysql_real_query(MYSQL *mysql, const char *query, unsigned int length)}
@subsubheading Description
@@ -41444,22 +41305,24 @@ Zero if the query was successful. Non-zero if an error occurred.
@item CR_COMMANDS_OUT_OF_SYNC
Commands were executed in an improper order.
@item CR_SERVER_GONE_ERROR
-The @strong{MySQL} server has gone away.
+The MySQL server has gone away.
@item CR_SERVER_LOST
The connection to the server was lost during the query.
@item CR_UNKNOWN_ERROR
An unknown error occurred.
@end table
-@findex @code{mysql_reload()}
+
@node mysql_reload, mysql_row_seek, mysql_real_query, C API functions
@subsubsection @code{mysql_reload()}
+@findex @code{mysql_reload()}
+
@code{int mysql_reload(MYSQL *mysql)}
@subsubheading Description
-Asks the @strong{MySQL} server to reload the grant tables. The
+Asks the MySQL server to reload the grant tables. The
connected user must have the @strong{reload} privilege.
This function is deprecated. It is preferable to use @code{mysql_query()}
@@ -41475,17 +41338,19 @@ Zero for success. Non-zero if an error occurred.
@item CR_COMMANDS_OUT_OF_SYNC
Commands were executed in an improper order.
@item CR_SERVER_GONE_ERROR
-The @strong{MySQL} server has gone away.
+The MySQL server has gone away.
@item CR_SERVER_LOST
The connection to the server was lost during the query.
@item CR_UNKNOWN_ERROR
An unknown error occurred.
@end table
-@findex @code{mysql_row_seek()}
+
@node mysql_row_seek, mysql_row_tell, mysql_reload, C API functions
@subsubsection @code{mysql_row_seek()}
+@findex @code{mysql_row_seek()}
+
@code{MYSQL_ROW_OFFSET mysql_row_seek(MYSQL_RES *result, MYSQL_ROW_OFFSET offset)}
@subsubheading Description
@@ -41507,10 +41372,12 @@ subsequent call to @code{mysql_row_seek()}.
@subsubheading Errors
None.
-@findex @code{mysql_row_tell()}
+
@node mysql_row_tell, mysql_select_db, mysql_row_seek, C API functions
@subsubsection @code{mysql_row_tell()}
+@findex @code{mysql_row_tell()}
+
@code{MYSQL_ROW_OFFSET mysql_row_tell(MYSQL_RES *result)}
@subsubheading Description
@@ -41529,10 +41396,12 @@ The current offset of the row cursor.
@subsubheading Errors
None.
-@findex @code{mysql_select_db()}
+
@node mysql_select_db, mysql_shutdown, mysql_row_tell, C API functions
@subsubsection @code{mysql_select_db()}
+@findex @code{mysql_select_db()}
+
@code{int mysql_select_db(MYSQL *mysql, const char *db)}
@subsubheading Description
@@ -41555,17 +41424,19 @@ Zero for success. Non-zero if an error occurred.
@item CR_COMMANDS_OUT_OF_SYNC
Commands were executed in an improper order.
@item CR_SERVER_GONE_ERROR
-The @strong{MySQL} server has gone away.
+The MySQL server has gone away.
@item CR_SERVER_LOST
The connection to the server was lost during the query.
@item CR_UNKNOWN_ERROR
An unknown error occurred.
@end table
-@findex @code{mysql_shutdown()}
+
@node mysql_shutdown, mysql_stat, mysql_select_db, C API functions
@subsubsection @code{mysql_shutdown()}
+@findex @code{mysql_shutdown()}
+
@code{int mysql_shutdown(MYSQL *mysql)}
@subsubheading Description
@@ -41583,17 +41454,19 @@ Zero for success. Non-zero if an error occurred.
@item CR_COMMANDS_OUT_OF_SYNC
Commands were executed in an improper order.
@item CR_SERVER_GONE_ERROR
-The @strong{MySQL} server has gone away.
+The MySQL server has gone away.
@item CR_SERVER_LOST
The connection to the server was lost during the query.
@item CR_UNKNOWN_ERROR
An unknown error occurred.
@end table
-@findex @code{mysql_stat()}
+
@node mysql_stat, mysql_store_result, mysql_shutdown, C API functions
@subsubsection @code{mysql_stat()}
+@findex @code{mysql_stat()}
+
@code{char *mysql_stat(MYSQL *mysql)}
@subsubheading Description
@@ -41613,17 +41486,19 @@ error occurred.
@item CR_COMMANDS_OUT_OF_SYNC
Commands were executed in an improper order.
@item CR_SERVER_GONE_ERROR
-The @strong{MySQL} server has gone away.
+The MySQL server has gone away.
@item CR_SERVER_LOST
The connection to the server was lost during the query.
@item CR_UNKNOWN_ERROR
An unknown error occurred.
@end table
-@findex @code{mysql_store_result()}
+
@node mysql_store_result, mysql_thread_id, mysql_stat, C API functions
@subsubsection @code{mysql_store_result()}
+@findex @code{mysql_store_result()}
+
@code{MYSQL_RES *mysql_store_result(MYSQL *mysql)}
@subsubheading Description
@@ -41684,17 +41559,19 @@ Commands were executed in an improper order.
@item CR_OUT_OF_MEMORY
Out of memory.
@item CR_SERVER_GONE_ERROR
-The @strong{MySQL} server has gone away.
+The MySQL server has gone away.
@item CR_SERVER_LOST
The connection to the server was lost during the query.
@item CR_UNKNOWN_ERROR
An unknown error occurred.
@end table
-@findex @code{mysql_thread_id()}
+
@node mysql_thread_id, mysql_use_result, mysql_store_result, C API functions
@subsubsection @code{mysql_thread_id()}
+@findex @code{mysql_thread_id()}
+
@code{unsigned long mysql_thread_id(MYSQL *mysql)}
@subsubheading Description
@@ -41713,10 +41590,12 @@ The thread ID of the current connection.
@subsubheading Errors
None.
-@findex @code{mysql_use_result()}
+
@node mysql_use_result, , mysql_thread_id, C API functions
@subsubsection @code{mysql_use_result()}
+@findex @code{mysql_use_result()}
+
@code{MYSQL_RES *mysql_use_result(MYSQL *mysql)}
@subsubheading Description
@@ -41769,25 +41648,28 @@ Commands were executed in an improper order.
@item CR_OUT_OF_MEMORY
Out of memory.
@item CR_SERVER_GONE_ERROR
-The @strong{MySQL} server has gone away.
+The MySQL server has gone away.
@item CR_SERVER_LOST
The connection to the server was lost during the query.
@item CR_UNKNOWN_ERROR
An unknown error occurred.
@end table
-@node C API problems, Thread-safe clients, C API functions, C
+
+@node C API problems, Building clients, C API functions, C
@subsection Common questions and problems when using the C API
@tindex @code{mysql_query()}
@tindex @code{mysql_store_result()}
+
@menu
-* NULL mysql_store_result::
-* Query results::
-* Getting unique ID::
-* C API linking problems::
+* NULL mysql_store_result:: Why Is It that After @code{mysql_query()} Returns Success, @code{mysql_store_result()} Sometimes Returns @code{NULL?}
+* Query results:: What Results Can I Get From a Query?
+* Getting unique ID:: How Can I Get the Unique ID for the Last Inserted Row?
+* C API linking problems:: Problems Linking with the C API
@end menu
+
@node NULL mysql_store_result, Query results, C API problems, C API problems
@subsubsection Why Is It that After @code{mysql_query()} Returns Success, @code{mysql_store_result()} Sometimes Returns @code{NULL?}
@@ -41822,11 +41704,12 @@ You can test for an error by calling @code{mysql_error()} or
@cindex queries, C API results
@menu
-* Query results::
-* Getting unique ID::
-* C API linking problems::
+* Query results:: What Results Can I Get From a Query?
+* Getting unique ID:: How Can I Get the Unique ID for the Last Inserted Row?
+* C API linking problems:: Problems Linking with the C API
@end menu
+
@node Query results, Getting unique ID, NULL mysql_store_result, C API problems
@subsubsection What Results Can I Get From a Query?
@@ -41862,12 +41745,14 @@ for the format of the string that it returns. @code{mysql_info()} returns a
@code{NULL} pointer if there is no additional information.
@end itemize
+
+@node Getting unique ID, C API linking problems, Query results, C API problems
+@subsubsection How Can I Get the Unique ID for the Last Inserted Row?
+
@cindex unique ID
@cindex last row, unique ID
@cindex ID, unique
@cindex tables, unique ID for last row
-@node Getting unique ID, C API linking problems, Query results, C API problems
-@subsubsection How Can I Get the Unique ID for the Last Inserted Row?
If you insert a record in a table containing a column that has the
@code{AUTO_INCREMENT} attribute, you can get the most recently generated
@@ -41904,11 +41789,13 @@ INSERT INTO foo2 (id,text)
VALUES(LAST_INSERT_ID(),'text'); # use ID in second table
@end example
-@cindex linking, problems
-@cindex C API, linking problems
+
@node C API linking problems, , Getting unique ID, C API problems
@subsubsection Problems Linking with the C API
+@cindex linking, problems
+@cindex C API, linking problems
+
When linking with the C API, the following errors may occur on some systems:
@example
@@ -41923,10 +41810,33 @@ ld: fatal: Symbol referencing errors. No output written to client
If this happens on your system, you must include the math library by
adding @code{-lm} to the end of the compile/link line.
+
+@node Building clients, Thread-safe clients, C API problems, C
+@subsection Building Client Programs
+
+@cindex client programs, building
+@cindex linking
+@cindex building, client programs
+@cindex programs, client
+
+If you compile MySQL clients that you've written yourself or that
+you obtain from a third party, they must be linked using the
+@code{-lmysqlclient -lz} option on the link command. You may also need to
+specify a @code{-L} option to tell the linker where to find the library. For
+example, if the library is installed in @file{/usr/local/mysql/lib}, use
+@code{-L/usr/local/mysql/lib -lmysqlclient -lz} on the link command.
+
+For clients that use MySQL header files, you may need to specify a
+@code{-I} option when you compile them (for example,
+@code{-I/usr/local/mysql/include}), so the compiler can find the header
+files.
+
+
+@node Thread-safe clients, , Building clients, C
+@subsection How to Make a Thread-safe Client
+
@cindex clients, thread-safe
@cindex thread-safe clients
-@node Thread-safe clients, , C API problems, C
-@subsection How to Make a Thread-safe Client
The client library is almost thread safe. The biggest problem is
that the subroutines in @file{net.c} that read from sockets are not
@@ -41942,14 +41852,14 @@ Newer binary distributions should have both a normal and a
thread-safe client library.
To get a really thread-safe client where you can interrupt the client
-from other threads and set timeouts when talking with the @strong{MySQL}
+from other threads and set timeouts when talking with the MySQL
server, you should use the @code{-lmysys}, @code{-lstring}, and @code{-ldbug}
libraries and the @code{net_serv.o} code that the server uses.
If you don't need interrupts or timeouts, you can just compile a thread
safe client library @code{(mysqlclient_r)} and use this. @xref{C,,
MySQL C API}. In this case you don't have to worry about the
-@code{net_serv.o} object file or the other @strong{MySQL} libraries.
+@code{net_serv.o} object file or the other MySQL libraries.
When using a threaded client and you want to use timeouts and interrupts,
you can make great use of the routines in the @file{thr_alarm.c} file.
@@ -41977,7 +41887,7 @@ as you do the following:
@itemize @bullet
@item
-Two threads can't send a query to the @strong{MySQL} at the same time on
+Two threads can't send a query to the MySQL at the same time on
the same connection. In particular, you have to ensure that between a
@code{mysql_query()} and @code{mysql_store_result()} no other thread is using
the same connection.
@@ -42005,1631 +41915,811 @@ You may get some errors because of undefined symbols when linking your
client with @code{mysqlclient_r}. In most cases this is because you haven't
included the thread libraries on the link/compile line.
-@cindex APIs, Perl
-@cindex Perl API
-@node Perl, Eiffel, C, Clients
-@section MySQL Perl API
-This section documents the Perl @code{DBI} interface. The former interface
-was called @code{mysqlperl}. @code{DBI}/@code{DBD} now is the
-recommended Perl interface, so @code{mysqlperl} is obsolete and is not
-documented here.
+@node Cplusplus, Java, C, Clients
+@section MySQL C++ APIs
@menu
-* DBI with DBD:: @code{DBI} with @code{DBD::mysql}
-* Perl DBI Class:: The @code{DBI} interface
-* DBI-info:: More @code{DBI}/@code{DBD} information
+* Borland C++:: Borland C++
@end menu
-@cindex @code{DBI} interface
-@node DBI with DBD, Perl DBI Class, Perl, Perl
-@subsection @code{DBI} with @code{DBD::mysql}
-@code{DBI} is a generic interface for many databases. That means that
-you can write a script that works with many different database engines
-without change. You need a DataBase Driver (DBD) defined for each
-database type. For @strong{MySQL}, this driver is called
-@code{DBD::mysql}.
-
-For more information on the Perl5 DBI, please visit the @code{DBI} Web
-page and read the documentation:
-@example
-@uref{http://www.symbolstone.org/technology/perl/DBI/index.html}
-@end example
-For more information on Object Oriented Programming
-(OOP) as defined in Perl5, see the Perl OOP page:
-@example
-@uref{http://language.perl.com/info/documentation.html}
-@end example
-
-Note that if you want to use transactions with Perl, you need to have
-@code{Msql-Mysql-modules} version 1.2216 or newer.
-
-Installation instructions for @strong{MySQL} Perl support are given in
-@ref{Perl support}.
-
-@cindex @code{DBI} Perl module
-@node Perl DBI Class, DBI-info, DBI with DBD, Perl
-@subsection The @code{DBI} Interface
-
-@noindent
-@strong{Portable DBI Methods}
-
-@multitable @columnfractions .3 .7
-@item @code{connect} @tab Establishes a connection to a database server.
-@item @code{disconnect} @tab Disconnects from the database server.
-@item @code{prepare} @tab Prepares a SQL statement for execution.
-@item @code{execute} @tab Executes prepared statements.
-@item @code{do} @tab Prepares and executes a SQL statement.
-@item @code{quote} @tab Quotes string or @code{BLOB} values to be inserted.
-@item @code{fetchrow_array} @tab Fetches the next row as an array of fields.
-@item @code{fetchrow_arrayref} @tab Fetches next row as a reference array of fields.
-@item @code{fetchrow_hashref} @tab Fetches next row as a reference to a hashtable.
-@item @code{fetchall_arrayref} @tab Fetches all data as an array of arrays.
-@item @code{finish} @tab Finishes a statement and lets the system free resources.
-@item @code{rows} @tab Returns the number of rows affected.
-@item @code{data_sources} @tab Returns an array of databases available on localhost.
-@item @code{ChopBlanks} @tab Controls whether @code{fetchrow_*} methods trim spaces.
-@item @code{NUM_OF_PARAMS} @tab The number of placeholders in the prepared statement.
-@item @code{NULLABLE} @tab Which columns can be @code{NULL}.
-@item @code{trace} @tab Perform tracing for debugging.
-@end multitable
-
-@noindent
-@strong{MySQL-specific Methods}
+@cindex C++ APIs
-@multitable @columnfractions .3 .7
-@item @code{insertid} @tab The latest @code{AUTO_INCREMENT} value.
-@item @code{is_blob} @tab Which columns are @code{BLOB} values.
-@item @code{is_key} @tab Which columns are keys.
-@item @code{is_num} @tab Which columns are numeric.
-@item @code{is_pri_key} @tab Which columns are primary keys.
-@item @code{is_not_null} @tab Which columns CANNOT be @code{NULL}. See @code{NULLABLE}.
-@item @code{length} @tab Maximum possible column sizes.
-@item @code{max_length} @tab Maximum column sizes actually present in result.
-@item @code{NAME} @tab Column names.
-@item @code{NUM_OF_FIELDS} @tab Number of fields returned.
-@item @code{table} @tab Table names in returned set.
-@item @code{type} @tab All column types.
-@end multitable
+Two APIs are available in the MySQL
+@uref{http://www.mysql.com/Downloads/Contrib/,Contrib directory}.
-The Perl methods are described in more detail in the following sections.
-Variables used for method return values have these meanings:
-@table @code
-@item $dbh
-Database handle
+@node Borland C++, , Cplusplus, Cplusplus
+@subsection Borland C++
-@item $sth
-Statement handle
+@cindex Borland C++ compiler
-@item $rc
-Return code (often a status)
+You can compile the MySQL Windows source with Borland C++ 5.02.
+(The Windows source includes only projects for Microsoft VC++, for
+Borland C++ you have to do the project files yourself).
-@item $rv
-Return value (often a row count)
-@end table
+One known problem with Borland C++ is that it uses a different structure
+alignment than VC++. This means that you will run into problems if you
+try to use the default @code{libmysql.dll} libraries (that was compiled
+with VC++) with Borland C++. You can do one of the following to avoid
+this problem.
-@noindent
-@strong{Portable DBI Methods}
+@itemize @bullet
+@item
+You can use the static MySQL libraries for Borland C++ that you
+can find on @uref{http://www.mysql.com/downloads/os-win32.html}.
+@item
+Only call @code{mysql_init()} with @code{NULL} as an argument, not a
+pre-allocated MYSQL struct.
+@end itemize
-@table @code
-@findex DBI->connect()
-@findex connect() DBI method
-@item connect($data_source, $username, $password)
-Use the @code{connect} method to make a database connection to the data
-source. The @code{$data_source} value should begin with
-@code{DBI:driver_name:}.
-Example uses of @code{connect} with the @code{DBD::mysql} driver:
-@example
-$dbh = DBI->connect("DBI:mysql:$database", $user, $password);
-$dbh = DBI->connect("DBI:mysql:$database:$hostname",
- $user, $password);
-$dbh = DBI->connect("DBI:mysql:$database:$hostname:$port",
- $user, $password);
-@end example
-If the user name and/or password are undefined, @code{DBI} uses the
-values of the @code{DBI_USER} and @code{DBI_PASS} environment variables,
-respectively. If you don't specify a hostname, it defaults to
-@code{'localhost'}. If you don't specify a port number, it defaults to the
-default @strong{MySQL} port (@value{default_port}).
+@node Java, Python, Cplusplus, Clients
+@section MySQL Java Connectivity (JDBC)
-As of @code{Msql-Mysql-modules} Version 1.2009,
-the @code{$data_source} value allows certain modifiers:
+@cindex Java connectivity
+@cindex JDBC
-@table @code
-@item mysql_read_default_file=file_name
-Read @file{filename} as an option file. For information on option files,
-see @ref{Option files}.
+There are 2 supported JDBC drivers for MySQL (the mm driver and
+the Reisin JDBC driver). You can find a copy of the mm driver at
+@uref{http://mmmysql.sourceforge.net/} or
+@uref{http://www.mysql.com/Downloads/Contrib/} and the Reisin driver at
+@uref{http://www.caucho.com/projects/jdbc-mysql/index.xtp} For
+documentation consult any JDBC documentation and the driver's own
+documentation for MySQL-specific features.
-@item mysql_read_default_group=group_name
-The default group when reading an option file is normally the
-@code{[client]} group. By specifying the @code{mysql_read_default_group}
-option, the default group becomes the @code{[group_name]} group.
-@item mysql_compression=1
-Use compressed communication between the client and server (@strong{MySQL}
-Version 3.22.3 or later).
+@node Python, Tcl, Java, Clients
+@section MySQL Python APIs
-@item mysql_socket=/path/to/socket
-Specify the pathname of the Unix socket that is used to connect
-to the server (@strong{MySQL} Version 3.21.15 or later).
-@end table
+@cindex Python APIs
-Multiple modifiers may be given; each must be preceded by a semicolon.
+The MySQL @uref{http://www.mysql.com/Downloads/Contrib/,Contrib directory}
+contains a Python interface written by Joseph Skinner.
-For example, if you want to avoid hardcoding the user name and password into
-a @code{DBI} script, you can take them from the user's @file{~/.my.cnf}
-option file instead by writing your @code{connect} call like this:
+You can also use the Python interface to iODBC to access a
+MySQL server.
+@uref{http://starship.skyport.net/~lemburg/,mxODBC}
-@example
-$dbh = DBI->connect("DBI:mysql:$database"
- . ";mysql_read_default_file=$ENV@{HOME@}/.my.cnf",
- $user, $password);
-@end example
-This call will read options defined for the @code{[client]} group in the
-option file. If you wanted to do the same thing but use options specified
-for the @code{[perl]} group as well, you could use this:
+@node Tcl, Eiffel, Python, Clients
+@section MySQL Tcl APIs
-@example
-$dbh = DBI->connect("DBI:mysql:$database"
- . ";mysql_read_default_file=$ENV@{HOME@}/.my.cnf"
- . ";mysql_read_default_group=perl",
- $user, $password);
-@end example
+@cindex Tcl APIs
-@findex DBI->disconnect
-@findex disconnect DBI method
-@item disconnect
-The @code{disconnect} method disconnects the database handle from the database.
-This is typically called right before you exit from the program.
-Example:
-@example
-$rc = $dbh->disconnect;
-@end example
+@uref{http://www.binevolve.com/~tdarugar/tcl-sql/, Tcl at binevolve}.
+The
+@uref{http://www.mysql.com/Downloads/Contrib,Contrib directory} contains a Tcl
+interface that is based on msqltcl 1.50.
-@findex DBI->prepare()
-@findex prepare() DBI method
-@item prepare($statement)
-Prepares a SQL statement for execution by the database engine
-and returns a statement handle @code{($sth)}, which you can use to invoke
-the @code{execute} method.
-Typically you handle @code{SELECT} statements (and @code{SELECT}-like statements
-such as @code{SHOW}, @code{DESCRIBE}, and @code{EXPLAIN}) by means of
-@code{prepare} and @code{execute}.
-Example:
-@example
-$sth = $dbh->prepare($statement)
- or die "Can't prepare $statement: $dbh->errstr\n";
-@end example
-@findex DBI->execute
-@findex execute DBI method
-@item execute
-The @code{execute} method executes a prepared statement. For
-non-@code{SELECT} statements, @code{execute} returns the number of rows
-affected. If no rows are affected, @code{execute} returns @code{"0E0"},
-which Perl treats as zero but regards as true. If an error occurs,
-@code{execute} returns @code{undef}. For @code{SELECT} statements,
-@code{execute} only starts the SQL query in the database; you need to use one
-of the @code{fetch_*} methods described below to retrieve the data.
-Example:
-@example
-$rv = $sth->execute
- or die "can't execute the query: $sth->errstr;
-@end example
+@node Eiffel, , Tcl, Clients
+@section MySQL Eiffel wrapper
-@findex DBI->do()
-@findex do() DBI method
-@item do($statement)
-The @code{do} method prepares and executes a SQL statement and returns the
-number of rows affected. If no rows are affected, @code{do} returns
-@code{"0E0"}, which Perl treats as zero but regards as true. This method is
-generally used for non-@code{SELECT} statements that cannot be prepared in
-advance (due to driver limitations) or that do not need to be executed more
-than once (inserts, deletes, etc.). Example:
-@example
-$rv = $dbh->do($statement)
- or die "Can't execute $statement: $dbh- >errstr\n";
-@end example
+@cindex Eiffel Wrapper
+@cindex wrappers, Eiffel
-Generally the 'do' statement is MUCH faster (and is preferable)
-than prepare/execute for statements that don't contain parameters.
+The MySQL @uref{http://www.mysql.com/Downloads/Contrib/,Contrib directory}
+contains an Eiffel wrapper written by Michael Ravits.
-@findex DBI->quote()
-@findex quote() DBI method
-@cindex quoting strings
-@cindex strings, quoting
-@item quote($string)
-The @code{quote} method is used to "escape" any special characters contained in
-the string and to add the required outer quotation marks.
-Example:
-@example
-$sql = $dbh->quote($string)
-@end example
+You can also find this at:
+@url{http://www.netpedia.net/hosting/newplayer/}
-@findex DBI->fetchrow_array
-@findex fetchrow_array DBI method
-@item fetchrow_array
-This method fetches the next row of data and returns it as an array of
-field values. Example:
-@example
-while(@@row = $sth->fetchrow_array) @{
- print qw($row[0]\t$row[1]\t$row[2]\n);
-@}
-@end example
-@findex DBI->fetchrow_arrayref
-@findex fetchrow_arrayref DBI method
-@item fetchrow_arrayref
-This method fetches the next row of data and returns it as a reference
-to an array of field values. Example:
-@example
-while($row_ref = $sth->fetchrow_arrayref) @{
- print qw($row_ref->[0]\t$row_ref->[1]\t$row_ref->[2]\n);
-@}
-@end example
-@findex DBI->fetchrow_hashref
-@findex fetchrow_hashref DBI method
-@item fetchrow_hashref
-This method fetches a row of data and returns a reference to a hash
-table containing field name/value pairs. This method is not nearly as
-efficient as using array references as demonstrated above. Example:
-@example
-while($hash_ref = $sth->fetchrow_hashref) @{
- print qw($hash_ref->@{firstname@}\t$hash_ref->@{lastname@}\t\
- $hash_ref- > title@}\n);
-@}
-@end example
-@findex DBI->fetchall_arrayref
-@findex fetchall_arrayref DBI method
-@item fetchall_arrayref
-This method is used to get all the data (rows) to be returned from the
-SQL statement. It returns a reference to an array of references to arrays
-for each row. You access or print the data by using a nested
-loop. Example:
-@example
-my $table = $sth->fetchall_arrayref
- or die "$sth->errstr\n";
-my($i, $j);
-for $i ( 0 .. $#@{$table@} ) @{
- for $j ( 0 .. $#@{$table->[$i]@} ) @{
- print "$table->[$i][$j]\t";
- @}
- print "\n";
-@}
-@end example
+@node Extending MySQL, Problems, Clients, Top
+@chapter Extending MySQL
-@findex DBI->finish
-@findex finish DBI method
-@item finish
-Indicates that no more data will be fetched from this statement
-handle. You call this method to free up the statement handle and any
-system resources associated with it. Example:
-@example
-$rc = $sth->finish;
-@end example
+@menu
+* Adding functions:: Adding New Functions to MySQL
+* Adding procedures:: Adding New Procedures to MySQL
+* MySQL internals:: MySQL Internals
+@end menu
-@findex DBI->rows
-@findex rows DBI method
-@item rows
-Returns the number of rows changed (updated, deleted, etc.) by the last
-command. This is usually used after a non-@code{SELECT} @code{execute}
-statement. Example:
-@example
-$rv = $sth->rows;
-@end example
-@findex DBI->@{NULLABLE@}
-@findex NULLABLE DBI method
-@item NULLABLE
-Returns a reference to an array of boolean values; for each element of
-the array, a value of TRUE indicates that this
-column may contain @code{NULL} values.
-Example:
-@example
-$null_possible = $sth->@{NULLABLE@};
-@end example
+@node Adding functions, Adding procedures, Extending MySQL, Extending MySQL
+@section Adding New Functions to MySQL
-@findex DBI->@{NUM_OF_FIELDS@}
-@findex NUM_OF_FIELDS DBI method
-@item NUM_OF_FIELDS
-This attribute indicates
-the number of fields returned by a @code{SELECT} or @code{SHOW FIELDS}
-statement. You may use this for checking whether a statement returned a
-result: A zero value indicates a non-@code{SELECT} statement like
-@code{INSERT}, @code{DELETE}, or @code{UPDATE}.
-Example:
-@example
-$nr_of_fields = $sth->@{NUM_OF_FIELDS@};
-@end example
+@cindex functions, new
+@cindex adding, new functions
+@cindex user-defined functions, adding
+@cindex UDFs, defined
+@cindex functions, user-defined
-@findex DBI->data_sources()
-@findex data_sources() DBI method
-@item data_sources($driver_name)
-This method returns an array containing names of databases available to the
-@strong{MySQL} server on the host @code{'localhost'}.
-Example:
-@example
-@@dbs = DBI->data_sources("mysql");
-@end example
+There are two ways to add new functions to MySQL:
-@findex DBI->@{ChopBlanks@}
-@findex ChopBlanks DBI method
-@item ChopBlanks
-This attribute determines whether the @code{fetchrow_*} methods will chop
-leading and trailing blanks from the returned values.
-Example:
-@example
-$sth->@{'ChopBlanks'@} =1;
-@end example
-
-@findex DBI->trace
-@findex trace DBI method
-@item trace($trace_level)
-@itemx trace($trace_level, $trace_filename)
-The @code{trace} method enables or disables tracing. When invoked as a
-@code{DBI} class method, it affects tracing for all handles. When invoked as
-a database or statement handle method, it affects tracing for the given
-handle (and any future children of the handle). Setting @code{$trace_level}
-to 2 provides detailed trace information. Setting @code{$trace_level} to 0
-disables tracing. Trace output goes to the standard error output by
-default. If @code{$trace_filename} is specified, the file is opened in
-append mode and output for @emph{all} traced handles is written to that
-file. Example:
-@example
-DBI->trace(2); # trace everything
-DBI->trace(2,"/tmp/dbi.out"); # trace everything to
- # /tmp/dbi.out
-$dth->trace(2); # trace this database handle
-$sth->trace(2); # trace this statement handle
-@end example
+@itemize @bullet
+@item You can add the function through the user-definable function (UDF)
+interface. User-definable functions are added and removed dynamically using
+the @code{CREATE FUNCTION} and @code{DROP FUNCTION} statements.
+@xref{CREATE FUNCTION, , @code{CREATE FUNCTION}}.
-@tindex DBI_TRACE environment variable
-@tindex Environment variable, DBI_TRACE
-You can also enable @code{DBI} tracing by setting the @code{DBI_TRACE}
-environment variable. Setting it to a numeric value is equivalent to calling
-@code{DBI->(value)}. Setting it to a pathname is equivalent to calling
-@code{DBI->(2,value)}.
+@item You can add the function as a native (built in) MySQL function.
+Native functions are compiled into the @code{mysqld} server and become
+available on a permanent basis.
+@end itemize
-@end table
+Each method has advantages and disadvantages:
-@noindent
-@strong{MySQL-specific Methods}
+@itemize @bullet
+@item
+If you write a user-definable function, you must install the object file
+in addition to the server itself. If you compile your function into the
+server, you don't need to do that.
+@item
+You can add UDFs to a binary MySQL distribution. Native functions
+require you to modify a source distribution.
+@item
+If you upgrade your MySQL distribution, you can continue to use your
+previously installed UDFs. For native functions, you must repeat your
+modifications each time you upgrade.
+@end itemize
-The methods shown below are @strong{MySQL}-specific and not part of the
-@code{DBI} standard. Several of them are now deprecated:
-@code{is_blob}, @code{is_key}, @code{is_num}, @code{is_pri_key},
-@code{is_not_null}, @code{length}, @code{max_length}, and @code{table}.
-Where @code{DBI}-standard alternatives exist, they are noted below:
+Whichever method you use to add new functions, they may be used just like
+native functions such as @code{ABS()} or @code{SOUNDEX()}.
-@table @code
-@findex DBI->@{insertid@}
-@findex insertid DBI method
-@tindex AUTO_INCREMENT, using with DBI
-@item insertid
-If you use the @code{AUTO_INCREMENT} feature of @strong{MySQL}, the new
-auto-incremented values will be stored here.
-Example:
-@example
-$new_id = $sth->@{insertid@};
-@end example
+@menu
+* CREATE FUNCTION:: @code{CREATE FUNCTION/DROP FUNCTION} Syntax
+* Adding UDF:: Adding a new user-definable function
+* Adding native function:: Adding a new native function
+@end menu
-As an alternative, you can use @code{$dbh->@{'mysql_insertid'@}}.
-@findex DBI->@{is_blob@}
-@findex is_blob DBI method
-@item is_blob
-Returns a reference to an array of boolean values; for each element of the
-array, a value of TRUE indicates that the
-respective column is a @code{BLOB}.
-Example:
-@example
-$keys = $sth->@{is_blob@};
-@end example
+@node CREATE FUNCTION, Adding UDF, Adding functions, Adding functions
+@subsection @code{CREATE FUNCTION/DROP FUNCTION} Syntax
-@findex DBI->@{is_key@}
-@findex is_key DBI method
-@item is_key
-Returns a reference to an array of boolean values; for each element of the
-array, a value of TRUE indicates that the
-respective column is a key.
-Example:
-@example
-$keys = $sth->@{is_key@};
-@end example
+@findex CREATE FUNCTION
+@findex DROP FUNCTION
+@findex UDF functions
+@findex User-defined functions
+@findex Functions, user-defined
-@findex DBI->@{is_num@}
-@findex is_num DBI method
-@item is_num
-Returns a reference to an array of boolean values; for each element of the
-array, a value of TRUE indicates that the
-respective column contains numeric values.
-Example:
@example
-$nums = $sth->@{is_num@};
-@end example
+CREATE [AGGREGATE] FUNCTION function_name RETURNS @{STRING|REAL|INTEGER@}
+ SONAME shared_library_name
-@findex DBI->@{is_pri_key@}
-@findex is_pri_key DBI method
-@item is_pri_key
-Returns a reference to an array of boolean values; for each element of the
-array, a value of TRUE indicates that the respective column is a primary key.
-Example:
-@example
-$pri_keys = $sth->@{is_pri_key@};
+DROP FUNCTION function_name
@end example
-@findex DBI->@{is_not_null@}
-@findex is_not_null DBI method
-@item is_not_null
-Returns a reference to an array of boolean values; for each element of the
-array, a value of FALSE indicates that this column may contain @code{NULL}
-values.
-Example:
-@example
-$not_nulls = $sth->@{is_not_null@};
-@end example
+A user-definable function (UDF) is a way to extend MySQL with a new
+function that works like native (built in) MySQL functions such as
+@code{ABS()} and @code{CONCAT()}.
-@code{is_not_null} is deprecated; it is preferable to use the
-@code{NULLABLE} attribute (described above), because that is a DBI standard.
+@code{AGGREGATE} is a new option for MySQL Version 3.23. An
+@code{AGGREGATE} function works exactly like a native MySQL
+@code{GROUP} function like @code{SUM} or @code{COUNT()}.
-@findex DBI->@{length@}
-@findex length DBI method
-@findex DBI->@{max_length@}
-@findex max_length DBI method
-@item length
-@itemx max_length
-Each of these methods returns a reference to an array of column sizes. The
-@code{length} array indicates the maximum possible sizes that each column may
-be (as declared in the table description). The @code{max_length} array
-indicates the maximum sizes actually present in the result table. Example:
+@code{CREATE FUNCTION} saves the function's name, type, and shared library
+name in the @code{mysql.func} system table. You must have the
+@strong{insert} and @strong{delete} privileges for the @code{mysql} database
+to create and drop functions.
-@example
-$lengths = $sth->@{length@};
-$max_lengths = $sth->@{max_length@};
-@end example
+All active functions are reloaded each time the server starts, unless
+you start @code{mysqld} with the @code{--skip-grant-tables} option. In
+this case, UDF initialization is skipped and UDFs are unavailable.
+(An active function is one that has been loaded with @code{CREATE FUNCTION}
+and not removed with @code{DROP FUNCTION}.)
-@findex DBI->@{NAME@}
-@findex NAME DBI method
-@item NAME
-Returns a reference to an array of column names.
-Example:
-@example
-$names = $sth->@{NAME@};
-@end example
+For instructions on writing user-definable functions, see @ref{Adding
+functions}. For the UDF mechanism to work, functions must be written in C or
+C++, your operating system must support dynamic loading and you must have
+compiled @code{mysqld} dynamically (not statically).
-@findex DBI->@{table@}
-@findex table DBI method
-@item table
-Returns a reference to an array of table names.
-Example:
-@example
-$tables = $sth->@{table@};
-@end example
-@findex DBI->@{type@}
-@findex type DBI method
-@item type
-Returns a reference to an array of column types.
-Example:
-@example
-$types = $sth->@{type@};
-@end example
-@end table
+@node Adding UDF, Adding native function, CREATE FUNCTION, Adding functions
+@subsection Adding a New User-definable Function
-@cindex @code{DBI/DBD}
-@node DBI-info, , Perl DBI Class, Perl
-@subsection More @code{DBI}/@code{DBD} Information
+@cindex adding, user-definable functions
+@cindex user-defined functions, adding
+@cindex functions, user-definable, adding
-You can use the @code{perldoc} command to get more information about
-@code{DBI}.
+@menu
+* UDF calling sequences:: UDF calling sequences
+* UDF arguments:: Argument processing
+* UDF return values:: Return values and error handling
+* UDF compiling:: Compiling and installing user-definable functions
+@end menu
-@example
-perldoc DBI
-perldoc DBI::FAQ
-perldoc DBD::mysql
-@end example
-You can also use the @code{pod2man}, @code{pod2html}, etc., tools to
-translate to other formats.
+For the UDF mechanism to work, functions must be written in C or C++ and your
+operating system must support dynamic loading. The MySQL source
+distribution includes a file @file{sql/udf_example.cc} that defines 5 new
+functions. Consult this file to see how UDF calling conventions work.
-You can find the latest @code{DBI} information at
-the @code{DBI} Web page:
-@example
-@uref{http://www.symbolstone.org/technology/perl/DBI/index.html}
-@end example
+For @code{mysqld} to be able to use UDF functions, you should configure MySQL
+with @code{--with-mysqld-ldflags=-rdynamic} The reason is that to on
+many platforms (including Linux) you can load a dynamic library (with
+@code{dlopen()}) from a static linked program, which you would get if
+you are using @code{--with-mysqld-ldflags=-all-static} If you want to
+use an UDF that needs to access symbols from @code{mysqld} (like the
+@code{methaphone} example in @file{sql/udf_example.cc} that uses
+@code{default_charset_info}), you must link the program with
+@code{-rdynamic}. (see @code{man dlopen}).
-@cindex Eiffel Wrapper
-@cindex wrappers, Eiffel
-@node Eiffel, Java, Perl, Clients
-@section MySQL Eiffel wrapper
+For each function that you want to use in SQL statements, you should define
+corresponding C (or C++) functions. In the discussion below, the name
+``xxx'' is used for an example function name. To distinquish between SQL and
+C/C++ usage, @code{XXX()} (uppercase) indicates a SQL function call, and
+@code{xxx()} (lowercase) indicates a C/C++ function call.
-The @strong{MySQL} @uref{http://www.mysql.com/Downloads/Contrib/,Contrib directory}
-contains an Eiffel wrapper written by Michael Ravits.
+The C/C++ functions that you write to implement the interface for
+@code{XXX()} are:
-You can also find this at:
-@url{http://www.netpedia.net/hosting/newplayer/}
+@table @asis
+@item @code{xxx()} (required)
+The main function. This is where the function result is computed.
+The correspondence between the SQL type and return type of your C/C++
+function is shown below:
-@cindex Java connectivity
-@cindex JDBC
-@node Java, PHP, Eiffel, Clients
-@section MySQL Java Connectivity (JDBC)
+@multitable @columnfractions .2 .8
+@item @strong{SQL type} @tab @strong{C/C++ type}
+@item @code{STRING} @tab @code{char *}
+@item @code{INTEGER} @tab @code{long long}
+@item @code{REAL} @tab @code{double}
+@end multitable
-There are 2 supported JDBC drivers for @strong{MySQL} (the mm driver and
-the Reisin JDBC driver). You can find a copy of the mm driver at
-@uref{http://mmmysql.sourceforge.net/} or
-@uref{http://www.mysql.com/Downloads/Contrib/} and the Reisin driver at
-@uref{http://www.caucho.com/projects/jdbc-mysql/index.xtp} For
-documentation consult any JDBC documentation and the driver's own
-documentation for @strong{MySQL}-specific features.
+@item @code{xxx_init()} (optional)
+The initialization function for @code{xxx()}. It can be used to:
-@cindex PHP API
-@node PHP, Cplusplus, Java, Clients
-@section MySQL PHP API
+@itemize @bullet
+@item
+Check the number of arguments to @code{XXX()}.
+@item
+Check that the arguments are of a required type or, alternatively,
+tell MySQL to coerce arguments to the types you want when
+the main function is called.
+@item
+Allocate any memory required by the main function.
+@item
+Specify the maximum length of the result.
+@item
+Specify (for @code{REAL} functions) the maximum number of decimals.
+@item
+Specify whether or not the result can be @code{NULL}.
+@end itemize
-PHP is a server-side, HTML-embedded scripting language that may be used to
-create dynamic Web pages. It contains support for accessing several
-databases, including @strong{MySQL}. PHP may be run as a separate program
-or compiled as a module for use with the Apache Web server.
+@item @code{xxx_deinit()} (optional)
+The deinitialization function for @code{xxx()}. It should deallocate any
+memory allocated by the initialization function.
+@end table
-The distribution and documentation are available at the
-@uref{http://www.php.net/, PHP web site}.
+When a SQL statement invokes @code{XXX()}, MySQL calls the
+initialization function @code{xxx_init()} to let it perform any required
+setup, such as argument checking or memory allocation. If @code{xxx_init()}
+returns an error, the SQL statement is aborted with an error message and the
+main and deinitialization functions are not called. Otherwise, the main
+function @code{xxx()} is called once for each row. After all rows have been
+processed, the deinitialization function @code{xxx_deinit()} is called so it
+can perform any required cleanup.
-@menu
-* PHP problems:: Common problems with MySQL and PHP
-@end menu
+All functions must be thread safe (not just the main function,
+but the initialization and deinitialization functions as well). This means
+that you are not allowed to allocate any global or static variables that
+change! If you need memory, you should allocate it in @code{xxx_init()}
+and free it in @code{xxx_deinit()}.
-@node PHP problems, , PHP, PHP
-@subsection Common Problems with MySQL and PHP
-@itemize @bullet
-@item Error: "Maximum Execution Time Exceeded"
-This is a PHP limit; Go into the @file{php3.ini} file and set the maximum
-execution time up from 30 seconds to something higher, as needed.
-It is also not a bad idea to double the ram allowed per script to 16MB instead of
-8 MB.
-@item Error: "Fatal error: Call to unsupported or undefined function mysql_connect() in .."
-This means that your PHP version isn't compiled with @strong{MySQL} support.
-You can either compile a dynamic @strong{MySQL} module and load it into PHP or
-recompile PHP with built-in @strong{MySQL} support. This is described in
-detail in the PHP manual.
-@item Error: "undefined reference to `uncompress'"
-This means that the client library is compiled with support for a compressed
-client/server protocol. The fix is to add @code{-lz} last when linking
-with @code{-lmysqlclient}.
-@end itemize
+@node UDF calling sequences, UDF arguments, Adding UDF, Adding UDF
+@subsubsection UDF Calling Sequences
-@cindex C++ APIs
-@node Cplusplus, Python, PHP, Clients
-@section MySQL C++ APIs
+@cindex calling sequences, UDF
-Two APIs are available in the @strong{MySQL}
-@uref{http://www.mysql.com/Downloads/Contrib/,Contrib directory}.
+The main function should be declared as shown below. Note that the return
+type and parameters differ, depending on whether you will declare the SQL
+function @code{XXX()} to return @code{STRING}, @code{INTEGER}, or @code{REAL}
+in the @code{CREATE FUNCTION} statement:
-@cindex Python APIs
-@node Python, Tcl, Cplusplus, Clients
-@section MySQL Python APIs
+@noindent
+For @code{STRING} functions:
-The @strong{MySQL} @uref{http://www.mysql.com/Downloads/Contrib/,Contrib directory}
-contains a Python interface written by Joseph Skinner.
+@example
+char *xxx(UDF_INIT *initid, UDF_ARGS *args,
+ char *result, unsigned long *length,
+ char *is_null, char *error);
+@end example
-You can also use the Python interface to iODBC to access a
-@strong{MySQL} server.
-@uref{http://starship.skyport.net/~lemburg/,mxODBC}
+@noindent
+For @code{INTEGER} functions:
-@cindex Tcl APIs
-@node Tcl, , Python, Clients
-@section MySQL Tcl APIs
+@example
+long long xxx(UDF_INIT *initid, UDF_ARGS *args,
+ char *is_null, char *error);
+@end example
-@uref{http://www.binevolve.com/~tdarugar/tcl-sql/, Tcl at binevolve}.
-The
-@uref{http://www.mysql.com/Downloads/Contrib,Contrib directory} contains a Tcl
-interface that is based on msqltcl 1.50.
+@noindent
+For @code{REAL} functions:
-@cindex databases, MySQL vs. others
-@cindex comparisons, MySQL vs. others
-@node Comparisons, MySQL internals, Clients, Top
-@chapter How MySQL Compares to Other Databases
+@example
+double xxx(UDF_INIT *initid, UDF_ARGS *args,
+ char *is_null, char *error);
+@end example
-@menu
-* Compare mSQL:: How @strong{MySQL} compares to @code{mSQL}
-* Compare PostgreSQL:: How @strong{MySQL} compares with PostgreSQL
-@end menu
+The initialization and deinitialization functions are declared like this:
-This chapter compares @strong{MySQL} to other popular databases.
+@example
+my_bool xxx_init(UDF_INIT *initid, UDF_ARGS *args, char *message);
-This chapter has been written by the @strong{MySQL} developers, so it
-should be read with that in mind. There are no factual errors contained
-in this chapter that we know of. If you find something which you believe
-to be an error, please contact us about it at @email{docs@@mysql.com}.
+void xxx_deinit(UDF_INIT *initid);
+@end example
-For a list of all supported limits, functions, and types, see the
-@code{crash-me} Web page at
-@uref{http://www.mysql.com/information/crash-me.php}.
+The @code{initid} parameter is passed to all three functions. It points to a
+@code{UDF_INIT} structure that is used to communicate information between
+functions. The @code{UDF_INIT} structure members are listed below. The
+initialization function should fill in any members that it wishes to change.
+(To use the default for a member, leave it unchanged.):
-@node Compare mSQL, Compare PostgreSQL, Comparisons, Comparisons
-@section How MySQL Compares to @code{mSQL}
+@table @code
+@item my_bool maybe_null
+@code{xxx_init()} should set @code{maybe_null} to @code{1} if @code{xxx()}
+can return @code{NULL}. The default value is @code{1} if any of the
+arguments are declared @code{maybe_null}.
-@table @strong
-@item Performance
+@item unsigned int decimals
+Number of decimals. The default value is the maximum number of decimals in
+the arguments passed to the main function. (For example, if the function is
+passed @code{1.34}, @code{1.345}, and @code{1.3}, the default would be 3,
+because @code{1.345} has 3 decimals.
-For a true comparison of speed, consult the growing @strong{MySQL} benchmark
-suite. @xref{Benchmarks}.
+@item unsigned int max_length
+The maximum length of the string result. The default value differs depending
+on the result type of the function. For string functions, the default is the
+length of the longest argument. For integer functions, the default is 21
+digits. For real functions, the default is 13 plus the number of decimals
+indicated by @code{initid->decimals}. (For numeric functions, the length
+includes any sign or decimal point characters.)
-Because there is no thread creation overhead, a small parser, few features, and
-simple security, @code{mSQL} should be quicker at:
+@item char *ptr
+A pointer that the function can use for its own purposes. For example,
+functions can use @code{initid->ptr} to communicate allocated memory
+between functions. In @code{xxx_init()}, allocate the memory and assign it
+to this pointer:
-@itemize @bullet
-@item
-Tests that perform repeated connects and disconnects, running a very simple
-query during each connection.
-@item
-@code{INSERT} operations into very simple tables with few columns and keys.
-@item
-@code{CREATE TABLE} and @code{DROP TABLE}.
-@item
-@code{SELECT} on something that isn't an index. (A table scan is very
-easy.)
-@end itemize
+@example
+initid->ptr = allocated_memory;
+@end example
-Because these operations are so simple, it is hard to be better at them when
-you have a higher startup overhead. After the connection is established,
-@strong{MySQL} should perform much better.
+In @code{xxx()} and @code{xxx_deinit()}, refer to @code{initid->ptr} to use
+or deallocate the memory.
+@end table
-On the other hand, @strong{MySQL} is much faster than @code{mSQL} (and
-most other SQL implementations) on the following:
-@itemize @bullet
-@item
-Complex @code{SELECT} operations.
-@item
-Retrieving large results (@strong{MySQL} has a better, faster, and safer
-protocol).
-@item
-Tables with variable-length strings, because @strong{MySQL} has more efficient
-handling and can have indexes on @code{VARCHAR} columns.
-@item
-Handling tables with many columns.
-@item
-Handling tables with large record lengths.
-@item
-@code{SELECT} with many expressions.
-@item
-@code{SELECT} on large tables.
-@item
-Handling many connections at the same time. @strong{MySQL} is fully
-multi-threaded. Each connection has its own thread, which means that
-no thread has to wait for another (unless a thread is modifying
-a table another thread wants to access). In @code{mSQL}, once one connection
-is established, all others must wait until the first has finished, regardless
-of whether the connection is running a query that is short or long. When the
-first connection terminates, the next can be served, while all the others wait
-again, etc.
-@item
-Joins.
-@code{mSQL} can become pathologically slow if you change the order of tables
-in a @code{SELECT}. In the benchmark suite, a time more than 15000 times
-slower than @strong{MySQL} was seen. This is due to @code{mSQL}'s lack of a
-join optimizer to order tables in the optimal order. However, if you put the
-tables in exactly the right order in @code{mSQL}2 and the @code{WHERE} is
-simple and uses index columns, the join will be relatively fast!
-@xref{Benchmarks}.
-@item
-@code{ORDER BY} and @code{GROUP BY}.
-@item
-@code{DISTINCT}.
-@item
-Using @code{TEXT} or @code{BLOB} columns.
-@end itemize
+@node UDF arguments, UDF return values, UDF calling sequences, Adding UDF
+@subsubsection Argument Processing
-@item SQL Features
+@cindex argument processing
+@cindex processing, arguments
-@itemize @bullet
-@item @code{GROUP BY} and @code{HAVING}.
-@code{mSQL} does not support @code{GROUP BY} at all.
-@strong{MySQL} supports a full @code{GROUP BY} with both @code{HAVING} and
-the following functions: @code{COUNT()}, @code{AVG()}, @code{MIN()},
-@code{MAX()}, @code{SUM()}, and @code{STD()}. @code{COUNT(*)} is optimized to
-return very quickly if the @code{SELECT} retrieves from one table, no other
-columns are retrieved, and there is no @code{WHERE} clause. @code{MIN()} and
-@code{MAX()} may take string arguments.
+The @code{args} parameter points to a @code{UDF_ARGS} structure that thas the
+members listed below:
-@item @code{INSERT} and @code{UPDATE} with calculations.
-@strong{MySQL} can do calculations in an @code{INSERT} or @code{UPDATE}.
+@table @code
+@item unsigned int arg_count
+The number of arguments. Check this value in the initialization function
+if you want your function to be called with a particular number of arguments.
For example:
+
@example
-mysql> UPDATE SET x=x*10+y WHERE x<20;
+if (args->arg_count != 2)
+@{
+ strcpy(message,"XXX() requires two arguments");
+ return 1;
+@}
@end example
-@item Aliasing.
-@strong{MySQL} has column aliasing.
-
-@item Qualifying column names.
-In @strong{MySQL}, if a column name is unique among the tables used in a
-query, you do not have to use the full qualifier.
-@item @code{SELECT} with functions.
-@strong{MySQL} has many functions (too many to list here; see @ref{Functions}).
+@item enum Item_result *arg_type
+The types for each argument. The possible type values are
+@code{STRING_RESULT}, @code{INT_RESULT}, and @code{REAL_RESULT}.
-@end itemize
+To make sure that arguments are of a given type and return an
+error if they are not, check the @code{arg_type} array in the initialization
+function. For example:
-@item Disk Space Efficiency
-That is, how small can you make your tables?
+@example
+if (args->arg_type[0] != STRING_RESULT ||
+ args->arg_type[1] != INT_RESULT)
+@{
+ strcpy(message,"XXX() requires a string and an integer");
+ return 1;
+@}
+@end example
-@strong{MySQL} has very precise types, so you can create tables that take
-very little space. An example of a useful @strong{MySQL} datatype is the
-@code{MEDIUMINT} that is 3 bytes long. If you have 100,000,000 records,
-saving even one byte per record is very important.
+As an alternative to requiring your function's arguments to be of particular
+types, you can use the initialization function to set the @code{arg_type}
+elements to the types you want. This causes MySQL to coerce
+arguments to those types for each call to @code{xxx()}. For example, to
+specify coercion of the first two arguments to string and integer, do this in
+@code{xxx_init()}:
-@code{mSQL2} has a more limited set of column types, so it is
-more difficult to get small tables.
-@item Stability
-This is harder to judge objectively. For a discussion of @strong{MySQL}
-stability, see @ref{Stability}.
+@example
+args->arg_type[0] = STRING_RESULT;
+args->arg_type[1] = INT_RESULT;
+@end example
-We have no experience with @code{mSQL} stability, so we cannot say
-anything about that.
+@item char **args
+@code{args->args} communicates information to the initialization function
+about the general nature of the arguments your function was called with. For a
+constant argument @code{i}, @code{args->args[i]} points to the argument
+value. (See below for instructions on how to access the value properly.)
+For a non-constant argument, @code{args->args[i]} is @code{0}.
+A constant argument is an expression that uses only constants, such as
+@code{3} or @code{4*7-2} or @code{SIN(3.14)}. A non-constant argument is an
+expression that refers to values that may change from row to row, such as
+column names or functions that are called with non-constant arguments.
-@item Price
-Another important issue is the license. @strong{MySQL} has a
-more flexible license than @code{mSQL}, and is also less expensive than
-@code{mSQL}. Whichever product you choose to use, remember to at least
-consider paying for a license or e-mail support. (You are required to get
-a license if you include @strong{MySQL} with a product that you sell,
-of course.)
+For each invocation of the main function, @code{args->args} contains the
+actual arguments that are passed for the row currently being processed.
-@item Perl Interfaces
-@strong{MySQL} has basically the same interfaces to Perl as @code{mSQL} with
-some added features.
+Functions can refer to an argument @code{i} as follows:
-@item JDBC (Java)
-@strong{MySQL} currently has a lot of different JDBC drivers:
@itemize @bullet
@item
-The mm driver: A type 4 JDBC driver by Mark Matthews
-@email{mmatthew@@ecn.purdue.edu}. This is released under the LGPL.
-@item
-The Resin driver. This is a commercial JDBC driver released under open
-source. @uref{http://www.caucho.com/projects/jdbc-mysql/index.xtp}
-@item
-The gwe driver: A Java interface by GWE technologies (not supported anymore).
+An argument of type @code{STRING_RESULT} is given as a string pointer plus a
+length, to allow handling of binary data or data of arbitrary length. The
+string contents are available as @code{args->args[i]} and the string length
+is @code{args->lengths[i]}. You should not assume that strings are
+null-terminated.
+
@item
-The jms driver: An improved gwe driver by Xiaokun Kelvin ZHU
-@email{X.Zhu@@brad.ac.uk} (not supported anymore).
+For an argument of type @code{INT_RESULT}, you must cast
+@code{args->args[i]} to a @code{long long} value:
+
+@example
+long long int_val;
+int_val = *((long long*) args->args[i]);
+@end example
+
@item
-The twz driver: A type 4 JDBC driver by Terrence W. Zellers
-@email{zellert@@voicenet.com}. This is commercial but is free for private
-and educational use (not supported anymore).
+For an argument of type @code{REAL_RESULT}, you must cast
+@code{args->args[i]} to a @code{double} value:
+
+@example
+double real_val;
+real_val = *((double*) args->args[i]);
+@end example
@end itemize
-The recommended driver is the mm driver. The Resin driver may also be
-good (at least the benchmarks looks good), but we haven't received that much
-information about this yet.
+@item unsigned long *lengths
+For the initialization function, the @code{lengths} array indicates the
+maximum string length for each argument. For each invocation of the main
+function, @code{lengths} contains the actual lengths of any string arguments
+that are passed for the row currently being processed. For arguments of
+types @code{INT_RESULT} or @code{REAL_RESULT}, @code{lengths} still contains
+the maximum length of the argument (as for the initialization function).
+@end table
-We know that @code{mSQL} has a JDBC driver, but we have too little experience
-with it to compare.
-@item Rate of Development
-@strong{MySQL} has a very small team of developers, but we are quite
-used to coding C and C++ very rapidly. Because threads, functions,
-@code{GROUP BY}, and so on are still not implemented in @code{mSQL}, it
-has a lot of catching up to do. To get some perspective on this, you
-can view the @code{mSQL} @file{HISTORY} file for the last year and
-compare it with the News section of the @strong{MySQL} Reference Manual
-(@pxref{News}). It should be pretty obvious which one has developed
-most rapidly.
+@node UDF return values, UDF compiling, UDF arguments, Adding UDF
+@subsubsection Return Values and Error Handling
-@item Utility Programs
-Both @code{mSQL} and @strong{MySQL} have many interesting third-party
-tools. Because it is very easy to port upward (from @code{mSQL} to
-@strong{MySQL}), almost all the interesting applications that are available for
-@code{mSQL} are also available for @strong{MySQL}.
+@cindex UDFs, return values
+@cindex return values, UDFs
+@cindex errors, handling for UDFs
+@cindex handling, errors
-@strong{MySQL} comes with a simple @code{msql2mysql} program that fixes
-differences in spelling between @code{mSQL} and @strong{MySQL} for the
-most-used C API functions.
-For example, it changes instances of @code{msqlConnect()} to
-@code{mysql_connect()}. Converting a client program from @code{mSQL} to
-@strong{MySQL} usually takes a couple of minutes.
-@end table
+The initialization function should return @code{0} if no error occurred and
+@code{1} otherwise. If an error occurs, @code{xxx_init()} should store a
+null-terminated error message in the @code{message} parameter. The message
+will be returned to the client. The message buffer is
+@code{MYSQL_ERRMSG_SIZE} characters long, but you should try to keep the
+message to less than 80 characters so that it fits the width of a standard
+terminal screen.
-@menu
-* Using mSQL tools:: How to convert @code{mSQL} tools for @strong{MySQL}
-* Protocol differences:: How @code{mSQL} and @strong{MySQL} client/server communications protocols differ
-* Syntax differences:: How @code{mSQL} 2.0 SQL syntax differs from @strong{MySQL}
-@end menu
+The return value of the main function @code{xxx()} is the function value, for
+@code{long long} and @code{double} functions. A string functions should
+return a pointer to the result and store the length of the string in the
+@code{length} arguments. @code{result} is a buffer at least 255 bytes long.
+Set these to the contents and length of the return value. For example:
-@cindex MySQL tools, conversion
-@cindex converting, tools
-@cindex tools, converting
-@node Using mSQL tools, Protocol differences, Compare mSQL, Compare mSQL
-@subsection How to Convert @code{mSQL} Tools for MySQL
+@example
+memcpy(result, "result string", 13);
+*length = 13;
+@end example
-According to our experience, it would just take a few hours to convert tools
-such as @code{msql-tcl} and @code{msqljava} that use the
-@code{mSQL} C API so that they work with the @strong{MySQL} C API.
+If your string functions that needs to return a string longer than 255
+bytes, you must allocate the space for it with @code{malloc()} in your
+@code{xxx_init()} function or your @code{xxx()} function and free it in
+your @code{xxx_deinit()} function. You can store the allocated memory
+in the @code{ptr} slot in the @code{UDF_INIT} structure for reuse by
+future @code{xxx()} calls. @xref{UDF calling sequences}.
-The conversion procedure is:
+To indicate a return value of @code{NULL} in the main function, set
+@code{is_null} to @code{1}:
-@enumerate
-@item
-Run the shell script @code{msql2mysql} on the source. This requires the
-@code{replace} program, which is distributed with @strong{MySQL}.
-@item
-Compile.
-@item
-Fix all compiler errors.
-@end enumerate
+@example
+*is_null = 1;
+@end example
-Differences between the @code{mSQL} C API and the @strong{MySQL} C API are:
-@itemize @bullet
-@item
-@strong{MySQL} uses a @code{MYSQL} structure as a connection type (@code{mSQL}
-uses an @code{int}).
-@item
-@code{mysql_connect()} takes a pointer to a @code{MYSQL} structure as a
-parameter. It is easy to define one globally or to use @code{malloc()} to get
-one.
-@code{mysql_connect()} also takes two parameters for specifying the user and
-password. You may set these to @code{NULL, NULL} for default use.
-@item
-@code{mysql_error()} takes the @code{MYSQL} structure as a parameter. Just add
-the parameter to your old @code{msql_error()} code if you are porting old code.
-@item
-@strong{MySQL} returns an error number and a text error message for all
-errors. @code{mSQL} returns only a text error message.
-@item
-Some incompatibilities exist as a result of @strong{MySQL} supporting
-multiple connections to the server from the same process.
-@end itemize
+To indicate an error return in the main function, set the @code{error}
+parameter to @code{1}:
-@cindex communications protocols
-@cindex mSQL vs. MySQL
-@node Protocol differences, Syntax differences, Using mSQL tools, Compare mSQL
-@subsection How @code{mSQL} and MySQL Client/Server Communications Protocols Differ
+@example
+*error = 1;
+@end example
-There are enough differences that it is impossible (or at least not easy)
-to support both.
+If @code{xxx()} sets @code{*error} to @code{1} for any row, the function
+value is @code{NULL} for the current row and for any subsequent rows
+processed by the statement in which @code{XXX()} was invoked. (@code{xxx()}
+will not even be called for subsequent rows.) @strong{NOTE:} In
+MySQL versions prior to 3.22.10, you should set both @code{*error}
+and @code{*is_null}:
-The most significant ways in which the @strong{MySQL} protocol differs
-from the @code{mSQL} protocol are listed below:
+@example
+*error = 1;
+*is_null = 1;
+@end example
-@itemize @bullet
-@item
-A message buffer may contain many result rows.
-@item
-The message buffers are dynamically enlarged if the query or the
-result is bigger than the current buffer, up to a configurable server and
-client limit.
-@item
-All packets are numbered to catch duplicated or missing packets.
-@item
-All column values are sent in ASCII. The lengths of columns and rows are sent
-in packed binary coding (1, 2, or 3 bytes).
-@item
-@strong{MySQL} can read in the result unbuffered (without having to store the
-full set in the client).
-@item
-If a single read/write takes more than 30 seconds, the server closes
-the connection.
-@item
-If a connection is idle for 8 hours, the server closes the connection.
-@end itemize
-@node Syntax differences, , Protocol differences, Compare mSQL
-@subsection How @code{mSQL} 2.0 SQL Syntax Differs from MySQL
+@node UDF compiling, , UDF return values, Adding UDF
+@subsubsection Compiling and Installing User-definable Functions
-@noindent
-@strong{Column types}
+@cindex compiling, user-defined functions
+@cindex UDFs, compiling
+@cindex installing, user-defined functions
+
+Files implementing UDFs must be compiled and installed on the host where the
+server runs. This process is described below for the example UDF file
+@file{udf_example.cc} that is included in the MySQL source
+distribution. This file contains the following functions:
-@table @code
-@item @strong{MySQL}
-Has the following additional types (among others;
-@pxref{CREATE TABLE, , @code{CREATE TABLE}}):
@itemize @bullet
@item
-@code{ENUM} type for one of a set of strings.
-@item
-@code{SET} type for many of a set of strings.
-@item
-@code{BIGINT} type for 64-bit integers.
-@end itemize
+@code{metaphon()} returns a metaphon string of the string argument.
+This is something like a soundex string, but it's more tuned for English.
@item
-@strong{MySQL} also supports
-the following additional type attributes:
-@itemize @bullet
+@code{myfunc_double()} returns the sum of the ASCII values of the
+characters in its arguments, divided by the sum of the length of its arguments.
@item
-@code{UNSIGNED} option for integer columns.
+@code{myfunc_int()} returns the sum of the length of its arguments.
@item
-@code{ZEROFILL} option for integer columns.
+@code{sequence([const int])} returns an sequence starting from the given
+number or 1 if no number has been given.
@item
-@code{AUTO_INCREMENT} option for integer columns that are a
-@code{PRIMARY KEY}.
-@xref{mysql_insert_id, , @code{mysql_insert_id()}}.
+@code{lookup()} returns the IP number for a hostname.
@item
-@code{DEFAULT} value for all columns.
+@code{reverse_lookup()} returns the hostname for an IP number.
+The function may be called with a string @code{"xxx.xxx.xxx.xxx"} or
+four numbers.
@end itemize
-@item mSQL2
-@code{mSQL} column types correspond to the @strong{MySQL} types shown below:
-@multitable @columnfractions .15 .85
-@item @code{mSQL} @strong{type} @tab @strong{Corresponding @strong{MySQL} type}
-@item @code{CHAR(len)} @tab @code{CHAR(len)}
-@item @code{TEXT(len)} @tab @code{TEXT(len)}. @code{len} is the maximal length.
-And @code{LIKE} works.
-@item @code{INT} @tab @code{INT}. With many more options!
-@item @code{REAL} @tab @code{REAL}. Or @code{FLOAT}. Both 4- and 8-byte versions are available.
-@item @code{UINT} @tab @code{INT UNSIGNED}
-@item @code{DATE} @tab @code{DATE}. Uses ANSI SQL format rather than @code{mSQL}'s own format.
-@item @code{TIME} @tab @code{TIME}
-@item @code{MONEY} @tab @code{DECIMAL(12,2)}. A fixed-point value with two decimals.
-@end multitable
-@end table
-
-@noindent
-@strong{Index Creation}
-
-@table @code
-@item @strong{MySQL}
-Indexes may be specified at table creation time with the @code{CREATE TABLE}
-statement.
-@item mSQL
-Indexes must be created after the table has been created, with separate
-@code{CREATE INDEX} statements.
-@end table
-
-@noindent
-@strong{To Insert a Unique Identifier into a Table}
-
-@table @code
-@item @strong{MySQL}
-Use @code{AUTO_INCREMENT} as a column type
-specifier.
-@xref{mysql_insert_id, , @code{mysql_insert_id()}}.
-@item mSQL
-Create a @code{SEQUENCE} on a table and select the @code{_seq} column.
-@end table
-
-@noindent
-@strong{To Obtain a Unique Identifier for a Row}
-
-@table @code
-@item @strong{MySQL}
-Add a @code{PRIMARY KEY} or @code{UNIQUE} key to the table and use this.
-New in Version 3.23.11: If the @code{PRIMARY} or @code{UNIQUE} key consists of only one
-column and this is of type integer, one can also refer to it as
-@code{_rowid}.
-@item mSQL
-Use the @code{_rowid} column. Observe that @code{_rowid} may change over time
-depending on many factors.
-@end table
-
-@noindent
-@strong{To Get the Time a Column Was Last Modified}
-
-@table @code
-@item @strong{MySQL}
-Add a @code{TIMESTAMP} column to the table. This column is automatically set
-to the current date and time for @code{INSERT} or @code{UPDATE} statements if
-you don't give the column a value or if you give it a @code{NULL} value.
-
-@item mSQL
-Use the @code{_timestamp} column.
-@end table
-
-@noindent
-@strong{@code{NULL} Value Comparisons}
-
-@table @code
-@item @strong{MySQL}
-@strong{MySQL} follows
-ANSI SQL, and a comparison with @code{NULL} is always @code{NULL}.
-@item mSQL
-In @code{mSQL}, @code{NULL = NULL} is TRUE. You
-must change @code{=NULL} to @code{IS NULL} and @code{<>NULL} to
-@code{IS NOT NULL} when porting old code from @code{mSQL} to @strong{MySQL}.
-@end table
-
-@noindent
-@strong{String Comparisons}
-
-@table @code
-@item @strong{MySQL}
-Normally, string comparisons are performed in case-independent fashion with
-the sort order determined by the current character set (ISO-8859-1 Latin1 by
-default). If you don't like this, declare your columns with the
-@code{BINARY} attribute, which causes comparisons to be done according to the
-ASCII order used on the @strong{MySQL} server host.
-@item mSQL
-All string comparisons are performed in case-sensitive fashion with
-sorting in ASCII order.
-@end table
-
-@noindent
-@strong{Case-insensitive Searching}
-
-@table @code
-@item @strong{MySQL}
-@code{LIKE} is a case-insensitive or case-sensitive operator, depending on
-the columns involved. If possible, @strong{MySQL} uses indexes if the
-@code{LIKE} argument doesn't start with a wild-card character.
-@item mSQL
-Use @code{CLIKE}.
-@end table
-@noindent
-@strong{Handling of Trailing Spaces}
-
-@table @code
-@item @strong{MySQL}
-Strips all spaces at the end of @code{CHAR} and @code{VARCHAR}
-columns. Use a @code{TEXT} column if this behavior is not desired.
-@item mSQL
-Retains trailing space.
-@end table
-
-@noindent
-@strong{@code{WHERE} Clauses}
+A dynamically loadable file should be compiled as a sharable object file,
+using a command something like this:
-@table @code
-@item @strong{MySQL}
-@strong{MySQL} correctly prioritizes everything (@code{AND} is evaluated
-before @code{OR}). To get @code{mSQL} behavior in @strong{MySQL}, use
-parentheses (as shown in an example below).
-@item mSQL
-Evaluates everything from left to right. This means that some logical
-calculations with more than three arguments cannot be expressed in any
-way. It also means you must change some queries when you upgrade to
-@strong{MySQL}. You do this easily by adding parentheses. Suppose you
-have the following @code{mSQL} query:
@example
-mysql> SELECT * FROM table WHERE a=1 AND b=2 OR a=3 AND b=4;
-@end example
-To make @strong{MySQL} evaluate this the way that @code{mSQL} would,
-you must add parentheses:
-@example
-mysql> SELECT * FROM table WHERE (a=1 AND (b=2 OR (a=3 AND (b=4))));
+shell> gcc -shared -o udf_example.so myfunc.cc
@end example
-@end table
-@noindent
-@strong{Access Control}
-
-@table @code
-@item @strong{MySQL}
-Has tables to store grant (permission) options per user, host, and
-database. @xref{Privileges}.
-@item mSQL
-Has a file @file{mSQL.acl} in which you can grant read/write privileges for
-users.
-@item
-@end table
+You can easily find out the correct compiler options for your system by
+running this command in the @file{sql} directory of your MySQL
+source tree:
-@cindex PostgreSQL/MySQL, overview
-@node Compare PostgreSQL, , Compare mSQL, Comparisons
-@section How MySQL Compares to PostgreSQL
+@example
+shell> make udf_example.o
+@end example
-When reading the following, please note that both products are
-continually evolving. We at @strong{MySQL AB} and the PostgreSQL
-developers are both working on making our respective database as good as
-possible, so we are both a serious choice to any commercial database.
+You should run a compile command similar to the one that @code{make} displays,
+except that you should remove the @code{-c} option near the end of the line
+and add @code{-o udf_example.so} to the end of the line. (On some systems,
+you may need to leave the @code{-c} on the command.)
-The following comparison is made by us at MySQL AB. We have tried to be
-as accurate and fair as possible, but because we don't have a full
-knowledge of all PostgreSQL features while we know MySQL througly, we
-may have got some things wrong. We will however correct these when they
-come to our attention.
+Once you compile a shared object containing UDFs, you must install it
+and tell MySQL about it. Compiling a shared object from
+@file{udf_example.cc} produces a file named something like
+@file{udf_example.so} (the exact name may vary from platform to platform).
+Copy this file to some directory searched by @code{ld}, such as
+@file{/usr/lib}. On many systems, you can set the @code{LD_LIBRARY} or
+@code{LD_LIBRARY_PATH} environment variable to point at the directory where
+you have your UDF function files. The @code{dlopen} manual page tells you
+which variable you should use on your system. You should set this in
+@code{mysql.server} or @code{safe_mysqld} and restart @code{mysqld}.
-We would first like to note that @code{PostgreSQL} and @strong{MySQL}
-are both widely used products, but with different design goals, even if
-we are both striving to be ANSI SQL compatible. This means that for
-some applications @strong{MySQL} is more suitable and for others
-@code{PostgreSQL} is more suitable. When choosing which database to
-use, you should first check if the database's feature set satisfies your
-application. If you need speed, @strong{MySQL} is probably your best
-choice. If you need some of the extra features that only @code{PostgreSQL}
-can offer, you should use @code{PostgreSQL}.
+After the library is installed, notify @code{mysqld} about the new
+functions with these commands:
-@cindex PostgreSQL/MySQL, strategies
-@menu
-* MySQL-PostgreSQL goals:: MySQL and PostgreSQL development strategies
-* MySQL-PostgreSQL features:: Featurevise Comparison of MySQL and PostgreSQL
-* MySQL-PostgreSQL benchmarks:: Benchmarking MySQL and PostgreSQL
-@end menu
+@example
+mysql> CREATE FUNCTION metaphon RETURNS STRING SONAME "udf_example.so";
+mysql> CREATE FUNCTION myfunc_double RETURNS REAL SONAME "udf_example.so";
+mysql> CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "udf_example.so";
+mysql> CREATE FUNCTION lookup RETURNS STRING SONAME "udf_example.so";
+mysql> CREATE FUNCTION reverse_lookup RETURNS STRING SONAME "udf_example.so";
+@end example
-@node MySQL-PostgreSQL goals, MySQL-PostgreSQL features, Compare PostgreSQL, Compare PostgreSQL
-@subsection MySQL and PostgreSQL development strategies
+Functions can be deleted using @code{DROP FUNCTION}:
-When adding things to MySQL we take pride to do an optimal, definite
-solution. The code should be so good that we shouldn't have any need to
-change it in the foreseeable future. We also do not like to sacrifice
-speed for features but instead will do our utmost to find a solution
-that will give maximal throughput. This means that development will take
-a little longer, but the end result will be well worth this. This kind
-of development is only possible because all server code are checked by
-one of a few (currently two) persons before it's included in the
-@strong{MySQL} server.
+@example
+mysql> DROP FUNCTION metaphon;
+mysql> DROP FUNCTION myfunc_double;
+mysql> DROP FUNCTION myfunc_int;
+mysql> DROP FUNCTION lookup;
+mysql> DROP FUNCTION reverse_lookup;
+@end example
-We at MySQL AB believe in frequent releases to be able to push out new
-features quickly to our users. Because of this we do a new small release
-about every 3 weeks, which a major branch every year. All releases are
-throughly tested with our testing tools on a lot of different platforms.
+The @code{CREATE FUNCTION} and @code{DROP FUNCTION} statements update the
+system table @code{func} in the @code{mysql} database. The function's name,
+type and shared library name are saved in the table. You must have the
+@strong{insert} and @strong{delete} privileges for the @code{mysql} database
+to create and drop functions.
-PostgreSQL is based on a kernel with lots of contributors. In this setup
-it makes sense to prioritize adding a lot of new features, instead of
-implementing them optimally, because one can always optimize things
-later if there arises a need for this.
+You should not use @code{CREATE FUNCTION} to add a function that has already
+been created. If you need to reinstall a function, you should remove it with
+@code{DROP FUNCTION} and then reinstall it with @code{CREATE FUNCTION}. You
+would need to do this, for example, if you recompile a new version of your
+function, so that @code{mysqld} gets the new version. Otherwise the server
+will continue to use the old version.
-Another big difference between @strong{MySQL} and PostgreSQL is that
-nearly all of the code in the MySQL server are coded by developers that
-are employed by MySQL AB and are still working on the server code. The
-exceptions are the transaction engines and the regexp library.
+Active functions are reloaded each time the server starts, unless you start
+@code{mysqld} with the @code{--skip-grant-tables} option. In this case, UDF
+initialization is skipped and UDFs are unavailable. (An active function is
+one that has been loaded with @code{CREATE FUNCTION} and not removed with
+@code{DROP FUNCTION}.)
-This is in sharp contrast to the PostgreSQL code where the majority of
-the code is coded by a big group of people with different backgrounds.
-It was only recently that the PostgreSQL developers announced that they
-current developer group had finally had time to take a look at all
-the code in the current PostgreSQL release.
-Both of the above development methods has it's own merits and drawbacks.
-We here at @strong{MySQL AB} think of course that our model is better
-because our model gives better code consistence, more optimal and
-reusable code and, in our opinion, fewer bugs. Because we are the
-authors of the @strong{MySQL} server code we are better able to
-coordinate new features and releases.
+@node Adding native function, , Adding UDF, Adding functions
+@subsection Adding a New Native Function
-@cindex PostgreSQL/MySQL, features
-@node MySQL-PostgreSQL features, MySQL-PostgreSQL benchmarks, MySQL-PostgreSQL goals, Compare PostgreSQL
-@subsection Featurevise Comparison of MySQL and PostgreSQL
+@cindex adding, native functions
+@cindex native functions, adding
+@cindex functions, native, adding
-On the @uref{http://www.mysql.com/information/crash-me.php, crash-me}
-page you can find a list of those database constructs and limits that
-one can detect automatically with a program. Note however that a lot of
-the numerical limits may be changed with startup options for respective
-database. The above web page is however extremely useful when you want to
-ensure that your applications works with many different databases or
-when you want to convert your application from one datbase to another.
+The procedure for adding a new native function is described below. Note
+that you cannot add native functions to a binary distribution because
+the procedure involves modifying MySQL source code. You must
+compile MySQL yourself from a source distribution. Also note
+that if you migrate to another version of MySQL (for example,
+when a new version is released), you will need to repeat the procedure
+with the new version.
-@strong{MySQL} offers the following advantages over PostgreSQL:
+To add a new native MySQL function, follow these steps:
-@itemize @bullet
-@item
-@code{MySQL} is generally much faster than PostgreSQL.
-@xref{MySQL-PostgreSQL benchmarks}.
-@item
-Because @strong{MySQL} has a much larger user base than PostgreSQL the
-code is more tested and has historically been more stable than
-PostgreSQL. @strong{MySQL} is the much more used in production
-environments than PostgreSQL, mostly thanks to that @strong{MySQL AB},
-former TCX DataKonsult AB, has provided top quality commercial support
-for @strong{MySQL} from the day it was released, whereas until recently
-PostgreSQL was unsupported.
-@item
-@strong{MySQL} works on more platforms than PostgreSQL. @xref{Which OS}.
-@item
-@strong{MySQL} works better on Windows; @strong{MySQL} is running as a
-native windows application (a service on NT/Win2000/WinXP), while
-PostgreSQL is run under the cygwin emulation. We have heard that
-PostgreSQL is not yet that stable on windows but we haven't been able to
-verify this ourselves.
-@item
-@strong{MySQL} has more API to other languages and is supported by more
-programs than PostgreSQL. @xref{Contrib}.
-@item
-@strong{MySQL} works on 24/7 heavy duty systems. In most circumstances
-you never have to run any cleanups on @code{MySQL}. PostgreSQL doesn't
-yet support 24/7 systems because you have have to run @code{vacuum()}
-once in a while to reclaim space from @code{UPDATE} and @code{DELETE}
-commands and to perform statistics analyzes that are critical to get
-good performance with PostgreSQL. Vacuum is also needed after adding
-a lot of new rows to a table. On a busy system with lots of changes
-vacuum must be run very frequently, in the worst cases even many times a
-day. During the @code{vacuum()} run, which may take hours if the
-database is big, the database is from a production standpoint
-practically dead. The PostgreSQL team has fixing this on their TODO,
-but we assume that this is not an easy thing to fix permanently.
-@item
-A working, tested replication feature used by sites like
-@uref{http://finance.yahoo.com, Yahoo finance},
-@uref{http://www.mobile.de/,mobile.de} and
-@uref{http://www.slashdot.org,Slashdot}.
-@item
-Included in the @strong{MySQL} distribution is included two different
-testing suits (@file{mysql-test-run} and
-@uref{http://www.mysql.com/information/crash-me.php,crash-me}) and a
-benchmark suite. The test system is actively updated with code to test
-each new feature and almost all repeatable bugs that comes to our
-attention. We test @strong{MySQL} with these on a lot of platforms
-before every release. These tests are more sofisticated than anything
-have seen from PostgreSQL and ensures that the @strong{MySQL} code keeps
-at a high standard.
-@item
-There are far moore books in print on @strong{MySQL} than on PostgreSQL.
-O'Reilly, Sams, Que, and New Riders are all major publishers with books
-about MySQL. All @strong{MySQL} features is also documented in the
-@strong{MySQL} on-line manual because when a feature is implemented, the
-@strong{MySQL} developers are required to document it before it's
-included in the source.
-@item
-@strong{MySQL} has supports more of the standard ODBC functions than
-@code{PostgreSQL}.
-@item
-@strong{MySQL} has a much more sophisticated @code{ALTER TABLE}.
-@item
-@strong{MySQL} has support for tables without transactions for
-applications that need all speed they can get. The tables may be memory
-based,@code{HEAP} tables or disk based @code{MyISAM}. @xref{Table types}.
-@item
-@strong{MySQL} has support for 2 different table handles that support
-transactions (@code{BDB} and @code{InnoDB}). Because
-every transaction engine performs differently under different
-conditions, this gives the application writer more options to find an
-optimal solution for his/her setup. @xref{Table types}.
-@item
-@code{MERGE} tables gives you a unique way to instantly make a view over
-a set of identical tables and use these as one. This is perfectly for
-systems where you have log files that you order for example by month.
-@xref{MERGE}.
-@item
-The option to compress read-only tables, but still have direct access to
-the rows in the table, gives you better performance by minimizing disk
-reads. This is very useful when you are archiving
-things.@xref{myisampack}.
-@item
-@strong{MySQL} has internal support for text search. @xref{Fulltext Search}.
-@item
-You can access many databases from the same connection (depending of course
-on your privileges).
-@item
-@strong{MySQL} is coded from the start with multi-threading while
-PostgreSQL uses processes. Because context switching and access to
-common storage areas is much faster between threads, than are separate
-processes, this gives @strong{MySQL} a big speed advantage in multi-user
-applications and also makes it easier for @strong{MySQL} to take full
-advantage of symmetric multiprocessor systems (SMP).
-@item
-@strong{MySQL} has a much more sophisticated privilege system than
-PostgreSQL. While PostgreSQL only supports @code{INSERT},
-@code{SELECT}, @code{update/delete} grants per user on a database or a
-table @strong{MySQL} allows you to define a full set of different
-privileges on database, table and columns level. @strong{MySQL} also allows
-you to specify the privilege on host+user combinations. @xref{GRANT}.
-@item
-@strong{MySQL} supports a compressed server/client protocol which
-improves performance over slow links.
-@item
-@strong{MySQL} employs the table handler concept and is the only
-relational database we know of built around this concept. This allows
-different low level table types to be swapped into the SQL engine, each
-table type optimized for a different performance characteristics.
-@item
-All @code{MySQL} table types (except @strong{InnoDB}) are implemented as
-files (ie: one table per file), which makes it really easy to backup,
-move, delete and even symlink databases and tables when the server is
-down.
+@enumerate
@item
-Tools to repair and optimize @strong{MyISAM} tables (the most common
-@strong{MySQL} table type). A repair tool is only needed when a
-physical corruption of a data file happens, usually from a hardware
-failure. It allows a majority of the data to be recovered.
+Add one line to @file{lex.h} that defines the function name in the
+@code{sql_functions[]} array.
@item
-Upgrading @strong{MySQL} is painless. When you are upgrading @strong{MySQL},
-you don't need to dump/restore your data, as you have to do with most
-PostgreSQL upgrades.
-@end itemize
-
-Drawbacks with @strong{MySQL} compared to PostgreSQL:
+If the function prototype is simple (just takes zero, one, two or three
+arguments), you should in lex.h specify SYM(FUNC_ARG#) (where # is the
+number of arguments) as the second argument in the
+@code{sql_functions[]} array and add a function that creates a function
+object in @file{item_create.cc}. Take a look at @code{"ABS"} and
+@code{create_funcs_abs()} for an example of this.
-@itemize @bullet
-@item
-The transaction support in @strong{MySQL} is not yet as well tested as
-PostgreSQL's system.
-@item
-Because @strong{MySQL} uses threads, which are still a moving target on
-many OS, one must either use binaries from
-@uref{http://www.mysql.com/downloads} or carefully follow our
-instructions on
-@uref{http://www.mysql.com/doc/I/n/Installing_source.html} to get an
-optimal binary that works in all cases.
-@item
-Table locking, as used by the non-transactional @code{MyISAM} tables, is
-in many cases faster than page locks, row locks or versioning. The
-drawback however is that if one doesn't take into account how table
-locks works, a single long-running query can block a table for updates
-for a long time. This can usable be avoided when designing the
-application. If not, one can always switch the trouble table to use one
-of the transactional table types. @xref{Table locking}.
+If the function prototype is complicated (for example takes a variable number
+of arguments), you should add two lines to @file{sql_yacc.yy}. One
+indicates the preprocessor symbol that @code{yacc} should define (this
+should be added at the beginning of the file). Then define the function
+parameters and add an ``item'' with these parameters to the
+@code{simple_expr} parsing rule. For an example, check all occurrences
+of @code{ATAN} in @file{sql_yacc.yy} to see how this is done.
@item
-With UDF (user defined functions) one can extend @strong{MySQL} with
-both normal SQL functions and aggregates, but this is not as easy or as
-flexible as in PostgreSQL. @xref{Adding functions}.
+In @file{item_func.h}, declare a class inheriting from @code{Item_num_func} or
+@code{Item_str_func}, depending on whether your function returns a number or a
+string.
@item
-Updates and deletes that goes over multiple tables is harder to do in
-@strong{MySQL}. (Will be fixed in @strong{MySQL} 4.0 with multi-table
-@code{DELETE} and multi-table @code{UPDATE} and in @strong{MySQL} 4.1
-with @code{SUB-SELECT})
-@end itemize
-
-PostgreSQL offers currently the following advantages over @strong{MySQL}:
+In @file{item_func.cc}, add one of the following declarations, depending
+on whether you are defining a numeric or string function:
+@example
+double Item_func_newname::val()
+longlong Item_func_newname::val_int()
+String *Item_func_newname::Str(String *str)
+@end example
-Note that because we know the @strong{MySQL} road map, we have included
-in the following table the version when @strong{MySQL} should support
-this feature. Unfortunately we couldn't do this for previous comparison,
-because we don't know the PostgreSQL roadmap.
+If you inherit your object from any of the standard items (like
+@code{Item_num_func} you probably only have to define one of the above
+functions and let the parent object take care of the other functions.
+For example, the @code{Item_str_func} class defines a @code{val()} function
+that executes @code{atof()} on the value returned by @code{::str()}.
-@multitable @columnfractions .70 .30
-@item @strong{Feature} @tab @strong{MySQL version}
-@item Subselects @tab 4.1
-@item Foreign keys @tab 4.0 and 4.1
-@item Views. @tab 4.2
-@item Stored procedures in multiple languages @tab 4.1
-@item Extensible type system. @tab Not planed
-@item Unions @tab 4.0.
-@item Full join. @tab 4.0 or 4.1.
-@item Triggers. @tab 4.1
-@item Constrainst @tab 4.1
-@item Cursors @tab 4.1 or 4.2
-@item Extensible index types like R-trees @tab R-trees are planned to 4.2
-@item Inherited tables @tab Not planned
-@end multitable
+@item
+You should probably also define the following object function:
+@example
+void Item_func_newname::fix_length_and_dec()
+@end example
+This function should at least calculate @code{max_length} based on the
+given arguments. @code{max_length} is the maximum number of characters
+the function may return. This function should also set @code{maybe_null
+= 0} if the main function can't return a @code{NULL} value. The
+function can check if any of the function arguments can return
+@code{NULL} by checking the arguments @code{maybe_null} variable. You
+can take a look at @code{Item_func_mod::fix_length_and_dec} for a
+typical example of how to do this.
+@end enumerate
-Other reasons to use PostgreSQL:
+All functions must be thread safe (In other words, don't use any global or
+static variables in the functions without protecting them with mutexes).
-@itemize @bullet
-@item
-Standard usage is in PostgreSQL closer to ANSI SQL in some cases.
-@item
-One can get speed up PostgreSQL by coding things as stored procedures.
-@item
-Bigger team of developers that contributes to the server.
-@end itemize
+If you want to return @code{NULL}, from @code{::val()}, @code{::val_int()}
+or @code{::str()} you should set @code{null_value} to 1 and return 0.
-Drawbacks with PostgreSQL compared to @strong{MySQL}:
+For @code{::str()} object functions, there are some additional
+considerations to be aware of:
@itemize @bullet
@item
-@code{Vaccum()} makes PostgreSQL hard to use in a 24/7 environment.
+The @code{String *str} argument provides a string buffer that may be
+used to hold the result. (For more information about the @code{String} type,
+take a look at the @file{sql_string.h} file.)
@item
-Only transactional tables.
+The @code{::str()} function should return the string that holds the result or
+@code{(char*) 0} if the result is @code{NULL}.
@item
-Much slower insert/delete/update.
+All current string functions try to avoid allocating any memory unless
+absolutely necessary!
@end itemize
-For a complete list of drawbacks, you should also examine the first table
-in this section.
-@cindex PostgreSQL/MySQL, benchmarks
-@node MySQL-PostgreSQL benchmarks, , MySQL-PostgreSQL features, Compare PostgreSQL
-@subsection Benchmarking MySQL and PostgreSQL
-
-The only open source benchmark, that we know of, that can be used to
-benchmark @strong{MySQL} and PostgreSQL (and other databases) is our
-own. It can be found at:
-@uref{http://www.mysql.com/information/benchmarks.html}.
+@node Adding procedures, MySQL internals, Adding functions, Extending MySQL
+@section Adding New Procedures to MySQL
-We have many times asked the PostgreSQL developers and some PostgreSQL
-users to help us extend this benchmark to make the definitive benchmark
-for databases, but unfortunately we haven't got any feedback for this.
-
-We, the @strong{MySQL} developers, have because of this spent a lot of
-hours to get maximum performance from PostgreSQL for the benchmarks, but
-because we don't know PostgreSQL intimately we are sure that there are
-things that we have missed. We have on the benchmark page documented
-exactly how we did run the benchmark so that it should be easy for
-anyone to repeat and verify our results.
-
-The benchmarks are usually run with and without the @code{--fast}
-option. When run with @code{--fast} we are trying to use every trick
-the server can do to get the code to execute as fast as possible.
-The idea is that the normal run should show how the server would work in
-a default setup and the @code{--fast} run shows how the server would do
-if the application developer would use extensions in the server to make
-his application run faster.
-
-When running with PostgreSQL and @code{--fast} we do a @code{vacuum()}
-between after every major table update and drop table to make the database
-in perfect shape for the following selects. The time for vacuum() is
-measured separately.
-
-When running with PostgreSQL 7.1.1 we could however not run with
-@code{--fast} because during the insert test, the postmaster (the
-PostgreSQL deamon) died and the database was so corrupted that it was
-impossible to restart postmaster. (The details about the machine we run
-the benchmark can be found on the benchmark page). After this happened
-twice, we decided to postpone the @code{--fast} test until next
-PostgreSQL release.
+@cindex procedures, adding
+@cindex adding, procedures
+@cindex new procedures, adding
-Before going to the other benchmarks we know of, We would like to give
-some background to benchmarks:
+In MySQL, you can define a procedure in C++ that can access and
+modify the data in a query before it is sent to the client. The modification
+can be done on row-by-row or @code{GROUP BY} level.
-It's very easy to write a test that shows ANY database to be best
-database in the world, by just restricting the test to something the
-database is very good at and not test anything that the database is not
-good at; If one after this publish the result with a single figure
-things is even easier.
-
-This would be like we would measure the speed of @strong{MySQL} compared
-to PostgreSQL by looking at the summary time of the MySQL benchmarks on
-our web page. Based on this @strong{MySQL} would be more than 40 times
-faster than PostgreSQL, something that is of course not true. We could
-make things even worse by just taking the test where PostgreSQL performs
-worst and claim that @strong{MySQL} is more than 2000 times faster than
-PostgreSQL.
-
-The case is that @strong{MySQL} does a lot of optimizations that
-PostgreSQL doesn't do and the other way around. An SQL optimizer is a
-very complex thing and a company could spend years on just making the
-optimizer faster and faster.
+We have created an example procedure in MySQL Version 3.23 to
+show you what can be done.
-When looking at the benchmark results you should look for things that
-you do in your application and just use these results to decide which
-database would be best suited for your application. The benchmark
-results also shows things a particular database is not good at and should
-give you a notion about things to avoid and what you may have to do in
-other ways.
+Additionally we recommend you to take a look at 'mylua', which you can find in the Contrib directory. @xref{Contrib}. Which this you can use the LUA
+language to load a procedure at runtime into @code{mysqld}.
-We know of two benchmark tests that claims that PostgreSQL performers
-better than @strong{MySQL}. These both where multi-user tests, a test
-that we here at @strong{MySQL AB} haven't had time to write and include in
-the benchmark suite, mainly because it's a big task to do this in a
-manner that is fair against all databases.
+@menu
+* procedure analyse:: Procedure analyse
+* Writing a procedure:: Writing a procedure.
+@end menu
-One is the benchmark paid for by
-@uref{http://www.greatbridge.com/about/press.php?content_id=4,Great
-Bridge}.
-This is the worst benchmark we have ever seen anyone ever conduct. This
-was not only tuned to only test what PostgreSQL is absolutely best at,
-it was also totally unfair against every other database involved in the
-test.
+@node procedure analyse, Writing a procedure, Adding procedures, Adding procedures
+@subsection Procedure Analyse
-@strong{NOTE}: We know that not even some of the main PostgreSQL
-developers did like the way Great Bridge conducted the benchmark, so we
-don't blame them for the way the benchmark was made.
+@code{analyse([max elements,[max memory]])}
-This benchmark has been condemned in a lot of postings and newsgroups so
-we will here just shortly repeat some things that where wrong with it.
+This procedure is defined in the @file{sql/sql_analyse.cc}. This
+examines the result from your query and returns an analysis of the
+results:
@itemize @bullet
@item
-The tests where run with an expensive commercial tool, that makes it
-impossible for an open source company like us to verify the benchmarks,
-or even check how the benchmark where really done. The tool is not even
-a true benchmark tool, but a application/setup testing tool. To refer
-this as STANDARD benchmark tool is to stretch the truth a long way.
-@item
-Great Bridge admitted that they had optimized the PostgreSQL database
-(with vacuum() before the test) and tuned the startup for the tests,
-something they hadn't done for any of the other databases involved. To
-say "This process optimizes indexes and frees up disk space a bit. The
-optimized indexes boost performance by some margin". Our benchmarks
-clearly indicates that the difference in running a lot of selects on a
-database with and without vacuum() can easily differ by a factor of 10.
-@item
-The test results where also strange; The AS3AP test documentation
-mentions that the test does:
-
-"selections, simple joins, projections, aggregates, one-tuple updates,
-and bulk updates"
-
-PostgreSQL is good at doing selects and joins (especially after a
-vacuum()), but doesn't perform as well on inserts/updates; The
-benchmarks seem to indicate that only SELECTs where done (or very few
-updates) . This could easily explain they good results for PostgreSQL in
-this test. The bad results for MySQL will be obvious a bit down in this
-document.
-@item
-They did run the so called benchmark from a Windows machine against a
-Linux machine over ODBC, a setup that no normal database user would ever
-do when running a heavy multi-user application. This tested more the
-ODBC driver and the Windows protocol used between the clients than the
-database itself.
-@item
-When running the database against Oracle and MS-SQL (Great Bridge has
-indirectly indicated that the databases they used in the test),
-they didn't use the native protocol but instead ODBC. Anyone that has
-ever used Oracle, knows that all real application uses the native
-interface instead of ODBC. Doing a test through ODBC and claiming that
-the results had anything to do with using the database for real can't
-be regarded as fair play. They should have done two tests with and
-without ODBC to provide the right facts (after having got experts to tune
-all involved databases of course).
-@item
-They refer to the TPC-C tests, but doesn't anywhere mention that the
-tests they did where not a true TPC-C test and they where not even
-allowed to call it a TPC-C test. A TPC-C test can only be conducted by
-the rules approved by the @uref{http://www.tpc.org,TPC-council}. Great
-Bridge didn't do that. By doing this they have both violated the TPC
-trademark and miscredited their own benchmarks. The rules set by the
-TPC-council are very strict to ensure that no one can produce false
-results or make unprovable statements. Apparently Great Bridge wasn't
-interested in doing this.
-@item
-After the first test, we contacted Great Bridge and mentioned to them
-some of the obvious mistakes they had done with @strong{MySQL}; Running
-with a debug version of our ODBC driver, running on a Linux system that
-wasn't optimized for threads, using an old MySQL version when there was
-a recommended newer one available, not starting @strong{MySQL} with the
-right options for heavy multi-user use (the default installation of
-MySQL is tuned for minimal resource use). Great Bridge did run a new
-test, with our optimized ODBC driver and with better startup options for
-MySQL, but refused to either use our updated glibc library or our
-standard binary (used by 80% of our users), which was statically linked
-with a fixed glibc library.
-
-According to what we know, Great Bridge did nothing to ensure that the
-other databases where setup correctly to run good in their test
-environment. We are sure however that they didn't contact Oracle or
-Microsoft to ask for their advice in this matter ;)
+@code{max elements} (default 256) is the maximum number of distinct values
+@code{analyse} will notice per column. This is used by @code{analyse} to check if
+the optimal column type should be of type @code{ENUM}.
@item
-The benchmark was paid for by Great Bridge, and they decided to publish
-only partial chosen results (instead of publishing it all).
+@code{max memory} (default 8192) is the maximum memory @code{analyse} should
+allocate per column while trying to find all distinct values.
@end itemize
-Tim Perdue, a long time PostgreSQL fan and a reluctant MySQL user
-published a comparison on
-@uref{http://www.phpbuilder.com/columns/tim20001112.php3,phpbuider}.
-
-When we got aware of the comparison, we phoned Tim Perdue about this
-because there was a lot of strange things in his results. For example,
-he claimed that MySQL had a problem with five users in his tests, when we
-know that there are users with similar machines as his that are using
-MySQL with 2000 simultaneous connections doing 400 queries per second (In
-this case the limit was the web bandwidth, not the database).
-
-It sounded like he was using a Linux kernel that either had some
-problems with many threads (Linux kernels before 2.4 had a problem with
-this but we have documented how to fix this and Tim should be aware of
-this problem). The other possible problem could have been an old glibc
-library and that Tim didn't use a MySQL binary from our site, which is
-linked with a corrected glibc library, but had compiled a version of his
-own with. In any of the above cases, the symptom would have been exactly
-what Tim had measured.
+@example
+SELECT ... FROM ... WHERE ... PROCEDURE ANALYSE([max elements,[max memory]])
+@end example
-We asked Tim if we could get access to his data so that we could repeat
-the benchmark and if he could check the MySQL version on the machine to
-find out what was wrong and he promised to come back to us about this.
-He has not done that yet.
-Because of this we can't put any trust in this benchmark either :(
+@node Writing a procedure, , procedure analyse, Adding procedures
+@subsection Writing a Procedure
-Conclusion:
+For the moment, the only documentation for this is the source.
-The only benchmarks that exist today that anyone can download and run
-against @strong{MySQL}and PostgreSQL is the MySQL benchmarks. We here
-at @strong{MySQL} believe that open source databases should be tested
-with open source tools! This is the only way to ensure that no one
-does tests that nobody can reproduce and use this to claim that a
-database is better than another. Without knowing all the facts it's
-impossible to answer the claims of the tester.
+You can find all information about procedures by examining the following files:
-The thing we find strange is that every test we have seen about
-PostgreSQL, that is impossible to reproduce, claims that PostgreSQL is
-better in most cases while our tests, which anyone can reproduce,
-clearly shows otherwise. With this we don't want to say that PostgreSQL
-isn't good at many things (It is!) We would just like to see a fair test
-where they are very good so that we could get some friendly competition
-going!
+@itemize @bullet
+@item @file{sql/sql_analyse.cc}
+@item @file{sql/procedure.h}
+@item @file{sql/procedure.cc}
+@item @file{sql/sql_select.cc}
+@end itemize
-For more information about our benchmarks suite see @xref{MySQL
-Benchmarks}.
-We are working on an even better benchmark suite, including much better
-documentation of what the individual tests really do and how to add more
-tests to the suite.
+@node MySQL internals, , Adding procedures, Extending MySQL
+@section MySQL Internals
@cindex internals
@cindex threads
-@node MySQL internals, Environment variables, Comparisons, Top
-@chapter MySQL Internals
This chapter describes a lot of things that you need to know when
-working on the @strong{MySQL} code. If you plan to contribute to MySQL
+working on the MySQL code. If you plan to contribute to MySQL
development, want to have access to the bleeding-edge in-between
versions code, or just want to keep track of development, follow the
instructions in @xref{Installing source tree}. If you are interested in MySQL
@@ -43642,10 +42732,11 @@ This is a relatively low traffic list, in comparison with
* MySQL test suite:: MySQL test suite
@end menu
+
@node MySQL threads, MySQL test suite, MySQL internals, MySQL internals
-@section MySQL Threads
+@subsection MySQL Threads
-The @strong{MySQL} server creates the following threads:
+The MySQL server creates the following threads:
@itemize @bullet
@@ -43689,10 +42780,12 @@ started to read and apply updates from the master.
@code{mysqladmin processlist} only shows the connection, @code{INSERT DELAYED},
and replication threads.
+
+@node MySQL test suite, , MySQL threads, MySQL internals
+@subsection MySQL Test Suite
+
@cindex mysqltest, MySQL Test Suite
@cindex testing mysqld, mysqltest
-@node MySQL test suite, , MySQL threads, MySQL internals
-@section MySQL Test Suite
Until recently, our main full-coverage test suite was based on proprietary
customer data and for that reason has not been publicly available. The only
@@ -43700,27 +42793,28 @@ publicly available part of our testing process consisted of the @code{crash-me}
test, a Perl DBI/DBD benchmark found in the @code{sql-bench} directory, and
miscellaneous tests located in @code{tests} directory. The lack of a
standardized publicly available test suite has made it difficult for our users,
-as well developers, to do regression tests on the @strong{MySQL} code. To
+as well developers, to do regression tests on the MySQL code. To
address this problem, we have created a new test system that is included in
the source and binary distributions starting in Version 3.23.29.
-The current set of test cases doesn't test everything in MySQL but, it
+The current set of test cases doesn't test everything in MySQL, but it
should catch most obvious bugs in the SQL processing code, OS/library
issues, and is quite thorough in testing replication. Our eventual goal
is to have the tests cover 100% of the code. We welcome contributions
to our test suite. You may especially want to contribute tests that
examine the functionality critical to your system, as this will ensure
-that all future @strong{MySQL} releases will work well with your
+that all future MySQL releases will work well with your
applications.
@menu
-* running mysqltest::
-* extending mysqltest::
-* Reporting mysqltest bugs::
+* running mysqltest:: Running the MySQL Test Suite
+* extending mysqltest:: Extending the MySQL Test Suite
+* Reporting mysqltest bugs:: Reporting Bugs in the MySQL Test Suite
@end menu
+
@node running mysqltest, extending mysqltest, MySQL test suite, MySQL test suite
-@subsection Running the MySQL Test Suite
+@subsubsection Running the MySQL Test Suite
The test system consist of a test language interpreter
(@code{mysqltest}), a shell script to run all
@@ -43731,7 +42825,7 @@ your system after a build, type @code{make test} or
installed a binary distribution, @code{cd} to the install root
(eg. @code{/usr/local/mysql}), and do @code{scripts/mysql-test-run}.
All tests should succeed. If not, you should try to find out why and
-report the problem if this is a bug in @strong{MySQL}.
+report the problem if this is a bug in MySQL.
@xref{Reporting mysqltest bugs}.
If you have a copy of @code{mysqld} running on the machine where you want to
@@ -43746,22 +42840,23 @@ You can run one individual test case with
If one test fails, you should test running @code{mysql-test-run} with
the @code{--force} option to check if any other tests fails.
+
@node extending mysqltest, Reporting mysqltest bugs, running mysqltest, MySQL test suite
-@subsection Extending the MySQL Test Suite
+@subsubsection Extending the MySQL Test Suite
You can use the @code{mysqltest} language to write your own test cases.
Unfortunately, we have not yet written full documentation for it - we plan to
do this shortly. You can, however, look at our current test cases and use
them as an example. The following points should help you get started:
-@itemize
+@itemize @bullet
@item
The tests are located in @code{mysql-test/t/*.test}
@item
A test case consists of @code{;} terminated statements and is similar to the
input of @code{mysql} command line client. A statement by default is a query
-to be sent to @strong{MySQL} server, unless it is recognized as internal
+to be sent to MySQL server, unless it is recognized as internal
command ( eg. @code{sleep} ).
@item
@@ -43827,10 +42922,11 @@ attachments, you should ftp all the relevant files to:
@end itemize
+
@node Reporting mysqltest bugs, , extending mysqltest, MySQL test suite
-@subsection Reporting bugs in the MySQL Test Suite
+@subsubsection Reporting Bugs in the MySQL Test Suite
-If your @strong{MySQL} version doesn't pass the test suite you should
+If your MySQL version doesn't pass the test suite you should
do the following:
@itemize @bullet
@@ -43851,7 +42947,7 @@ cd mysql-test
mysql-test-run --local test-name
@end example
-If this fails, then you should configure @strong{MySQL} with
+If this fails, then you should configure MySQL with
@code{--with-debug} and run @code{mysql-test-run} with the
@code{--debug} option. If this also fails send the trace file
@file{var/tmp/master.trace} to ftp://support.mysql.com/pub/mysql/secret
@@ -43864,8 +42960,8 @@ Try also to run @code{mysql-test-run} with the @code{--force} option to
see if there is any other test that fails.
@item
-If you have compiled @strong{MySQL} yourself, check our manual for how
-to compile @strong{MySQL} on your platform or, preferable, use one of
+If you have compiled MySQL yourself, check our manual for how
+to compile MySQL on your platform or, preferable, use one of
the binaries we have compiled for you at
@uref{http://www.mysql.com/downloads/}. All our standard binaries should
pass the test suite !
@@ -43873,7 +42969,7 @@ pass the test suite !
@item
If you get an error, like @code{Result length mismatch} or @code{Result
content mismatch} it means that the output of the test didn't match
-exactly the expected output. This could be a bug in @strong{MySQL} or
+exactly the expected output. This could be a bug in MySQL or
that your mysqld version produces slight different results under some
circumstances.
@@ -43888,106 +42984,1805 @@ If a test fails totally, you should check the logs file in the
@code{mysql-test/var/log} directory for hints of what went wrong.
@item
-If you have compiled @strong{MySQL} with debugging you can try to debug this
+If you have compiled MySQL with debugging you can try to debug this
by running @code{mysql-test-run} with the @code{--gdb} and/or @code{--debug}
options.
@xref{Making trace files}.
-If you have not compiled @strong{MySQL} for debugging you should probably
+If you have not compiled MySQL for debugging you should probably
do that. Just specify the @code{--with-debug} options to @code{configure}!
@xref{Installing source}.
@end itemize
-@page
-@cindex environment variables, list of
-@node Environment variables, Users, MySQL internals, Top
-@appendix Environment Variables
-Here is a list of all the environment variables that are used directly or
-indirectly by @strong{MySQL}. Most of these can also be found in other
-places in this manual.
-Note that any options on the command line will take precedence over
-values specified in configuration files and environment variables, and
-values in configuration files take precedence over values in environment
-variables.
-In many cases it's preferable to use a configure file instead of environment
-variables to modify the behavior of @strong{MySQL}. @xref{Option files}.
+@node Problems, Users, Extending MySQL, Top
+@appendix Problems and Common Errors
+
+@cindex problems, common errors
+@cindex errors, common
+
+@menu
+* What is crashing:: How to determine what is causing problems
+* Common errors:: Some common errors when using MySQL
+* Installation Issues:: Installation Related Issues
+* Administration Issues:: Administration Related Issues
+* Query Issues:: Query Related Issues
+* Table Definition Issues:: Table Definition Related Issues
+@end menu
+
+This chapter lists some common problems and error messages that users have
+run into. You will learn how to figure out what the problem is, and what
+to do to solve it. You will also find proper solutions to some common
+problems.
+
+
+@node What is crashing, Common errors, Problems, Problems
+@appendixsec How to Determine What Is Causing Problems
+
+When you run into problems, the first thing you should do is to find out
+which program / piece of equipment is causing problems:
+
+@itemize @bullet
+@item
+If you have one of the following symptoms, then it is probably a hardware
+(like memory, motherboard, CPU, or hard disk) or kernel problem:
+@itemize @minus
+@item
+The keyboard doesn't work. This can normally be checked by pressing
+Caps Lock. If the Caps Lock light doesn't change you have to replace
+your keyboard. (Before doing this, you should try to reboot
+your computer and check all cables to the keyboard.)
+@item
+The mouse pointer doesn't move.
+@item
+The machine doesn't answer to a remote machine's pings.
+@item
+Different, unrelated programs don't behave correctly.
+@item
+If your system rebooted unexpectedly (a faulty user level program should
+NEVER be able to take down your system).
+@end itemize
+
+In this case you should start by checking all your cables and run some
+diagnostic tool to check your hardware!
+You should also check if there are any patches, updates, or service
+packs for your operating system that could likely solve your problems.
+Check also that all your libraries (like glibc) are up to date.
+
+It's always good to use a machine with ECC memory to discover
+memory problems early!
+@item
+If your keyboard is locked up, you may be able to fix this by
+logging into your machine from another machine and execute
+@code{kbd_mode -a} on it.
+
+@item
+Please examine your system log file (/var/log/messages or similar) for
+reasons for your problems. If you think the problem is in MySQL
+then you should also examine MySQL's log files. @xref{Update log}.
+
+@item
+If you don't think you have hardware problems, you should try to find
+out which program is causing problems.
+
+Try using @code{top}, @code{ps}, @code{taskmanager}, or some similar program,
+to check which program is taking all CPU or is locking the machine.
+
+@item
+Check with @code{top}, @code{df}, or a similar program if you are out of
+memory, disk space, open files, or some other critical resource.
+
+@item
+If the problem is some runaway process, you can always try to kill it. If it
+doesn't want to die, there is probably a bug in the operating system.
+@end itemize
+
+If after you have examined all other possibilities and you have
+concluded that it's the MySQL server or a MySQL client
+that is causing the problem, it's time to do a bug report for our
+mailing list or our support team. In the bug report, try to give a
+very detailed description of how the system is behaving and what you think is
+happening. You should also state why you think it's MySQL that
+is causing the problems. Take into consideration all the situations in
+this chapter. State any problems exactly how they appear when you
+examine your system. Use the 'cut and paste' method for any output
+and/or error messages from programs and/or log files!
+
+Try to describe in detail which program is not working and all
+symptoms you see! We have in the past received many bug reports that just
+state "the system doesn't work". This doesn't provide us with any
+information about what could be the problem.
+
+If a program fails, it's always useful to know:
+
+@itemize @bullet
+@item
+Has the program in question made a segmentation fault (core dumped)?
+@item
+Is the program taking the whole CPU? Check with @code{top}. Let the
+program run for a while, it may be evaluating something heavy.
+@item
+If it's the @code{mysqld} server that is causing problems, can you
+do @code{mysqladmin -u root ping} or @code{mysqladmin -u root processlist}?
+@item
+What does a client program say (try with @code{mysql}, for example)
+when you try to connect to the MySQL server?
+Does the client jam? Do you get any output from the program?
+@end itemize
+
+When sending a bug report, you should of follow the outlines
+described in this manual. @xref{Asking questions}.
+
+
+@node Common errors, Installation Issues, What is crashing, Problems
+@appendixsec Some Common Errors When Using MySQL
+
+@cindex errors, list of
+
+@menu
+* Error Access denied:: @code{Access denied} Error
+* Gone away:: @code{MySQL server has gone away} error
+* Can not connect to server:: @code{Can't connect to [local] MySQL server} error
+* Blocked host:: @code{Host '...' is blocked} error
+* Too many connections:: @code{Too many connections} error
+* Non-transactional tables:: @code{Some non-transactional changed tables couldn't be rolled back} Error
+* Out of memory:: @code{Out of memory} error
+* Packet too large:: @code{Packet too large} error
+* Communication errors:: Communication errors / Aborted connection
+* Full table:: @code{The table is full} error
+* Cannot create:: @code{Can't create/write to file} Error
+* Commands out of sync:: @code{Commands out of sync} error in client
+* Ignoring user:: @code{Ignoring user} error
+* Cannot find table:: @code{Table 'xxx' doesn't exist} error
+* Cannot initialize character set:: @code{Can@'t initialize character set xxx} error.
+* Not enough file handles:: File Not Found
+@end menu
+
+
+This section lists some errors that users frequently get. You will find
+descriptions of the errors, and how to solve the problem here.
+
+
+@node Error Access denied, Gone away, Common errors, Common errors
+@appendixsubsec @code{Access denied} Error
+
+@cindex errors, access denied
+@cindex problems, access denied errors
+@cindex access denied errors
+
+@xref{Privileges}, and especially. @xref{Access denied}.
+
+
+@node Gone away, Can not connect to server, Error Access denied, Common errors
+@appendixsubsec @code{MySQL server has gone away} Error
+
+This section also covers the related @code{Lost connection to server
+during query} error.
+
+The most common reason for the @code{MySQL server has gone away} error
+is that the server timed out and closed the connection. By default, the
+server closes the connection after 8 hours if nothing has happened. You
+can change the time limit by setting the @code{wait_timeout} variable when
+you start @code{mysqld}.
+
+Another common reason to receive the @code{MySQL server has gone away} error
+is because you have issued a ``close'' on your MySQL connection
+and then tried to run a query on the closed connection.
+
+You can check that the MySQL hasn't died by executing
+@code{mysqladmin version} and examining the uptime.
+
+If you have a script, you just have to issue the query again for the client
+to do an automatic reconnection.
+
+You normally can get the following error codes in this case
+(which one you get is OS-dependent):
+
+@multitable @columnfractions .3 .7
+@item @code{CR_SERVER_GONE_ERROR} @tab The client couldn't send a question to the
+server.
+@item @code{CR_SERVER_LOST} @tab The client didn't get an error when writing
+to the server, but it didn't get a full answer (or any answer) to the question.
+@end multitable
+
+You can also get these errors if you send a query to the server that is
+incorrect or too large. If @code{mysqld} gets a packet that is too large
+or out of order, it assumes that something has gone wrong with the client and
+closes the connection. If you need big queries (for example, if you are
+working with big @code{BLOB} columns), you can increase the query limit by
+starting @code{mysqld} with the @code{-O max_allowed_packet=#} option
+(default 1M). The extra memory is allocated on demand, so @code{mysqld} will
+use more memory only when you issue a big query or when @code{mysqld} must
+return a big result row!
+
+
+@node Can not connect to server, Blocked host, Gone away, Common errors
+@appendixsubsec @code{Can't connect to [local] MySQL server} error
+
+A MySQL client on Unix can connect to the @code{mysqld} server in two
+different ways: Unix sockets, which connect through a file in the file
+system (default @file{/tmp/mysqld.sock}) or TCP/IP, which connects
+through a port number. Unix sockets are faster than TCP/IP but can only
+be used when connecting to a server on the same computer. Unix sockets
+are used if you don't specify a hostname or if you specify the special
+hostname @code{localhost}.
+
+On Windows you can connect only with TCP/IP if the @code{mysqld} server
+is running on Win95/Win98. If it's running on NT, you can also connect
+with named pipes. The name of the named pipe is MySQL. If you
+don't give a hostname when connecting to @code{mysqld}, a MySQL client
+will first try to connect to the named pipe, and if this doesn't work it
+will connect to the TCP/IP port. You can force the use of named pipes
+on Windows by using @code{.} as the hostname.
+
+The error (2002) @code{Can't connect to ...} normally means that there
+isn't a MySQL server running on the system or that you are
+using a wrong socket file or TCP/IP port when trying to connect to the
+@code{mysqld} server.
+
+Start by checking (using @code{ps} or the task manager on Windows) that
+there is a process running named @code{mysqld} on your server! If there
+isn't any @code{mysqld} process, you should start one. @xref{Starting
+server}.
+
+If a @code{mysqld} process is running, you can check the server by
+trying these different connections (the port number and socket pathname
+might be different in your setup, of course):
+
+@example
+shell> mysqladmin version
+shell> mysqladmin variables
+shell> mysqladmin -h `hostname` version variables
+shell> mysqladmin -h `hostname` --port=3306 version
+shell> mysqladmin -h 'ip for your host' version
+shell> mysqladmin --socket=/tmp/mysql.sock version
+@end example
+
+Note the use of backquotes rather than forward quotes with the @code{hostname}
+command; these cause the output of @code{hostname} (that is, the current
+hostname) to be substituted into the @code{mysqladmin} command.
+
+Here are some reasons the @code{Can't connect to local MySQL server}
+error might occur:
+
+@itemize @bullet
+@item
+@code{mysqld} is not running.
+@item
+You are running on a system that uses MIT-pthreads.
+If you are running on a system that doesn't have native threads,
+@code{mysqld} uses the MIT-pthreads package. @xref{Which OS}. However,
+all MIT-pthreads versions doesn't support Unix sockets. On a system
+without sockets support you must always specify the hostname explicitly
+when connecting to the server. Try using this command to check the
+connection to the server:
+@example
+shell> mysqladmin -h `hostname` version
+@end example
+@item
+Someone has removed the Unix socket that @code{mysqld} uses (default
+@file{/tmp/mysqld.sock}). You might have a @code{cron} job that removes
+the MySQL socket (for example, a job that removes old files
+from the @file{/tmp} directory). You can always run @code{mysqladmin
+version} and check that the socket @code{mysqladmin} is trying to use
+really exists. The fix in this case is to change the @code{cron} job to
+not remove @file{mysqld.sock} or to place the socket somewhere else. You
+can specify a different socket location at MySQL configuration
+time with this command:
+@example
+shell> ./configure --with-unix-socket-path=/path/to/socket
+@end example
+You can also start @code{safe_mysqld} with the
+@code{--socket=/path/to/socket} option and set the environment variable
+@code{MYSQL_UNIX_PORT} to the socket pathname before starting your
+MySQL clients.
+@item
+You have started the @code{mysqld} server with
+the @code{--socket=/path/to/socket} option. If you change the socket
+pathname for the server, you must also notify the MySQL clients
+about the new path. You can do this by setting the environment variable
+@code{MYSQL_UNIX_PORT} to the socket pathname or by providing the socket path
+as an argument to the clients. You can test the socket with this command:
+
+@example
+shell> mysqladmin --socket=/path/to/socket version
+@end example
+@item
+You are using Linux and one thread has died (core dumped). In this case
+you must kill the other @code{mysqld} threads (for example, with the
+@code{mysql_zap} script before you can start a new MySQL
+server. @xref{Crashing}.
+@item
+You may not have read and write privilege to either the directory that holds
+the socket file or privilege to the socket file itself. In this case you
+have to either change the privilege for the directory / file or restart
+@code{mysqld} so that it uses a directory that you can access.
+@end itemize
+
+If you get the error message @code{Can't connect to MySQL server on
+some_hostname}, you can try the following things to find out what the
+problem is :
+
+@itemize @bullet
+@item
+Check if the server is up by doing @code{telnet your-host-name
+tcp-ip-port-number} and press @code{RETURN} a couple of times. If there
+is a MySQL server running on this port you should get a
+responses that includes the version number of the running MySQL
+server. If you get an error like @code{telnet: Unable to connect to
+remote host: Connection refused}, then there is no server running on the
+given port.
+@item
+Try connecting to the @code{mysqld} daemon on the local machine and check
+the TCP/IP port that @code{mysqld} it's configured to use (variable @code{port}) with
+@code{mysqladmin variables}.
+@item
+Check that your @code{mysqld} server is not started with the
+@code{--skip-networking} option.
+@end itemize
+
+
+@node Blocked host, Too many connections, Can not connect to server, Common errors
+@appendixsubsec @code{Host '...' is blocked} Error
+
+If you get an error like this:
+
+@example
+Host 'hostname' is blocked because of many connection errors.
+Unblock with 'mysqladmin flush-hosts'
+@end example
+
+this means that @code{mysqld} has gotten a lot (@code{max_connect_errors})
+of connect requests from the host @code{'hostname'} that have been interrupted
+in the middle. After @code{max_connect_errors} failed requests, @code{mysqld}
+assumes that something is wrong (like an attack from a cracker), and
+blocks the site from further connections until someone executes the command
+@code{mysqladmin flush-hosts}.
+
+By default, @code{mysqld} blocks a host after 10 connection errors.
+You can easily adjust this by starting the server like this:
+
+@example
+shell> safe_mysqld -O max_connect_errors=10000 &
+@end example
+
+Note that if you get this error message for a given host, you should first
+check that there isn't anything wrong with TCP/IP connections from that
+host. If your TCP/IP connections aren't working, it won't do you any good to
+increase the value of the @code{max_connect_errors} variable!
+
+
+@node Too many connections, Non-transactional tables, Blocked host, Common errors
+@appendixsubsec @code{Too many connections} Error
+
+If you get the error @code{Too many connections} when you try to connect
+to MySQL, this means that there is already @code{max_connections}
+clients connected to the @code{mysqld} server.
+
+If you need more connections than the default (100), then you should restart
+@code{mysqld} with a bigger value for the @code{max_connections} variable.
+
+Note that @code{mysqld} actually allows (@code{max_connections}+1)
+clients to connect. The last connection is reserved for a user with the
+@strong{process} privilege. By not giving this privilege to normal
+users (they shouldn't need this), an administrator with this privilege
+can log in and use @code{SHOW PROCESSLIST} to find out what could be
+wrong. @xref{SHOW}.
+
+The maximum number of connects MySQL is depending on how good
+the thread library is on a given platform. Linux or Solaris should be
+able to support 500-1000 simultaneous connections, depending on how much
+RAM you have and what your clients are doing.
+
+
+@node Non-transactional tables, Out of memory, Too many connections, Common errors
+@appendixsubsec @code{Some non-transactional changed tables couldn't be rolled back} Error
+
+@cindex Non-transactional tables
+
+If you get the error/warning: @code{Warning: Some non-transactional
+changed tables couldn't be rolled back} when trying to do a
+@code{ROLLBACK}, this means that some of the tables you used in the
+transaction didn't support transactions. These non-transactional tables
+will not be affected by the @code{ROLLBACK} statement.
+
+The most typical case when this happens is when you have tried to create
+a table of a type that is not supported by your @code{mysqld} binary.
+If @code{mysqld} doesn't support a table type (or if the table type is
+disabled by a startup option) , it will instead create the table type
+with the table type that is most resembles to the one you requested,
+probably @code{MyISAM}.
+
+You can check the table type for a table by doing:
+
+@code{SHOW TABLE STATUS LIKE 'table_name'}. @xref{SHOW TABLE STATUS}.
+
+You can check the extensions your @code{mysqld} binary supports by doing:
+
+@code{show variables like 'have_%'}. @xref{SHOW VARIABLES}.
+
+
+@node Out of memory, Packet too large, Non-transactional tables, Common errors
+@appendixsubsec @code{Out of memory} Error
+
+If you issue a query and get something like the following error:
+
+@example
+mysql: Out of memory at line 42, 'malloc.c'
+mysql: needed 8136 byte (8k), memory in use: 12481367 bytes (12189k)
+ERROR 2008: MySQL client ran out of memory
+@end example
+
+note that the error refers to the MySQL client @code{mysql}. The
+reason for this error is simply that the client does not have enough memory to
+store the whole result.
+
+To remedy the problem, first check that your query is correct. Is it
+reasonable that it should return so many rows? If so,
+you can use @code{mysql --quick}, which uses @code{mysql_use_result()}
+to retrieve the result set. This places less of a load on the client (but
+more on the server).
+
+
+@node Packet too large, Communication errors, Out of memory, Common errors
+@appendixsubsec @code{Packet too large} Error
+
+When a MySQL client or the @code{mysqld} server gets a packet bigger
+than @code{max_allowed_packet} bytes, it issues a @code{Packet too large}
+error and closes the connection.
+
+If you are using the @code{mysql} client, you may specify a bigger buffer by
+starting the client with @code{mysql --set-variable=max_allowed_packet=8M}.
+
+If you are using other clients that do not allow you to specify the maximum
+packet size (such as @code{DBI}), you need to set the packet size when you
+start the server. You cau use a command-line option to @code{mysqld} to set
+@code{max_allowed_packet} to a larger size. For example, if you are
+expecting to store the full length of a @code{BLOB} into a table, you'll need
+to start the server with the @code{--set-variable=max_allowed_packet=16M}
+option.
+
+You can also get strange problems with large packets if you are using
+big blobs, but you haven't given @code{mysqld} access to enough memory
+to handle the query. If you suspect this is the case, try adding
+@code{ulimit -d 256000} to the beginning of the @code{safe_mysqld} script
+and restart @code{mysqld}.
+
+@node Communication errors, Full table, Packet too large, Common errors
+@appendixsubsec Communication Errors / Aborted Connection
+
+@cindex aborted clients
+@cindex aborted connection
+@cindex connection, aborted
+
+Starting with @code{MySQL 3.23.40} you only get the @code{Aborted
+connection} error of you start @code{mysqld} with @code{--warnings}.
+
+If you find errors like the following in your error log.
+
+@example
+010301 14:38:23 Aborted connection 854 to db: 'users' user: 'josh'
+@end example
+
+@xref{Error log}.
+
+This means that something of the following has happened:
+
+@itemize @bullet
+@item
+The client program did not call @code{mysql_close()} before exit.
+@item
+The client had been sleeping more than @code{wait_timeout} or
+@code{interactive_timeout} without doing any requests. @xref{SHOW
+VARIABLES}.
+@item
+The client program ended abruptly in the middle of the transfer.
+@end itemize
+
+When the above happens, the server variable @code{Aborted_clients} is
+incremented.
+
+The server variable @code{Aborted_connects} is incremented when:
+
+@itemize @bullet
+@item
+When a connection packet doesn't contain the right information.
+@item
+When the user didn't have privileges to connect to a database.
+@item
+When a user uses a wrong password.
+@item
+When it takes more than @code{connect_timeout} seconds to get
+a connect package.
+@end itemize
+
+Note that the above could indicate that someone is trying to break into
+your database!
+
+@xref{SHOW VARIABLES}.
+
+Other reasons for problems with Aborted clients / Aborted connections.
+@itemize @bullet
+@item
+Usage of duplex Ethernet protocol, both half and full with
+Linux. Many Linux Ethernet drivers have this bug. You should test
+for this bug by transferring a huge file via ftp between these two
+machines. If a transfer goes in burst-pause-burst-pause ... mode then
+you are experiencing a Linux duplex syndrome. The only solution to
+this problem is switching of both half and full duplexing on hubs
+and switches.
+@item
+Some problem with the thread library that causes interrupts on reads.
+@item
+Badly configured TCP/IP.
+@item
+Faulty Ethernets or hubs or switches, cables ... This can be diagnosed
+properly only by replacing hardware.
+@item
+@code{max_allowed_packet} is too small or queries require more memory
+than you have alloacated for @code{mysqld}. @xref{Packet too large}.
+@end itemize
+
+
+@node Full table, Cannot create, Communication errors, Common errors
+@appendixsubsec @code{The table is full} Error
+
+@cindex table is full
+
+This error occurs in older MySQL versions when an in-memory temporary
+table becomes larger than @code{tmp_table_size} bytes. To avoid this
+problem, you can use the @code{-O tmp_table_size=#} option to
+@code{mysqld} to increase the temporary table size or use the SQL
+option @code{SQL_BIG_TABLES} before you issue the problematic
+query. @xref{SET OPTION, , @code{SET OPTION}}.
+
+You can also start @code{mysqld} with the @code{--big-tables} option.
+This is exactly the same as using @code{SQL_BIG_TABLES} for all queries.
+
+In MySQL Version 3.23, in-memory temporary tables will automatically be
+converted to a disk-based @code{MyISAM} table after the table size gets
+bigger than @code{tmp_table_size}.
+
+
+@node Cannot create, Commands out of sync, Full table, Common errors
+@appendixsubsec @code{Can't create/write to file} Error
+
+@cindex can't create/write to file
+
+If you get an error for some queries of type:
+
+@example
+Can't create/write to file '\\sqla3fe_0.ism'.
+@end example
+
+this means that MySQL can't create a temporary file for the
+result set in the given temporary directory. (The above error is a
+typical error message on Windows, and the Unix error message is similar.)
+The fix is to start @code{mysqld} with @code{--tmpdir=path} or to add to your option
+file:
+
+@example
+[mysqld]
+tmpdir=C:/temp
+@end example
+
+assuming that the @file{c:\\temp} directory exists. @xref{Option files}.
+
+Check also the error code that you get with @code{perror}. One reason
+may also be a disk full error;
+
+@example
+shell> perror 28
+Error code 28: No space left on device
+@end example
+
+
+@node Commands out of sync, Ignoring user, Cannot create, Common errors
+@appendixsubsec @code{Commands out of sync} Error in Client
+
+@cindex commands out of sync
+
+If you get @code{Commands out of sync; You can't run this command now}
+in your client code, you are calling client functions in the wrong order!
+
+This can happen, for example, if you are using @code{mysql_use_result()} and
+try to execute a new query before you have called @code{mysql_free_result()}.
+It can also happen if you try to execute two queries that return data without
+a @code{mysql_use_result()} or @code{mysql_store_result()} in between.
+
+
+@node Ignoring user, Cannot find table, Commands out of sync, Common errors
+@appendixsubsec @code{Ignoring user} Error
+
+If you get the following error:
+
+@code{Found wrong password for user: 'some_user@@some_host'; Ignoring user}
+
+this means that when @code{mysqld} was started or when it reloaded the
+permissions tables, it found an entry in the @code{user} table with
+an invalid password. As a result, the entry is simply ignored by the
+permission system.
+
+Possible causes of and fixes for this problem:
+
+@itemize @bullet
+@item
+You may be running a new version of @code{mysqld} with an old
+@code{user} table.
+You can check this by executing @code{mysqlshow mysql user} to see if
+the password field is shorter than 16 characters. If so, you can correct this
+condition by running the @code{scripts/add_long_password} script.
+
+@item
+The user has an old password (8 characters long) and you didn't start
+@code{mysqld} with the @code{--old-protocol} option.
+Update the user in the @code{user} table with a new password or
+restart @code{mysqld} with @code{--old-protocol}.
+
+@item
+@findex PASSWORD()
+You have specified a password in the @code{user} table without using the
+@code{PASSWORD()} function. Use @code{mysql} to update the user in the
+@code{user} table with a new password. Make sure to use the @code{PASSWORD()}
+function:
+
+@example
+mysql> update user set password=PASSWORD('your password')
+ where user='XXX';
+@end example
+@end itemize
+
+
+@node Cannot find table, Cannot initialize character set, Ignoring user, Common errors
+@appendixsubsec @code{Table 'xxx' doesn't exist} Error
+
+If you get the error @code{Table 'xxx' doesn't exist} or @code{Can't
+find file: 'xxx' (errno: 2)}, this means that no table exists
+in the current database with the name @code{xxx}.
+
+Note that as MySQL uses directories and files to store databases and
+tables, the database and table names are @strong{case sensitive}!
+(On Windows the databases and tables names are not case sensitive, but all
+references to a given table within a query must use the same case!)
+
+You can check which tables you have in the current database with
+@code{SHOW TABLES}. @xref{SHOW, , @code{SHOW}}.
+
+
+@node Cannot initialize character set, Not enough file handles, Cannot find table, Common errors
+@appendixsubsec @code{Can@'t initialize character set xxx} error.
+
+@cindex multibyte character sets
+
+If you get an error like:
+
+@example
+MySQL Connection Failed: Can't initialize character set xxx
+@end example
+
+This means one of the following things:
+
+@itemize @bullet
+@item
+The character set is a multi-byte character set and you have not support
+for the character set in the client.
+
+In this case you need to recompile the client with
+@code{--with-charset=xxx} or with @code{--with-extra-charsets=xxx}.
+@xref{configure options}.
+
+All standard MySQL binaries are compiled with
+@code{--with-extra-character-sets=complex} which will enable support for
+all multi-byte character sets. @xref{Character sets}.
+
+@item
+The character set is a simple character set which is not compiled into
+@code{mysqld} and the character set definition files is not in the place
+where the client expect to find them.
+
+In this case you need to:
+
+@itemize @bullet
+@item
+Recompile the client with support for the character set.
+@xref{configure options}.
+@item
+Specify to the client where the character set definition files are. For many
+client you can do this with the
+@code{--character-sets-dir=path-to-charset-dir} option.
+@item
+Copy the character definition files to the path where the client expect them
+to be.
+@end itemize
+@end itemize
+
+
+@node Not enough file handles, , Cannot initialize character set, Common errors
+@appendixsubsec File Not Found
+
+If you get @code{ERROR '...' not found (errno: 23)}, @code{Can't open
+file: ... (errno: 24)}, or any other error with @code{errno 23} or
+@code{errno 24} from MySQL, it means that you haven't allocated
+enough file descriptors for MySQL. You can use the
+@code{perror} utility to get a description of what the error number
+means:
+
+@example
+shell> perror 23
+File table overflow
+shell> perror 24
+Too many open files
+shell> perror 11
+Resource temporarily unavailable
+@end example
+
+The problem here is that @code{mysqld} is trying to keep open too many
+files simultaneously. You can either tell @code{mysqld} not to open so
+many files at once or increase the number of file descriptors
+available to @code{mysqld}.
+
+To tell @code{mysqld} to keep open fewer files at a time, you can make
+the table cache smaller by using the @code{-O table_cache=32} option to
+@code{safe_mysqld} (the default value is 64). Reducing the value of
+@code{max_connections} will also reduce the number of open files (the
+default value is 90).
+
+@tindex ulimit
+To change the number of file descriptors available to @code{mysqld}, you
+can use the option @code{--open-files-limit=#} to @code{safe_mysqld} or
+@code{-O open-files-limit=#} to @code{mysqld}. @xref{SHOW VARIABLES}.
+The easiest way to do that is to add the option to your option file.
+@xref{Option files}. If you have an old @code{mysqld} version that
+doesn't support this, you can edit the @code{safe_mysqld} script. There
+is a commented-out line @code{ulimit -n 256} in the script. You can
+remove the @code{'#'} character to uncomment this line, and change the
+number 256 to affect the number of file descriptors available to
+@code{mysqld}.
+
+@code{ulimit} (and @code{open-files-limit}) can increase the number of
+file descriptors, but only up to the limit imposed by the operating
+system. There is also a 'hard' limit that can only be overrided if you
+start @code{safe_mysqld} or @code{mysqld} as root (Just remember that
+you need to also use the @code{--user=..} option in this case). If you
+need to increase the OS limit on the number of file descriptors
+available to each process, consult the documentation for your operating
+system.
+
+Note that if you run the @code{tcsh} shell, @code{ulimit} will not work!
+@code{tcsh} will also report incorrect values when you ask for the current
+limits! In this case you should start @code{safe_mysqld} with @code{sh}!
+
+
+@node Installation Issues, Administration Issues, Common errors, Problems
+@appendixsec Installation Related Issues
+
+
+@menu
+* Link errors:: Problems When Linking with the MySQL Client Library
+* Changing MySQL user:: How to Run MySQL As a Normal User
+* File permissions :: Problems with File Permissions
+@end menu
+
+@node Link errors, Changing MySQL user, Installation Issues, Installation Issues
+@appendixsubsec Problems When Linking with the MySQL Client Library
+
+@cindex linking, errors
+@cindex errors, linking
+@cindex problems, linking
+
+If you are linking your program and you get errors for unreferenced
+symbols that start with @code{mysql_}, like the following:
+
+@example
+/tmp/ccFKsdPa.o: In function `main':
+/tmp/ccFKsdPa.o(.text+0xb): undefined reference to `mysql_init'
+/tmp/ccFKsdPa.o(.text+0x31): undefined reference to `mysql_real_connect'
+/tmp/ccFKsdPa.o(.text+0x57): undefined reference to `mysql_real_connect'
+/tmp/ccFKsdPa.o(.text+0x69): undefined reference to `mysql_error'
+/tmp/ccFKsdPa.o(.text+0x9a): undefined reference to `mysql_close'
+@end example
+
+you should be able to solve this by adding @code{-Lpath-to-the-mysql-library
+-lmysqlclient} @strong{LAST} on your link line.
+
+If you get @code{undefined reference} errors for the @code{uncompress}
+or @code{compress} function, add @code{-lz} @strong{LAST} on your link
+line and try again!
+
+If you get @code{undefined reference} errors for functions that should
+exist on your system, like @code{connect}, check the man page for the
+function in question, for which libraries you should add to the link
+line!
+
+If you get @code{undefined reference} errors for functions that don't
+exist on your system, like the following:
+
+@example
+mf_format.o(.text+0x201): undefined reference to `__lxstat'
+@end example
+
+it usually means that your library is compiled on a system that is not
+100 % compatible with yours. In this case you should download the
+latest MySQL source distribution and compile this yourself.
+@xref{Installing source}.
+
+If you are trying to run a program and you then get errors for
+unreferenced symbols that start with @code{mysql_} or that the
+@code{mysqlclient} library can't be found, this means that your system
+can't find the share @code{libmysqlclient.so} library.
+
+The fix for this is to tell your system to search after shared
+libraries where the library is located by one of the following methods:
+
+@itemize @bullet
+@item
+Add the path to the directory where you have @code{libmysqlclient.so} the
+@code{LD_LIBRARY_PATH} environment variable.
+@item
+Add the path to the directory where you have @code{libmysqlclient.so} the
+@code{LD_LIBRARY} environment variable.
+@item
+Copy @code{libmysqlclient.so} to some place that is searched by your system,
+like @file{/lib}, and update the shared library information by executing
+@code{ldconfig}.
+@end itemize
+
+Another way to solve this problem is to link your program statically, with
+@code{-static}, or by removing the dynamic MySQL libraries
+before linking your code. In the second case you should be
+sure that no other programs are using the dynamic libraries!
+
+
+@node Changing MySQL user, File permissions , Link errors, Installation Issues
+@appendixsubsec How to Run MySQL As a Normal User
+
+@cindex starting, @code{mysqld}
+@cindex @code{mysqld}, starting
+
+The MySQL server @code{mysqld} can be started and run by any user.
+In order to change @code{mysqld} to run as a Unix user @code{user_name}, you must
+do the following:
+
+@enumerate
+@item
+Stop the server if it's running (use @code{mysqladmin shutdown}).
+
+@item
+Change the database directories and files so that @code{user_name} has
+privileges to read and write files in them (you may need to do this as
+the Unix @code{root} user):
+
+@example
+shell> chown -R user_name /path/to/mysql/datadir
+@end example
+
+If directories or files within the MySQL data directory are
+symlinks, you'll also need to follow those links and change the directories
+and files they point to. @code{chown -R} may not follow symlinks for
+you.
+
+@item
+Start the server as user @code{user_name}, or, if you are using
+MySQL Version 3.22 or later, start @code{mysqld} as the Unix @code{root}
+user and use the @code{--user=user_name} option. @code{mysqld} will switch
+to run as the Unix user @code{user_name} before accepting any connections.
+
+@item
+To start the server as the given user name automatically at system
+startup time, add a @code{user} line that specifies the user name to
+the @code{[mysqld]} group of the @file{/etc/my.cnf} option file or the
+@file{my.cnf} option file in the server's data directory. For example:
+
+@example
+[mysqld]
+user=user_name
+@end example
+@end enumerate
+
+At this point, your @code{mysqld} process should be running fine and dandy as
+the Unix user @code{user_name}. One thing hasn't changed, though: the
+contents of the permissions tables. By default (right after running the
+permissions table install script @code{mysql_install_db}), the MySQL
+user @code{root} is the only user with permission to access the @code{mysql}
+database or to create or drop databases. Unless you have changed those
+permissions, they still hold. This shouldn't stop you from accessing
+MySQL as the MySQL @code{root} user when you're logged in
+as a Unix user other than @code{root}; just specify the @code{-u root} option
+to the client program.
+
+Note that accessing MySQL as @code{root}, by supplying @code{-u
+root} on the command line, has @emph{nothing} to do with MySQL running
+as the Unix @code{root} user, or, indeed, as another Unix user. The access
+permissions and user names of MySQL are completely separate from
+Unix user names. The only connection with Unix user names is that if you
+don't provide a @code{-u} option when you invoke a client program, the client
+will try to connect using your Unix login name as your MySQL user
+name.
+
+If your Unix box itself isn't secured, you should probably at least put a
+password on the MySQL @code{root} users in the access tables.
+Otherwise, any user with an account on that machine can run @code{mysql -u
+root db_name} and do whatever he likes.
+
+
+@node File permissions , , Changing MySQL user, Installation Issues
+@appendixsubsec Problems with File Permissions
+
+@cindex files, permissions
+@cindex error mesaages, can't find file
+@cindex files, not found message
+
+If you have problems with file permissions, for example, if @code{mysql}
+issues the following error message when you create a table:
+
+@example
+ERROR: Can't find file: 'path/with/filename.frm' (Errcode: 13)
+@end example
-@tindex CCX environment variable
-@tindex Environment variable, CCX
-@tindex CC environment variable
-@tindex Environment variable, CC
-@tindex CFLAGS environment variable
-@tindex Environment variable, CFLAGS
-@tindex CXXFLAGS environment variable
-@tindex Environment variable, CXXFLAGS
-@tindex DBI_USER environment variable
-@tindex Environment variable, DBI_USER
-@tindex DBI_TRACE environment variable
-@tindex Environment variable, DBI_TRACE
-@tindex HOME environment variable
-@tindex Environment variable, HOME
-@tindex LD_RUN_PATH environment variable
-@tindex Environment variable, LD_RUN_PATH
-@tindex MYSQL_DEBUG environment variable
-@tindex Environment variable, MYSQL_DEBUG
-@tindex MYSQL_HISTFILE environment variable
-@tindex Environment variable, MYSQL_HISTFILE
-@tindex MYSQL_HOST environment variable
-@tindex Environment variable, MYSQL_HOST
-@tindex MYSQL_PWD environment variable
-@tindex Environment variable, MYSQL_PWD
-@tindex MYSQL_TCP_PORT environment variable
-@tindex Environment variable, MYSQL_TCP_PORT
-@tindex MYSQL_UNIX_PORT environment variable
-@tindex Environment variable, MYSQL_UNIX_PORT
-@tindex PATH environment variable
-@tindex Environment variable, PATH
-@tindex TMPDIR environment variable
-@tindex Environment variable, TMPDIR
-@tindex TZ environment variable
-@tindex Environment variable, TZ
-@tindex UMASK_DIR environment variable
-@tindex Environment variable, UMASK_DIR
@tindex UMASK environment variable
@tindex Environment variable, UMASK
-@tindex USER environment variable
-@tindex Environment variable, USER
+then the environment variable @code{UMASK} might be set incorrectly when
+@code{mysqld} starts up. The default umask value is @code{0660}. You can
+change this behavior by starting @code{safe_mysqld} as follows:
-@multitable @columnfractions .2 .8
-@item @code{CCX} @tab Set this to your C++ compiler when running configure.
-@item @code{CC} @tab Set this to your C compiler when running configure.
-@item @code{CFLAGS} @tab Flags for your C compiler when running configure.
-@item @code{CXXFLAGS} @tab Flags for your C++ compiler when running configure.
-@item @code{DBI_USER} @tab The default user name for Perl DBI.
-@item @code{DBI_TRACE} @tab Used when tracing Perl DBI.
-@item @code{HOME} @tab The default path for the @code{mysql} history file is @file{$HOME/.mysql_history}.
-@item @code{LD_RUN_PATH} @tab Used to specify where your @code{libmysqlclient.so} is.
-@item @code{MYSQL_DEBUG} @tab Debug-trace options when debugging.
-@item @code{MYSQL_HISTFILE} @tab The path to the @code{mysql} history file.
-@item @code{MYSQL_HOST} @tab Default host name used by the @code{mysql} command-line prompt.
-@item @code{MYSQL_PWD} @tab The default password when connecting to @code{mysqld}. Note that use of this is insecure!
-@item @code{MYSQL_TCP_PORT} @tab The default TCP/IP port.
-@item @code{MYSQL_UNIX_PORT} @tab The default socket; used for connections to @code{localhost}.
-@item @code{PATH} @tab Used by the shell to finds the @strong{MySQL} programs.
-@item @code{TMPDIR} @tab The directory where temporary tables/files are created.
-@item @code{TZ} @tab This should be set to your local time zone. @xref{Timezone problems}.
-@item @code{UMASK_DIR} @tab The user-directory creation mask when creating directories. Note that this is ANDed with @code{UMASK}!
-@item @code{UMASK} @tab The user-file creation mask when creating files.
-@item @code{USER} @tab The default user on Windows to use when connecting to @code{mysqld}.
-@end multitable
+@example
+shell> UMASK=384 # = 600 in octal
+shell> export UMASK
+shell> /path/to/safe_mysqld &
+@end example
+
+@tindex UMASK_DIR environment variable
+@tindex Environment variable, UMASK_DIR
+By default MySQL will create database and @code{RAID}
+directories with permission type 0700. You can modify this behavior by
+setting the @code{UMASK_DIR} variable. If you set this, new
+directories are created with the combined @code{UMASK} and
+@code{UMASK_DIR}. For example, if you want to give group access to
+all new directories, you can do:
+
+@example
+shell> UMASK_DIR=504 # = 770 in octal
+shell> export UMASK_DIR
+shell> /path/to/safe_mysqld &
+@end example
+
+In MySQL Version 3.23.25 and above, MySQL assumes that the
+value for @code{UMASK} and @code{UMASK_DIR} is in octal if it starts
+with a zero.
+
+@xref{Environment variables}.
+
+
+@node Administration Issues, Query Issues, Installation Issues, Problems
+@appendixsec Administration Related Issues
+
+
+@menu
+* Crashing:: What To Do If MySQL Keeps Crashing
+* Resetting permissions:: How to Reset a Forgotten Password
+* Full disk:: How MySQL Handles a Full Disk
+* Temporary files:: Where MySQL Stores Temporary Files
+* Problems with mysql.sock:: How to Protect @file{/tmp/mysql.sock} from Being Deleted
+* Timezone problems:: Time Zone Problems
+@end menu
+
+@node Crashing, Resetting permissions, Administration Issues, Administration Issues
+@appendixsubsec What To Do If MySQL Keeps Crashing
+
+@cindex crash, repeated
+
+All MySQL versions are tested on many platforms before they are
+released. This doesn't mean that there aren't any bugs in
+MySQL, but it means if there are bugs, they are very few and can be
+hard to find. If you have a problem, it will always help if you try to
+find out exactly what crashes your system, as you will have a much better
+chance of getting this fixed quickly.
+
+First, you should try to find out whether the problem is that the
+@code{mysqld} daemon dies or whether your problem has to do with your
+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}. @xref{Error log}.
+
+Many crashes of MySQL are caused by corrupted index / data
+files. MySQL will update the data on disk, with the
+@code{write()} system call, after every SQL statement and before the
+client is notified about the result. (This is not true if you are running
+with @code{delayed_key_writes}, in which case only the data is written.)
+This means that the data is safe even if @code{mysqld} crashes, as the OS will
+ensure that the not flushed data is written to disk. You can force
+MySQL to sync everything to disk after every SQL command by
+starting @code{mysqld} with @code{--flush}.
+
+The above means that normally you shouldn't get corrupted tables unless:
+
+@itemize @bullet
+@item
+Someone/something killed @code{mysqld} or the machine in the middle
+of an update.
+@item
+You have found a bug in @code{mysqld} that caused it to die in the
+middle of an update.
+@item
+Someone is manipulating the data/index files outside of @strong{mysqld}
+without locking the table properly.
+@item
+If you are running many @code{mysqld} servers on the same data on a
+system that doesn't support good file system locks (normally handled by
+the @code{lockd} daemon ) or if you are running
+multiple servers with @code{--skip-locking}
+@item
+You have a crashed index/data file that contains very wrong data that
+got @code{mysqld} confused.
+@item
+You have found a bug in the data storage code. This isn't that likely,
+but it's at least possible. In this case you can try to change the file
+type to another database handler by using @code{ALTER TABLE} on a
+repaired copy of the table!
+@end itemize
+
+Because it is very difficult to know why something is crashing, first try to
+check whether or not things that work for others crash for you. Please try
+the following things:
+
+@itemize @bullet
+@item
+Take down the @code{mysqld} daemon with @code{mysqladmin shutdown}, run
+@code{myisamchk --silent --force */*.MYI} on all tables, and restart the
+@code{mysqld} daemon. This will ensure that you are running from a clean
+state. @xref{MySQL Database Administration}.
+
+@item
+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 MySQL restarted. @xref{Query log}.
+If you can repeatadly kill 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
+Try to make a test case that we can use to reproduce the problem.
+@xref{Reproduceable test case}.
+
+@item
+Try running the included mysql-test test and the MySQL
+benchmarks. @xref{MySQL test suite}. They should test 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 MySQL installation
+directory.
+
+@item
+Try @code{fork_test.pl} and @code{fork2_test.pl}.
+
+@item
+If you configure MySQL for debugging, it will be much easier to
+gather information about possible errors if something goes wrong.
+Reconfigure MySQL with the @code{--with-debug} option or
+@code{--with-debug=full} to @code{configure} and then recompile.
+@xref{Debugging server}.
+
+@item
+Configuring MySQL for debugging causes a safe memory allocator to be
+included that can find some errors. It also provides a lot of output about
+what is happening.
+
+@item
+Have you applied the latest patches for your operating system?
+
+@item
+Use the @code{--skip-locking} option to @code{mysqld}. On some systems, the
+@code{lockd} lock manager does not work properly; the @code{--skip-locking}
+option tells @code{mysqld} not to use external locking. (This means that you
+cannot run 2 @code{mysqld} servers on the same data and that you must be
+careful if you use @code{myisamchk}, but it may be instructive to try the
+option as a test.)
+
+@item
+Have you tried @code{mysqladmin -u root processlist} when @code{mysqld}
+appears to be running but not responding? Sometimes @code{mysqld} is not
+comatose even though you might think so. The problem may be that all
+connections are in use, or there may be some internal lock problem.
+@code{mysqladmin processlist} will usually be able to make a connection even
+in these cases, and can provide useful information about the current number
+of connections and their status.
+
+@item
+Run the command @code{mysqladmin -i 5 status} or @code{mysqladmin -i 5
+-r status} or in a separate window to produce statistics while you run
+your other queries.
+
+@item
+Try the following:
+@enumerate
+@item
+Start @code{mysqld} from @code{gdb} (or in another debugger).
+@xref{Using gdb on mysqld}.
+
+@item
+Run your test scripts.
+
+@item
+Print the backtrace and the local variables at the 3 lowest levels. In gdb you
+can do this with the following commands when @code{mysqld} has crashed inside
+gdb:
+
+@example
+backtrace
+info local
+up
+info local
+up
+info local
+@end example
+
+With gdb you can also examine which threads exist with @code{info
+threads} and switch to a specific thread with @code{thread #}, where
+@code{#} is the thread id.
+@end enumerate
+
+@item
+Try to simulate your application with a Perl script to force
+MySQL to crash or misbehave.
+
+@item
+Send a normal bug report. @xref{Bug reports}. Be even more detailed
+than usual. Because MySQL works for many people, it may be that the
+crash results from something that exists only on your computer (for example,
+an error that is related to your particular system libraries).
+@item
+If you have a problem with tables with dynamic-length rows and you are
+not using @code{BLOB/TEXT} columns (but only @code{VARCHAR} columns), you
+can try to change all @code{VARCHAR} to @code{CHAR} with @code{ALTER
+TABLE}. This will force MySQL to use fixed-size rows.
+Fixed-size rows take a little extra space, but are much more tolerant to
+corruption!
+
+The current dynamic row code has been in use at MySQL AB for at
+least 3 years without any problems, but by nature dynamic-length rows are
+more prone to errors, so it may be a good idea to try the above to see if
+it helps!
+@end itemize
+
+
+@node Resetting permissions, Full disk, Crashing, Administration Issues
+@appendixsubsec How to Reset a Forgotten Password
+
+@cindex passwords, forgotten
+@cindex passwords, resetting
+@cindex root user, password resetting
+
+If you have forgotten the @code{root} user password for MySQL, you
+can restore it with the following procedure:
+
+@enumerate
+@item
+Take down the @code{mysqld} server by sending a @code{kill} (not @code{kill
+-9}) to the @code{mysqld} server. The pid is stored in a @code{.pid}
+file, which is normally in the MySQL database directory:
+
+@example
+kill `cat /mysql-data-directory/hostname.pid`
+@end example
+
+You must be either the Unix @code{root} user or the same user the server
+runs as to do this.
+
+@item
+Restart @code{mysqld} with the @code{--skip-grant-tables} option.
+@item
+Connect to the @code{mysqld} server with @code{mysql -h hostname mysql} and change
+the password with a @code{GRANT} command. @xref{GRANT,,@code{GRANT}}.
+You can also do this with
+@code{mysqladmin -h hostname -u user password 'new password'}
+@item
+Load the privilege tables with: @code{mysqladmin -h hostname
+flush-privileges} or with the SQL command @code{FLUSH PRIVILEGES}.
+@end enumerate
+
+Note that after you started @code{mysqld} with @code{--skip-grant-tables},
+any usage of @code{GRANT} commands will give you an @code{Unknown command}
+error until you have executed @code{FLUSH PRIVILEGES}.
+
+
+@node Full disk, Temporary files, Resetting permissions, Administration Issues
+@appendixsubsec How MySQL Handles a Full Disk
+
+@cindex full disk
+@cindex disk full
+
+@noindent
+When a disk-full condition occurs, MySQL does the following:
+
+@itemize @bullet
+@item
+It checks once every minute to see whether or not there is enough space to
+write the current row. If there is enough space, it continues as if nothing had
+happened.
+@item
+Every 6 minutes it writes an entry to the log file warning about the disk
+full condition.
+@end itemize
+
+@noindent
+To alleviate the problem, you can take the following actions:
+
+@itemize @bullet
+@item
+To continue, you only have to free enough disk space to insert all records.
+@item
+To abort the thread, you must send a @code{mysqladmin kill} to the thread.
+The thread will be aborted the next time it checks the disk (in 1 minute).
+@item
+Note that other threads may be waiting for the table that caused the disk
+full condition. If you have several ``locked'' threads, killing the one
+thread that is waiting on the disk-full condition will allow the other
+threads to continue.
+@end itemize
+
+You need to know the following if you have a thread that is calling
+MySQL functions, but that thread has not created the connection to the
+MySQL database:
+
+When you call @code{mysql_init()} or @code{mysql_connect()}, MySQL will
+create a thread specific variable for the thread that is used by the
+debug library (among other things).
+
+If you have in a thread call a MySQL function, before a thread has
+called @code{mysql_init()} or @code{mysql_connect()}, the thread will
+not have the necessary thread specific variables in place and you are
+likely to end up with a core dump sooner or later.
+
+The get things to work smoothly you have to do the following:
+
+@enumerate
+@item
+Call @code{my_init()} at the start of your program if it calls
+any other MySQL function before calling @code{mysql_real_connect()}.
+@item
+Call @code{my_thread_init()} in the thread handler before calling
+any MySQL function.
+@item
+In the thread, call @code{my_thread_end()} before calling
+@code{pthread_exit()}. This will free the memory used by MySQL thread
+specific variables.
+@end enumerate
+
+Exceptions to the above behaveour is when you use @code{REPAIR} or
+@code{OPTIMIZE} or when the indexes are created in a batch after an
+@code{LOAD DATA INFILE} or after an @code{ALTER TABLE} statement.
+
+All of the above commands may use big temporary files that left to
+themself would cause big problems for the rest of the system. If
+MySQL gets disk full while doing any of the above operations,
+it will remove the big temporary files and mark the table as crashed
+(except for @code{ALTER TABLE}, in which the old table will be left
+unchanged).
+
+
+@node Temporary files, Problems with mysql.sock, Full disk, Administration Issues
+@appendixsubsec Where MySQL Stores Temporary Files
+
+MySQL uses the value of the @code{TMPDIR} environment variable as
+the pathname of the directory in which to store temporary files. If you don't
+have @code{TMPDIR} set, MySQL uses the system default, which is
+normally @file{/tmp} or @file{/usr/tmp}. If the file system containing your
+temporary file directory is too small, you should edit @code{safe_mysqld} to
+set @code{TMPDIR} to point to a directory in a file system where you have
+enough space! You can also set the temporary directory using the
+@code{--tmpdir} option to @code{mysqld}.
+
+MySQL creates all temporary files as hidden files. This ensures
+that the temporary files will be removed if @code{mysqld} is terminated. The
+disadvantage of using hidden files is that you will not see a big temporary
+file that fills up the file system in which the temporary file directory is
+located.
+
+When sorting (@code{ORDER BY} or @code{GROUP BY}), MySQL normally
+uses one or two temporary files. The maximum disk-space needed is:
+
+@example
+(length of what is sorted + sizeof(database pointer))
+* number of matched rows
+* 2
+@end example
+
+@code{sizeof(database pointer)} is usually 4, but may grow in the future for
+really big tables.
+
+For some @code{SELECT} queries, MySQL also creates temporary SQL
+tables. These are not hidden and have names of the form @file{SQL_*}.
+
+@code{ALTER TABLE} creates a temporary table in the same directory as
+the original table.
+
+
+@node Problems with mysql.sock, Timezone problems, Temporary files, Administration Issues
+@appendixsubsec How to Protect @file{/tmp/mysql.sock} from Being Deleted
+
+@cindex @code{mysql.sock}, protection
+@cindex deletion, @code{mysql.sock}
+
+If you have problems with the fact that anyone can delete the
+MySQL communication socket @file{/tmp/mysql.sock}, you can,
+on most versions of Unix, protect your @file{/tmp} file system by setting
+the @code{sticky} bit on it. Log in as @code{root} and do the following:
+
+@example
+shell> chmod +t /tmp
+@end example
+
+This will protect your @file{/tmp} file system so that files can be deleted
+only by their owners or the superuser (@code{root}).
+
+You can check if the @code{sticky} bit is set by executing @code{ls -ld /tmp}.
+If the last permission bit is @code{t}, the bit is set.
+
+
+@node Timezone problems, , Problems with mysql.sock, Administration Issues
+@appendixsubsec Time Zone Problems
+
+@cindex timezone problems
+@cindex problems, timezone
+
+@tindex TZ environment variable
+@tindex Environment variable, TZ
+
+If you have a problem with @code{SELECT NOW()} returning values in GMT and
+not your local time, you have to set the @code{TZ} environment variable to
+your current time zone. This should be done for the environment in which
+the server runs, for example, in @code{safe_mysqld} or @code{mysql.server}.
+@xref{Environment variables}.
+
+
+@node Query Issues, Table Definition Issues, Administration Issues, Problems
+@appendixsec Query Related Issues
+
+
+@menu
+* Case sensitivity:: Case Sensitivity in Searches
+* Using DATE:: Problems Using @code{DATE} Columns
+* Problems with NULL:: Problems with @code{NULL} Values
+* Problems with alias:: Problems with @code{alias}
+* Deleting from related tables:: Deleting Rows from Related Tables
+* No matching rows:: Solving Problems with No Matching Rows
+@end menu
+
+@node Case sensitivity, Using DATE, Query Issues, Query Issues
+@appendixsubsec Case Sensitivity in Searches
+
+@cindex case sensitivity, in searches
+@cindex searching, and case-sensitivity
+@cindex Chinese
+@cindex Big5 Chinese character encoding
+
+By default, MySQL searches are case-insensitive (although there are
+some character sets that are never case insensitive, such as @code{czech}).
+That means that if you search with @code{col_name LIKE 'a%'}, you will get all
+column values that start with @code{A} or @code{a}. If you want to make this
+search case-sensitive, use something like @code{INDEX(col_name, "A")=0} to
+check a prefix. Or use @code{STRCMP(col_name, "A") = 0} if the column value
+must be exactly @code{"A"}.
+
+Simple comparison operations (@code{>=, >, = , < , <=}, sorting and
+grouping) are based on each character's ``sort value''. Characters with
+the same sort value (like E, e and é) are treated as the same character!
+
+In older MySQL versions @code{LIKE} comparisons where done on
+the uppercase value of each character (E == e but E <> é). In newer
+MySQL versions @code{LIKE} works just like the other comparison
+operators.
+
+If you want a column always to be treated in case-sensitive fashion,
+declare it as @code{BINARY}. @xref{CREATE TABLE, , @code{CREATE TABLE}}.
+
+If you are using Chinese data in the so-called big5 encoding, you want to
+make all character columns @code{BINARY}. This works because the sorting
+order of big5 encoding characters is based on the order of ASCII codes.
+
+
+@node Using DATE, Problems with NULL, Case sensitivity, Query Issues
+@appendixsubsec Problems Using @code{DATE} Columns
+
+@findex DATE
+
+@cindex DATE columns, problems
+@cindex problems, @code{DATE} columns
+
+The format of a @code{DATE} value is @code{'YYYY-MM-DD'}. According to ANSI
+SQL, no other format is allowed. You should use this format in @code{UPDATE}
+expressions and in the WHERE clause of @code{SELECT} statements. For
+example:
+
+@example
+mysql> SELECT * FROM tbl_name WHERE date >= '1997-05-05';
+@end example
+
+As a convenience, MySQL automatically converts a date to a number if
+the date is used in a numeric context (and vice versa). It is also smart
+enough to allow a ``relaxed'' string form when updating and in a @code{WHERE}
+clause that compares a date to a @code{TIMESTAMP}, @code{DATE}, or a
+@code{DATETIME} column. (Relaxed form means that any punctuation character
+may be used as the separator between parts. For example, @code{'1998-08-15'}
+and @code{'1998#08#15'} are equivalent.) MySQL can also convert a
+string containing no separators (such as @code{'19980815'}), provided it
+makes sense as a date.
+
+The special date @code{'0000-00-00'} can be stored and retrieved as
+@code{'0000-00-00'.} When using a @code{'0000-00-00'} date through
+@strong{MyODBC}, it will automatically be converted to @code{NULL} in
+@strong{MyODBC} Version 2.50.12 and above, because ODBC can't handle this kind of
+date.
+
+Because MySQL performs the conversions described above, the following
+statements work:
+
+@example
+mysql> INSERT INTO tbl_name (idate) VALUES (19970505);
+mysql> INSERT INTO tbl_name (idate) VALUES ('19970505');
+mysql> INSERT INTO tbl_name (idate) VALUES ('97-05-05');
+mysql> INSERT INTO tbl_name (idate) VALUES ('1997.05.05');
+mysql> INSERT INTO tbl_name (idate) VALUES ('1997 05 05');
+mysql> INSERT INTO tbl_name (idate) VALUES ('0000-00-00');
+
+mysql> SELECT idate FROM tbl_name WHERE idate >= '1997-05-05';
+mysql> SELECT idate FROM tbl_name WHERE idate >= 19970505;
+mysql> SELECT mod(idate,100) FROM tbl_name WHERE idate >= 19970505;
+mysql> SELECT idate FROM tbl_name WHERE idate >= '19970505';
+@end example
+
+@noindent
+However, the following will not work:
+
+@example
+mysql> SELECT idate FROM tbl_name WHERE STRCMP(idate,'19970505')=0;
+@end example
+
+@code{STRCMP()} is a string function, so it converts @code{idate} to
+a string and performs a string comparison. It does not convert
+@code{'19970505'} to a date and perform a date comparison.
+
+Note that MySQL does no checking whether or not the date is
+correct. If you store an incorrect date, such as @code{'1998-2-31'}, the
+wrong date will be stored. If the date cannot be converted to any reasonable
+value, a @code{0} is stored in the @code{DATE} field. This is mainly a speed
+issue and we think it is up to the application to check the dates, and not
+the server.
+
+
+@node Problems with NULL, Problems with alias, Using DATE, Query Issues
+@appendixsubsec Problems with @code{NULL} Values
+
+@cindex @code{NULL} values, vs. empty values
+
+@tindex NULL
+
+The concept of the @code{NULL} value is a common source of confusion for
+newcomers to SQL, who often think that @code{NULL} is the same thing as an
+empty string @code{''}. This is not the case! For example, the following
+statements are completely different:
+
+@example
+mysql> INSERT INTO my_table (phone) VALUES (NULL);
+mysql> INSERT INTO my_table (phone) VALUES ("");
+@end example
+
+Both statements insert a value into the @code{phone} column, but the first
+inserts a @code{NULL} value and the second inserts an empty string. The
+meaning of the first can be regarded as ``phone number is not known'' and the
+meaning of the second can be regarded as ``she has no phone''.
+
+In SQL, the @code{NULL} value is always false in comparison to any
+other value, even @code{NULL}. An expression that contains @code{NULL}
+always produces a @code{NULL} value unless otherwise indicated in
+the documentation for the operators and functions involved in the
+expression. All columns in the following example return @code{NULL}:
+
+@example
+mysql> SELECT NULL,1+NULL,CONCAT('Invisible',NULL);
+@end example
+
+If you want to search for column values that are @code{NULL}, you
+cannot use the @code{=NULL} test. The following statement returns no
+rows, because @code{expr = NULL} is FALSE, for any expression:
+
+@example
+mysql> SELECT * FROM my_table WHERE phone = NULL;
+@end example
+
+To look for @code{NULL} values, you must use the @code{IS NULL} test.
+The following shows how to find the @code{NULL} phone number and the
+empty phone number:
+
+@example
+mysql> SELECT * FROM my_table WHERE phone IS NULL;
+mysql> SELECT * FROM my_table WHERE phone = "";
+@end example
+
+In MySQL, as in many other SQL servers, you can't index
+columns that can have @code{NULL} values. You must declare such columns
+@code{NOT NULL}. Conversely, you cannot insert @code{NULL} into an indexed
+column.
+
+@findex LOAD DATA INFILE
+When reading data with @code{LOAD DATA INFILE}, empty columns are updated
+with @code{''}. If you want a @code{NULL} value in a column, you should use
+@code{\N} in the text file. The literal word @code{'NULL'} may also be used
+under some circumstances.
+@xref{LOAD DATA, , @code{LOAD DATA}}.
+
+When using @code{ORDER BY}, @code{NULL} values are presented first. If you
+sort in descending order using @code{DESC}, @code{NULL} values are presented
+last. When using @code{GROUP BY}, all @code{NULL} values are regarded as
+equal.
+
+To help with @code{NULL} handling, you can use the @code{IS NULL} and
+@code{IS NOT NULL} operators and the @code{IFNULL()} function.
+
+@cindex @code{TIMESTAMP}, and @code{NULL} values
+@cindex @code{AUTO_INCREMENT}, and @code{NULL} values
+@cindex @code{NULL} values, and @code{TIMESTAMP} columns
+@cindex @code{NULL} values, and @code{AUTO_INCREMENT} columns
+For some column types, @code{NULL} values are handled specially. If you
+insert @code{NULL} into the first @code{TIMESTAMP} column of a table, the
+current date and time is inserted. If you insert @code{NULL} into an
+@code{AUTO_INCREMENT} column, the next number in the sequence is inserted.
+
+
+@node Problems with alias, Deleting from related tables, Problems with NULL, Query Issues
+@appendixsubsec Problems with @code{alias}
+
+@tindex alias
+
+You can use an alias to refer to a column in the @code{GROUP BY},
+@code{ORDER BY}, or in the @code{HAVING} part. Aliases can also be used
+to give columns better names:
+
+@example
+SELECT SQRT(a*b) as rt FROM table_name GROUP BY rt HAVING rt > 0;
+SELECT id,COUNT(*) AS cnt FROM table_name GROUP BY id HAVING cnt > 0;
+SELECT id AS "Customer identity" FROM table_name;
+@end example
+
+Note that ANSI SQL doesn't allow you to refer to an alias in a
+@code{WHERE} clause. This is because when the @code{WHERE} code is
+executed the column value may not yet be determined. For example, the
+following query is @strong{illegal}:
+
+@example
+SELECT id,COUNT(*) AS cnt FROM table_name WHERE cnt > 0 GROUP BY id;
+@end example
+
+The @code{WHERE} statement is executed to determine which rows should
+be included in the @code{GROUP BY} part while @code{HAVING} is used to
+decide which rows from the result set should be used.
+
+
+@node Deleting from related tables, No matching rows, Problems with alias, Query Issues
+@appendixsubsec Deleting Rows from Related Tables
+
+@cindex deleting, rows
+@cindex rows, deleting
+@cindex tables, deleting rows
+
+As MySQL doesn't support sub-selects or use of more than one table
+in the @code{DELETE} statement, you should use the following approach to
+delete rows from 2 related tables:
+
+@enumerate
+@item
+@code{SELECT} the rows based on some @code{WHERE} condition in the main table.
+@item
+@code{DELETE} the rows in the main table based on the same condition.
+@item
+@code{DELETE FROM related_table WHERE related_column IN (selected_rows)}.
+@end enumerate
+
+If the total number of characters in the query with
+@code{related_column} is more than 1,048,576 (the default value of
+@code{max_allowed_packet}, you should split it into smaller parts and
+execute multiple @code{DELETE} statements. You will probably get the
+fastest @code{DELETE} by only deleting 100-1000 @code{related_column}
+id's per query if the @code{related_column} is an index. If the
+@code{related_column} isn't an index, the speed is independent of the
+number of arguments in the @code{IN} clause.
+
+
+@node No matching rows, , Deleting from related tables, Query Issues
+@appendixsubsec Solving Problems with No Matching Rows
+
+@cindex no matching rows
+@cindex rows, matching problems
+
+If you have a complicated query that has many tables and that doesn't
+return any rows, you should use the following procedure to find out what
+is wrong with your query:
+
+@enumerate
+@item
+Test the query with @code{EXPLAIN} and check if you can find something that is
+obviously wrong. @xref{EXPLAIN, , @code{EXPLAIN}}.
+
+@item
+Select only those fields that are used in the @code{WHERE} clause.
+
+@item
+Remove one table at a time from the query until it returns some rows.
+If the tables are big, it's a good idea to use @code{LIMIT 10} with the query.
+
+@item
+Do a @code{SELECT} for the column that should have matched a row against
+the table that was last removed from the query.
+
+@item
+If you are comparing @code{FLOAT} or @code{DOUBLE} columns with numbers that
+have decimals, you can't use @code{=}! This problem is common in most
+computer languages because floating-point values are not exact values:
+
+@example
+mysql> SELECT * FROM table_name WHERE float_column=3.5;
+ ->
+mysql> SELECT * FROM table_name WHERE float_column between 3.45 and 3.55;
+@end example
+
+In most cases, changing the @code{FLOAT} to a @code{DOUBLE} will fix this!
+
+@item
+If you still can't figure out what's wrong, create a minimal test that can
+be run with @code{mysql test < query.sql} that shows your problems.
+You can create a test file with @code{mysqldump --quick database tables > query.sql}. Open the file in an editor, remove some insert lines (if there are
+too many of these), and add your select statement at the end of the file.
+
+Test that you still have your problem by doing:
+
+@example
+shell> mysqladmin create test2
+shell> mysql test2 < query.sql
+@end example
+
+Post the test file using @code{mysqlbug} to @email{mysql@@lists.mysql.com}.
+@end enumerate
+
+
+@node Table Definition Issues, , Query Issues, Problems
+@appendixsec Table Definition Related Issues
+
+
+@menu
+* ALTER TABLE problems:: Problems with @code{ALTER TABLE}.
+* Change column order:: How To Change the Order of Columns in a Table
+* Temporary table problems:: TEMPORARY TABLE problems
+@end menu
+
+@node ALTER TABLE problems, Change column order, Table Definition Issues, Table Definition Issues
+@appendixsubsec Problems with @code{ALTER TABLE}.
+
+@tindex ALTER TABLE
+
+@code{ALTER TABLE} changes a table to the current character set.
+If you during @code{ALTER TABLE} get a duplicate key error, then the cause
+is either that the new character sets maps to keys to the same value
+or that the table is corrupted, in which case you should run
+@code{REPAIR TABLE} on the table.
+
+If @code{ALTER TABLE} dies with an error like this:
+
+@example
+Error on rename of './database/name.frm' to './database/B-a.frm' (Errcode: 17)
+@end example
+
+the problem may be that MySQL has crashed in a previous @code{ALTER
+TABLE} and there is an old table named @file{A-something} or
+@file{B-something} lying around. In this case, go to the MySQL data
+directory and delete all files that have names starting with @code{A-} or
+@code{B-}. (You may want to move them elsewhere instead of deleting them.)
+
+@code{ALTER TABLE} works the following way:
+
+@itemize @bullet
+@item Create a new table named @file{A-xxx} with the requested changes.
+@item All rows from the old table are copied to @file{A-xxx}.
+@item The old table is renamed @file{B-xxx}.
+@item @file{A-xxx} is renamed to your old table name.
+@item @file{B-xxx} is deleted.
+@end itemize
+
+If something goes wrong with the renaming operation, MySQL tries to
+undo the changes. If something goes seriously wrong (this shouldn't happen,
+of course), MySQL may leave the old table as @file{B-xxx}, but a
+simple rename on the system level should get your data back.
+
+
+@node Change column order, Temporary table problems, ALTER TABLE problems, Table Definition Issues
+@appendixsubsec How To Change the Order of Columns in a Table
+
+@cindex reordering, columns
+@cindex columns, changing
+@cindex changing, column order
+@cindex tables, changing column order
+
+The whole point of SQL is to abstract the application from the data
+storage format. You should always specify the order in which you wish to
+retrieve your data. For example:
+
+@example
+SELECT col_name1, col_name2, col_name3 FROM tbl_name;
+@end example
+
+will return columns in the order @code{col_name1}, @code{col_name2}, @code{col_name3}, whereas:
+
+@example
+SELECT col_name1, col_name3, col_name2 FROM tbl_name;
+@end example
+
+will return columns in the order @code{col_name1}, @code{col_name3}, @code{col_name2}.
+
+You should @strong{NEVER}, in an application, use @code{SELECT *} and
+retrieve the columns based on their position, because the order in which
+columns are returned @strong{CANNOT} be guaranteed over time. A simple
+change to your database may cause your application to fail rather
+dramatically.
+
+If you want to change the order of columns anyway, you can do it as follows:
+
+@enumerate
+@item
+Create a new table with the columns in the right order.
+@item
+Execute
+@code{INSERT INTO new_table SELECT fields-in-new_table-order FROM old_table}.
+@item
+Drop or rename @code{old_table}.
+@item
+@code{ALTER TABLE new_table RENAME old_table}.
+@end enumerate
+
+
+@node Temporary table problems, , Change column order, Table Definition Issues
+@appendixsubsec TEMPORARY TABLE problems
+
+@cindex temporary tables, problems
+
+The following are a list of the limitations with @code{TEMPORARY TABLES}.
+
+@itemize @bullet
+@item
+A temporary table can only be of type @code{HEAP}, @code{ISAM} or
+@code{MyISAM}.
+@item
+You can't use temporary tables more than once in the same query.
+For example, the following doesn't work.
+
+@example
+select * from temporary_table, temporary_table as t2;
+@end example
+
+We plan to fix the above in 4.0.
+@item
+You can't use @code{RENAME} on a @code{TEMPORARY} table.
+Note that @code{ALTER TABLE org_name RENAME new_name} works!
+
+We plan to fix the above in 4.0.
+@end itemize
+
+
+
+
+@node Users, MySQL customer usage, Problems, Top
+@appendix Some MySQL Users
-@page
@cindex users, of MySQL
@cindex news sites
-@node Users, MySQL customer usage, Environment variables, Top
-@appendix Some MySQL Users
-This appendix lists some users of @strong{MySQL} that have given us permission
+This appendix lists some users of MySQL that have given us permission
to list them in our documentation. It is by far not a complete list, but
-should give you a general idea of who uses @strong{MySQL} and what it can
+should give you a general idea of who uses MySQL and what it can
be used for.
@appendixsec General News Sites
@@ -44112,7 +44907,7 @@ An online magazine featuring music, literature, arts, and design content.
@item @uref{http://pgss.iss.uw.edu.pl/en_index.ISS, Polish General Social Survey}
@item @uref{http://www.expo2000.com, Expo2000} World-wide distribution of
-tickets for this event is implemented using @strong{MySQL} and tcl/tk. More than
+tickets for this event is implemented using MySQL and tcl/tk. More than
5000 travel agencies all over the world have access to it.
@item @uref{http://www.freevote.com/, FreeVote.com is a free voting
@@ -44130,7 +44925,7 @@ service with millions of users.}
@itemize @bullet
@item @uref{http://www.wix.com/mysql-hosting, Registry of Web providers that
-support @strong{MySQL}}
+support MySQL}
@item @uref{http://www.yi.org/, Dynamic DNS Services}
@@ -44191,8 +44986,8 @@ everybody who wants to find friends over the internet.}
@c @item @uref{http://cabinboy.powersurfr.com, An Internet RFC search engine}
@item @uref{http://www.dslreports.com, DSL-provider search with reviews}.
-Made with @strong{MySQL} and Modperl, all pages are generated dynamically out of
-the @strong{MySQL} database
+Made with MySQL and Modperl, all pages are generated dynamically out of
+the MySQL database
@end itemize
@cindex PHP, web sites
@@ -44203,7 +44998,7 @@ the @strong{MySQL} database
@item @uref{http://support.jgaa.com/, Jgaa's Internet - Official Support Site}
-@item @uref{http://io.incluso.com, Ionline - online publication:} @strong{MySQL},
+@item @uref{http://io.incluso.com, Ionline - online publication:} MySQL,
PHP, Java, Web programming, DB development
@item @uref{http://www.baboo.com, BaBoo(Browse and bookmark). Free Web-based bookmark manager and Calendar}
@@ -44242,9 +45037,9 @@ Ecommerce site that is selling computers.
@item @uref{http://worldcommunity.com/, Online Database}
-@item @uref{http://www2.dataguard.no/,DataGuard (Uses @strong{MySQL} and PHP)}
+@item @uref{http://www2.dataguard.no/,DataGuard (Uses MySQL and PHP)}
-@item @uref{http://wwits.net/programs/mysql.phtml, WWITS (Uses @strong{MySQL} and PHP)}
+@item @uref{http://wwits.net/programs/mysql.phtml, WWITS (Uses MySQL and PHP)}
@item @uref{http://www.worldcommunity.com/, WCN - The World Community Network}
@@ -44315,7 +45110,7 @@ Weather World 2010 Technical Credits} @*
@item @uref{http://gimp.foebud.org/registry/doc/, About The Gimp plugin registry}
@item @uref{http://www.fast-inc.com/Products/Archiver/database.html, Java tool
-Archiver technical detail (Slightly optimistic about @strong{MySQL}
+Archiver technical detail (Slightly optimistic about MySQL
ANSI-92 compliance)}
@item @uref{http://www.gamesdomain.com/cheats/usrcheat.phtml, Games Domain Cheats Database}
@@ -44350,7 +45145,7 @@ ANSI-92 compliance)}
@item @uref{http://www.nbi.nl, Elsevier Bussines Information}
-@item @uref{http://vaccination.medicallink.se/, Medical Links (Using ColdFusion and @strong{MySQL})}
+@item @uref{http://vaccination.medicallink.se/, Medical Links (Using ColdFusion and MySQL)}
@item @uref{http://www.joblink-usa.com, Search for jobs & people at JobLink-USA}
@@ -44398,20 +45193,25 @@ Washington's Eastside residents and businesses}
Send any additions to this list to @email{webmaster@@mysql.com}.
@page
-@cindex MySQL usage
+
+
+
+
@node MySQL customer usage, Contrib, Users, Top
@appendix MySQL customer usage
+@cindex MySQL usage
+
The section 'Some MySQL Users' contains a lot of different links to
-@strong{MySQL} users but doesn't provide that much information about how
-they are using @strong{MySQL}. @xref{Users}. This manual section is to
-give you an idea of how other @strong{MySQL} users are using
-@strong{MySQL} to solve their problems.
+MySQL users but doesn't provide that much information about how
+they are using MySQL. @xref{Users}. This manual section is to
+give you an idea of how other MySQL users are using
+MySQL to solve their problems.
This manual section is very new and we plan to add more stories here
shortly. If you are interested in contributing of how you use
-@strong{MySQL} in a unique environment or have success store about how you
-use @strong{MySQL}, you can write to @code{docs@@mysql.com} with
+MySQL in a unique environment or have success store about how you
+use MySQL, you can write to @code{docs@@mysql.com} with
subject @code{Success:}. Note that as we are very busy it may take some
time before you get some feedback for your story.
@@ -44427,23 +45227,28 @@ as soon as I'll move to 2.4 kernel with large files. Currently I have to
delete much of logs for large sites to hold table sizes in 2Gb.
@item
-@strong{Texas Instruments} is using @strong{MySQL} for handling tables
+@strong{Texas Instruments} is using MySQL for handling tables
that contain up to 2,000 million rows in a validation regression database.
@end itemize
@page
-@cindex contributed programs
-@cindex programs, contributed
+
+
+
+
@node Contrib, Credits, MySQL customer usage, Top
@appendix Contributed Programs
-Many users of @strong{MySQL} have contributed @emph{very} useful support
+@cindex contributed programs
+@cindex programs, contributed
+
+Many users of MySQL have contributed @emph{very} useful support
tools and add-ons.
@ifclear web
A list of what is available at @uref{http://www.mysql.com/Downloads/Contrib/}
(or any mirror) is shown below.
-If you want to build @strong{MySQL} support for the Perl @code{DBI}/@code{DBD}
+If you want to build MySQL support for the Perl @code{DBI}/@code{DBD}
interface, you should fetch the @code{Data-Dumper}, @code{DBI}, and
@code{Msql-Mysql-modules} files and install them.
@xref{Perl support}.
@@ -44463,13 +45268,13 @@ older Perl installations.
Perl @code{DBI} module.
@item @uref{http://www.mysql.com/Downloads/Contrib/KAMXbase1.2.tar.gz,KAMXbase1.2.tar.gz}
-Convert between @file{.dbf} files and @strong{MySQL} tables. Perl
+Convert between @file{.dbf} files and MySQL tables. Perl
module written by Pratap Pereira @email{pereira@@ee.eng.ohio-state.edu},
extended by Kevin A. McGrail @email{kmcgrail@@digital1.peregrinehw.com}.
This converter can handle MEMO fields.
@item @uref{http://www.mysql.com/Downloads/Contrib/Msql-Mysql-modules-1.2216.tar.gz, Msql-Mysql-modules-1.2216.tar.gz}
-Perl @code{DBD} module to access mSQL and @strong{MySQL} databases.
+Perl @code{DBD} module to access mSQL and MySQL databases.
@item @uref{http://www.mysql.com/Downloads/Contrib/Data-ShowTable-3.3.tar.gz, Data-ShowTable-3.3.tar.gz}
Perl @code{Data-ShowTable} module. Useful with @code{DBI}/@code{DBD} support.
@@ -44484,12 +45289,12 @@ approximately 20% faster than regular DBI.
@item JDBC
@itemize @bullet
@item @uref{http://www.mysql.com/Downloads/Contrib/mm.mysql.jdbc-1.2c.tar.gz, mm.mysql.jdbc-1.2c.tar.gz}
-The mm JDBC driver for @strong{MySQL}. This is a production release
+The mm JDBC driver for MySQL. This is a production release
and is actively developed. By Mark Matthews
(@email{mmatthew@@ecn.purdue.edu}).
@item @uref{http://www.mysql.com/Downloads/Contrib/mm.mysql.jdbc-2.0pre5.tar.gz, mm.mysql.jdbc-2.0pre5.tar.gz}
-The mm JDBC driver for @strong{MySQL}. This is a pre-release beta version
+The mm JDBC driver for MySQL. This is a pre-release beta version
and is actively developed. By Mark Matthews
(@email{mmatthew@@ecn.purdue.edu}).
The two drivers above have an LGPL
@@ -44508,7 +45313,7 @@ private and educational use. (Not supported anymore.)
@c no answer from server 990830
@c You can always find the latest driver at @uref{http://www.voicenet.com/~zellert/tjFM/}.
@item @uref{http://www.mysql.com/Downloads/Contrib/pmdamysql.tgz,pmdamysql.tgz}
-A @strong{MySQL} PMDA. Provides @strong{MySQL} server status and configuration
+A MySQL PMDA. Provides MySQL server status and configuration
variables.
@end itemize
@@ -44516,7 +45321,7 @@ variables.
@item OLEDB
@itemize @bullet
@item @uref{http://www.mysql.com/Downloads/Win32/MyOLEDB.exe, MyOLEDB.exe}
-OLEDB handler for @strong{MySQL}. By SWsoft.
+OLEDB handler for MySQL. By SWsoft.
@item @uref{http://www.mysql.com/Downloads/Win32/MySamples.zip, MySamples.zip}
Examples and documentation for MyOLEDB. By SWsoft.
@item @uref{http://www.mysql.com/Downloads/Win32/Myoledb.zip, Myoledb.zip}
@@ -44532,19 +45337,19 @@ Static MyODBC library used for build MyOLEDB. Based on MyODBC code.
@itemize @bullet
@item @uref{http://www.mysql.com/Downloads/Contrib/mysql-c++-0.02.tar.gz, mysql-c++-0.02.tar.gz}
-@strong{MySQL} C++ wrapper library. By Roland Haenel,
+MySQL C++ wrapper library. By Roland Haenel,
@email{rh@@ginster.net}.
@item @uref{http://www.mysql.com/Downloads/Contrib/MyDAO.tar.gz, MyDAO}
-@strong{MySQL} C++ API. By Satish @email{spitfire@@pn3.vsnl.net.in}. Inspired
+MySQL C++ API. By Satish @email{spitfire@@pn3.vsnl.net.in}. Inspired
by Roland Haenel's C++ API and Ed Carp's MyC library.
@item @uref{http://www.mysql.com/download_mysql++.html, mysql++}
-@strong{MySQL} C++ API (More than just a wrapper library.) Originally by
-@email{kevina@@clark.net}. Nowadays maintained by Sinisa at @strong{MySQL AB}.
+MySQL C++ API (More than just a wrapper library.) Originally by
+@email{kevina@@clark.net}. Nowadays maintained by Sinisa at MySQL AB.
@item @uref{http://nelsonjr.homepage.com/NJrAPI,NJrAPI}
-A C++ database independent library that supports @strong{MySQL}.
+A C++ database independent library that supports MySQL.
@end itemize
@cindex Delphi
@@ -44560,11 +45365,11 @@ Delphi interface to @code{libmysql.dll}, by @email{bsilva@@umesd.k12.or.us}.
@item @uref{http://www.mysql.com/Downloads/Contrib/Udmysel.pas, Udmysql.pas}
A wrapper for libmysql.dll for usage in Delphi. By Reiner Sombrowsky.
-@item @uref{http://www.fichtner.net/delphi/mysql.delphi.phtml, A Delphi interface to @strong{MySQL}.}
+@item @uref{http://www.fichtner.net/delphi/mysql.delphi.phtml, A Delphi interface to MySQL.}
With source code. By Matthias Fichtner.
-@item @uref{http://www.productivity.org/projects/mysql/, @strong{TmySQL}
-A library to use @strong{MySQL} with Delphi}.
+@item @uref{http://www.productivity.org/projects/tmysql/, @strong{TmySQL}
+A library to use MySQL with Delphi}.
@item @uref{http://www.geocities.com/CapeCanaveral/2064/mysql.html, Delphi TDataset-component}.
@item
@@ -44572,18 +45377,18 @@ A library to use @strong{MySQL} with Delphi}.
@end itemize
@item @uref{http://www.mysql.com/Downloads/Contrib/mysql-ruby-2.2.0.tar.gz, mysql-ruby-2.2.0.tar.gz}
-@strong{MySQL} Ruby module. By TOMITA Masahiro @email{tommy@@tmtm.org}
+MySQL Ruby module. By TOMITA Masahiro @email{tommy@@tmtm.org}
@uref{http://www.netlab.co.jp/ruby/. Ruby} is an Object-Oriented Interpreter Language.
@item @uref{http://www.mysql.com/Downloads/Contrib/JdmMysqlDriver-0.1.0.tar.gz,JdmMysqlDriver-0.1.0.tar.gz}
-A VisualWorks 3.0 Smalltalk driver for @strong{MySQL}. By
+A VisualWorks 3.0 Smalltalk driver for MySQL. By
@email{joshmiller@@earthlink.net}.
@item @uref{http://www.mysql.com/Downloads/Contrib/Db.py, Db.py}
Python module with caching. By @email{gandalf@@rosmail.com}.
@item @uref{http://www.mysql.com/Downloads/Contrib/MySQLmodule-1.4.tar.gz, MySQLmodule-1.4.tar.gz}
-Python interface for @strong{MySQL}. By Joseph Skinner @email{joe@@earthlight.co.nz}. Modified by Joerg Senekowitsch @email{senekow@@ibm.net}.
+Python interface for MySQL. By Joseph Skinner @email{joe@@earthlight.co.nz}. Modified by Joerg Senekowitsch @email{senekow@@ibm.net}.
@item @uref{http://www.mysql.com/Downloads/Contrib/MySQL-python-0.3.0.tar.gz, MySQL-python-0.3.0.tar.gz}
MySQLdb Python is an DB-API v2.0-compliant interface to MySQL. Transactions
@@ -44598,7 +45403,7 @@ Check @uref{http://boojum.hut.fi/~kuutela/mysqlmex.html,mysqlmex.html}
for more information.
@item @uref{http://www.mysql.com/Downloads/Contrib/mysqltcl-1.53.tar.gz, mysqltcl-1.53.tar.gz}
-Tcl interface for @strong{MySQL}. Based on @file{msqltcl-1.50.tar.gz}.
+Tcl interface for MySQL. Based on @file{msqltcl-1.50.tar.gz}.
Updated by Tobias Ritzau, @email{tobri@@ida.liu.se}.
@item @uref{http://www.mysql.com/Downloads/Contrib/MyC-0.1.tar.gz, MyC-0.1.tar.gz}
@@ -44616,12 +45421,12 @@ implementing one file for the new backend without making any
changes to your applications. By @email{damian@@cablenet.net}.
@item @uref{http://www.mysql.com/Downloads/Contrib/DbFramework-1.10.tar.gz, DbFramework-1.10.tar.gz}
-DbFramework is a collection of classes for manipulating @strong{MySQL}
+DbFramework is a collection of classes for manipulating MySQL
databases. The classes are loosely based on the CDIF Data Model
Subject Area. By Paul Sharpe @email{paul@@miraclefish.com}.
@item @uref{http://www.mysql.com/Downloads/Contrib/pike-mysql-1.4.tar.gz, pike-mysql-1.4.tar.gz}
-@strong{MySQL} module for pike. For use with the Roxen web server.
+MySQL module for pike. For use with the Roxen web server.
@item @uref{http://www.mysql.com/Downloads/Contrib/squile.tar.gz, squile.tar.gz}
Module for @code{guile} that allows @code{guile} to interact with SQL
@@ -44645,27 +45450,27 @@ and remove the DSN registry file for the MyODBC driver in Coldfusion
applications. By Miguel Angel Solórzano.
@item @uref{http://www.mysql.com/Downloads/Contrib/MySQL-ADA95_API.zip, MySQL-ADA95_API.zip}
-An ADA95 interface to the @strong{MySQL} API. By Francois Fabien.
+An ADA95 interface to the MySQL API. By Francois Fabien.
@item @uref{http://www.mysql.com/Downloads/Contrib/MyTool-DLL_for_VB_and_MySQL.zip, MyTool-DLL_for_VB_and_MySQL.zip}
-A DLL with @strong{MySQL} C API for Visual Basic.
+A DLL with MySQL C API for Visual Basic.
By Ken Menzel @email{kenm@@icarz.com}.
@item @uref{http://www.mysql.com/Downloads/Contrib/MYSQLX.EXE, MYSQL.EXE}
-@strong{MySQL} ActiveX Object for directly accessing your @strong{MySQL}
+MySQL ActiveX Object for directly accessing your MySQL
servers from IIS/ASP, VB, VC++ skipping the slower ODBC methods. Fully
-updatable, multithreaded with full support for all @strong{MySQL} fieldtypes
+updatable, multithreaded with full support for all MySQL fieldtypes
(version 2001.1.1). By SciBit @uref{http://www.scibit.com/}.
@item @uref{http://www.fastflow.it/mylua/, MyLUA home page}
-How to use the LUA language to write @strong{MySQL} @code{PROCEDURE} that can
+How to use the LUA language to write MySQL @code{PROCEDURE} that can
be loaded runtime.
@itemize @bullet
@item @uref{http://www.mysql.com/Downloads/Contrib/lua-4.0.tar.gz, Lua 4.0}
LUA 4.0
@item @uref{http://www.mysql.com/Downloads/Contrib/mylua-3.23.32.1.tar.gz, mylua-3.23.32.1.tar.gz}
-Patch for @strong{MySQL} 3.23.32 to use LUA 4.0. By Cristian Giussani.
+Patch for MySQL 3.23.32 to use LUA 4.0. By Cristian Giussani.
@end itemize
@item @uref{http://www.mysql.com/Downloads/Contrib/patched_myodbc.zip, patched_myodbc.zip}
@@ -44684,11 +45489,11 @@ Freeware JDBC client to graphically visualize the data and structure
of several databases simultaneously. By Innovative-IT Development AB.
@item @uref{http://www.mysql.com/downloads/gui-clients.html, MySQLGUI}
-The @strong{MySQL} GUI client homepage. By Sinisa at @strong{MySQL AB}.
+The MySQL GUI client homepage. By Sinisa at MySQL AB.
@item @uref{http://www.mysql.com/Downloads/Contrib/mysql_navigator_0.9.0.tar.gz, MySQL navigator 0.9}
-MySQL Navigator is a @strong{MySQL} database server GUI client program. The purpose
-of MySQL Navigator is to provide a useful client interface to @strong{MySQL}
+MySQL Navigator is a MySQL database server GUI client program. The purpose
+of MySQL Navigator is to provide a useful client interface to MySQL
database servers, whilst supporting multiple operating systems and
languages. You can currently import/export database, enter queries, get
result sets, edit scripts, run scripts, add, alter, and delete users,
@@ -44696,14 +45501,14 @@ and retrieve client and server information. Uses QT 2.2. GPL
@uref{http://sql.kldp.org/mysql, Home page for MySQL Navigator}.
@item @uref{http://www.mysql.com/Downloads/Win32/secman.zip, MySQL Security GUI}
-A user and security management GUI for @strong{MySQL} on Windows.
+A user and security management GUI for MySQL on Windows.
By Martin Jeremic.
@uref{http://jsoft.webjump.com/, Home page for MySQL Security GUI}.
@item @uref{http://www.mysql.com/Downloads/Contrib/kmysqladmin-0.4.1.tar.gz, kmysqladmin-0.4.1.tar.gz}.
@item @uref{http://www.mysql.com/Downloads/Contrib/kmysqladmin-0.4.1-1.src.rpm, kmysqladmin-0.4.1-1.src.rpm}.
@item @uref{http://www.mysql.com/Downloads/Contrib/kmysqladmin-0.4.1-1.i386.rpm, kmysqladmin-0.4.1-1.i386.rpm}
-An administration tool for the @strong{MySQL} server using QT / KDE. Tested
+An administration tool for the MySQL server using QT / KDE. Tested
only on Linux.
@item @uref{http://www.mysql.com/Downloads/Contrib/mysql-admin-using-java+swing.tar.gz, Java client using Swing} By Fredy Fischer, @email{se-afs@@dial.eunet.ch}.
@@ -44711,7 +45516,7 @@ You can always find the latest version
@uref{http://www.trash.net/~ffischer/admin/index.html, here}.
@item @uref{http://www.mysql.com/Downloads/Win32/MySQL-Maker-1.0.zip,MySQL-Maker 1.0}.
-Shareware @strong{MySQL} client for Windows. It's a WYSIWYG tool which allows
+Shareware MySQL client for Windows. It's a WYSIWYG tool which allows
you to create, change and delete databases and tables.
You can change field - structure and add, change and delete data in
these tables directly without ODBC-driver.
@@ -44722,18 +45527,18 @@ Windows GUI (binary only) to administrate a database, by David B. Mansel,
@email{david@@zhadum.org}.
@item @uref{http://home.online.no/~runeberg/myqa, MyQA}
-is a Linux-based query client for the @strong{MySQL} database server. MyQA
+is a Linux-based query client for the MySQL database server. MyQA
lets you enter SQL queries, execute them, and view the results, all in a
graphical user interface. The GUI is roughly similar to that of the
'Query Analyzer' client that comes with MS SQL Server.
@item @uref{http://members.xoom.com/_opex_/mysqlmanager/index.html, MySQL Manager}
-a graphical @strong{MySQL} server manager for @strong{MySQL} server written in Java, for Windows
+a graphical MySQL server manager for MySQL server written in Java, for Windows
@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
+An administrator tool for MySQL on Windows 95/98 and Windows NT
+4.0. Only tested with MySQL Versions 3.23.5 - 3.23.7. Written
using the Tmysql components.
You can write queries and show tables, indexes, table syntax, and
@@ -44745,7 +45550,7 @@ URL @url{http://www.it-netservice.de/pages/software/index.html}.
@item @uref{http://www.mysql.com/Downloads/Win32/netadmin2.zip, netadmin2.zip}
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}.
+@item @uref{http://www.mysql.com/Downloads/Win32/ARTADMIN203.EXE,Atronic's 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}
@@ -44758,41 +45563,41 @@ import-/export-files. (Freeware). By Ansgar Becker.
@item @uref{http://bardo.hyperlink.cz/mysqlmon,a light weight GUI client for Windows}.
@item @uref{http://dbtools.vila.bol.com.br/, Dbtools}
-A tool to manage @strong{MySQL} databases. Currently only for Windows.
+A tool to manage MySQL databases. Currently only for Windows.
Some features:
@itemize @bullet
@item Manage servers, databases, tables, columns, indexes, and users
@item Import wizard to import structure and data from MS Access, MS Excel, Dbase, FoxPro, Paradox, and ODBC Databases.
@item @uref{http://www.mysql.com/Downloads/Contrib/KMYENG113.zip,KMYENG113.zip}
-An administrator GUI for @strong{MySQL}. Works only on windows, no source.
+An administrator GUI for MySQL. Works only on windows, no source.
Available in English and Japanese. By Mitunobu Kaneko.
Home page: @uref{http://sql.jnts.ne.jp/}
@end itemize
@item @uref{http://www.mysql.com/Downloads/Contrib/xmysqladmin-1.0.tar.gz, xmysqladmin-1.0.tar.gz}
-An X-based front end to the @strong{MySQL} database engine. It allows reloads,
+An X-based front end to the MySQL database engine. It allows reloads,
status check, process control, myisamchk, grant/revoke privileges,
creating databases, dropping databases, create, alter, browse, and drop
tables. Originally by Gilbert Therrien, @email{gilbert@@ican.net} but
-now in public domain and supported by @strong{MySQL AB}.
+now in public domain and supported by MySQL AB.
@item @uref{http://www.mysql.com/Downloads/Contrib/xmysql-1.9.tar.gz, xmysql-1.9.tar.gz}.
@item @uref{http://web.wt.net/~dblhack, xmysql home page}
-A front end to the @strong{MySQL} database engine. It allows for simple
+A front end to the MySQL database engine. It allows for simple
queries and table maintenance, as well as batch queries. By Rick
Mehalick, @email{dblhack@@wt.net}.
Requires @uref{http://bragg.phys.uwm.edu/xforms,xforms 0.88} to work.
@item @uref{http://www.tamos.net/sw/dbMetrix,dbMetrix}
An open source client for exploring databases and executing SQL. Supports
-@strong{MySQL}, Oracle, PostgreSQL, and mSQL.
+MySQL, Oracle, PostgreSQL, and mSQL.
@item @uref{http://www.multimania.com/bbrox/GtkSQL,GtkSQL}
-A query tool for @strong{MySQL} and PostgreSQL.
+A query tool for MySQL and PostgreSQL.
@item @uref{http://dbman.linux.cz/,dbMan}
A query tool written in Perl. Uses DBI and Tk.
@item @uref{http://www.mysql.com/Downloads/Win32/Msc201.EXE, Mascon 202}
@item @uref{http://www.mysql.com/Downloads/Win32/FrMsc202.EXE, Free Mascon 202}
-Mascon is a powerful Win32 GUI for the administering @strong{MySQL} server
+Mascon is a powerful Win32 GUI for the administering MySQL server
databases. Mascon's features include visual table design, connections to
multiple servers, data and blob editing of tables, security setting, SQL
color coding, dump functionality and much more.
@@ -44807,7 +45612,7 @@ databases written with Java 2. JRetriever displays database
tables/views in a Windows explorer-like front end. Users can retrieve
data either by clicking on the table folder or by composing their own SQL
statements with our built-in SQL editor. The tool has been tested with
-Oracle 8 and @strong{MySQL} as the back-end databases. It requires JDK 1.3 from
+Oracle 8 and MySQL as the back-end databases. It requires JDK 1.3 from
JavaSoft.
@item @uref{http://www.jetools.com/products/databrowser/, DataBrowser}
The DataBrowser is a cross-database, cross-platform data access tool. It is more
@@ -44833,18 +45638,18 @@ by Query Analysis.
@item Web Clients
@itemize @minus
@item @uref{http://www.mysql.com/Downloads/Contrib/mysqladmin-atif-1.0.tar.gz, mysqladmin-atif-1.0.tar.gz}
-WWW @strong{MySQL} administrator for the @code{user,} @code{db} and
+WWW MySQL administrator for the @code{user,} @code{db} and
@code{host} tables. By Tim Sailer, modified by Atif Ghaffar
@email{aghaffar@@artemedia.ch}.
@item @uref{http://www.mysql.com/Downloads/Contrib/mysql-webadmin-1.0a8-rz.tar.gz, mysql-webadmin-1.0a8-rz.tar.gz}
-A tool written in PHP-FI to administrate @strong{MySQL} databases
+A tool written in PHP-FI to administrate MySQL databases
remotely over the web within a Web-Browser. By Peter Kuppelwieser,
@email{peter.kuppelwieser@@kantea.it}. Updated by Wim Bonis,
@email{bonis@@kiss.de}. Not maintained anymore!
@item @uref{http://www.mysql.com/Downloads/Contrib/mysqladm.tar.gz, mysqladm.tar.gz}
-@strong{MySQL} Web Database Administration written in Perl. By Tim Sailer.
+MySQL Web Database Administration written in Perl. By Tim Sailer.
@item @uref{http://www.mysql.com/Downloads/Contrib/mysqladm-2.tar.gz, mysqladm-2.tar.gz}
Updated version of @file{mysqladm.tar.gz}, by High Tide.
@@ -44855,16 +45660,16 @@ newest version from @uref{http://civeng.com/sqldemo/, the home site}.
@item @uref{http://www.mysql.com/Downloads/Contrib/myadmin-0.4.tar.gz, myadmin-0.4.tar.gz}.
@item @uref{http://myadmin.cheapnet.net/, MyAdmin home page}
-A Web-based @strong{MySQL} administrator by Mike Machado.
+A Web-based MySQL administrator by Mike Machado.
@item @uref{http://www.mysql.com/Downloads/Contrib/phpMyAdmin_2.0.1.tar.gz,phpMyAdmin_2.0.1.tar.gz}
-A set of PHP3-scripts to adminstrate @strong{MySQL} over the WWW.
+A set of PHP3-scripts to adminstrate MySQL over the WWW.
@item @uref{http://www.phpwizard.net/projects/phpMyAdmin/, phpMyAdmin home page}
A PHP3 tool in the spirit of mysql-webadmin, by Tobias Ratschiller, tobias@@dnet.it.
@item @uref{http://www.mysql.com/Downloads/Contrib/useradm.tar.gz, useradm.tar.gz}
-@strong{MySQL} administrator in PHP. By Ofni Thomas
+MySQL administrator in PHP. By Ofni Thomas
@email{othomas@@vaidsystems.com}.
@item @uref{http://gossamer-threads.com/perl/mysqlman/mysql.cgi, MySQLMan}
@@ -44879,10 +45684,10 @@ database. By Tomas Zeman.
@uref{http://worldcommunity.com/opensource/futuresql, FutureSQL Web Database Administration Tool}.
FutureSQL by Peter F. Brown, is a free, open source rapid application
development Web database administration tool, written in Perl,
-using @strong{MySQL}. It uses @code{DBI:DBD} and @code{CGI.pm}.
+using MySQL. It uses @code{DBI:DBD} and @code{CGI.pm}.
FutureSQL allows one to easily set up config files to view, edit, delete,
-and otherwise process records from a @strong{MySQL} database. It uses a data
+and otherwise process records from a MySQL database. It uses a data
dictionary, configuration files and templates, and allows "pre-processing"
and "post-processing" on both fields, records, and operations.
@end itemize
@@ -44894,12 +45699,12 @@ and "post-processing" on both fields, records, and operations.
@itemize @bullet
@item @uref{http://www.mysql.com/Downloads/Contrib/mod_mysql_include_1.0.tar.gz, mod_mysql_include_1.0.tar.gz}
-Apache module to include HTML from @strong{MySQL} queries into your pages,
+Apache module to include HTML from MySQL queries into your pages,
and run update queries. Originally written to implement a simple fast
low-overhead banner-rotation system. By Sasha Pachev.
@item @uref{http://htcheck.sourceforge.net, htCheck} - URL checker with
-@strong{MySQL} backend. Spidered URLs can later be queried using SQL to retrieve
+MySQL backend. Spidered URLs can later be queried using SQL to retrieve
various kinds of information, eg. broken links. Written by Gabriele Bartolini.
@item @uref{http://www.odbsoft.com/cook/sources.htm}
@@ -44910,7 +45715,7 @@ interface to a SQL database (query, add, update, delete) without any
programming! By Marc Beneteau, @email{marc@@odbsoft.com}.
@item @uref{http://www.mysql.com/Downloads/Contrib/sqlhtml.tar.gz, sqlhtml.tar.gz}
-SQL/HTML is an HTML database manager for @strong{MySQL} using @code{DBI} 1.06.
+SQL/HTML is an HTML database manager for MySQL using @code{DBI} 1.06.
@item @uref{http://www.mysql.com/Downloads/Contrib/udmsearch-3.0.23.tar.gz, UdmSearch 3.0.23 (stable version)}.
@item @uref{http://www.mysql.com/Downloads/Contrib/mnogosearch-3.1.12.tar.gz, mnogosearch 3.1.12 (development but recommended version)}.
@@ -44926,7 +45731,7 @@ With this you can write HTML files with inclusions of Tcl code. By
@item @uref{http://www.mysql.com/Downloads/Contrib/www-sql-0.5.7.lsm, www-sql-0.5.7.lsm}.
@item @uref{http://www.mysql.com/Downloads/Contrib/www-sql-0.5.7.tar.gz, www-sql-0.5.7.tar.gz}
A CGI program that parses an HTML file containing special tags, parses
-them, and inserts data from a @strong{MySQL} database.
+them, and inserts data from a MySQL database.
@item @uref{http://www.mysql.com/Downloads/Contrib/genquery.zip, genquery.zip}
Perl SQL database interface package for html.
@@ -44948,7 +45753,7 @@ Full-text searching with Perl on @code{BLOB}/@code{TEXT} columns by Daniel Koch.
@itemize @bullet
@item @uref{http://www.mysql.com/Downloads/super-smack/super-smack-1.0.tar.gz,
super-smack}
-Multi-threaded benchmarking tool for @strong{MySQL} and
+Multi-threaded benchmarking tool for MySQL and
@strong{PostgreSQL}. Written in C++. Easy to extend to support other
databases that have C/C++ client libraries. By Sasha Pachev.
@end itemize
@@ -44959,7 +45764,7 @@ databases that have C/C++ client libraries. By Sasha Pachev.
@itemize @bullet
@item @uref{http://www.mysql.com/Downloads/Contrib/ascend-radius-mysql-0.7.2.patch.gz,ascend-radius-mysql-0.7.2.patch.gz}
-This is an authentication and logging patch using @strong{MySQL} for
+This is an authentication and logging patch using MySQL for
Ascend-Radius. By @email{takeshi@@SoftAgency.co.jp}.
@item @uref{http://www.mysql.com/Downloads/Contrib/icradius-0.10.tar.gz, icradius 0.10}
@@ -44967,16 +45772,16 @@ Ascend-Radius. By @email{takeshi@@SoftAgency.co.jp}.
@item @uref{http://www.mysql.com/Downloads/Contrib/checkpassword-0.81-mysql-0.6.6.patch.gz,
checkpassword-0.81-mysql-0.6.6.patch.gz}
-@strong{MySQL} authentication patch for QMAIL and checkpassword. These are
-useful for management user (mail, pop account) by @strong{MySQL}.
+MySQL authentication patch for QMAIL and checkpassword. These are
+useful for management user (mail, pop account) by MySQL.
By @email{takeshi@@SoftAgency.co.jp}.
@item @uref{http://www.mysql.com/Downloads/Contrib/jradius-diff.gz, jradius-diff.gz}
-@strong{MySQL} support for Livingston's Radius 2.01. Authentication and
+MySQL support for Livingston's Radius 2.01. Authentication and
Accounting. By Jose de Leon, @email{jdl@@thevision.net}.
@item @uref{http://www.mysql.com/Downloads/Contrib/mod_auth_mysql-2.20.tar.gz, mod_auth_mysql-2.20.tar.gz}
-Apache authentication module for @strong{MySQL}. By Zeev Suraski,
+Apache authentication module for MySQL. By Zeev Suraski,
@email{bourbon@@netvision.net.il}.
@c @strong{Please} register this module at:
@@ -44985,13 +45790,13 @@ Apache authentication module for @strong{MySQL}. By Zeev Suraski,
@c encourage further development of this module!
@item @uref{http://www.mysql.com/Downloads/Contrib/mod_log_mysql-1.05.tar.gz, mod_log_mysql-1.05.tar.gz}
-@strong{MySQL} logging module for Apache. By Zeev Suraski,
+MySQL logging module for Apache. By Zeev Suraski,
@email{bourbon@@netvision.net.il}.
@item @uref{http://www.mysql.com/Downloads/Contrib/mypasswd-2.0.tar.gz, mypasswd-2.0.tar.gz}
Extra for @code{mod_auth_mysql}. This is a little tool that allows you
to add/change user records storing group and/or password entries in
-@strong{MySQL} tables. By Harry Brueckner, @email{brueckner@@respublica.de}.
+MySQL tables. By Harry Brueckner, @email{brueckner@@respublica.de}.
@item @uref{http://www.mysql.com/Downloads/Contrib/mysql-passwd.README, mysql-passwd.README}.
@item @uref{http://www.mysql.com/Downloads/Contrib/mysql-passwd-1.2.tar.gz, mysql-passwd-1.2.tar.gz}
@@ -44999,14 +45804,14 @@ Extra for @code{mod_auth_mysql}. This is a two-part system for use with
@code{mod_auth_mysql}.
@item @uref{http://www.mysql.com/Downloads/Contrib/pam_mysql.tar.gz, pam_mysql.tar.gz}
-This module authenticates users via @code{pam}, using @strong{MySQL}.
+This module authenticates users via @code{pam}, using MySQL.
@item @uref{http://www.mysql.com/Downloads/Contrib/nsapi_auth_mysql.tar, nsapi_auth_mysql.tar}
Netscape Web Server API (NSAPI) functions to authenticate (BASIC) users
-against @strong{MySQL} tables. By Yuan John Jiang.
+against MySQL tables. By Yuan John Jiang.
@item @uref{http://www.mysql.com/Downloads/Contrib/qmail-1.03-mysql-0.6.6.patch.gz,qmail-1.03-mysql-0.6.6.patch.gz}
-Patch for qmail to authenticate users from a @strong{MySQL} table.
+Patch for qmail to authenticate users from a MySQL table.
By @email{takeshi@@SoftAgency.co.jp}.
@item @uref{http://www.mysql.com/Downloads/Contrib/proftpd-1.2.0rc2-fix-mysql.patch, proftpd-1.2.0rc2-fix-mysql.patch}
@@ -45027,23 +45832,23 @@ Converter from MS-SQL to MySQL. By Michael Kofler.
@uref{http://www.kofler.cc/mysql/mssql2mysql.html, mssql2mysql home page}.
@item @uref{http://www.mysql.com/Downloads/Contrib/dbf2mysql-1.14.tar.gz, dbf2mysql-1.14.tar.gz}
-Convert between @file{.dbf} files and @strong{MySQL} tables. By Maarten
+Convert between @file{.dbf} files and MySQL tables. By Maarten
Boekhold (@email{boekhold@@cindy.et.tudelft.nl}), William Volkman, and
Michael Widenius. This converter includes rudimentary read-only support
for MEMO fields.
@item @uref{http://www.mysql.com/Downloads/Contrib/dbf2mysql-1.13.tgz, dbf2mysql-1.13.tgz}
-Convert between @file{.dbf} files and @strong{MySQL} tables. By Maarten
+Convert between @file{.dbf} files and MySQL tables. By Maarten
Boekhold, @email{boekhold@@cindy.et.tudelft.nl}, and Michael Widenius.
This converter can't handle MEMO fields.
@item @uref{http://www.mysql.com/Downloads/Contrib/dbf2mysql.zip, dbf2mysql.zip}
-Convert between FoxPro @file{.dbf} files and @strong{MySQL} tables on Windows.
+Convert between FoxPro @file{.dbf} files and MySQL tables on Windows.
By Alexander Eltsyn, @email{ae@@nica.ru} or @email{ae@@usa.net}.
@item @uref{http://www.mysql.com/Downloads/Contrib/dbf2sql.zip, dbf2sql.zip}
Short and simple prg that can help you transport your data from foxpro
-table into @strong{MySQL} table. By Danko Josic.
+table into MySQL table. By Danko Josic.
@item @uref{http://www.mysql.com/Downloads/Contrib/dump2h-1.20.gz, dump2h-1.20.gz}
Convert from @code{mysqldump} output to a C header file. By Harry Brueckner,
@@ -45066,22 +45871,22 @@ NOTE: Doesn't work with Access2!
@item @uref{http://www.mysql.com/Downloads/Contrib/importsql.txt, importsql.txt}
A script that does the exact reverse of @code{exportsql.txt}. That is,
-it imports data from @strong{MySQL} into an Access database via
+it imports data from MySQL into an Access database via
ODBC. This is very handy when combined with exportsql, because it lets you
use Access for all DB design and administration, and synchronize with
-your actual @strong{MySQL} server either way. Free of charge. See
+your actual MySQL server either way. Free of charge. See
@uref{http://www.netdive.com/freebies/importsql/} for any updates.
Created by Laurent Bossavit of NetDIVE.
@strong{NOTE:} Doesn't work with Access2!
@item @uref{http://www.mysql.com/Downloads/Contrib/mdb2sql.bas, mdb2sql.bas}
-Converter from Access97 to @strong{MySQL} by Moshe Gurvich.
+Converter from Access97 to MySQL by Moshe Gurvich.
@item @uref{http://www.mysql.com/Downloads/Contrib/msql2mysqlWrapper-1.0.tgz, msql2mysqlWrapper 1.0}
-A C wrapper from @code{mSQL} to @strong{MySQL}. By @email{alfred@@sb.net}
+A C wrapper from @code{mSQL} to MySQL. By @email{alfred@@sb.net}
@item @uref{http://www.mysql.com/Downloads/Contrib/sqlconv.pl, sqlconv.pl}
-A simple script that can be used to copy fields from one @strong{MySQL} table
+A simple script that can be used to copy fields from one MySQL table
to another in bulk. Basically, you can run @code{mysqldump} and pipe it to
the @code{sqlconv.pl} script. The script will parse through the
@code{mysqldump} output and will rearrange the fields so they can be
@@ -45090,14 +45895,14 @@ table for a different site you are working on, but the table is just a
bit different (that is - fields in different order, etc.).
By Steve Shreeve.
@item @uref{http://www.mysql.com/Downloads/Contrib/oracledump, oracledump}
-Perl program to convert Oracle databases to @strong{MySQL}. Has same
+Perl program to convert Oracle databases to MySQL. Has same
output format as mysqldump. By Johan Andersson.
-@item @uref{http://www.mysql.com/Downloads/Contrib/excel2mysql, excel2mysql}
-Perl program to import Excel spreadsheets into a @strong{MySQL} database. By Stephen Hurd @email{shurd@@sk.sympatico.ca}
+@item @uref{http://www.mysql.com/Downloads/Contrib/excel2mysql.pl, excel2mysql.pl}
+Perl program to import Excel spreadsheets into a MySQL database. By Stephen Hurd @email{shurd@@sk.sympatico.ca}
@item @uref{http://www.mysql.com/Downloads/Contrib/T2S_100.ZIP, T2S_100.ZIP}.
-Windows program to convert text files to @strong{MySQL} databases. By
+Windows program to convert text files to MySQL databases. By
Asaf Azulay.
@end itemize
@@ -45108,13 +45913,13 @@ Asaf Azulay.
@item @uref{http://www.mysql.com/Downloads/Contrib/emacs-sql-mode.tar.gz, emacs-sql-mode.tar.gz}
Raw port of a SQL mode for XEmacs. Supports completion. Original by
Peter D. Pezaris @email{pez@@atlantic2.sbi.com} and partial
-@strong{MySQL} port by David Axmark.
+MySQL port by David Axmark.
@item @uref{http://www.mysql.com/Downloads/Win32/myaccess97_1_4.zip, MyAccess97 1.4}.
@item @uref{http://www.mysql.com/Downloads/Win32/myaccess2000_1_4.zip, MyAccess2000 1.4}.
MyAccess is an AddIn for MS Access 97/2000 that allows you to manage
-@strong{MySQL} databases from within Access. Main functions are:
+MySQL databases from within Access. Main functions are:
@itemize @minus
@item Create/Modify Tables
@item Execute Queries against MySQL
@@ -45127,7 +45932,7 @@ MyAccess is an AddIn for MS Access 97/2000 that allows you to manage
Written by Hubertus Hiden. @uref{http://www.accessmysql.com, MyAccess homepage}.
@item @uref{http://www.mysql.com/Downloads/Contrib/radius-0.3.tar.gz, radius-0.3.tar.gz}
-Patches for @code{radiusd} to make it support @strong{MySQL}. By Wim Bonis,
+Patches for @code{radiusd} to make it support MySQL. By Wim Bonis,
@email{bonis@@kiss.de}.
@end itemize
@@ -45141,12 +45946,12 @@ A backup script for MySQL. By Peter F. Brown.
@item @uref{http://www.mysql.com/Downloads/Contrib/mytop, mytop}
@item @uref{http://public.yahoo.com/~jzawodn/mytop/, mytop home page}
-mytop is a Perl program that allows you to monitor @strong{MySQL} servers by
+mytop is a Perl program that allows you to monitor MySQL servers by
viewing active threads, queries, and overall server performance
numbers. By Jeremy D. Zawodny.
@item @uref{http://www.mysql.com/Downloads/Contrib/mysql_watchdog.pl, mysql_watchdog.pl}
-Monitor the @strong{MySQL} daemon for possible lockups. By Yermo Lamers,
+Monitor the MySQL daemon for possible lockups. By Yermo Lamers,
@email{yml@@yml.com}.
@item @uref{http://www.mysql.com/Downloads/Contrib/mysqltop.tar.gz, mysqltop.tar.gz}
@@ -45159,14 +45964,14 @@ Prints out the structure of the all tables in a database. By Thomas Wana.
Prints the structure of every table in a database. By Thomas Wana.
@item @uref{http://www.mysql.com/Downloads/Contrib/mysqlsync, mysqlsync-1.0-alpha.tar.gz}.
-A Perl script to keep remote copies of a @strong{MySQL} database in sync with a
+A Perl script to keep remote copies of a MySQL database in sync with a
central master copy. By Mark Jeftovic. @email{markjr@@easydns.com}.
@item @uref{http://www.mysql.com/Downloads/Contrib/MySQLTutor-0.2.tar.gz, MySQLTutor}.
-MySQLTutor. A @strong{MySQL} tutorial for beginners.
+MySQLTutor. A MySQL tutorial for beginners.
@item @uref{http://www.mysql.com/Downloads/Contrib/MySQLDB.zip, MySQLDB.zip}
-A COM library for @strong{MySQL} by Alok Singh.
+A COM library for MySQL by Alok Singh.
@item @uref{http://www.mysql.com/Downloads/Contrib/MySQLDB-readme.html, MySQLDB-readme.html}.
@item @uref{http://www.mysql.com/Downloads/Contrib/mysql_replicate.pl, mysql_replicate.pl}
@@ -45185,7 +45990,7 @@ By Elizabeth.
Wrapper for mysqldump to backup all databases. By Marc Swanson.
@item @uref{http://www.mysql.com/Downloads/Contrib/mdu.pl.gz,mdu.pl.gz}
-Prints the storage usage of a @strong{MySQL} database.
+Prints the storage usage of a MySQL database.
@end itemize
@cindex RPMs, for common tools
@@ -45211,7 +46016,7 @@ sprintf() function for SQL queries that can escape blobs. By Chunhua Liu.
@appendixsec Windows programs
@itemize @bullet
@item @uref{http://www.mysql.com/Downloads/Contrib/LaunchMySQL.zip, LaunchMySQL.zip}
-The program launches the @strong{MySQL} server, shuts it down, and
+The program launches the MySQL server, shuts it down, and
display status information. By Bill Thompson
@end itemize
@@ -45227,50 +46032,55 @@ Performance handicapping system for yachts. Uses PHP. By
@email{rhill@@stobyn.ml.org}.
@item @uref{http://www.mysql.com/Downloads/Contrib/hylalog-1.0.tar.gz, hylalog-1.0.tar.gz}
-Store @code{hylafax} outgoing faxes in a @strong{MySQL} database. By Sinisa
+Store @code{hylafax} outgoing faxes in a MySQL database. By Sinisa
Milivojevic, @email{sinisa@@mysql.com}.
@item @uref{http://www.mysql.com/Downloads/Contrib/mrtg-mysql-1.0.tar.gz, mrtg-mysql-1.0.tar.gz}
-@strong{MySQL} status plotting with MRTG, by Luuk de Boer, @email{luuk@@wxs.nl}.
+MySQL status plotting with MRTG, by Luuk de Boer, @email{luuk@@wxs.nl}.
@item @uref{http://www.mysql.com/Downloads/Contrib/wuftpd-2.4.2.18-mysql_support.2.tar.gz, wuftpd-2.4.2.18-mysql_support.2.tar.gz}
-Patches to add logging to @strong{MySQL} for WU-ftpd. By Zeev Suraski,
+Patches to add logging to MySQL for WU-ftpd. By Zeev Suraski,
@email{bourbon@@netvision.net.il}.
@item @uref{http://www.mysql.com/Downloads/Contrib/wu-ftpd-2.6.0-mysql.4.tar.gz,wu-ftpd-2.6.0-mysql.4.tar.gz}
-Patches to add logging to @strong{MySQL} for WU-ftpd 2.6.0. By
+Patches to add logging to MySQL for WU-ftpd 2.6.0. By
@email{takeshi@@SoftAgency.co.jp}, based on Zeev Suraski wuftpd patches.
@item @uref{http://www.mysql.com/Downloads/Contrib/Old-Versions, Old-Versions}
Previous versions of things found here that you probably won't be
interested in.
@end itemize
-
@page
+
+
+
+
@node Credits, News, Contrib, Top
@appendix Credits
+@cindex developers, list of
+
This appendix lists the developers, contributors, and supporters that have
-helped to make @strong{MySQL} what it is today.
+helped to make MySQL what it is today.
-@cindex developers, list of
@menu
-* Developers::
-* Contributors::
-* Supporters::
+* Developers:: Developers at MySQL AB
+* Contributors:: Contributors to MySQL
+* Supporters:: Supporters to MySQL
@end menu
+
@node Developers, Contributors, Credits, Credits
-@appendixsubsec Developers at MySQL AB
+@appendixsec Developers at MySQL AB
-These are the developers that are or have been employed by @strong{MySQL AB}
-to work on @strong{MySQL}, roughly in the order they started to work with us.
+These are the developers that are or have been employed by MySQL AB
+to work on MySQL, roughly in the order they started to work with us.
Following each developer is a small list of the tasks that the developer is
responsible for, or the accomplishments they have made.
@table @asis
@item Michael (Monty) Widenius
-Has written the following parts of @strong{MySQL}:
+Has written the following parts of MySQL:
@itemize @bullet
@item
All the main code in @code{mysqld}.
@@ -45289,13 +46099,13 @@ The @code{replace} program (look into it, it's COOL!).
@item
@strong{MyODBC}, the ODBC driver for Windows95.
@item
-Fixing bugs in MIT-pthreads to get it to work for @strong{MySQL}. And
+Fixing bugs in MIT-pthreads to get it to work for MySQL. And
also Unireg, a curses-based application tool with many utilities.
@item
Porting of @code{mSQL} tools like @code{msqlperl}, @code{DBD}/@code{DBI}, and
@code{DB2mysql}.
@item
-Most of crash-me and the foundation for the @strong{MySQL} benchmarks.
+Most of crash-me and the foundation for the MySQL benchmarks.
@end itemize
@item David Axmark
@@ -45355,7 +46165,7 @@ Our security expert.
@item
Vio interface (The foundation for the encrypted client/server protocol).
@item
-@strong{MySQL} Filesystem (A way to use @strong{MySQL} databases as files
+MySQL Filesystem (A way to use MySQL databases as files
and directories).
@item
The CASE Expression.
@@ -45382,7 +46192,7 @@ mysql-bench
@item Matt Wagner
@itemize @bullet
@item
-@strong{MySQL} test suite.
+MySQL test suite.
@item
Our webmaster.
@end itemize
@@ -45398,7 +46208,7 @@ Winmysqladmin.
@item
Dynamic character support.
@item
-Responsible for @strong{MySQL} configure.
+Responsible for MySQL configure.
@end itemize
@item Sergei Golubchik
@@ -45407,8 +46217,6 @@ Responsible for @strong{MySQL} configure.
Full-text search.
@item
Added keys to the @code{MERGE} library.
-@item
-@code{HANDLER} command.
@end itemize
@item Jeremy Cole
@@ -45426,7 +46234,7 @@ Proofreading and editing this fine manual.
@item John Dean
@itemize @bullet
@item
-The new @strong{MySQL} GUI client.
+The new MySQL GUI client.
@end itemize
@item Indrek Siitan
@@ -45436,26 +46244,28 @@ Designer/programmer of our web interface.
@end itemize
@end table
-The following non-developers are also working in/with @strong{MySQL AB}:
+The following non-developers are also working in/with MySQL AB:
@table @asis
@item
-Hans Kierkegaard - Responsible for @strong{MySQL} license handling.
+Hans Kierkegaard - Responsible for MySQL license handling.
@item
Antti Halonen - Sales manager.
@item
Jonas Norrman - Handles licensing questions sent to @email{info@@mysql.com}.
@item
-Erik Granberg - Handles @strong{MySQL} partners (and a lot of other stuff).
+Erik Granberg - Handles MySQL partners (and a lot of other stuff).
@item
Allan Larsson (The BOSS for TCX DataKonsult AB).
@end table
-@cindex contributors, list of
+
@node Contributors, Supporters, Developers, Credits
-@appendixsubsec Contributors to MySQL
+@appendixsec Contributors to MySQL
-Contributors to the @strong{MySQL} distribution are listed here, in
+@cindex contributors, list of
+
+Contributors to the MySQL distribution are listed here, in
somewhat random order:
@table @asis
@@ -45480,13 +46290,13 @@ For the effort to make a shareware SQL database. We at TcX started with
wrote a SQL interface to our application builder Unireg. @code{mysqladmin}
and @code{mysql} are programs that were largely influenced by their
@code{mSQL} counterparts. We have put a lot of effort into making the
-@strong{MySQL} syntax a superset of @code{mSQL}. Many of the API's ideas are
+MySQL syntax a superset of @code{mSQL}. Many of the API's ideas are
borrowed from @code{mSQL} to make it easy to port free @code{mSQL} programs
-to @strong{MySQL}. @strong{MySQL} doesn't contain any code from @code{mSQL}.
+to MySQL. MySQL doesn't contain any code from @code{mSQL}.
Two files in the distribution (@file{client/insert_test.c} and
@file{client/select_test.c}) are based on the corresponding (non-copyrighted)
files in the @code{mSQL} distribution, but are modified as examples showing
-the changes necessary to convert code from @code{mSQL} to @strong{MySQL}.
+the changes necessary to convert code from @code{mSQL} to MySQL.
(@code{mSQL} is copyrighted David J. Hughes.)
@item Fred Fish
For his excellent C debugging and trace library. Monty has made a number
@@ -45505,25 +46315,27 @@ TcX/MySQL AB/detron.
@item Patrick Lynch
For helping us acquire @code{http://www.mysql.com/}.
@item Fred Lindberg
-For setting up qmail to handle the @strong{MySQL} mailing list and for the
-incredible help we got in managing the @strong{MySQL} mailing lists.
+For setting up qmail to handle the MySQL mailing list and for the
+incredible help we got in managing the MySQL mailing lists.
@item Igor Romanenko @email{igor@@frog.kiev.ua}
@code{mysqldump} (previously @code{msqldump}, but ported and enhanced by
Monty).
+@item Yuri Dario
+For keeping up and extending the MySQL OS/2 port.
@item Tim Bunce, Alligator Descartes
For the @code{DBD} (Perl) interface.
@item Tim Bunce
Author of @code{mysqlhotcopy}.
@item Andreas Koenig @email{a.koenig@@mind.de}
-For the Perl interface to @strong{MySQL}.
+For the Perl interface to MySQL.
@item Eugene Chan @email{eugene@@acenet.com.sg}
-For porting PHP to @strong{MySQL}.
+For porting PHP to MySQL.
@item Michael J. Miller Jr. @email{mke@@terrapin.turbolift.com}
-For the first @strong{MySQL} manual. And a lot of spelling/language
-fixes for the FAQ (that turned into the @strong{MySQL} manual a long
+For the first MySQL manual. And a lot of spelling/language
+fixes for the FAQ (that turned into the MySQL manual a long
time ago).
@item Yan Cailin
-First translator of the @strong{MySQL} Reference Manual into simplified
+First translator of the MySQL Reference Manual into simplified
chinese in early 2000 on which the Big5 and HK coded
(@uref{http://mysql.hitstar.com, mysql.hitstar.com}) versions were
based. @uref{http://linuxdb.yeah.net, Personal home page at
@@ -45536,7 +46348,7 @@ software developed by Chris Provenzano, the University of California,
Berkeley, and contributors. We are currently using version 1_60_beta6
patched by Monty (see @file{mit-pthreads/Changes-mysql}).
@item Xavier Leroy @email{Xavier.Leroy@@inria.fr}
-The author of LinuxThreads (used by @strong{MySQL} on Linux).
+The author of LinuxThreads (used by MySQL on Linux).
@item Zarko Mocnik @email{zarko.mocnik@@dem.si}
Sorting for Slovenian language and the @file{cset.tar.gz} module that makes
it easier to add other character sets.
@@ -45544,28 +46356,28 @@ it easier to add other character sets.
The @code{_MB} character set macros and the ujis and sjis character sets.
@item Joshua Chamas @email{joshua@@chamas.com}
Base for concurrent insert, extended date syntax, debugging on NT, and
-answering on the @strong{MySQL} mailing list.
+answering on the MySQL mailing list.
@item Yves Carlier @email{Yves.Carlier@@rug.ac.be}
@code{mysqlaccess}, a program to show the access rights for a user.
@item Rhys Jones @email{rhys@@wales.com} (And GWE Technologies Limited)
-For the JDBC, a module to extract data from @strong{MySQL} with a Java
+For the JDBC, a module to extract data from MySQL with a Java
client.
@item Dr Xiaokun Kelvin ZHU @email{X.Zhu@@brad.ac.uk}
-Further development of the JDBC driver and other @strong{MySQL}-related
+Further development of the JDBC driver and other MySQL-related
Java tools.
@item James Cooper @email{pixel@@organic.com}
For setting up a searchable mailing list archive at his site.
@item Rick Mehalick @email{Rick_Mehalick@@i-o.com}
-For @code{xmysql}, a graphical X client for @strong{MySQL}.
+For @code{xmysql}, a graphical X client for MySQL.
@item Doug Sisk @email{sisk@@wix.com}
-For providing RPM packages of @strong{MySQL} for RedHat Linux.
+For providing RPM packages of MySQL for RedHat Linux.
@item Diemand Alexander V. @email{axeld@@vial.ethz.ch}
-For providing RPM packages of @strong{MySQL} for RedHat Linux-Alpha.
+For providing RPM packages of MySQL for RedHat Linux-Alpha.
@item Antoni Pamies Olive @email{toni@@readysoft.es}
-For providing RPM versions of a lot of @strong{MySQL} clients for Intel
+For providing RPM versions of a lot of MySQL clients for Intel
and SPARC.
@item Jay Bloodworth @email{jay@@pathways.sde.state.sc.us}
-For providing RPM versions for @strong{MySQL} Version 3.21.
+For providing RPM versions for MySQL Version 3.21.
@item Jochen Wiedmann @email{wiedmann@@neckar-alb.de}
For maintaining the Perl @code{DBD::mysql} module.
@item Therrien Gilbert @email{gilbert@@ican.net}, Jean-Marc Pouyot @email{jmp@@scalaire.fr}
@@ -45592,6 +46404,8 @@ Romanian error messages.
Hungarian error messages.
@item Roberto M. Serqueira
Portugise error messages.
+@item Carsten H. Pedersen
+Danish error messages
@item David Sacerdote @email{davids@@secnet.com}
Ideas for secure checking of DNS hostnames.
@item Wei-Jou Chen @email{jou@@nematic.ieo.nctu.edu.tw}
@@ -45616,27 +46430,27 @@ User-definable functions (UDFs); @code{CREATE FUNCTION} and
@item Andreas F. Bobak @email{bobak@@relog.ch}
The @code{AGGREGATE} extension to UDF functions.
@item Ross Wakelin @email{R.Wakelin@@march.co.uk}
-Help to set up InstallShield for @strong{MySQL}-Win32.
+Help to set up InstallShield for MySQL-Win32.
@item Jethro Wright III @email{jetman@@li.net}
The @file{libmysql.dll} library.
@item James Pereria @email{jpereira@@iafrica.com}
-Mysqlmanager, a Win32 GUI tool for administrating @strong{MySQL}.
+Mysqlmanager, a Win32 GUI tool for administrating MySQL.
@item Curt Sampson @email{cjs@@portal.ca}
Porting of MIT-pthreads to NetBSD/Alpha and NetBSD 1.3/i386.
@item Antony T. Curtis @email{antony.curtis@@olcs.net}
-Porting of @strong{MySQL} to OS/2.
+Porting of MySQL to OS/2.
@item Martin Ramsch @email{m.ramsch@@computer.org}
-Examples in the @strong{MySQL} Tutorial.
+Examples in the MySQL Tutorial.
@item Steve Harvey
For making @code{mysqlaccess} more secure.
@item Konark IA-64 Centre of Persistent Systems Private Limited
@uref{http://www.pspl.co.in/konark/}. Help with the Win64 port of the
-@strong{MySQL} server.
+MySQL server.
@item Albert Chin-A-Young.
Configure updates for Tru64, large file support and better TCP wrappers
support.
-@item Valueclick Inc.
-For sponsoring the optimize section in this manual.
+@item John Birrell
+Emulation of pthread_mutex() for OS/2.
@end table
Other contributors, bugfinders, and testers: James H. Thompson, Maurizio
@@ -45670,12 +46484,12 @@ General questions.
Questions pertaining to OS-specifics with Linux, SQL syntax, and other
things that might need some work.
@item David Sklar @email{sklar@@student.net}
-Using @strong{MySQL} from PHP and Perl.
+Using MySQL from PHP and Perl.
@item Alistair MacDonald @email{A.MacDonald@@uel.ac.uk}
Not yet specified, but is flexible and can handle Linux and maybe HP-UX.
Will try to get user to use @code{mysqlbug}.
@item John Lyon @email{jlyon@@imag.net}
-Questions about installing @strong{MySQL} on Linux systems, using either
+Questions about installing MySQL on Linux systems, using either
@file{.rpm} files or compiling from source.
@item Lorvid Ltd. @email{lorvid@@WOLFENET.com}
Simple billing/license/support/copyright issues.
@@ -45685,22 +46499,24 @@ ODBC and VisualC++ interface questions.
@code{DBD}, Linux, some SQL syntax questions.
@end table
-@cindex contributing companies, list of
+
@node Supporters, , Contributors, Credits
-@appendixsubsec Supporters to MySQL
+@appendixsec Supporters to MySQL
+
+@cindex contributing companies, list of
The following companies has helped us finance development of
-@strong{MySQL} by either paying us for developing a new feature,
-developed a @strong{MySQL} feature themselves or by giving us hardware for
-@strong{MySQL} development.
+MySQL by either paying us for developing a new feature,
+developed a MySQL feature themselves or by giving us hardware for
+MySQL development.
@table @asis
@item VA Linux / Andover.net
Funded replication.
@item NuSphere
-Editing of the @strong{MySQL} manual.
+Editing of the MySQL manual.
@item Stork Design studio
-The @strong{MySQL} web site in use between 1998-2000.
+The MySQL web site in use between 1998-2000.
@item Intel
Contributed to development on Windows and Linux platforms.
@item Compaq
@@ -45711,16 +46527,23 @@ Development on the embedded @code{mysqld} version.
@code{--skip-show-variables}
@end table
-@node News, Bugs, Credits, Top
+
+
+
+@node News, Porting, Credits, Top
@appendix MySQL change history
-This appendix lists the changes from version to version in the @strong{MySQL}
+@cindex ChangeLog
+@cindex changes, log
+@cindex log, changes
+
+This appendix lists the changes from version to version in the MySQL
source code.
Note that we tend to update the manual at the same time we make changes to
-@strong{MySQL}. If you find a version listed below that you can't
+MySQL. If you find a version listed below that you can't
find on the
-@uref{http://www.mysql.com/downloads/,@strong{MySQL} download page},
+@uref{http://www.mysql.com/downloads/,MySQL download page},
this means that the version has not yet been released!
@menu
@@ -45732,10 +46555,11 @@ this means that the version has not yet been released!
* News-3.19.x:: Changes in release 3.19.x
@end menu
+
@node News-4.0.x, News-3.23.x, News, News
@appendixsec Changes in release 4.0.x (Development; Alpha)
-We have now started to work on @strong{MySQL} 4.0. We will update this
+We have now started to work on MySQL 4.0. We will update this
section as we add new features, so that others can follow our development.
Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}.
@@ -45744,56 +46568,40 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}.
* News-4.0.0:: Changes in release 4.0.0
@end menu
+
@node News-4.0.0, , News-4.0.x, News-4.0.x
@appendixsubsec Changes in release 4.0.0
+@cindex changes, version 4.0
+
@itemize @bullet
@item
-@code{TRUNCATE TABLE} and @code{DELETE FROM table_name} are now separate
-functions. One bonus is that @code{DELETE FROM table_name} now returns
-the number of deleted rows.
-@item
-@code{DROP DATABASE} now executes a @code{DROP TABLE} on all tables in
-the database, which fixes a problem with InnoDB tables.
-@item
-Changed WEEK(#,0) to match the calender in the USA.
-@item
-Cleaned up global lock handling for @code{FLUSH TABLES WITH READ LOCK}
-@item
-Fixed problem with @code{DATETIME = constant} in @code{WHERE} optimization.
-@item
-Speed up all internal list handling.
-@item
-Added support for @code{UNION}.
-@item
-Allow ANSI SQL syntax @code{X'hexadecimal-number'}
-@item
-Tree-like cache to speed up bulk inserts and
-@code{myisam_bulk_insert_tree_size} variable.
+Multi-table @code{DELETE}.
@item
-Added @code{ALTER TABLE table_name DISABLE KEYS} and
-@code{ALTER TABLE table_name ENABLE KEYS} commands.
+Don't support old client protocols prior to MySQL 3.21 any more.
@item
-@code{LOAD DATA FROM MASTER} "auto-magically" sets up a slave.
+Don't include the old C API functions @code{mysql_drop_db},
+@code{mysql_create_db} and @code{mysql_connect}, unless compiled with
+@code{USE_OLD_FUNCTIONS}.
@item
Renamed @code{safe_mysqld} to @code{mysqld_safe}.
@item
-Allow one to use @code{IN} instead of @code{FROM} in @code{SHOW} commands.
+Allow @code{IN} as a synonym for @code{FROM} in @code{SHOW} commands.
@item
@code{SHOW INDEXES} is now a synonym for @code{SHOW INDEX}.
@item
Added support for symbolic links to @code{MyISAM} tables. Symlink handling is
now enabled by default for Windows.
@item
-@code{LOAD DATA FROM MASTER} "auto-magically" sets up a slave.
+@code{LOAD DATA FROM MASTER} ``auto-magically'' sets up a slave.
@item
A new @code{HANDLER} interface to @code{MyISAM} tables.
@item
@code{COUNT(DISTINCT)} is about 30% faster.
@item
-Creating full text indexes are now much faster.
+@code{FULLTEXT} index creation now is much faster.
@item
-Searching on packed (@code{CHAR}/@code{VARCHAR}) keys are now much faster.
+Searching on packed (@code{CHAR}/@code{VARCHAR}) keys now is much faster.
@item
Added @code{SQL_CALC_FOUND_ROWS} and @code{FOUND_ROWS()}. This makes it
possible to know how many rows a query would have returned
@@ -45811,9 +46619,12 @@ Optimized queries of type:
@code{SELECT DISTINCT * from table_name ORDER by key_part1 LIMIT #}
@end itemize
+
@node News-3.23.x, News-3.22.x, News-4.0.x, News
@appendixsec Changes in release 3.23.x (Stable)
+@cindex changes, version 3.23
+
The 3.23 release has several major features that are not
present in previous versions. We have added three new
table types:
@@ -45842,7 +46653,7 @@ The replication code and BerkeleyDB code is still not as tested and as
the rest of the code, so we will probably need to do a couple of future
releases of 3.23 with small fixes for this part of the code. As long as
you don't use these features, you should be quite safe with
-@strong{MySQL} 3.23!
+MySQL 3.23!
Note that the above doesn't mean that replication or Berkeley DB don't
work; We have done a lot of testing of all code, including replication
@@ -45851,6 +46662,8 @@ users use this code as the rest of the code and because of this we are
not yet 100% confident in this code.
@menu
+* News-3.23.42:: Changes in release 3.23.42
+* News-3.23.41:: Changes in release 3.23.41
* News-3.23.40:: Changes in release 3.23.40
* News-3.23.39:: Changes in release 3.23.39
* News-3.23.38:: Changes in release 3.23.38
@@ -45895,31 +46708,124 @@ not yet 100% confident in this code.
* News-3.23.0:: Changes in release 3.23.0
@end menu
-@node News-3.23.40, News-3.23.39, News-3.23.x, News-3.23.x
-@appendixsubsec Changes in release 3.23.40
+@node News-3.23.42, News-3.23.41, News-3.23.x, News-3.23.x
+@appendixsubsec Changes in release 3.23.42
@itemize @bullet
@item
-Added option @code{--warnings} to @code{mysqld}. Now @code{mysqld}
-only prints the error @code{Aborted connection} if this option is used.
+Fixed rare hang when doing @code{mysqladmin shutdown} when there was
+a lot of activity in other threads.
+@item
+Fixed problem with @code{INSERT DELAYED} where delay thread could be
+hanging on @code{upgrading locks} without any apparent reasons.
+@item
+Fixed problem with @code{myisampack} and @code{BLOB}.
+@item
+Fixes problem when one edited @code{.MRG} tables by hand.
+(Patch from Benjamin Pflugmann).
+@item
+Enforce that all tables in a @code{MERGE} table come from the same
+database.
+@item
+Fixed bug with @code{LOAD DATA INFILE} and transactional tables.
+@item
+Fix bug when using @code{INSERT DELAYED} with wrong column definition.
+@item
+Fixed coredump during @code{REPAIR} of some particularly broken tables.
+@item
+Fixed bug in @code{InnoDB} and @code{AUTO_INCREMENT} columns.
+@item
+Fixed critical bug in @code{InnoDB} and @code{BLOB} columns. If one has
+used @code{BLOB} columns larger than 8K in an @code{InnoDB} table, one must
+dump the table with @code{mysqldump}, drop it and restore it from the dump.
+@item
+Applied large patch for OS/2 from Yuri Dario.
+@item
+Fixed problem with @code{InnoDB} when one could get the error @code{Can't
+execute the given command...} even when one didn't have an active
+transaction.
+@item
+Applied some minor fixes that concern Gemini.
+@item
+Use real arithmetic operations even in integer context if not
+all arguments are integers. (Fixes uncommon bug in some integer
+contexts).
+@item
+Don't force everything to lower cases on Windows. (To fix problem
+with Windows and @code{ALTER TABLE}). Now @code{--lower_case_names}
+also works on Unix.
+@item
+Fixed that automatic rollback that is done when thread end doesn't lock
+other threads.
+@end itemize
+
+@node News-3.23.41, News-3.23.40, News-3.23.42, News-3.23.x
+@appendixsubsec Changes in release 3.23.41
+
+@itemize @bullet
+@item
+Added option @code{--sql-mode=option[,option[,option]]}.
+@xref{Command-line options}.
+@item
+Fixed possible problem with @code{shutdown} on Solaris where the
+@file{.pid} file wasn't deleted.
+@item
+InnoDB now supports < 4 GB rows. The former limit was 8000 bytes.
+@item
+The @code{doublewrite} file flush method is used in InnoDB.
+It reduces the need for Unix fsync calls to a fraction and
+improves performance on most Unix flavors.
+@item
+You can now use the InnoDB Monitor to print a lot of InnoDB state
+information, including locks, to the standard output; useful in
+performance tuning.
+@item
+Several bugs which could cause hangs in InnoDB have been fixed.
+@item
+Split @code{record_buffer} to @code{record_buffer} and
+@code{record_rnd_buffer}. To make things compatible to previous MySQL
+versions, if @code{record_rnd_buffer} is not set, then it takes the
+value of @code{record_buffer}.
+@item
+Fixed optimizing bug in @code{ORDER BY} where some @code{ORDER BY} parts
+where wrongly removed.
+@item
+Fixed overflow bug with @code{ALTER TABLE} and @code{MERGE} tables.
+@item
+Added prototypes for @code{my_thread_init()} and @code{my_thread_end()} to
+@file{mysql_com.h}
+@item
+Added option @code{--safe-user-create} to @code{mysqld}.
+@item
+Fixed bug in @code{SELECT DISTINCT ... HAVING} that casued error message
+@code{Can't find record in '#...}
+@end itemize
+
+
+@node News-3.23.40, News-3.23.39, News-3.23.41, News-3.23.x
+@appendixsubsec Changes in release 3.23.40
+
+@itemize @bullet
@item
Fixed problem with @code{--low-priority-updates} and @code{INSERT}'s.
@item
Fixed bug in slave thread when under some rare circumstances it could
-get 22 bytes ahead on the offset in the master
+get 22 bytes ahead on the offset in the master.
@item
Added @code{slave_wait_timeout} for replication.
@item
-Fixed problem with @code{UPDATE} and BDB tables.
+Fixed problem with @code{UPDATE} and @code{BDB} tables.
@item
-Fixed hard bug in BDB tables when using key parts.
+Fixed hard bug in @code{BDB} tables when using key parts.
@item
Fixed problem when using the @code{GRANT FILE ON database.* ...}; Previously
we added the @code{DROP} privilege for the database.
@item
-Fixed that @code{DELETE FROM table_name ... LIMIT 0} and
-@code{UPDATE FROM table_name ... LIMIT 0} doesn't delete/update anything.
+Fixed @code{DELETE FROM table_name ... LIMIT 0} and
+@code{UPDATE FROM table_name ... LIMIT 0} acted as though the @code{LIMIT}
+clause was not present (they deleted or updated all selected rows).
@item
-@code{CHECK TABLE} now checks if an auto_increment column contains the value 0.
+@code{CHECK TABLE} now checks if an @code{AUTO_INCREMENT} column contains
+the value 0.
@item
Sending a @code{SIGHUP} to @code{mysqld} will now only flush the logs,
not reset the replication.
@@ -45934,11 +46840,11 @@ only prints the error @code{Aborted connection} if this option is used.
Fixed problem with @code{SHOW CREATE TABLE} when you didn't have a
@code{PRIMARY KEY}.
@item
-Fixed properly the rename of @code{innodb_unix_file_flush_method} to
+Properly fixed the rename of @code{innodb_unix_file_flush_method} to
@code{innodb_flush_method}.
@item
Fixed bug when converting @code{UNSIGNED BIGINT} to @code{DOUBLE}. This caused
-a problem when doing comparisons with @code{BIGINT}'s outside of the
+a problem when doing comparisons with @code{BIGINT} values outside of the
signed range.
@item
Fixed bug in @code{BDB} tables when querying empty tables.
@@ -45950,8 +46856,10 @@ Removed all documentation referring to the @code{GEMINI} table
type. @code{GEMINI} is not released under an Open Source license.
@end itemize
+
@node News-3.23.39, News-3.23.38, News-3.23.40, News-3.23.x
@appendixsubsec Changes in release 3.23.39
+
@itemize @bullet
@item
The @code{AUTO_INCREMENT} sequence wasn't reset when dropping
@@ -45973,7 +46881,7 @@ that only had the open count wrong.
Added functions to handle symbolic links to make life easier in 4.0.
@item
We are now using the @code{-lcma} thread library on HP-UX 10.20 so
-that @strong{MySQL} will be more stable on HP-UX.
+that MySQL will be more stable on HP-UX.
@item
Fixed problem with @code{IF()} and number of decimals in the result.
@item
@@ -45991,8 +46899,10 @@ Fixed problem with @code{MERGE} tables and big tables (> 4G) when using
@code{ORDER BY}.
@end itemize
+
@node News-3.23.38, News-3.23.37, News-3.23.39, News-3.23.x
@appendixsubsec Changes in release 3.23.38
+
@itemize @bullet
@item
Fixed a bug when @code{SELECT} from @code{MERGE} table
@@ -46041,8 +46951,10 @@ when @code{to_table} was empty.
Fixed bug with @code{LOCK TABLE} and BDB tables.
@end itemize
+
@node News-3.23.37, News-3.23.36, News-3.23.38, News-3.23.x
@appendixsubsec Changes in release 3.23.37
+
@itemize @bullet
@item
Fixed a bug when using @code{MATCH} in @code{HAVING} clause.
@@ -46105,8 +47017,10 @@ fixed with @code{myisamchk -r} or @code{REPAIR TABLE} !
Added @code{--skip-safemalloc} option to @code{mysqld}.
@end itemize
+
@node News-3.23.36, News-3.23.35, News-3.23.37, News-3.23.x
@appendixsubsec Changes in release 3.23.36
+
@itemize @bullet
@item
Fixed a bug that allowed you to use database names containing a @samp{.}
@@ -46144,8 +47058,10 @@ allow concurrent inserts as this could make the binary log hard to repeat.
Changed some macros to be able to use fast mutex with glibc 2.2.
@end itemize
+
@node News-3.23.35, News-3.23.34a, News-3.23.36, News-3.23.x
@appendixsubsec Changes in release 3.23.35
+
@itemize @bullet
@item
Fixed newly introduced bug in @code{ORDER BY}.
@@ -46161,20 +47077,24 @@ Tuned @code{SHOW ANALYZE} for small tables.
Fixed handling of arguments in the benchmark script @file{run-all-tests}.
@end itemize
+
@node News-3.23.34a, News-3.23.34, News-3.23.35, News-3.23.x
@appendixsubsec Changes in release 3.23.34a
+
@itemize @bullet
@item
Added extra files to the distribution to allow @code{INNOBASE} support
to be compiled.
@end itemize
+
@node News-3.23.34, News-3.23.33, News-3.23.34a, News-3.23.x
@appendixsubsec Changes in release 3.23.34
+
@itemize @bullet
@item
Added the @code{INNOBASE} table handler and the @code{BDB} table handler
-to the @strong{MySQL} source distribution.
+to the MySQL source distribution.
@item
Updated the documentation about @code{GEMINI} tables.
@item
@@ -46242,8 +47162,10 @@ Fixed a deadlock in the @code{SET} code, when one ran @code{SET @@foo=bar},
where @code{bar} is a column reference, an error was not properly generated.
@end itemize
+
@node News-3.23.33, News-3.23.32, News-3.23.34, News-3.23.x
@appendixsubsec Changes in release 3.23.33
+
@itemize @bullet
@item
Fixed that DNS lookups are not using the same mutex as the hostname
@@ -46331,8 +47253,10 @@ memory, as it's being allocated to the directory entry cache instead of
the disk cache.
@end itemize
+
@node News-3.23.32, News-3.23.31, News-3.23.33, News-3.23.x
@appendixsubsec Changes in release 3.23.32
+
@itemize @bullet
@item
Changed code to get around compiler bug in Compaq C++ on OSF1, that broke
@@ -46371,8 +47295,10 @@ Fixed a bug which caused a core dump on the slave when replicating
Added @code{MASTER_POS_WAIT()}.
@end itemize
+
@node News-3.23.31, News-3.23.30, News-3.23.32, News-3.23.x
@appendixsubsec Changes in release 3.23.31
+
@itemize @bullet
@item
The test suite now tests all reachable BDB interface code. During
@@ -46381,7 +47307,7 @@ testing we found and fixed many errors in the interface code.
Using @code{HAVING} on an empty table could produce one result row when
it shouldn't.
@item
-Fixed that the @strong{MySQL} RPM is not dependent on Perl5 anymore.
+Fixed that the MySQL RPM is not dependent on Perl5 anymore.
@item
Fixed some problems with @code{HEAP} tables on Windows.
@item
@@ -46398,7 +47324,7 @@ Fixed problem when using @code{DECIMAL()} keys on negative numbers.
always returned @code{NULL}.
@item
Fixed security bug in something (please upgrade if you are using a earlier
-@strong{MySQL} 3.23 version).
+MySQL 3.23 version).
@item
Fixed buffer overflow bug when writing a certain error message.
@item
@@ -46425,8 +47351,10 @@ Fixed @code{safe_mysqld} and @code{mysql.server} to also read the
Added @code{Threads_created} status variable to @code{mysqld}.
@end itemize
+
@node News-3.23.30, News-3.23.29, News-3.23.31, News-3.23.x
@appendixsubsec Changes in release 3.23.30
+
@itemize @bullet
@item
Added @code{SHOW OPEN TABLES} command.
@@ -46486,8 +47414,10 @@ name @code{UNOPENED} in error messages.
Fixed bug when running two simultaneous @code{SHOW LOGS} queries.
@end itemize
+
@node News-3.23.29, News-3.23.28, News-3.23.30, News-3.23.x
@appendixsubsec Changes in release 3.23.29
+
@itemize @bullet
@item
Configure updates for Tru64, large file support, and better TCP wrapper
@@ -46509,7 +47439,7 @@ When creating a table, put @code{PRIMARY} keys first, followed by
@item
Fixed a bug in @code{UPDATE} involving multi-part keys where one
specified all key parts both in the update and the @code{WHERE} part. In
-this case @strong{MySQL} could try to update a record that didn't match
+this case MySQL could try to update a record that didn't match
the whole @code{WHERE} part.
@item
Changed drop table to first drop the tables and then the @file{.frm} file.
@@ -46599,7 +47529,7 @@ Changed @code{mi_create()} to use less stack space.
Fixed bug with optimizer trying to over-optimize @code{MATCH} when used
with @code{UNIQUE} key.
@item
-Changed @code{crash-me} and the @strong{MySQL} benchmarks to also work
+Changed @code{crash-me} and the MySQL benchmarks to also work
with FrontBase.
@item
Allow @code{RESTRICT} and @code{CASCADE} after @code{DROP TABLE} to make
@@ -46613,8 +47543,10 @@ Added @code{connect_timeout} as an alias for @code{timeout} for option files
read by @code{mysql_options()}.
@end itemize
+
@node News-3.23.28, News-3.23.27, News-3.23.29, News-3.23.x
@appendixsubsec Changes in release 3.23.28
+
@itemize @bullet
@item
Added new options @code{--pager[=...]}, @code{--no-pager},
@@ -46733,8 +47665,10 @@ set it to 0 instead of 4 and hit the magic number in the master binlog.
new table with the rows in a specific order.
@end itemize
+
@node News-3.23.27, News-3.23.26, News-3.23.28, News-3.23.x
@appendixsubsec Changes in release 3.23.27
+
@itemize @bullet
@item
Fixed a bug where the automatic repair of MyISAM tables sometimes failed
@@ -46751,8 +47685,10 @@ Added the latin5 (turkish) character set.
Small portability fixes.
@end itemize
+
@node News-3.23.26, News-3.23.25, News-3.23.27, News-3.23.x
@appendixsubsec Changes in release 3.23.26
+
@itemize @bullet
@item
Fixed @code{<>} to work properly with @code{NULL}.
@@ -46812,7 +47748,7 @@ Allow floating-point numbers where there is no sign after the exponent
@item
@code{SHOW GRANTS} didn't always show all column grants.
@item
-Added @code{--default-extra-file=#} to all @strong{MySQL} clients.
+Added @code{--default-extra-file=#} to all MySQL clients.
@item
Columns referenced in @code{INSERT} statements now are initialized properly.
@item
@@ -46825,8 +47761,10 @@ Changed to use @code{mkstemp()} instead of @code{tempnam()}. Based
on a patch from John Jones.
@end itemize
+
@node News-3.23.25, News-3.23.24, News-3.23.26, News-3.23.x
@appendixsubsec Changes in release 3.23.25
+
@itemize @bullet
@item
Fixed that @code{databasename} works as second argument to @code{mysqlhotcopy}.
@@ -46872,7 +47810,7 @@ The slave now logs when it connects to the master.
Fixed a core dump bug when doing @code{FLUSH MASTER} if you didn't specify
a filename argument to @code{--log-bin}.
@item
-Added missing @file{ha_berkeley.x} files to the @strong{MySQL} Windows
+Added missing @file{ha_berkeley.x} files to the MySQL Windows
@item
Fixed some mutex bugs in the log code that could cause thread blocks if new
log files couldn't be created.
@@ -46913,17 +47851,19 @@ Fixed @code{CHECK TABLE} to work on Windows.
Added file mutexes to make @code{pwrite()} safe on Windows.
@end itemize
+
@node News-3.23.24, News-3.23.23, News-3.23.25, News-3.23.x
@appendixsubsec Changes in release 3.23.24
+
@itemize @bullet
@item
Added @code{mysqld} variable @code{created_tmp_disk_tables}.
@item
To make it possible to reliably dump and restore tables with
-@code{TIMESTAMP(X)} columns, @strong{MySQL} now reports columns with @code{X}
+@code{TIMESTAMP(X)} columns, MySQL now reports columns with @code{X}
other than 14 or 8 to be strings.
@item
-Changed sort order for latin1 as it was before @strong{MySQL} Version 3.23.23.
+Changed sort order for latin1 as it was before MySQL Version 3.23.23.
Any table with @code{CHAR} columns that may have characters with ASCII
values greater than 128 that was created or modified with 3.23.22 must
be repaired!
@@ -46936,8 +47876,10 @@ Fixed problem with BDB tables and reading on a unique (not primary) key.
Restored the win1251 character set (it's now only marked deprecated).
@end itemize
+
@node News-3.23.23, News-3.23.22, News-3.23.24, News-3.23.x
@appendixsubsec Changes in release 3.23.23
+
@itemize @bullet
@item
Changed sort order for 'German'; All tables created with 'German' sortorder
@@ -46946,7 +47888,7 @@ must be repaired with @code{REPAIR TABLE} or @code{myisamchk} before use!
Added option @code{--core-file} to @code{mysqld} to get a core file on
Linux if @code{mysqld} dies on the SIGSEGV signal.
@item
-@strong{MySQL} client @code{mysql} now starts with option
+MySQL client @code{mysql} now starts with option
@code{--no-named-commands} (@code{-g}) by default. This option can be
disabled with @code{--enable-named-commands} (@code{-G}). This may cause
incompatibility problems in some cases, for example, in SQL scripts that
@@ -47044,11 +47986,13 @@ Full text search via the @code{MATCH} function and @code{FULLTEXT} index type.
(For MyISAM files). This makes @code{FULLTEXT} a reserved word.
@end itemize
+
@node News-3.23.22, News-3.23.21, News-3.23.23, News-3.23.x
@appendixsubsec Changes in release 3.23.22
+
@itemize @bullet
@item
-Fixed that @code{lex_hash.h} is created properly for each @strong{MySQL}
+Fixed that @code{lex_hash.h} is created properly for each MySQL
distribution.
@item
Fixed that @code{MASTER} and @code{COLLECTION} are not reserved words.
@@ -47086,12 +48030,14 @@ get bigger than 64M.
Added @code{SHOW MASTER STATUS} and @code{SHOW SLAVE STATUS}.
@end itemize
+
@node News-3.23.21, News-3.23.20, News-3.23.22, News-3.23.x
@appendixsubsec Changes in release 3.23.21
+
@itemize @bullet
@item
Added @code{mysql_character_set_name(MYSQL *mysql)} function to the
-@strong{MySQL} C API.
+MySQL C API.
@item
Made the update log @code{ASCII 0} safe.
@item
@@ -47128,8 +48074,10 @@ a feature.
@code{MATCH} and @code{AGAINST} are now reserved words.
@end itemize
+
@node News-3.23.20, News-3.23.19, News-3.23.21, News-3.23.x
@appendixsubsec Changes in release 3.23.20
+
@itemize @bullet
@item
Fixed bug in 3.23.19; @code{DELETE FROM tbl_name} removed the .frm file.
@@ -47137,8 +48085,10 @@ Fixed bug in 3.23.19; @code{DELETE FROM tbl_name} removed the .frm file.
Added @code{SHOW CREATE TABLE}.
@end itemize
+
@node News-3.23.19, News-3.23.18, News-3.23.20, News-3.23.x
@appendixsubsec Changes in release 3.23.19
+
@itemize @bullet
@item
Changed copyright for all files to GPL for the server code and utilities and
@@ -47148,9 +48098,9 @@ Fixed bug where all rows matching weren't updated on a @code{MyISAM} table
when doing update based on key on a table with many keys and some key changed
values.
@item
-The Linux @strong{MySQL} RPM's and binaries are now statically linked with
+The Linux MySQL RPM's and binaries are now statically linked with
a linuxthread version that has faster mutex handling when used with
-@strong{MySQL}.
+MySQL.
@item
@code{ORDER BY} can now uses @code{REF} keys to find subset the rows
that needs to be sorted.
@@ -47166,7 +48116,7 @@ parameters to @code{mysqld}.
Fixed bug that destroyed index when doing @code{myisamchk --sort-records}
on a table with prefix compressed index.
@item
-Added pack_isam and myisampack to the standard @strong{MySQL} distribution.
+Added pack_isam and myisampack to the standard MySQL distribution.
@item
Added the syntax @code{BEGIN WORK} (the same as @code{BEGIN}).
@item
@@ -47176,14 +48126,16 @@ Fixed core dump bug when using @code{ORDER BY} on a @code{CONV()} expression.
@item Fixed big/little endian problem in the replication
@end itemize
+
@node News-3.23.18, News-3.23.17, News-3.23.19, News-3.23.x
@appendixsubsec Changes in release 3.23.18
+
@itemize @bullet
@item
Fixed a problem from 3.23.17 when choosing character set on the client side.
@item
Added @code{FLUSH TABLES WITH READ LOCK} to make a global lock suitable to
-make a copy of @strong{MySQL} data files.
+make a copy of MySQL data files.
@item
@code{CREATE TABLE ... SELECT ... PROCEDURE} now works.
@item
@@ -47196,8 +48148,10 @@ Fixed a problem when locking the same table with both a @code{READ} and a
Fixed problem with myisamchk and @code{RAID} tables.
@end itemize
+
@node News-3.23.17, News-3.23.16, News-3.23.18, News-3.23.x
@appendixsubsec Changes in release 3.23.17
+
@itemize @bullet
@item
Fixed a bug in @code{find_in_set()} when the first argument was @code{NULL}.
@@ -47253,15 +48207,17 @@ Fixed a race condition in @code{INSERT DELAYED} code when doing
Added deadlock detection sanity checks to @code{INSERT DELAYED}
@end itemize
+
@node News-3.23.16, News-3.23.15, News-3.23.17, News-3.23.x
@appendixsubsec Changes in release 3.23.16
+
@itemize @bullet
@item
Added option @code{TYPE=QUICK} to @code{CHECK} and @code{REPAIR}.
@item
Fixed bug in @code{REPAIR TABLE} when the table was in use by other threads.
@item
-Added a thread cache to make it possible to debug @strong{MySQL} with
+Added a thread cache to make it possible to debug MySQL with
@code{gdb} when one does a lot of reconnects. This will also improve
systems where you can't use persistent connections.
@item
@@ -47282,8 +48238,10 @@ restrict which databases get replicated
Added @code{SQL_LOG_BIN} option
@end itemize
+
@node News-3.23.15, News-3.23.14, News-3.23.16, News-3.23.x
@appendixsubsec Changes in release 3.23.15
+
@itemize @bullet
@item
To start @code{mysqld} as @code{root}, you must now use the @code{--user=root} option.
@@ -47318,7 +48276,7 @@ Fixed bug in locking code that could result it locking problems with
concurrent inserts under high load.
@item
Fixed a problem with @code{DELETE} of many rows on a table with
-compressed keys where @strong{MySQL} scanned the index to find the rows.
+compressed keys where MySQL scanned the index to find the rows.
@item
Fixed problem with @code{CHECK} on table with deleted keyblocks.
@item
@@ -47335,7 +48293,7 @@ Fixed bug when using @code{LOAD DATA INFILE} on a table with
@item
Optimised MyISAM to be faster when inserting keys in sorted order.
@item
-@code{EXPLAIN SELECT ...} now also prints out whether @strong{MySQL} needs to
+@code{EXPLAIN SELECT ...} now also prints out whether MySQL needs to
create a temporary table or use file sorting when resolving the @code{SELECT}.
@item
Added optimization to skip @code{ORDER BY} parts where the part is a
@@ -47352,8 +48310,10 @@ Changed @code{RAID_CHUNKSIZE} to be in 1024 byte increments.
Fixed coredump in LOAD_FILE(NULL).
@end itemize
+
@node News-3.23.14, News-3.23.13, News-3.23.15, News-3.23.x
@appendixsubsec Changes in release 3.23.14
+
@itemize @bullet
@item
Fixed a bug in @code{CONCAT()} where one of the arguments was a function
@@ -47398,8 +48358,10 @@ When running in ANSI mode, don't allow columns to be used that aren't in
the @code{GROUP BY} part.
@end itemize
+
@node News-3.23.13, News-3.23.12, News-3.23.14, News-3.23.x
@appendixsubsec Changes in release 3.23.13
+
@itemize @bullet
@item
Fixed problem when doing locks on the same table more than 2 times in
@@ -47424,8 +48386,10 @@ Added @code{print_defaults} to the @file{.rpm} files. Removed @code{mysqlbug}
from the client @file{.rpm} file.
@end itemize
+
@node News-3.23.12, News-3.23.11, News-3.23.13, News-3.23.x
@appendixsubsec Changes in release 3.23.12
+
@itemize @bullet
@item
Fixed bug in @code{MyISAM} involving @code{REPLACE ... SELECT ...} which could
@@ -47433,7 +48397,7 @@ give a corrupted table.
@item
Fixed bug in @code{myisamchk} where it wrongly reset the auto_increment value.
@item
-LOTS of patches for Linux Alpha. @strong{MySQL} now appears to be relatively
+LOTS of patches for Linux Alpha. MySQL now appears to be relatively
stable on Alpha.
@item
Changed @code{DISTINCT} on @code{HEAP} temporary tables to use hashed
@@ -47442,7 +48406,7 @@ type @code{SELECT DISTINCT ... GROUP BY ...}. This fixes a problem where
not all duplicates were removed in queries of the above type. In
addition, the new code is MUCH faster.
@item
-Added patches to make @strong{MySQL} compile on Mac OS X.
+Added patches to make MySQL compile on Mac OS X.
@item
Added option @code{IF NOT EXISTS} to @code{CREATE DATABASE}.
@item
@@ -47463,7 +48427,7 @@ Fixed that @code{myisamchk} works properly with RAID:ed tables.
Fixed problem with @code{LEFT JOIN} and @code{key_field IS NULL}.
@item
Fixed bug in @code{net_clear()} which could give the error @code{Aborted
-connection} in the @strong{MySQL} clients.
+connection} in the MySQL clients.
@item
Added options @code{USE INDEX (key_list)} and @code{IGNORE INDEX (key_list)} as
join parameters in @code{SELECT}.
@@ -47471,8 +48435,10 @@ join parameters in @code{SELECT}.
@code{DELETE} and @code{RENAME} should now work on @code{RAID} tables.
@end itemize
+
@node News-3.23.11, News-3.23.10, News-3.23.12, News-3.23.x
@appendixsubsec Changes in release 3.23.11
+
@itemize @bullet
@item
Allow the @code{ALTER TABLE tbl_name ADD (field_list)} syntax.
@@ -47491,7 +48457,7 @@ Fix problem with timezones that have half hour offsets.
Allow the syntax @code{UNIQUE INDEX} in @code{CREATE} statements.
@item
@code{mysqlhotcopy} - fast on-line hot-backup utility for local
-@strong{MySQL} databases. By Tim Bunce.
+MySQL databases. By Tim Bunce.
@item
New more secure @code{mysqlaccess}. Thanks to Steve Harvey for this.
@item
@@ -47518,16 +48484,20 @@ Added back blocking of @code{SIGPIPE} when compiling with @code{--thread-safe-cl
to make things safe for old clients.
@end itemize
+
@node News-3.23.10, News-3.23.9, News-3.23.11, News-3.23.x
@appendixsubsec Changes in release 3.23.10
+
@itemize @bullet
@item
Fixed bug in 3.23.9 where memory wasn't properly freed when doing
@code{LOCK TABLES}.
@end itemize
+
@node News-3.23.9, News-3.23.8, News-3.23.10, News-3.23.x
@appendixsubsec Changes in release 3.23.9
+
@itemize @bullet
@item
Fixed problem that affected queries that did arithmetic on group functions.
@@ -47554,7 +48524,7 @@ Added VIO wrapper (needed for SSL support ; By Andrei Errapart and
Tõnu Samuel).
@item
Fixed optimizer problem on @code{SELECT} when using many overlapping indexes.
-@strong{MySQL} should now be able to choose keys even better when there
+MySQL should now be able to choose keys even better when there
is many keys to choose from.
@item
Changed optimizer to prefer a range key instead of a ref key when the
@@ -47587,8 +48557,10 @@ when @code{key_column} could contain @code{NULL} values.
Fixed problem with 8-bit characters as separators in @code{LOAD DATA INFILE}.
@end itemize
+
@node News-3.23.8, News-3.23.7, News-3.23.9, News-3.23.x
@appendixsubsec Changes in release 3.23.8
+
@itemize @bullet
@item
Fixed problem when handling indexfiles larger than 8G.
@@ -47618,15 +48590,17 @@ Fixed problem with @code{BLOB NULL} keys and @code{LIKE} "prefix%".
@item
Fixed problem with @code{MyISAM} and fixed-length rows < 5 bytes.
@item
-Fixed problem that could cause @strong{MySQL} to touch freed memory when
+Fixed problem that could cause MySQL to touch freed memory when
doing very complicated @code{GROUP BY} queries.
@item
Fixed core dump if you got a crashed table where an @code{ENUM} field value
was too big.
@end itemize
+
@node News-3.23.7, News-3.23.6, News-3.23.8, News-3.23.x
@appendixsubsec Changes in release 3.23.7
+
@itemize @bullet
@item
Fixed workaround under Linux to avoid problems with @code{pthread_mutex_timedwait},
@@ -47680,6 +48654,7 @@ Changed the argument to @code{mysql_data_seek()} from @code{ulong} to
@code{ulonglong}.
@end itemize
+
@node News-3.23.6, News-3.23.5, News-3.23.7, News-3.23.x
@appendixsubsec Changes in release 3.23.6
@@ -47735,6 +48710,7 @@ Changed function @code{CHAR_LENGTH()} to be multi-byte character safe.
Added function @code{ORD(string)}.
@end itemize
+
@node News-3.23.5, News-3.23.4, News-3.23.6, News-3.23.x
@appendixsubsec Changes in release 3.23.5
@@ -47794,6 +48770,7 @@ Added bit operator @code{~} (negation).
Fixed problem with @code{UDF} functions.
@end itemize
+
@node News-3.23.4, News-3.23.3, News-3.23.5, News-3.23.x
@appendixsubsec Changes in release 3.23.4
@@ -47830,6 +48807,7 @@ Some configure issues to fix problems with big file system detection.
@code{REGEXP} is now case insensitive if you use non-binary strings.
@end itemize
+
@node News-3.23.3, News-3.23.2, News-3.23.4, News-3.23.x
@appendixsubsec Changes in release 3.23.3
@@ -47871,6 +48849,7 @@ Added @code{CASE} construct.
New function @code{COALESCE()}.
@end itemize
+
@node News-3.23.2, News-3.23.1, News-3.23.3, News-3.23.x
@appendixsubsec Changes in release 3.23.2
@@ -47937,6 +48916,7 @@ New functions @code{EXPORT_SET()} and @code{MD5()}.
Support for the GB2312 Chinese character set.
@end itemize
+
@node News-3.23.1, News-3.23.0, News-3.23.2, News-3.23.x
@appendixsubsec Changes in release 3.23.1
@@ -47945,6 +48925,7 @@ Support for the GB2312 Chinese character set.
Fixed some compilation problems.
@end itemize
+
@node News-3.23.0, , News-3.23.1, News-3.23.x
@appendixsubsec Changes in release 3.23.0
@@ -48018,7 +48999,7 @@ Check if a row has changed in an @code{UPDATE} now also works with
Added the @code{INNER} join syntax. @strong{NOTE}: This made @code{INNER}
a reserved word!
@item
-Added support for netmasks to the hostname in the @strong{MySQL} tables.
+Added support for netmasks to the hostname in the MySQL tables.
You can specify a netmask using the @code{IP/NETMASK} syntax.
@item
If you compare a @code{NOT NULL DATE/DATETIME} column with @code{IS
@@ -48059,7 +49040,7 @@ Added aggregate UDF functions. Thanks to Andreas F. Bobak
Some small changes to the join table optimizer to make some joins faster.
@item
@code{SELECT DISTINCT} is much faster; It uses the new @code{UNIQUE}
-functionality in @code{MyISAM}. One difference compared to @strong{MySQL} Version 3.22
+functionality in @code{MyISAM}. One difference compared to MySQL Version 3.22
is that the output of @code{DISTINCT} is not sorted anymore.
@item
All C client API macros are now functions to make shared libraries more
@@ -48091,9 +49072,12 @@ New @code{CREATE TABLE} options: @code{PACK_KEYS} and @code{CHECKSUM}.
Added @code{mysqld} option @code{--default-table-type}.
@end itemize
+
@node News-3.22.x, News-3.21.x, News-3.23.x, News
@appendixsec Changes in release 3.22.x (Older; Still supported)
+@cindex changes, version 3.22
+
The 3.22 version has faster and safer connect code than version 3.21, as well
as a lot of new nice enhancements. The reason for not including these changes
As there aren't really any MAJOR changes, upgrading from 3.21 to 3.22 should
@@ -48138,8 +49122,10 @@ be very easy and painless. @xref{Upgrading-from-3.21}.
* News-3.22.0:: Changes in release 3.22.0
@end menu
+
@node News-3.22.35, News-3.22.34, News-3.22.x, News-3.22.x
@appendixsubsec Changes in release 3.22.35
+
@itemize @bullet
@item
Fixed problem with @code{STD()}.
@@ -48152,8 +49138,10 @@ Fixed a bug core dump when using a @code{LEFT JOIN}/@code{STRAIGHT_JOIN}
on a table with only one row.
@end itemize
+
@node News-3.22.34, News-3.22.33, News-3.22.35, News-3.22.x
@appendixsubsec Changes in release 3.22.34
+
@itemize @bullet
@item
Fixed problem with @code{GROUP BY} on @code{TINYBLOB} columns; This
@@ -48163,8 +49151,10 @@ Had to do total recompile of the Windows binary version as VC++ didn't
compile all relevant files for 3.22.33 :(
@end itemize
+
@node News-3.22.33, News-3.22.32, News-3.22.34, News-3.22.x
@appendixsubsec Changes in release 3.22.33
+
@itemize @bullet
@item
Fixed problems in Windows when locking tables with @code{LOCK TABLE}
@@ -48172,15 +49162,17 @@ Fixed problems in Windows when locking tables with @code{LOCK TABLE}
Quicker kill of @code{SELECT DISTINCT} queries.
@end itemize
+
@node News-3.22.32, News-3.22.31, News-3.22.33, News-3.22.x
@appendixsubsec Changes in release 3.22.32
+
@itemize @bullet
@item
Fixed problem when storing numbers in timestamps.
@item
Fix problem with timezones that have half hour offsets.
@item
-@code{mysqlhotcopy} - fast on-line hot-backup utility for local @strong{MySQL}
+@code{mysqlhotcopy} - fast on-line hot-backup utility for local MySQL
databases. By Tim Bunce.
@item
New more secure @code{mysqlaccess}. Thanks to Steve Harvey for this.
@@ -48193,6 +49185,7 @@ Fixed a bug in the @code{ISAM} code when deleting rows on tables with
packed indexes.
@end itemize
+
@node News-3.22.31, News-3.22.30, News-3.22.32, News-3.22.x
@appendixsubsec Changes in release 3.22.31
@@ -48219,6 +49212,7 @@ Fixed critical problem with the @code{WITH GRANT OPTION} option.
Fixed non-critical Y2K problem when writing short date to log files.
@end itemize
+
@node News-3.22.29, News-3.22.28, News-3.22.30, News-3.22.x
@appendixsubsec Changes in release 3.22.29
@@ -48233,7 +49227,7 @@ Fixed problem with timezones that are < GMT -11.
@item
Fixed a bug when deleting packed keys in NISAM.
@item
-Fixed problem that could cause @strong{MySQL} to touch freed memory when
+Fixed problem that could cause MySQL to touch freed memory when
doing very complicated @code{GROUP BY} queries.
@item
Fixed core dump if you got a crashed table where an @code{ENUM} field value
@@ -48245,9 +49239,9 @@ distribution.
Fixed problem when doing @code{ORDER BY} on a reference key.
@item
Fixed that @code{INSERT DELAYED} doesn't update timestamps that are given.
-
@end itemize
+
@node News-3.22.28, News-3.22.27, News-3.22.29, News-3.22.x
@appendixsubsec Changes in release 3.22.28
@@ -48261,6 +49255,7 @@ Fixed core dump problem when using @code{CONCAT()} in a @code{WHERE} clause.
Fixed problem with @code{AVG()} and @code{STD()} with @code{NULL} values.
@end itemize
+
@node News-3.22.27, News-3.22.26, News-3.22.28, News-3.22.x
@appendixsubsec Changes in release 3.22.27
@@ -48275,6 +49270,7 @@ Fixed problem when sorting on big blob columns.
@code{ROUND()} will now work on Windows.
@end itemize
+
@node News-3.22.26, News-3.22.25, News-3.22.27, News-3.22.x
@appendixsubsec Changes in release 3.22.26
@@ -48302,6 +49298,7 @@ Fixed range optimizer bug in
Fixed bug in compression key handling in ISAM.
@end itemize
+
@node News-3.22.25, News-3.22.24, News-3.22.26, News-3.22.x
@appendixsubsec Changes in release 3.22.25
@@ -48310,6 +49307,7 @@ Fixed bug in compression key handling in ISAM.
Fixed some small problems with the installation.
@end itemize
+
@node News-3.22.24, News-3.22.23, News-3.22.25, News-3.22.x
@appendixsubsec Changes in release 3.22.24
@@ -48329,6 +49327,7 @@ Changed @file{configure} to not use big file handling on Linux as this
crashes some RedHat 6.0 systems
@end itemize
+
@node News-3.22.23, News-3.22.22, News-3.22.24, News-3.22.x
@appendixsubsec Changes in release 3.22.23
@@ -48341,7 +49340,7 @@ Better support for SCO in @code{configure}.
Added option @code{--defaults-file=###} to option file handling to force use
of only one specific option file.
@item
-Extended @code{CREATE} syntax to ignore @strong{MySQL} Version 3.23 keywords.
+Extended @code{CREATE} syntax to ignore MySQL Version 3.23 keywords.
@item
Fixed deadlock problem when using @code{INSERT DELAYED} on a table locked with
@code{LOCK TABLES}.
@@ -48356,6 +49355,7 @@ Fixed @code{isamchk} to detect a new error condition.
Fixed bug in @code{NATURAL LEFT JOIN}.
@end itemize
+
@node News-3.22.22, News-3.22.21, News-3.22.23, News-3.22.x
@appendixsubsec Changes in release 3.22.22
@@ -48373,14 +49373,15 @@ Fixed bug in @code{CONCAT()} with many arguments.
@item
Added patches for DEC 3.2 and SCO.
@item
-Fixed path-bug when installing @strong{MySQL} as a service on NT.
+Fixed path-bug when installing MySQL as a service on NT.
@item
-The @strong{MySQL}-Windows version is now compiled with VC++ 6.0 instead of
+The MySQL-Windows version is now compiled with VC++ 6.0 instead of
with VC++ 5.0.
@item
-New installation setup for @strong{MySQL}-Windows.
+New installation setup for MySQL-Windows.
@end itemize
+
@node News-3.22.21, News-3.22.20, News-3.22.22, News-3.22.x
@appendixsubsec Changes in release 3.22.21
@@ -48398,13 +49399,14 @@ Changed the @code{mysql.db} column from @code{char(32)} to @code{char(60)}.
Fixed a bug when storing days in a @code{TIME} column.
@item
Fixed a problem with @code{Host '...' is not allowed to connect to this MySQL
-server} after one had inserted a new @strong{MySQL} user with a @code{GRANT}
+server} after one had inserted a new MySQL user with a @code{GRANT}
command.
@item
Changed to use @code{TCP_NODELAY} also on Linux (Should give faster TCP/IP
connections).
@end itemize
+
@node News-3.22.20, News-3.22.19, News-3.22.21, News-3.22.x
@appendixsubsec Changes in release 3.22.20
@@ -48417,6 +49419,7 @@ The update log didn't have newlines on some operating systems.
@code{INSERT DELAYED} had some garbage at end in the update log.
@end itemize
+
@node News-3.22.19, News-3.22.18, News-3.22.20, News-3.22.x
@appendixsubsec Changes in release 3.22.19
@@ -48430,6 +49433,7 @@ Fixed problem with queries that needed temporary tables with @code{BLOB}
columns.
@end itemize
+
@node News-3.22.18, News-3.22.17, News-3.22.19, News-3.22.x
@appendixsubsec Changes in release 3.22.18
@@ -48439,13 +49443,14 @@ Fixes a fatal problem in 3.22.17 on Linux; After @code{shutdown}
all threads didn't die properly.
@item
Added option @code{-O flush_time=#} to @code{mysqld}. This is mostly
-useful on Windows and tells how often @strong{MySQL} should close all
+useful on Windows and tells how often MySQL should close all
unused tables and flush all updated tables to disk.
@item
Fixed problem that a @code{VARCHAR} column compared with @code{CHAR} column
didn't use keys efficiently.
@end itemize
+
@node News-3.22.17, News-3.22.16, News-3.22.18, News-3.22.x
@appendixsubsec Changes in release 3.22.17
@@ -48460,6 +49465,7 @@ Using @code{LEFT JOIN} on tables that had circular dependencies caused
@code{mysqld} to hang forever.
@end itemize
+
@node News-3.22.16, News-3.22.15, News-3.22.17, News-3.22.x
@appendixsubsec Changes in release 3.22.16
@@ -48482,6 +49488,7 @@ platforms, this function is written in optimized assembler.
Added the @code{MODIFY} keyword to @code{ALTER TABLE}.
@end itemize
+
@node News-3.22.15, News-3.22.14, News-3.22.16, News-3.22.x
@appendixsubsec Changes in release 3.22.15
@@ -48522,6 +49529,7 @@ name as an alias.
Added @code{BENCHMARK(loop_count,expression)} function to time expressions.
@end itemize
+
@node News-3.22.14, News-3.22.13, News-3.22.15, News-3.22.x
@appendixsubsec Changes in release 3.22.14
@@ -48546,9 +49554,10 @@ Added escape of @code{^Z} (ASCII 26) to @code{\Z} as @code{^Z} doesn't
work with pipes on Windows.
@item
@code{mysql_fix_privileges} adds a new column to the @code{mysql.func} to
-support aggregate UDF functions in future @strong{MySQL} releases.
+support aggregate UDF functions in future MySQL releases.
@end itemize
+
@node News-3.22.13, News-3.22.12, News-3.22.14, News-3.22.x
@appendixsubsec Changes in release 3.22.13
@@ -48559,13 +49568,14 @@ column didn't work.
@item
@code{SELECT COUNT(*) ... LEFT JOIN ...} didn't work with no @code{WHERE} part.
@item
-Updated @file{config.guess} to allow @strong{MySQL} to configure on
+Updated @file{config.guess} to allow MySQL to configure on
UnixWare 7.0.x.
@item
Changed the implementation of @code{pthread_cond()} on the Windows version.
@code{get_lock()} now correctly times out on Windows!
@end itemize
+
@node News-3.22.12, News-3.22.11, News-3.22.13, News-3.22.x
@appendixsubsec Changes in release 3.22.12
@@ -48603,6 +49613,7 @@ without quotes in the context of the @code{GRANT}, @code{REVOKE} and
Fix for @code{isamchk} for tables which need big temporary files.
@end itemize
+
@node News-3.22.11, News-3.22.10, News-3.22.12, News-3.22.x
@appendixsubsec Changes in release 3.22.11
@@ -48636,7 +49647,7 @@ Configuration and portability fixes.
Added option @code{SET SQL_WARNINGS=1} to get a warning count also for simple
inserts.
@item
-@strong{MySQL} now uses @code{SIGTERM} instead of @code{SIGQUIT} with
+MySQL now uses @code{SIGTERM} instead of @code{SIGQUIT} with
shutdown to work better on FreeBSD.
@item
Added option @code{\G} (print vertically) to @code{mysql}.
@@ -48649,25 +49660,26 @@ work as expected.
New function @code{MAKE_SET()}.
@end itemize
+
@node News-3.22.10, News-3.22.9, News-3.22.11, News-3.22.x
@appendixsubsec Changes in release 3.22.10
@itemize @bullet
@item
-@code{mysql_install_db} no longer starts the @strong{MySQL} server! You
+@code{mysql_install_db} no longer starts the MySQL server! You
should start @code{mysqld} with @code{safe_mysqld} after installing it! The
-@strong{MySQL} RPM will, however, start the server as before.
+MySQL RPM will, however, start the server as before.
@item
Added @code{--bootstrap} option to @code{mysqld} and recoded
@code{mysql_install_db} to use it. This will make it easier to install
-@strong{MySQL} with RPMs.
+MySQL with RPMs.
@item
Changed @code{+}, @code{-} (sign and minus), @code{*}, @code{/}, @code{%},
@code{ABS()} and @code{MOD()} to be @code{BIGINT} aware (64-bit safe).
@item
Fixed a bug in @code{ALTER TABLE} that caused @code{mysqld} to crash.
@item
-@strong{MySQL} now always reports the conflicting key values when a
+MySQL now always reports the conflicting key values when a
duplicate key entry occurs. (Before this was only reported for @code{INSERT}).
@item
New syntax: @code{INSERT INTO tbl_name SET col_name=value, col_name=value, ...}
@@ -48679,7 +49691,7 @@ a query on connect or reconnect.
@item
Added option @code{MYSQL_READ_DEFAULT_FILE} and
@code{MYSQL_READ_DEFAULT_GROUP} to @code{mysql_options()} to read the
-following parameters from the @strong{MySQL} option files: @code{port},
+following parameters from the MySQL option files: @code{port},
@code{socket}, @code{compress}, @code{password}, @code{pipe}, @code{timeout},
@code{user}, @code{init-command}, @code{host} and @code{database}.
@item
@@ -48706,6 +49718,7 @@ Added @code{extended-status} command to @code{mysqladmin} which will show the
new status variables.
@end itemize
+
@node News-3.22.9, News-3.22.8, News-3.22.10, News-3.22.x
@appendixsubsec Changes in release 3.22.9
@@ -48717,7 +49730,7 @@ New SQL command: @code{FLUSH [ TABLES | HOSTS | LOGS | PRIVILEGES ] [, ...]}
@item
New SQL command: @code{KILL} @code{thread_id}.
@item
-Added casts and changed include files to make @strong{MySQL} easier to
+Added casts and changed include files to make MySQL easier to
compile on AIX and DEC OSF1 4.x
@item
Fixed conversion problem when using @code{ALTER TABLE} from a @code{INT}
@@ -48739,6 +49752,7 @@ This will flush all tables to disk after each update. This makes things
much safer on NT/Win98 but also @strong{MUCH} slower.
@end itemize
+
@node News-3.22.8, News-3.22.7, News-3.22.9, News-3.22.x
@appendixsubsec Changes in release 3.22.8
@@ -48762,7 +49776,7 @@ was a key and the rest of the @code{ORDER BY} columns wasn't part of the key.
@item
Fixed a big problem with @code{OPTIMIZE TABLE}.
@item
-@strong{MySQL} clients on NT will now by default first try to connect with
+MySQL clients on NT will now by default first try to connect with
named pipes and after this with TCP/IP.
@item
Fixed a problem with @code{DROP TABLE} and @code{mysqladmin shutdown} on Windows
@@ -48773,12 +49787,13 @@ Fixed problems with @code{TIME columns} and negative strings.
Added an extra thread signal loop on shutdown to avoid some error messages
from the client.
@item
-@strong{MySQL} now uses the next available number as extension for the update
+MySQL now uses the next available number as extension for the update
log file.
@item
Added patches for UNIXWARE 7.
@end itemize
+
@node News-3.22.7, News-3.22.6, News-3.22.8, News-3.22.x
@appendixsubsec Changes in release 3.22.7
@@ -48786,8 +49801,8 @@ Added patches for UNIXWARE 7.
@item
Added @code{LIMIT} clause for the @code{DELETE} statement.
@item
-You can now use the @code{/*! ... */} syntax to hide @strong{MySQL}-specific
-keywords when you write portable code. @strong{MySQL} will parse the code
+You can now use the @code{/*! ... */} syntax to hide MySQL-specific
+keywords when you write portable code. MySQL will parse the code
inside the comments as if the surrounding @code{/*!} and @code{*/} comment
characters didn't exist.
@item
@@ -48825,6 +49840,7 @@ The lexical analyzer now uses ``perfect hashing'' for faster parsing of SQL
statements.
@end itemize
+
@node News-3.22.6, News-3.22.5, News-3.22.7, News-3.22.x
@appendixsubsec Changes in release 3.22.6
@@ -48840,10 +49856,11 @@ Fixed small optimize problem when updating keys.
@item
Changed makefiles to support shared libraries.
@item
-@strong{MySQL}-NT can now use named pipes, which means that you can now use
-@strong{MySQL}-NT without having to install TCP/IP.
+MySQL-NT can now use named pipes, which means that you can now use
+MySQL-NT without having to install TCP/IP.
@end itemize
+
@node News-3.22.5, News-3.22.4, News-3.22.6, News-3.22.x
@appendixsubsec Changes in release 3.22.5
@@ -48863,7 +49880,7 @@ try to use an old error message file.)
All count structures in the client (@code{affected_rows()},
@code{insert_id()}, ...) are now of type @code{BIGINT} to allow 64-bit values
to be used.
-This required a minor change in the @strong{MySQL} protocol which should affect
+This required a minor change in the MySQL protocol which should affect
only old clients when using tables with @code{AUTO_INCREMENT} values > 16M.
@item
The return type of @code{mysql_fetch_lengths()} has changed from @code{uint *}
@@ -48886,7 +49903,7 @@ You can now store values in the range @code{-838:59:59} <= x <=
@code{838:59:59} in a @code{TIME} column.
@item
@strong{WARNING: INCOMPATIBLE CHANGE!!}
-If you set a @code{TIME} column to too short a value, @strong{MySQL} now
+If you set a @code{TIME} column to too short a value, MySQL now
assumes the value is given as: @code{[[[D ]HH:]MM:]SS} instead of
@code{HH[:MM[:SS]]}.
@item
@@ -48951,14 +49968,15 @@ Added @code{--vertical} option to @code{mysql}, for printing results in
vertical mode.
@item
Index-only optimization; some queries are now resolved using
-only indexes. Until @strong{MySQL} 4.0, this works only for numeric columns.
-@xref{MySQL indexes, , @strong{MySQL} indexes}.
+only indexes. Until MySQL 4.0, this works only for numeric columns.
+@xref{MySQL indexes, , MySQL indexes}.
@item
Lots of new benchmarks.
@item
A new C API chapter and lots of other improvements in the manual.
@end itemize
+
@node News-3.22.4, News-3.22.3, News-3.22.5, News-3.22.x
@appendixsubsec Changes in release 3.22.4
@@ -48967,7 +49985,7 @@ A new C API chapter and lots of other improvements in the manual.
Added @code{--tmpdir} option to @code{mysqld}, for specifying the location
of the temporary file directory.
@item
-@strong{MySQL} now automatically changes a query from an ODBC client:
+MySQL now automatically changes a query from an ODBC client:
@example
SELECT ... FROM table WHERE auto_increment_column IS NULL
@end example
@@ -49010,20 +50028,22 @@ Changed name of user-specific configuration file from @file{my.cnf} to
Added @code{DATE_ADD()} and @code{DATE_SUB()} functions.
@end itemize
+
@node News-3.22.3, News-3.22.2, News-3.22.4, News-3.22.x
@appendixsubsec Changes in release 3.22.3
@itemize @bullet
@item
-Fixed a lock problem (bug in @strong{MySQL} Version 3.22.1) when closing temporary tables.
+Fixed a lock problem (bug in MySQL Version 3.22.1) when closing temporary tables.
@item
Added missing @code{mysql_ping()} to the client library.
@item
-Added @code{--compress} option to all @strong{MySQL} clients.
+Added @code{--compress} option to all MySQL clients.
@item
Changed @code{byte} to @code{char} in @file{mysql.h} and @file{mysql_com.h}.
@end itemize
+
@node News-3.22.2, News-3.22.1, News-3.22.3, News-3.22.x
@appendixsubsec Changes in release 3.22.2
@@ -49038,7 +50058,7 @@ You can now save default options (like passwords) in a configuration file
(@file{my.cnf}).
@item
Lots of small changes to get @code{ORDER BY} to work when no records are found
-when using fields that are not in @code{GROUP BY} (@strong{MySQL} extension).
+when using fields that are not in @code{GROUP BY} (MySQL extension).
@item
Added @code{--chroot} option to @code{mysqld}, to start @code{mysqld} in
a chroot environment (by Nikki Chumakov @email{nikkic@@cityline.ru}).
@@ -49063,9 +50083,10 @@ Server error messages are now in @file{mysqld_error.h}.
@item
The server/client protocol now supports compression.
@item
-All bug fixes from @strong{MySQL} Version 3.21.32.
+All bug fixes from MySQL Version 3.21.32.
@end itemize
+
@node News-3.22.1, News-3.22.0, News-3.22.2, News-3.22.x
@appendixsubsec Changes in release 3.22.1
@@ -49094,7 +50115,7 @@ within a row in an existing table.
the week starts on Monday (some European countries). By default,
@code{WEEK()} assumes the week starts on Sunday.
@item
-@code{TIME} columns weren't stored properly (bug in @strong{MySQL} Version 3.22.0).
+@code{TIME} columns weren't stored properly (bug in MySQL Version 3.22.0).
@item
@code{UPDATE} now returns information about how many rows were
matched and updated, and how many ``warnings'' occurred when doing the update.
@@ -49105,6 +50126,7 @@ Fixed incorrect result from @code{FORMAT(-100,2)}.
fashion; changed to be case insensitive.
@end itemize
+
@node News-3.22.0, , News-3.22.1, News-3.22.x
@appendixsubsec Changes in release 3.22.0
@@ -49146,7 +50168,7 @@ Added caching of users and access rights (for faster access rights checking)
@item
Normal users (not anonymous ones) can change their password with
@code{mysqladmin password 'new_password'}. This uses encrypted passwords
-that are not logged in the normal @strong{MySQL} log!
+that are not logged in the normal MySQL log!
@item
All important string functions are now coded in assembler for x86 Linux
machines. This gives a speedup of 10% in many cases.
@@ -49184,7 +50206,7 @@ to join them in a specific order.
String functions now return @code{VARCHAR} rather than @code{CHAR} and
the column type is now @code{VARCHAR} for fields saved as @code{VARCHAR}.
This should make the @strong{MyODBC} driver better, but may break some old
-@strong{MySQL} clients that don't handle @code{FIELD_TYPE_VARCHAR} the same
+MySQL clients that don't handle @code{FIELD_TYPE_VARCHAR} the same
way as @code{FIELD_TYPE_CHAR}.
@item
@code{CREATE INDEX} and @code{DROP INDEX} are now implemented through
@@ -49214,9 +50236,12 @@ Added @code{--enable-assembler} option to @code{configure}, for x86 machines
most important string functions for more speed!
@end itemize
+
@node News-3.21.x, News-3.20.x, News-3.22.x, News
@appendixsec Changes in release 3.21.x
+@cindex changes, version 3.21
+
Version 3.21 is quite old now, and should be avoided if possible. This
information is kept here for historical purposes only.
@@ -49258,6 +50283,7 @@ information is kept here for historical purposes only.
* News-3.21.0:: Changes in release 3.21.0
@end menu
+
@node News-3.21.33, News-3.21.32, News-3.21.x, News-3.21.x
@appendixsubsec Changes in release 3.21.33
@@ -49275,6 +50301,7 @@ avoid race conditions.
@code{INSERT INTO TABLE (timestamp_column) VALUES (NULL);} didn't set timestamp.
@end itemize
+
@node News-3.21.32, News-3.21.31, News-3.21.33, News-3.21.x
@appendixsubsec Changes in release 3.21.32
@@ -49305,8 +50332,10 @@ Fixed a bug in the range optimizer that wrote
@code{Use_count: Wrong count for ...} in the error log file.
@end itemize
+
@node News-3.21.31, News-3.21.30, News-3.21.32, News-3.21.x
@appendixsubsec Changes in release 3.21.31
+
@itemize @bullet
@item
Fixed a sign extension problem for the @code{TINYINT} type on Irix.
@@ -49323,8 +50352,10 @@ Fixed problems with @code{DATE_FORMAT()} and incorrect dates.
it more easily in the future.
@end itemize
+
@node News-3.21.30, News-3.21.29, News-3.21.31, News-3.21.x
@appendixsubsec Changes in release 3.21.30
+
@itemize @bullet
@item
@code{mysql} now returns an exit code > 0 if the query returned an error.
@@ -49370,8 +50401,10 @@ When comparing a field = field, where one of the fields was a part key,
only the length of the part key was compared.
@end itemize
+
@node News-3.21.29, News-3.21.28, News-3.21.30, News-3.21.x
@appendixsubsec Changes in release 3.21.29
+
@itemize @bullet
@item
@code{LOCK TABLES} + @code{DELETE from tbl_name} never removed locks properly.
@@ -49392,8 +50425,10 @@ Fixed bug on Alpha when using integer keys. (Other keys worked on Alpha).
Fixed bug in @code{WEEK("XXXX-xx-01")}.
@end itemize
+
@node News-3.21.28, News-3.21.27, News-3.21.29, News-3.21.x
@appendixsubsec Changes in release 3.21.28
+
@itemize @bullet
@item
Fixed socket permission (clients couldn't connect to Unix socket on Linux).
@@ -49402,8 +50437,10 @@ Fixed bug in record caches; for some queries, you could get
@code{Error from table handler: #} on some operating systems.
@end itemize
+
@node News-3.21.27, News-3.21.26, News-3.21.28, News-3.21.x
@appendixsubsec Changes in release 3.21.27
+
@itemize @bullet
@item
Added user level lock functions @code{GET_LOCK(string,timeout)},
@@ -49434,8 +50471,10 @@ Ignore users with old (8-byte) password on startup if not using
case of the matched values, not of the found values. (Minor problem.)
@end itemize
+
@node News-3.21.26, News-3.21.25, News-3.21.27, News-3.21.x
@appendixsubsec Changes in release 3.21.26
+
@itemize @bullet
@item
@code{FROM_DAYS(0)} now returns "0000-00-00".
@@ -49461,8 +50500,10 @@ Added a retry loop around @code{accept()} to possibly fix some problems on some
Linux machines.
@end itemize
+
@node News-3.21.25, News-3.21.24, News-3.21.26, News-3.21.x
@appendixsubsec Changes in release 3.21.25
+
@itemize @bullet
@item
Changed @code{typedef 'string'} to @code{typedef 'my_string'} for better
@@ -49479,8 +50520,10 @@ Affects @code{DISTINCT}, @code{ORDER BY} and @code{GROUP BY} on 64-bit
processors.
@end itemize
+
@node News-3.21.24, News-3.21.23, News-3.21.25, News-3.21.x
@appendixsubsec Changes in release 3.21.24
+
@itemize @bullet
@item
Dynamic loadable functions. Based on source from Alexis Mikhailov.
@@ -49509,8 +50552,10 @@ support.
Upgraded @code{DBI} to 0.93.
@end itemize
+
@node News-3.21.23, News-3.21.22, News-3.21.24, News-3.21.x
@appendixsubsec Changes in release 3.21.23
+
@itemize @bullet
@item
The following symbols are now reserved words:
@@ -49540,21 +50585,23 @@ Added command @code{variables} to @code{mysqladmin}.
@item
A lot of small changes to the binary releases.
@item
-Fixed a bug in the new protocol from @strong{MySQL} Version 3.21.20.
+Fixed a bug in the new protocol from MySQL Version 3.21.20.
@item
Changed @code{ALTER TABLE} to work with Windows (Windows can't rename
open files). Also fixed a couple of small bugs in the Windows version.
@item
-All standard @strong{MySQL} clients are now ported to @strong{MySQL}-Windows.
+All standard MySQL clients are now ported to MySQL-Windows.
@item
-@strong{MySQL} can now be started as a service on NT.
+MySQL can now be started as a service on NT.
@end itemize
+
@node News-3.21.22, News-3.21.21a, News-3.21.23, News-3.21.x
@appendixsubsec Changes in release 3.21.22
+
@itemize @bullet
@item
-Starting with this version, all @strong{MySQL} distributions will be
+Starting with this version, all MySQL distributions will be
configured, compiled and tested with @code{crash-me} and the benchmarks on
the following platforms: SunOS 5.6 sun4u, SunOS 5.5.1 sun4u, SunOS 4.14 sun4c,
SunOS 5.6 i86pc, Irix 6.3 mips5k, HP-UX 10.20 hppa, AIX 4.2.1 ppc,
@@ -49597,15 +50644,19 @@ Ported to OpenBSD 2.1.
New Dutch error messages.
@end itemize
+
@node News-3.21.21a, News-3.21.21, News-3.21.22, News-3.21.x
@appendixsubsec Changes in release 3.21.21a
+
@itemize @bullet
@item
Configure changes for some operating systems.
@end itemize
+
@node News-3.21.21, News-3.21.20, News-3.21.21a, News-3.21.x
@appendixsubsec Changes in release 3.21.21
+
@itemize @bullet
@item
Fixed optimizer bug when using
@@ -49616,8 +50667,10 @@ Added command @code{SHOW STATUS}.
Removed @file{manual.ps} from the source distribution to make it smaller.
@end itemize
+
@node News-3.21.20, News-3.21.19, News-3.21.21, News-3.21.x
@appendixsubsec Changes in release 3.21.20
+
@itemize @bullet
@item
Changed the maximum table name and column name lengths from 32 to 64.
@@ -49636,8 +50689,10 @@ Solaris 2.6: Fixed @code{configure} bugs and increased maximum table size
from 2G to 4G.
@end itemize
+
@node News-3.21.19, News-3.21.18, News-3.21.20, News-3.21.x
@appendixsubsec Changes in release 3.21.19
+
@itemize @bullet
@item
Upgraded @code{DBD} to 1823. This version implements @code{mysql_use_result} in
@@ -49652,8 +50707,10 @@ Configure fixes (@file{Docs} directory).
Added function @code{REVERSE()} (by Zeev Suraski).
@end itemize
+
@node News-3.21.18, News-3.21.17, News-3.21.19, News-3.21.x
@appendixsubsec Changes in release 3.21.18
+
@itemize @bullet
@item
Issue error message if client C functions are called in wrong order.
@@ -49670,15 +50727,17 @@ Fixed a couple of problems with @code{LEFT OUTER JOIN}.
Added @code{CROSS JOIN} syntax. @code{CROSS} is now a reserved word.
@item
Recoded @code{yacc}/@code{bison} stack allocation to be even safer and to allow
-@strong{MySQL} to handle even bigger expressions.
+MySQL to handle even bigger expressions.
@item
Fixed a couple of problems with the update log.
@item
@code{ORDER BY} was slow when used with key ranges.
@end itemize
+
@node News-3.21.17, News-3.21.16, News-3.21.18, News-3.21.x
@appendixsubsec Changes in release 3.21.17
+
@itemize @bullet
@item
Changed documentation string of @code{--with-unix-socket-path} to avoid
@@ -49709,6 +50768,7 @@ Optimized key block caching. This will be quicker than the old algorithm when
using bigger key caches.
@end itemize
+
@node News-3.21.16, News-3.21.15, News-3.21.17, News-3.21.x
@appendixsubsec Changes in release 3.21.16
@@ -49731,6 +50791,7 @@ Allow empty strings as default values for @code{BLOB} and @code{TEXT}, to
be compatible with @code{mysqldump}.
@end itemize
+
@node News-3.21.15, News-3.21.14b, News-3.21.16, News-3.21.x
@appendixsubsec Changes in release 3.21.15
@@ -49758,16 +50819,16 @@ A new sortorder german-1. That is a normal ISO-Latin1 with a german sort
order.
@item
Perl @code{DBI}/@code{DBD} is now included in the distribution. @code{DBI}
-is now the recommended way to connect to @strong{MySQL} from Perl.
+is now the recommended way to connect to MySQL from Perl.
@item
New portable benchmark suite with @code{DBD}, with test results from
-@code{mSQL} 2.0.3, @strong{MySQL}, PostgreSQL 6.2.1 and Solid server 2.2.
+@code{mSQL} 2.0.3, MySQL, PostgreSQL 6.2.1 and Solid server 2.2.
@item
@code{crash-me} is now included with the benchmarks; This is a Perl program
designed to find as many limits as possible in a SQL server. Tested with
-@code{mSQL}, PostgreSQL, Solid and @strong{MySQL}.
+@code{mSQL}, PostgreSQL, Solid and MySQL.
@item
-Fixed bug in range-optimizer that crashed @strong{MySQL} on some queries.
+Fixed bug in range-optimizer that crashed MySQL on some queries.
@item
Table and column name completion for @code{mysql} command line tool, by Zeev
Suraski and Andi Gutmans.
@@ -49790,13 +50851,14 @@ Changed @code{net_write()} to @code{my_net_write()} because of a name
conflict with Sybase.
@item
@cindex ODBC compatibility
-@cindex Compatibility, with ODBC
+@cindex compatibility, with ODBC
New function @code{DAYOFWEEK()} compatible with ODBC.
@item
-Stack checking and @code{bison} memory overrun checking to make @strong{MySQL}
+Stack checking and @code{bison} memory overrun checking to make MySQL
safer with weird queries.
@end itemize
+
@node News-3.21.14b, News-3.21.14a, News-3.21.15, News-3.21.x
@appendixsubsec Changes in release 3.21.14b
@@ -49805,6 +50867,7 @@ safer with weird queries.
Fixed a couple of small @code{configure} problems on some platforms.
@end itemize
+
@node News-3.21.14a, News-3.21.13, News-3.21.14b, News-3.21.x
@appendixsubsec Changes in release 3.21.14a
@@ -49838,7 +50901,7 @@ Sorting on calculated @code{DOUBLE} values sorted on integer results instead.
@code{mysql} no longer needs a database argument.
@item
Changed the place where @code{HAVING} should be. According to ANSI, it should
-be after @code{GROUP BY} but before @code{ORDER BY}. @strong{MySQL} Version 3.20
+be after @code{GROUP BY} but before @code{ORDER BY}. MySQL Version 3.20
incorrectly had it last.
@item
Added Sybase command @code{USE DATABASE} to start using another database.
@@ -49852,6 +50915,7 @@ Added lots of limit checks to make it safer when running with too little
memory or when doing weird queries.
@end itemize
+
@node News-3.21.13, News-3.21.12, News-3.21.14a, News-3.21.x
@appendixsubsec Changes in release 3.21.13
@@ -49880,6 +50944,7 @@ New multi-user test @file{tests/fork_test.pl} to put some strain on the
thread library.
@end itemize
+
@node News-3.21.12, News-3.21.11, News-3.21.13, News-3.21.x
@appendixsubsec Changes in release 3.21.12
@@ -49922,7 +50987,7 @@ easily portable to Win95.
Changed the @code{CREATE COLUMN} syntax of @code{NOT NULL} columns to be after
the @code{DEFAULT} value, as specified in the ANSI SQL standard. This will
make @code{mysqldump} with @code{NOT NULL} and default values incompatible with
-@strong{MySQL} Version 3.20.
+MySQL Version 3.20.
@item
Added many function name aliases so the functions can be used with
ODBC or ANSI SQL92 syntax.
@@ -49944,6 +51009,7 @@ that matches many rows.
Added Russian error messages.
@end itemize
+
@node News-3.21.11, News-3.21.10, News-3.21.12, News-3.21.x
@appendixsubsec Changes in release 3.21.11
@@ -49951,7 +51017,7 @@ Added Russian error messages.
@item
Configure changes.
@item
-@strong{MySQL} now works with the new thread library on BSD/OS 3.0.
+MySQL now works with the new thread library on BSD/OS 3.0.
@item
Added new group functions @code{BIT_OR()} and @code{BIT_AND()}.
@item
@@ -49978,6 +51044,7 @@ Fixed problem with @code{ORDER BY}/@code{GROUP BY} because of bug in @code{gcc}.
Fixed problem with @code{INSERT ... SELECT ... GROUP BY}.
@end itemize
+
@node News-3.21.10, News-3.21.9, News-3.21.11, News-3.21.x
@appendixsubsec Changes in release 3.21.10
@@ -50007,6 +51074,7 @@ Fixed a couple of bugs in the range optimizer. Now the new range benchmark
@code{test-select} works.
@end itemize
+
@node News-3.21.9, News-3.21.8, News-3.21.10, News-3.21.x
@appendixsubsec Changes in release 3.21.9
@@ -50019,10 +51087,11 @@ Fixed a couple of portability problems with include files.
Fixed bug in range calculation that could return empty
set when searching on multiple key with only one entry (very rare).
@item
-Most things ported to FSU Pthreads, which should allow @strong{MySQL} to
+Most things ported to FSU Pthreads, which should allow MySQL to
run on SCO. @xref{SCO}.
@end itemize
+
@node News-3.21.8, News-3.21.7, News-3.21.9, News-3.21.x
@appendixsubsec Changes in release 3.21.8
@@ -50068,6 +51137,7 @@ Added machine-dependent files for MIT-pthreads i386-SCO. There is probably
more to do to get this to work on SCO 3.5.
@end itemize
+
@node News-3.21.7, News-3.21.6, News-3.21.8, News-3.21.x
@appendixsubsec Changes in release 3.21.7
@@ -50088,6 +51158,7 @@ More information can be found in the @file{README} file!
Fixed some problems when using very long, illegal names.
@end itemize
+
@node News-3.21.6, News-3.21.5, News-3.21.7, News-3.21.x
@appendixsubsec Changes in release 3.21.6
@@ -50100,6 +51171,7 @@ defines).
@code{accept()}.
@end itemize
+
@node News-3.21.5, News-3.21.4, News-3.21.6, News-3.21.x
@appendixsubsec Changes in release 3.21.5
@@ -50120,6 +51192,7 @@ New function @code{SEC_TO_TIME(seconds)} which returns a string in
New function @code{SUBSTRING_INDEX()}, originally by Zeev Suraski.
@end itemize
+
@node News-3.21.4, News-3.21.3, News-3.21.5, News-3.21.x
@appendixsubsec Changes in release 3.21.4
@@ -50134,6 +51207,7 @@ Configuration and compilation on FreeBSD 3.0 works, but I couldn't get
@code{pthread_create} to work.
@end itemize
+
@node News-3.21.3, News-3.21.2, News-3.21.4, News-3.21.x
@appendixsubsec Changes in release 3.21.3
@@ -50192,6 +51266,7 @@ existed.
Changed the default sort buffer size from 2M to 1M.
@end itemize
+
@node News-3.21.2, News-3.21.0, News-3.21.3, News-3.21.x
@appendixsubsec Changes in release 3.21.2
@@ -50241,7 +51316,7 @@ New function @code{ASCII()}.
Removed function @code{BETWEEN(a,b,c)}. Use the standard ANSI
syntax instead: @code{expr BETWEEN expr AND expr}.
@item
-@strong{MySQL} no longer has to use an extra temporary table when sorting
+MySQL no longer has to use an extra temporary table when sorting
on functions or @code{SUM()} functions.
@item
Fixed bug that you couldn't use @code{tbl_name.field_name} in @code{UPDATE}.
@@ -50255,6 +51330,7 @@ Note: @code{some_field} is normally in the @code{SELECT} part. ANSI SQL should
require it.
@end itemize
+
@node News-3.21.0, , News-3.21.2, News-3.21.x
@appendixsubsec Changes in release 3.21.0
@@ -50327,9 +51403,12 @@ mysql> SELECT * FROM tbl_name
@end example
@end itemize
+
@node News-3.20.x, News-3.19.x, News-3.21.x, News
@appendixsec Changes in release 3.20.x
+@cindex changes, version 3.20
+
Version 3.20 is quite old now, and should be avoided if possible. This
information is kept here for historical purposes only.
@@ -50354,6 +51433,7 @@ documented as changes to the 3.21 version.
* News-3.20.0:: Changes in releases 3.20.0
@end menu
+
@node News-3.20.18, News-3.20.17, News-3.20.x, News-3.20.x
@appendixsubsec Changes in release 3.20.18
@@ -50399,6 +51479,7 @@ When using overlapping (unnecessary) keys and join over many tables,
the optimizer could get confused and return 0 records.
@end itemize
+
@node News-3.20.17, News-3.20.16, News-3.20.18, News-3.20.x
@appendixsubsec Changes in release 3.20.17
@@ -50457,6 +51538,7 @@ number of type @code{YYYYMMDD} or @code{YYMMDD}.
Added new function @code{UNIX_TIMESTAMP(timestamp_column)}.
@end itemize
+
@node News-3.20.16, News-3.20.15, News-3.20.17, News-3.20.x
@appendixsubsec Changes in release 3.20.16
@@ -50485,6 +51567,7 @@ Added new latin2 and Russian KOI8 character tables.
Added support for a dummy @code{GRANT} command to satisfy Powerbuilder.
@end itemize
+
@node News-3.20.15, News-3.20.14, News-3.20.16, News-3.20.x
@appendixsubsec Changes in release 3.20.15
@@ -50508,6 +51591,7 @@ Fixed bug when doing a @code{SELECT} as superuser without a database.
Fixed bug when doing @code{SELECT} with group calculation to outfile.
@end itemize
+
@node News-3.20.14, News-3.20.13, News-3.20.15, News-3.20.x
@appendixsubsec Changes in release 3.20.14
@@ -50519,7 +51603,7 @@ an argument, the user is solicited for the password from the tty.
Added default password from @code{MYSQL_PWD} (by Elmar Haneke).
@item
Added command @code{kill} to @code{mysqladmin} to kill a specific
-@strong{MySQL} thread.
+MySQL thread.
@item
Sometimes when doing a reconnect on a down connection this succeeded
first on second try.
@@ -50550,6 +51634,7 @@ Fixed a bug in @code{OR} of multiple tables (gave empty set).
Added many patches to MIT-pthreads. This fixes at least one lookup bug.
@end itemize
+
@node News-3.20.13, News-3.20.11, News-3.20.14, News-3.20.x
@appendixsubsec Changes in release 3.20.13
@@ -50589,6 +51674,7 @@ rows that determine this grant.
Added @code{WHERE const op field} (by @email{bonis@@kiss.de}).
@end itemize
+
@node News-3.20.11, News-3.20.10, News-3.20.13, News-3.20.x
@appendixsubsec Changes in release 3.20.11
@@ -50617,6 +51703,7 @@ Added sync of records count in @code{sql_update}. This fixed slow updates
on first connection. (Thanks to Vaclav Bittner for the test.)
@end itemize
+
@node News-3.20.10, News-3.20.9, News-3.20.11, News-3.20.x
@appendixsubsec Changes in release 3.20.10
@@ -50645,6 +51732,7 @@ Added @code{--without-perl} option to @code{configure}.
Lots of small portability changes.
@end itemize
+
@node News-3.20.9, News-3.20.8, News-3.20.10, News-3.20.x
@appendixsubsec Changes in release 3.20.9
@@ -50660,6 +51748,7 @@ Some compatibility changes for SunOS.
Removed @file{config.cache} from old distribution.
@end itemize
+
@node News-3.20.8, News-3.20.7, News-3.20.9, News-3.20.x
@appendixsubsec Changes in release 3.20.8
@@ -50668,6 +51757,7 @@ Removed @file{config.cache} from old distribution.
Fixed bug with @code{ALTER TABLE} and multi-part keys.
@end itemize
+
@node News-3.20.7, News-3.20.6, News-3.20.8, News-3.20.x
@appendixsubsec Changes in release 3.20.7
@@ -50683,7 +51773,7 @@ Added new field @strong{file_priv} to @code{mysql/user} table.
New script @code{add_file_priv} which adds the new field @strong{file_priv}
to the @code{user} table. This script must be executed if you want to
use the new @code{SELECT ... INTO} and @code{LOAD DATA INFILE ...} commands
-with a version of @strong{MySQL} earlier than 3.20.7.
+with a version of MySQL earlier than 3.20.7.
@item
Fixed bug in locking code, which made @code{lock_test.pl} test fail.
@item
@@ -50703,6 +51793,7 @@ Added @code{-k} option to @code{mysqlshow}, to get key information for a table.
Added long options to @code{mysqldump}.
@end itemize
+
@node News-3.20.6, News-3.20.3, News-3.20.7, News-3.20.x
@appendixsubsec Changes in release 3.20.6
@@ -50787,6 +51878,7 @@ New math functions:
@code{EXP()}, @code{LOG()}, @code{SQRT()}, @code{ROUND()}, @code{CEILING()}.
@end itemize
+
@node News-3.20.3, News-3.20.0, News-3.20.6, News-3.20.x
@appendixsubsec Changes in release 3.20.3
@@ -50819,10 +51911,10 @@ Changed SQL function @code{INTERVALL()} to @code{INTERVAL()}.
@item
Made @code{SHOW COLUMNS} a synonym for @code{SHOW FIELDS}.
Added compatibility syntax @code{FRIEND KEY} to @code{CREATE TABLE}. In
-@strong{MySQL}, this creates a non-unique key on the given columns.
+MySQL, this creates a non-unique key on the given columns.
@item
Added @code{CREATE INDEX} and @code{DROP INDEX} as compatibility functions.
-In @strong{MySQL}, @code{CREATE INDEX} only checks if the index exists and
+In MySQL, @code{CREATE INDEX} only checks if the index exists and
issues an error if it doesn't exist. @code{DROP INDEX} always succeeds.
@item
@file{mysqladmin.c}: added client version to version information.
@@ -50847,6 +51939,7 @@ For example, @code{'user('} is regarded as beginning a function call, and
@code{'('}, not as a function call.
@end itemize
+
@node News-3.20.0, , News-3.20.3, News-3.20.x
@appendixsubsec Changes in release 3.20.0
@@ -50891,9 +51984,12 @@ A lot of small bug fixes done.
New @file{INSTALL} files (not final version) and some information regarding porting.
@end itemize
+
@node News-3.19.x, , News-3.20.x, News
@appendixsec Changes in release 3.19.x
+@cindex changes, version 3.19
+
Version 3.19 is quite old now, and should be avoided if possible. This
information is kept here for historical purposes only.
@@ -50903,6 +51999,7 @@ information is kept here for historical purposes only.
* News-3.19.3:: Changes in release 3.19.3
@end menu
+
@node News-3.19.5, News-3.19.4, News-3.19.x, News-3.19.x
@appendixsubsec Changes in release 3.19.5
@@ -50926,6 +52023,7 @@ A group on one column and a sort on a group function (@code{SUM()},
@code{mysqldump}: Didn't send password to server.
@end itemize
+
@node News-3.19.4, News-3.19.3, News-3.19.5, News-3.19.x
@appendixsubsec Changes in release 3.19.4
@@ -50951,6 +52049,7 @@ Added functions @code{CEILING()}, @code{ROUND()}, @code{EXP()}, @code{LOG()} and
Enhanced @code{BETWEEN} to handle strings.
@end itemize
+
@node News-3.19.3, , News-3.19.4, News-3.19.x
@appendixsubsec Changes in release 3.19.3
@@ -50969,745 +52068,14 @@ fields, the @code{BLOB} was garbage on output.
Fixed @code{DISTINCT} with calculated columns.
@end itemize
-@cindex bugs, known
-@cindex errors, known
-@cindex design, issues
-@cindex known errors
-@node Bugs, TODO, News, Top
-@appendix Known errors and design deficiencies in MySQL
-
-The following problems are known and have a very high priority to get
-fixed:
-
-@itemize @bullet
-@item
-@code{ANALYZE TABLE} on a BDB table may in some case make the table
-unusable until one has restarted @code{mysqld}. When this happens you will
-see errors like the following in the @strong{MySQL} error file:
-
-@example
-001207 22:07:56 bdb: log_flush: LSN past current end-of-log
-@end example
-
-@item
-Don't execute @code{ALTER TABLE} on a @code{BDB} table on which you are
-running not completed multi-statement transactions. (The transaction
-will probably be ignored).
-
-@item
-@code{ANALYZE TABLE}, @code{OPTIMIZE TABLE} and @code{REPAIR TABLE} may
-cause problems on tables for which you are using @code{INSERT DELAYED}.
-
-@item
-Doing a @code{LOCK TABLE ..} and @code{FLUSH TABLES ..} doesn't
-guarantee that there isn't a half-finished transaction in progress on the
-table.
-
-@item
-BDB tables are a bit slow to open. If you have many BDB tables in a
-database, it will take a long time to use the @code{mysql} client on the
-database if you are not using the @code{-A} option or if you are using
-@code{rehash}. This is especially notable when you have a big table
-cache.
-
-@item
-Th current replication protocol cannot deal with @code{LOAD DATA INFILE}
-and line terminator characters of more than 1 character.
-@end itemize
-
-The following problems are known and will be fixed in due time:
-
-@itemize @bullet
-@item
-For the moment @code{MATCH} only works with @code{SELECT} statements.
-@item
-When using @code{SET CHARACTER SET}, one can't use translated
-characters in database, table and column names.
-@item
-@code{DELETE FROM merge_table} used without a @code{WHERE}
-will only clear the mapping for the table, not delete everything in the
-mapped tables
-@item
-You cannot build in another directory when using
-MIT-pthreads. Because this requires changes to MIT-pthreads, we are not
-likely to fix this.
-@item
-@code{BLOB} values can't ``reliably'' be used in @code{GROUP BY} or
-@code{ORDER BY} or @code{DISTINCT}. Only the first @code{max_sort_length}
-bytes (default 1024) are used when comparing @code{BLOB}bs in these cases.
-This can be changed with the @code{-O max_sort_length} option to
-@code{mysqld}. A workaround for most cases is to use a substring:
-@code{SELECT DISTINCT LEFT(blob,2048) FROM tbl_name}.
-@item
-Calculation is done with @code{BIGINT} or @code{DOUBLE} (both are
-normally 64 bits long). It depends on the function which precision one
-gets. The general rule is that bit functions are done with @code{BIGINT}
-precision, @code{IF}, and @code{ELT()} with @code{BIGINT} or @code{DOUBLE}
-precision and the rest with @code{DOUBLE} precision. One should try to
-avoid using bigger unsigned long long values than 63 bits
-(9223372036854775807) for anything else than bit fields!
-@item
-All string columns, except @code{BLOB} and @code{TEXT} columns, automatically
-have all trailing spaces removed when retrieved. For @code{CHAR} types this
-is okay, and may be regarded as a feature according to ANSI SQL92. The bug is
-that in @strong{MySQL}, @code{VARCHAR} columns are treated the same way.
-@item
-You can only have up to 255 @code{ENUM} and @code{SET} columns in one table.
-@item
-@code{safe_mysqld} re-directs all messages from @code{mysqld} to the
-@code{mysqld} log. One problem with this is that if you execute
-@code{mysqladmin refresh} to close and reopen the log,
-@code{stdout} and @code{stderr} are still redirected to the old log.
-If you use @code{--log} extensively, you should edit @code{safe_mysqld} to
-log to @file{'hostname'.err} instead of @file{'hostname'.log} so you can
-easily reclaim the space for the old log by deleting the old one and
-executing @code{mysqladmin refresh}.
-@item
-In the @code{UPDATE} statement, columns are updated from left to right.
-If you refer to an updated column, you will get the updated value instead of the
-original value. For example:
-@example
-mysql> UPDATE tbl_name SET KEY=KEY+1,KEY=KEY+1;
-@end example
-will update @code{KEY} with @code{2} instead of with @code{1}.
-@item
-You can't use temporary tables more than once in the same query.
-For example, the following doesn't work.
-
-@example
-select * from temporary_table, temporary_table as t2;
-@end example
-
-@item
-@code{RENAME} doesn't work with @code{TEMPORARY} tables.
-
-@item
-The optimizer may handle @code{DISTINCT} differently if you are using
-'hidden' columns in a join or not. In a join, hidden columns are
-counted as part of the result (even if they are not shown) while in
-normal queries hidden columns doesn't participate in the @code{DISTINCT}
-comparison. We will probably change this in the future to never compare
-the hidden columns when executing @code{DISTINCT}
-
-An example of this is:
-
-@example
-SELECT DISTINCT mp3id FROM band_downloads WHERE userid = 9 ORDER BY id
-DESC;
-
-and
-
-SELECT DISTINCT band_downloads.mp3id, FROM band_downloads,band_mp3
-WHERE band_downloads.userid = 9 AND band_mp3.id = band_downloads.mp3id
-ORDER BY band_downloads.id DESC;
-@end example
-
-In the second case you may in @strong{MySQL} 3.23.x get two identical rows
-in the result set (because the hidden 'id' column may differ).
-
-Note that the this only happens for queries where you don't have the
-ORDER BY columns in the result, something that is you are not allowed
-to do in ANSI SQL.
-
-@item
-Because @strong{MySQL} allows you to work with table types that doesn't
-support transactions (and thus can't @code{rollback} data) some things
-behaves a little different in @strong{MySQL} than in other SQL servers:
-(This is just to ensure that @strong{MySQL} never need to do a rollback
-for a SQL command). This may be a little awkward at times as column
-Because @strong{MySQL} allows you to work with table types that don't
-support transactions, and thus can't @code{rollback} data, some things
-behave a little differently in @strong{MySQL} than in other SQL servers.
-This is just to ensure that @strong{MySQL} never need to do a rollback
-for a SQL command. This may be a little awkward at times as column
-values must be checked in the application, but this will actually give
-you a nice speed increase as it allows @strong{MySQL} to do some
-optimizations that otherwise would be very hard to do.
-
-If you set a column to an incorrect value, @strong{MySQL} will, instead of
-doing a rollback, store the @code{best possible value} in the column:
-
-@itemize @bullet
-@item
-If you try to store a value outside the range in a numerical column,
-@strong{MySQL} will instead store the smallest or biggest possible value in
-the column.
-@item
-If you try to store a string that doesn't start with a number into a
-numerical column, @strong{MySQL} will store 0 into it.
-@item
-If you try to store @code{NULL} into a column that doesn't take
-@code{NULL} values, @strong{MySQL} will store 0 or @code{''} (empty
-string) in it instead. (This behavior can, however, be changed with the
--DDONT_USE_DEFAULT_FIELDS compile option).
-@item
-@strong{MySQL} allows you to store some wrong date values into
-@code{DATE} and @code{DATETIME} columns. (Like 2000-02-31 or 2000-02-00).
-If the date is totally wrong, @strong{MySQL} will store the special
-0000-00-00 date value in the column.
-@item
-If you set an @code{enum} to an unsupported value, it will be set to
-the error value 'empty string', with numeric value 0.
-@end itemize
-
-@item
-If you execute a @code{PROCEDURE} on a query that returns an empty set,
-in some cases the @code{PROCEDURE} will not transform the columns.
-@item
-Creation of a table of type @code{MERGE} doesn't check if the underlying
-tables are of compatible types.
-@item
-@strong{MySQL} can't yet handle @code{NaN}, @code{-Inf} and @code{Inf}
-values in double. Using these will cause problems when trying to export
-and import data. We should as an intermediate solution change @code{NaN} to
-@code{NULL} (if possible) and @code{-Inf} and @code{Inf} to the
-Minimum respective maximum possible @code{double} value.
-@item
-@code{LIMIT} on negative numbers are treated as big positive numbers.
-@end itemize
-
-The following are known bugs in earlier versions of @strong{MySQL}:
-
-@itemize @bullet
-@item
-You can get a hung thread if you do a @code{DROP TABLE} on a table that is
-one among many tables that is locked with @code{LOCK TABLES}.
-
-@item
-In the following case you can get a core dump:
-@enumerate
-@item
-Delayed insert handler has pending inserts to a table.
-@item
-@code{LOCK table} with @code{WRITE}
-@item
-@code{FLUSH TABLES}
-@end enumerate
-
-@item
-Before @strong{MySQL} Version 3.23.2 an @code{UPDATE} that updated a key with
-a @code{WHERE} on the same key may have failed because the key was used to
-search for records and the same row may have been found multiple times:
-
-@example
-UPDATE tbl_name SET KEY=KEY+1 WHERE KEY > 100;
-@end example
-
-A workaround is to use:
-
-@example
-mysql> UPDATE tbl_name SET KEY=KEY+1 WHERE KEY+0 > 100;
-@end example
-
-This will work because @strong{MySQL} will not use index on expressions in
-the @code{WHERE} clause.
-@item
-Before @strong{MySQL} Version 3.23, all numeric types where treated as fixed-point
-fields. That means you had to specify how many decimals a floating-point
-field shall have. All results were returned with the correct number of
-decimals.
-@end itemize
-
-For platform-specific bugs, see the sections about compiling and porting.
-
-@cindex ToDo list for MySQL
-@node TODO, Porting, Bugs, Top
-@appendix MySQL and the future (The TODO)
-
-@menu
-* TODO MySQL 4.0:: Things that should be in Version 4.0
-* TODO future:: Things that must be done in the near future
-* TODO sometime:: Things that have to be done sometime
-* TODO unplanned:: Some things we don't have any plans to do
-@end menu
-
-This appendix lists the features that we plan to implement in @strong{MySQL}.
-
-Everything in this list is approximately in the order it will be done. If you
-want to affect the priority order, please register a license or support us and
-tell us what you want to have done more quickly. @xref{Licensing and Support}.
-
-The plan is that we in the future will support the full ANSI SQL99
-standard, but with a lot of useful extensions. The challenge is to do
-this without sacrifying the speed or compromise the code.
-
-@node TODO MySQL 4.0, TODO future, TODO, TODO
-@appendixsec Things that should be in 4.0
-
-We plan to make @strong{MySQL} Version 4.0 a ``quick'' release where we only
-add some new stuff to enable others to help us with developing new features
-into Version 4.1. The @strong{MySQL} 4.0 version should only take us about
-a month to make after which we want to stabilize it and start working on
-Version 4.1. Version 4.0 should have the following new features:
-
-The news section for 4.0 includes a list of the features we have already
-implemented in the 4.0 tree. @xref{News-4.0.x}.
-
-@itemize @bullet
-@item
-New table definition file format (@code{.frm} files) This will enable us
-to not run out of bits when adding more table options. One will still
-be able to use the old @code{.frm} file format with 4.0. All newly created
-tables will, however, use the new format.
-
-The new file format will enable us to add new column types, more options
-for keys and @code{FOREIGN KEY} support.
-@item
-@code{mysqld} as a library. This will have the same interface as the
-standard @strong{MySQL} client (with an extra function to just set up
-startup parameters) but will be faster (no TCP/IP or socket overhead),
-smaller and much easier to use for embedded products.
-
-One will be able to define at link time if one wants to use the
-client/server model or a stand-alone application just by defining which
-library to link with.
-
-The @code{mysqld} will support all standard @strong{MySQL} features and
-one can use it in a threaded client to run different queries in each
-thread.
-@item
-Replication should work with @code{RAND()} and user variables @code{@@var}.
-@item
-Online backup with very low performance penalty. The online backup will
-make it easy to add a new replication slave without taking down the
-master.
-@item
-@code{DELETE FROM table_name} will return the number of deleted rows. For
-fast execution one should use @code{TRUNCATE table_name}.
-@item
-Multi-table @code{DELETE} (cascading @code{DELETE} and multi-table
-@code{DELETE}.
-@item
-Allow @code{DELETE} on @code{MyISAM} tables to use the record cache.
-To do this, we need to update the threads record cache when we update
-the @code{.MYD} file.
-@item
-Better replication.
-@item
-More functions for full-text search.
-@xref{Fulltext Features to Appear in MySQL 4.0}.
-@item
-Character set casts and syntax for handling multiple character sets.
-@item
-Allow users to change startup options without taking down the server.
-@item
-Help for all commands from the client.
-@item
-Secure connections (with SSL).
-@item
-Extend the optimizer to be able to optimize some @code{ORDER BY key_name DESC}
-queries.
-@item
-@code{SHOW COLUMNS FROM table_name} (used by @code{mysql} client to allow
-expansions of column names) should not open the table, but only the
-definition file. This will require less memory and be much faster.
-@item
-New key cache
-@item
-When using @code{SET CHARACTER SET} we should translate the whole query
-at once and not only strings. This will enable users to use the translated
-characters in database, table and column names.
-@item
-Add a portable interface over @code{gethostbyaddr_r()} so that we can change
-@code{ip_to_hostname()} to not block other threads while doing DNS lookups.
-@item
-Add @code{record_in_range()} method to @code{MERGE} tables to be
-able to choose the right index when there is many to choose from. We should
-also extend the info interface to get the key distribution for each index,
-of @code{analyze} is run on all sub tables.
-@item
-@code{SET SQL_DEFAULT_TABLE_TYPE=[MyISAM | INNODB | BDB | GEMINI | HEAP]}.
-@end itemize
-
-@node TODO future, TODO sometime, TODO MySQL 4.0, TODO
-@appendixsec Things that must be done in the real near future
-
-@itemize @bullet
-@item
-Fail safe replication.
-@item
-Subqueries.
-@code{select id from t where grp in (select grp from g where u > 100)}
-@item
-Derived tables.
-@example
-select a.col1, b.col2 from (select max(col1) as col1 from root_table ) a,
-other_table b where a.col1=b.col1
-@end example
-
-This could be done by automatically creating temporary tables for the
-derived tables for the duration of the query.
-@item
-Add @code{PREPARE} of statements and sending of parameters to @code{mysqld}.
-@item
-Extend the server/client protocol to support warnings.
-@item
-Add options to the server/protocol protocol to get progress notes
-for long running commands.
-@item
-Add database and real table name (in case of alias) to the MYSQL_FIELD
-structure.
-@item
-Don't allow more than a defined number of threads to run MyISAM recover
-at the same time.
-@item
-Change @code{INSERT ... SELECT} to optionally use concurrent inserts.
-@item
-Implement @code{RENAME DATABASE}. To make this safe for all table handlers,
-it should work as follows:
-@itemize @bullet
-@item
-Create the new database.
-@item
-For every table do a rename of the table to another database, as
-we do with the @code{RENAME} command.
-@item
-Drop the old database.
-@end itemize
-@item
-Return the original field types() when doing @code{SELECT MIN(column)
-... GROUP BY}.
-@item
-Multiple result sets.
-@item
-Change the protocol to allow binary transfer of values. To do this
-efficiently, we need to add an API to allow binding of variables.
-@item
-Add @code{PREPARE} of statements and sending of parameters to @code{mysqld}.
-@item
-Make it possible to specify @code{long_query_time} with a granularity
-in microseconds.
-@item
-Add a configurable prompt to the @code{mysql} command line client, with
-options like database in use, time and date...
-@item
-Add range checking to @code{MERGE} tables.
-@item
-Link the @code{myisampack} code into the server.
-@item
-Port of @strong{MySQL} to BeOS.
-@item
-Port of the @strong{MySQL} clients to LynxOS.
-@item
-Add a temporary key buffer cache during @code{INSERT/DELETE/UPDATE} so that we
-can gracefully recover if the index file gets full.
-@item
-If you perform an @code{ALTER TABLE} on a table that is symlinked to another
-disk, create temporary tables on this disk.
-@item
-Implement a @code{DATE/DATETIME} type that handles time zone information
-properly, so that dealing with dates in different time zones is easier.
-@item
-FreeBSD and MIT-pthreads; Do sleeping threads take CPU?
-@item
-Check if locked threads take any CPU.
-@item
-Fix configure so that one can compile all libraries (like @code{MyISAM})
-without threads.
-@item
-Add an option to periodically flush key pages for tables with delayed keys
-if they haven't been used in a while.
-@item
-Allow join on key parts (optimization issue).
-@item
-@code{INSERT SQL_CONCURRENT} and @code{mysqld --concurrent-insert} to do
-a concurrent insert at the end of the file if the file is read-locked.
-@item
-Remember @code{FOREIGN} key definitions in the @file{.frm} file.
-@item
-Cascading @code{DELETE}
-@item
-Server side cursors.
-@item
-Check if @code{lockd} works with modern Linux kernels; If not, we have
-to fix @code{lockd}! To test this, start @code{mysqld} with
-@code{--enable-locking} and run the different fork* test suits. They shouldn't
-give any errors if @code{lockd} works.
-@item
-Allow SQL variables in @code{LIMIT}, like in @code{LIMIT @@a,@@b}.
-@item
-Allow update of variables in @code{UPDATE} statements. For example:
-@code{UPDATE TABLE foo SET @@a=a+b,a=@@a, b=@@a+c}
-@item
-Change when user variables are updated so that one can use them with
-@code{GROUP BY}, as in the following example:
-@code{SELECT id, @@a:=count(*), sum(sum_col)/@@a FROM table_name GROUP BY id}.
-@item
-Don't add automatic @code{DEFAULT} values to columns. Give an error when using
-an @code{INSERT} that doesn't contain a column that doesn't have a
-@code{DEFAULT}.
-@item
-Caching of queries and results. This should be done as a separated
-module that examines each query and if this is query is in the cache
-the cached result should be returned. When one updates a table one
-should remove as few queries as possible from the cache.
-This should give a big speed bost on machines with much RAM where
-queries are often repeated (like WWW applications).
-One idea would be to only cache queries of type:
-@code{SELECT CACHED ...}
-@item
-Fix @file{libmysql.c} to allow two @code{mysql_query()} commands in a row
-without reading results or give a nice error message when one does this.
-@item
-Optimize @code{BIT} type to take 1 bit (now @code{BIT} takes 1 char).
-@item
-Check why MIT-pthreads @code{ctime()} doesn't work on some FreeBSD systems.
-@item
-Add an @code{IMAGE} option to @code{LOAD DATA INFILE} to not update
-@code{TIMESTAMP} and @code{AUTO_INCREMENT} fields.
-@item
-Added @code{LOAD DATE INFILE.. UPDATE} syntax.
-@itemize @bullet
-@item
-For tables with primary keys, if the data contains the primary key,
-entries matching that primary key are updated from the remainder of the
-columns. However, columns MISSING from the incoming data feed are not
-touched.
-@item
-For tables tables with primary keys that are missing some part of the key
-in the incoming data stream, or that have no primary key, the feed is
-treated as a @code{LOAD DATA INFILE ... REPLACE INTO} is now.
-@end itemize
-@item
-Make @code{LOAD DATA INFILE} understand syntax like:
-@example
-LOAD DATA INFILE 'file_name.txt' INTO TABLE tbl_name
-TEXT_FIELDS (text_field1, text_field2, text_field3)
-SET table_field1=concatenate(text_field1, text_field2), table_field3=23
-IGNORE text_field3
-
-This can be used to skip over extra columns in the text file, or update columns
-based on expressions of the read data...
-@end example
-@item
-@code{LOAD DATA INFILE 'file_name' INTO TABLE 'table_name' ERRORS TO err_table_name}
-This would cause any errors and warnings to be logged into the err_table_name
-table. That table would have a structure like:
-@example
-line_number - line number in data file
-error_message - the error/warning message
-and maybe
-data_line - the line from the data file
-@end example
-@item
-Add true @code{VARCHAR} support (There is already support for this in MyISAM).
-@item
-Automatic output from @code{mysql} to netscape.
-@item
-@code{LOCK DATABASES}. (with various options)
-@item
-Change sort to allocate memory in ``hunks'' to get better memory utilization.
-@item
-@code{DECIMAL} and @code{NUMERIC} types can't read exponential numbers;
-@code{Field_decimal::store(const char *from,uint len)} must be recoded
-to fix this.
-@item
-Fix @code{mysql.cc} to do fewer @code{malloc()} calls when hashing field
-names.
-@item
-Functions:
-ADD_TO_SET(value,set) and REMOVE_FROM_SET(value,set)
-@item
-Add use of @code{t1 JOIN t2 ON ...} and @code{t1 JOIN t2 USING ...}
-Currently, you can only use this syntax with @code{LEFT JOIN}.
-@item
-Add full support for @code{unsigned long long} type.
-@item
-Many more variables for @code{show status}. Counts for:
-@code{INSERT}/@code{DELETE}/@code{UPDATE} statements. Records reads and
-updated. Selects on 1 table and selects with joins. Mean number of
-tables in select. Number of @code{ORDER BY} and @code{GROUP BY} queries.
-@item
-If you abort @code{mysql} in the middle of a query, you should open
-another connection and kill the old running query.
-Alternatively, an attempt should be made to detect this in the server.
-@item
-Add a handler interface for table information so you can use it as a system
-table. This would be a bit slow if you requested information about all tables,
-but very flexible. @code{SHOW INFO FROM tbl_name} for basic table information
-should be implemented.
-@item
-Add support for UNICODE.
-@item
-@code{NATURAL JOIN} and @code{UNION JOIN}
-@item
-Allow @code{select a from crash_me left join crash_me2 using (a)}; In this
-case a is assumed to come from the crash_me table.
-@item
-Fix that @code{ON} and @code{USING} works with the @code{JOIN} and
-@code{INNER JOIN} join types.
-@item
-Oracle like @code{CONNECT BY PRIOR ...} to search hierarchy structures.
-@item
-@code{RENAME DATABASE}
-@item
-@code{mysqladmin copy database new-database}. -- Requires COPY command to be
-added to @code{mysqld}
-@item
-Processlist should show number of queries/thread.
-@item
-@code{SHOW HOSTS} for printing information about the hostname cache.
-@item
-@code{DELETE} and @code{REPLACE} options to the @code{UPDATE} statement
-(this will delete rows when one gets a duplicate key error while updating).
-@item
-Change the format of @code{DATETIME} to store fractions of seconds.
-@item
-Add all missing ANSI92 and ODBC 3.0 types.
-@item
-Change table names from empty strings to @code{NULL} for calculated columns.
-@item
-Don't use 'Item_copy_string' on numerical values to avoid
-number->string->number conversion in case of:
-@code{SELECT COUNT(*)*(id+0) FROM table_name GROUP BY id}
-@item
-Make it possible to use the new GNU regexp library instead of the current
-one (The GNU library should be much faster than the old one).
-@item
-Change that @code{ALTER TABLE} doesn't abort clients that executes
-@code{INSERT DELAYED}.
-@item
-Fix that when columns referenced in an @code{UPDATE} clause contains the old
-values before the update started.
-@item
-@code{myisamchk}, @code{REPAIR} and @code{OPTIMIZE TABLE} should be able
-to handle cases where the data and/or index files are symbolic links.
-@item
-Add simulation of @code{pread()}/@code{pwrite()} on Windows to enable
-concurrent inserts.
-@item
-A logfile analyzer that could parsed out information about which tables
-are hit most often, how often multi-table joins are executed, etc. It
-should help users identify areas or table design that could be optimized
-to execute much more efficient queries.
-@item
-Add @code{SUM(DISTINCT)}
-@item
-Add @code{ANY()},@code{EVERY()} and @code{SOME()} group functions. In
-ANSI SQL these only works on boolean columns, but we can extend these to
-work on any columns/expressions by applying: value == 0 -> FALSE and
-value <> 0 -> TRUE.
-@item
-Fix that the type for @code{MAX(column)} is the same as the column type.
-@example
-create table t1 (a DATE);
-insert into t1 values (now());
-create table t2 select max(a) from t1;
-show columns from t2;
-@end example
-@item
-Come up with a nice syntax for a statement that will @code{UPDATE} the row
-if it exists and @code{INSERT} a new row if the row didn't exist.
-(Like @code{REPLACE} works with @code{INSERT} / @code{DELETE})
-@end itemize
-@node TODO sometime, TODO unplanned, TODO future, TODO
-@appendixsec Things that have to be done sometime
-@itemize @bullet
-@item
-Implement function: @code{get_changed_tables(timeout,table1,table2,...)}
-@item
-Atomic multi-table updates, eg @code{update items,month set
-items.price=month.price where items.id=month.id;};
-@item
-Change reading through tables to use memmap when possible. Now only
-compressed tables use memmap.
-@item
-Add a new privilege @strong{'Show_priv'} for @code{SHOW} commands.
-@item
-Make the automatic timestamp code nicer. Add timestamps to the update
-log with @code{SET TIMESTAMP=#;}
-@item
-Use read/write mutex in some places to get more speed.
-@item
-Full foreign key support. One probably wants to implement a procedural
-language first.
-@item
-Simple views (first on one table, later on any expression).
-@item
-Automatically close some tables if a table, temporary table or temporary files
-gets error 23 (not enough open files).
-@item
-When one finds a field=#, change all occurrences of field to #. Now this
-is only done for some simple cases.
-@item
-Change all const expressions with calculated expressions if possible.
-@item
-Optimize key = expression. At the moment only key = field or key =
-constant are optimized.
-@item
-Join some of the copy functions for nicer code.
-@item
-Change @file{sql_yacc.yy} to an inline parser to reduce its size and get
-better error messages (5 days).
-@item
-Change the parser to use only one rule per different number of arguments
-in function.
-@item
-Use of full calculation names in the order part. (For ACCESS97)
-@item
-@code{UNION}, @code{MINUS}, @code{INTERSECT} and @code{FULL OUTER JOIN}.
-(Currently only @code{LEFT OUTER JOIN} is supported)
-@item
-Allow @code{UNIQUE} on fields that can be @code{NULL}.
-@item
-@code{SQL_OPTION MAX_SELECT_TIME=#} to put a time limit on a query.
-@item
-Make the update log to a database.
-@item
-Negative @code{LIMIT} to retrieve data from the end.
-@item
-Alarm around client connect/read/write functions.
-@item
-Please note the changes to @code{safe_mysqld}: according to FSSTND (which
-Debian tries to follow) PID files should go into @file{/var/run/<progname>.pid}
-and log files into @file{/var/log}. It would be nice if you could put the
-"DATADIR" in the first declaration of "pidfile" and "log", so the
-placement of these files can be changed with a single statement.
-@item
-Allow a client to request logging.
-@item
-Add use of @code{zlib()} for @code{gzip}-ed files to @code{LOAD DATA INFILE}.
-@item
-Fix sorting and grouping of @code{BLOB} columns (partly solved now).
-@item
-Stored procedures. This is currently not regarded to be very
-important as stored procedures are not very standardized yet.
-Another problem is that true stored procedures make it much harder for
-the optimizer and in many cases the result is slower than before
-We will, on the other hand, add a simple (atomic) update language that
-can be used to write loops and such in the @strong{MySQL} server.
-@item
-Change to use semaphores when counting threads. One should first implement
-a semaphore library to MIT-pthreads.
-@item
-Don't assign a new @code{AUTO_INCREMENT} value when one sets a column to 0.
-Use @code{NULL} instead.
-@item
-Add full support for @code{JOIN} with parentheses.
-@item
-As an alternative for one thread / connection manage a pool of threads
-to handle the queries.
-@item
-Allow one to get more than one lock with @code{GET_LOCK}. When doing this,
-one must also handle the possible deadlocks this change will introduce.
-@end itemize
-Time is given according to amount of work, not real time.
-
-@node TODO unplanned, , TODO sometime, TODO
-@appendixsec Some things we don't have any plans to do
-
-@itemize @bullet
-@item
-Nothing; In the long run we plan to be fully ANSI 92 / ANSI 99 compliant.
-@end itemize
+@node Porting, Environment variables, News, Top
+@appendix Comments on porting to other systems
@cindex porting, to other systems
-@node Porting, Regexp, TODO, Top
-@appendix Comments on porting to other systems
A working Posix thread library is needed for the server. On Solaris 2.5
we use Sun PThreads (the native thread support in 2.4 and earlier
@@ -51719,7 +52087,7 @@ thread support is probably to port MIT-pthreads. See
@file{mit-pthreads/README} and
@uref{http://www.humanfactor.com/pthreads/, Programming POSIX Threads}.
-The @strong{MySQL} distribution includes a patched version of
+The MySQL distribution includes a patched version of
Provenzano's Pthreads from MIT (see
@uref{http://www.mit.edu:8001/people/proven/pthreads.html, MIT Pthreads
web page}). This can be used for some operating systems that do not
@@ -51764,7 +52132,7 @@ gmake clean all install init-db
@end example
If you run into problems with a new port, you may have to do some debugging
-of @strong{MySQL}!
+of MySQL!
@xref{Debugging server}.
@strong{NOTE:} Before you start debugging @code{mysqld}, first get the test
@@ -51772,21 +52140,23 @@ programs @code{mysys/thr_alarm} and @code{mysys/thr_lock} to work. This
will ensure that your thread installation has even a remote chance to work!
@menu
-* Debugging server:: Debugging a @strong{MySQL} server
-* Debugging client:: Debugging a @strong{MySQL} client
+* Debugging server:: Debugging a MySQL server
+* Debugging client:: Debugging a MySQL client
* The DBUG package:: The DBUG package
* Locking methods:: Locking methods
* RTS-threads:: Comments about RTS threads
* Thread packages:: Differences between different thread packages
@end menu
+
+@node Debugging server, Debugging client, Porting, Porting
+@appendixsec Debugging a MySQL server
+
@cindex server, debugging
@cindex debugging, server
@cindex crash
-@node Debugging server, Debugging client, Porting, Porting
-@appendixsec Debugging a MySQL server
-If you are using some functionality that is very new in @strong{MySQL},
+If you are using some functionality that is very new in MySQL,
you can try to run @code{mysqld} with the @code{--skip-new} (which will disable all
new, potentially unsafe functionality) or with @code{--safe-mode} which
disables a lot of optimization that may cause problems.
@@ -51806,33 +52176,34 @@ 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!
+information even if you haven't compiled 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}.
+@code{myisamchk}. @xref{MySQL Database Administration}. 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}.
+@xref{Operating System Specific Notes}.
@menu
-* Compiling for debugging::
-* Making trace files::
-* Using gdb on mysqld::
-* Using stack trace::
-* Using log files::
-* Reproduceable test case::
+* Compiling for debugging:: Compiling MYSQL for debugging.
+* Making trace files:: Creating trace files
+* Using gdb on mysqld:: Debugging mysqld under gdb
+* Using stack trace:: Using a stack trace
+* Using log files:: Using log files to find cause of errors in mysqld
+* Reproduceable test case:: Making a test case when you experience table corruption
@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
+MySQL. To do this you must configure MySQL with the
@code{--with-debug} or the @code{--with-debug=full} option. You can check
-whether or not @strong{MySQL} was compiled with debugging by doing:
+whether or not MySQL was compiled with debugging by doing:
@code{mysqld --help}. If the @code{--debug} flag is listed with the
options then you have debugging enabled. @code{mysqladmin ver} also
lists the @code{mysqld} version as @code{mysql ... --debug} in this case.
@@ -51845,9 +52216,9 @@ CC=gcc CFLAGS="-O2" CXX=gcc CXXFLAGS="-O2 -felide-constructors -fno-exceptions -
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.
+code) and compile a MySQL version with support for all character sets.
-If you suspect a memory overrun error, you can configure @strong{MySQL}
+If you suspect a memory overrun error, you can configure MySQL
with @code{--with-debug=full}, which will install a memory allocation
(@code{SAFEMALLOC}) checker. Running with @code{SAFEMALLOC} is however
quite slow, so if you get performance problems you should start
@@ -51857,26 +52228,27 @@ disable the memory overrun checks for each call to @code{malloc} and
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
+bug within MySQL. In this case you can try to add @code{-g} to
the @code{CFLAGS} and @code{CXXFLAGS} variables above and not use
@code{--with-debug}. If @code{mysqld} now dies, you can at least attach
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
+When you configure 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
+means that if you are having some unexpected problems with 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
+configure 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!
+MySQL version you are using!
-In the Windows @strong{MySQL} distribution, @code{mysqld.exe} is by
+In the Windows MySQL distribution, @code{mysqld.exe} is by
default compiled with support for trace files.
+
@node Making trace files, Using gdb on mysqld, Compiling for debugging, Debugging server
@appendixsubsec Creating trace files
@@ -51894,9 +52266,19 @@ Start the @code{mysqld} server with a trace log in @file{/tmp/mysqld.trace}
@code{mysqld --debug}
On Windows you should also use the @code{--standalone} flag to not start
-@code{mysqld} as a service.
-Note that the trace file will get very @emph{BIG}!
+@code{mysqld} as a service:
+
+In a DOS window do:
+
+@example
+mysqld --debug --standalone
+@end example
+
+After this you can use the @code{mysql.exe} command line tool in a
+second DOS window to reproduce the problem. You can take down the above
+@code{mysqld} server with @code{mysqladmin shutdown}.
+Note that the trace file will get very @emph{BIG}!
If you want to have a smaller trace file, you can use something like:
@code{mysqld --debug=d,info,error,query,general,where:O,/tmp/mysqld.trace}
@@ -51908,16 +52290,18 @@ If you make a bug report about this, please only send the lines from the
trace file to the appropriate mailing list where something seems to go
wrong! If you can't locate the wrong place, you can ftp the trace file,
together with a full bug report, to
-@uref{ftp://support.mysql.com/pub/mysql/secret} so that a @strong{MySQL}
+@uref{ftp://support.mysql.com/pub/mysql/secret} so that a MySQL
developer can take a look a this.
The trace file is made with the @strong{DBUG} package by Fred Fish.
@xref{The DBUG package}.
-@cindex gdb, using
+
@node Using gdb on mysqld, Using stack trace, Making trace files, Debugging server
@appendixsubsec Debugging mysqld under gdb
+@cindex gdb, using
+
On most system you can also start @code{mysqld} from @code{gdb} to get
more information if @code{mysqld} crashes.
@@ -51928,7 +52312,7 @@ this case you can only have one thread active at a time.
When running @code{mysqld} under gdb, you should disable the stack trace
with @code{--skip-stack-trace} to be able to catch segfaults within gdb.
-It's very hard to debug @strong{MySQL} under @code{gdb} if you do a lot of
+It's very hard to debug MySQL under @code{gdb} if you do a lot of
new connections the whole time as @code{gdb} doesn't free the memory for
old threads. You can avoid this problem by starting @code{mysqld} with
@code{-O thread_cache_size= 'max_connections +1'}. In most cases just
@@ -51996,6 +52380,7 @@ 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, Using gdb on mysqld, Debugging server
@appendixsubsec Using a stack trace
@@ -52043,7 +52428,7 @@ Make a symbol file for the @code{mysqld} server:
nm -n libexec/mysqld > /tmp/mysqld.sym
@end example
-Note that many @strong{MySQL} binary distributions comes with the above
+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
@@ -52064,11 +52449,13 @@ that killed @code{mysqld} and preferable a test case so that we can
repeat the problem! @xref{Bug reports}.
@end enumerate
+
@node Using log files, Reproduceable test case, Using stack trace, Debugging server
@appendixsubsec Using log files to find cause of errors in mysqld
Note that before starting @code{mysqld} with @code{--log} you should
-check all your tables with @code{myisamchk}. @xref{Maintenance}.
+check all your tables with @code{myisamchk}.
+@xref{MySQL Database Administration}.
If @code{mysqld} dies or hangs, you should start @code{mysqld} with
@code{--log}. When @code{mysqld} dies again, you can examine the end of
@@ -52091,19 +52478,19 @@ You can find the queries that take a long time to execute by starting
If you find the text @code{mysqld restarted} in the error log file
(normally named @file{hostname.err}) you have probably found a query
that causes @code{mysqld} to fail. If this happens you should check all
-your tables with @code{myisamchk} (@pxref{Maintenance}), and test the
-queries in the @strong{MySQL} log files to see if one doesn't work. If
-you find such a query, try first upgrading to the newest @strong{MySQL}
-version. If this doesn't help and you can't find anything in the
-@code{mysql} mail archive, you should report the bug to
+your tables with @code{myisamchk} (@pxref{MySQL Database Administration}),
+and test the queries in the MySQL log files to see if one doesn't
+work. If you find such a query, try first upgrading to the newest
+MySQL version. If this doesn't help and you can't find anything
+in the @code{mysql} mail archive, you should report the bug to
@email{mysql@@lists.mysql.com}. Links to mail archives are available
-online at the @uref{http://www.mysql.com/documentation/, @strong{MySQL}
+online at the @uref{http://www.mysql.com/documentation/, MySQL
documentation page}.
If you have started @code{mysqld} with @code{--with-myisam-recover},
-@strong{MySQL} will automatically check and try to repair @code{MyISAM}
+MySQL will automatically 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
+this happens, 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
@@ -52114,6 +52501,7 @@ 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 Reproduceable test case, , Using log files, Debugging server
@appendixsubsec Making a test case when you experience table corruption
@@ -52123,7 +52511,7 @@ following:
@itemize @bullet
@item
-Take down the @strong{MySQL} daemon (with @code{mysqladmin shutdown}).
+Take down the 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).
@@ -52133,7 +52521,7 @@ 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
+Remove (or move away) any old log files from the MySQL data
directory if you need more space.
@item
Start @code{mysqld} with @code{--log-binary}. @xref{Binary log}.
@@ -52147,7 +52535,7 @@ Restore the backup.
Restart the @code{mysqld} server @strong{without} @code{--log-binary}
@item
Re-execute the commands with @code{mysqlbinlog update-log-file | mysql}.
-The update log is saved in the @strong{MySQL} database directory with
+The update log is saved in the MySQL database directory with
the name @code{hostname-bin.#}.
@item
If the tables are corrupted again or you can get @code{mysqld} to die with the
@@ -52155,20 +52543,22 @@ 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
+@email{support@@mysql.com} about the problem and the MySQL team
will fix it as soon as possible.
@end itemize
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
+
@node Debugging client, The DBUG package, Debugging server, Porting
@appendixsec Debugging a MySQL client
-To be able to debug a @strong{MySQL} client with the integrated debug package,
-you should configure @strong{MySQL} with @code{--with-debug}.
+@cindex debugging, client
+@cindex clients, debugging
+
+To be able to debug a MySQL client with the integrated debug package,
+you should configure MySQL with @code{--with-debug}.
@xref{configure options}.
@tindex MYSQL_DEBUG environment variable
@@ -52186,7 +52576,7 @@ This causes clients to generate a trace file in @file{/tmp/client.trace}.
If you have problems with your own client code, you should attempt to
connect to the server and run your query using a client that is known to
work. Do this by running @code{mysql} in debugging mode (assuming you
-have compiled @strong{MySQL} with debugging on):
+have compiled MySQL with debugging on):
@example
shell> mysql --debug=d:t:O,/tmp/client.trace
@@ -52198,22 +52588,23 @@ This will provide useful information in case you mail a bug report.
If your client crashes at some 'legal' looking code, you should check
that your @file{mysql.h} include file matches your mysql library file.
A very common mistake is to use an old @file{mysql.h} file from an old
-@strong{MySQL} installation with new @strong{MySQL} library.
+MySQL installation with new MySQL library.
-@cindex DBUG package
@node The DBUG package, Locking methods, Debugging client, Porting
@appendixsec The DBUG package.
-The @strong{MySQL} server and most @strong{MySQL} clients are compiled
+@cindex DBUG package
+
+The MySQL server and most MySQL clients are compiled
with the DBUG package originally made by Fred Fish. When one has configured
-@strong{MySQL} for debugging, this package makes it possible to get a trace
+MySQL for debugging, this package makes it possible to get a trace
file of what the program is debugging. @xref{Making trace files}.
One uses the debug package by invoking the program with the
@code{--debug="..."} or the @code{-#...} option.
-Most @strong{MySQL} programs has a default debug string that will be
+Most MySQL programs has a default debug string that will be
used if you don't specify an option to @code{--debug}. The default
trace file is usually @code{/tmp/programname.trace} on Unix and
@code{\programname.trace} on Windows.
@@ -52264,16 +52655,18 @@ to an application program) are:
-#d:t:i:O,\\mysqld.trace
@end example
-In @strong{MySQL}, common tags to print (with the @code{d} option) are:
+In MySQL, common tags to print (with the @code{d} option) are:
@code{enter},@code{exit},@code{error},@code{warning},@code{info} and
@code{loop}.
-@cindex locking methods
-@cindex methods, locking
+
@node Locking methods, RTS-threads, The DBUG package, Porting
@appendixsec Locking methods
-Currently @strong{MySQL} only supports table locking for
+@cindex locking methods
+@cindex methods, locking
+
+Currently MySQL only supports table locking for
@code{ISAM}/@code{MyISAM} and @code{HEAP} tables and page level locking
for @code{BDB} tables. @xref{Internal locking}. With @code{MyISAM}
tables one can freely mix @code{INSERT} and @code{SELECT} without locks
@@ -52283,7 +52676,7 @@ Starting in version 3.23.33, you can analyze the table lock contention
on your system by checking @code{Table_locks_waited} and
@code{Table_locks_immediate} environment variables.
-Some database users claim that @strong{MySQL} cannot support near the
+Some database users claim that MySQL cannot support near the
number of concurrent users because it lacks row-level locking. This
may be true for some specific applications, but is not generally
true. As always this depends totally on what the application does and what
@@ -52339,7 +52732,7 @@ Many scans / @code{GROUP BY} on the whole table without any writers.
Other options than row / page level locking:
-Versioning (like we use in @strong{MySQL} for concurrent inserts) where
+Versioning (like we use in MySQL for concurrent inserts) where
you can have one writer at the same time as many readers. This means
that the database/table supports different views for the data depending
on when one started to access it. Other names for this are time travel,
@@ -52350,7 +52743,7 @@ locking; The worst case does, however, use much more memory than
when using normal locks.
Instead of using row level locks one can use application level locks.
-(Like get_lock/release_lock in @strong{MySQL}). This works of course
+(Like get_lock/release_lock in MySQL). This works of course
only in well-behaved applications.
In many cases one can do an educated guess which locking type is best
@@ -52358,11 +52751,11 @@ for the application but generally it's very hard to say that a given
lock type is better than another; Everything depends on the application
and different part of the application may require different lock types.
-Here are some tips about locking in @strong{MySQL}:
+Here are some tips about locking in MySQL:
On web application most applications do lots of selects, very few
deletes, updates mainly on keys and inserts in some specific tables.
-The base @strong{MySQL} setup is VERY tuned for this.
+The base MySQL setup is VERY tuned for this.
Concurrent users is not a problem if one doesn't mix updates and selects
that needs to examine many rows in the same table.
@@ -52374,19 +52767,21 @@ One can also use @code{LOCK TABLES} to speed up things (many updates within
a single lock is much faster than updates without locks). Splitting
thing to different tables will also helps.
-If you get speed problems with the table locks in @strong{MySQL}, you
+If you get speed problems with the table locks in MySQL, you
may be able to solve these to convert some of your tables to @code{BDB} tables.
@xref{BDB}.
The optimization section in the manual covers a lot of different aspects of
how to tune ones application. @xref{Tips}.
-@cindex RTS-threads
-@cindex threads, RTS
+
@node RTS-threads, Thread packages, Locking methods, Porting
@appendixsec Comments about RTS threads
-I have tried to use the RTS thread packages with @strong{MySQL} but
+@cindex RTS-threads
+@cindex threads, RTS
+
+I have tried to use the RTS thread packages with MySQL but
stumbled on the following problems:
They use an old version of a lot of POSIX calls and it is very tedious to
@@ -52406,7 +52801,7 @@ should return the error code on error. Now they return -1 and set @code{errno}.
Another problem is that user-level threads use the @code{ALRM} signal and this
aborts a lot of functions (@code{read}, @code{write}, @code{open}...).
-@strong{MySQL} should do a retry on interrupt on all of these but it is
+MySQL should do a retry on interrupt on all of these but it is
not that easy to verify it.
The biggest unsolved problem is the following:
@@ -52416,12 +52811,12 @@ alarms with @code{pthread_cond_timedwait()}, but this aborts with error
@code{EINTR}. I tried to debug the thread library as to why this happens,
but couldn't find any easy solution.
-If someone wants to try @strong{MySQL} with RTS threads I suggest the
+If someone wants to try MySQL with RTS threads I suggest the
following:
@itemize @bullet
@item
-Change functions @strong{MySQL} uses from the thread library to POSIX.
+Change functions MySQL uses from the thread library to POSIX.
This shouldn't take that long.
@item
Compile all libraries with the @code{-DHAVE_rts_threads}.
@@ -52477,12 +52872,14 @@ end
@end example
@end itemize
-@cindex thread packages, differences between
+
@node Thread packages, , RTS-threads, Porting
@appendixsec Differences between different thread packages
-@strong{MySQL} is very dependent on the thread package used. So when
-choosing a good platform for @strong{MySQL}, the thread package is very
+@cindex thread packages, differences between
+
+MySQL is very dependent on the thread package used. So when
+choosing a good platform for MySQL, the thread package is very
important.
There are at least three types of thread packages:
@@ -52525,17 +52922,105 @@ level threads in the system libraries. In such cases, the thread
switching can only be done by the thread library and the kernel isn't
really ``thread aware''.
+
+
+
+@node Environment variables, Regexp, Porting, Top
+@appendix Environment Variables
+
+@cindex environment variables, list of
+
+Here is a list of all the environment variables that are used directly or
+indirectly by MySQL. Most of these can also be found in other
+places in this manual.
+
+Note that any options on the command line will take precedence over
+values specified in configuration files and environment variables, and
+values in configuration files take precedence over values in environment
+variables.
+
+In many cases it's preferable to use a configure file instead of environment
+variables to modify the behavior of MySQL. @xref{Option files}.
+
+@tindex CCX environment variable
+@tindex Environment variable, CCX
+@tindex CC environment variable
+@tindex Environment variable, CC
+@tindex CFLAGS environment variable
+@tindex Environment variable, CFLAGS
+@tindex CXXFLAGS environment variable
+@tindex Environment variable, CXXFLAGS
+@tindex DBI_USER environment variable
+@tindex Environment variable, DBI_USER
+@tindex DBI_TRACE environment variable
+@tindex Environment variable, DBI_TRACE
+@tindex HOME environment variable
+@tindex Environment variable, HOME
+@tindex LD_RUN_PATH environment variable
+@tindex Environment variable, LD_RUN_PATH
+@tindex MYSQL_DEBUG environment variable
+@tindex Environment variable, MYSQL_DEBUG
+@tindex MYSQL_HISTFILE environment variable
+@tindex Environment variable, MYSQL_HISTFILE
+@tindex MYSQL_HOST environment variable
+@tindex Environment variable, MYSQL_HOST
+@tindex MYSQL_PWD environment variable
+@tindex Environment variable, MYSQL_PWD
+@tindex MYSQL_TCP_PORT environment variable
+@tindex Environment variable, MYSQL_TCP_PORT
+@tindex MYSQL_UNIX_PORT environment variable
+@tindex Environment variable, MYSQL_UNIX_PORT
+@tindex PATH environment variable
+@tindex Environment variable, PATH
+@tindex TMPDIR environment variable
+@tindex Environment variable, TMPDIR
+@tindex TZ environment variable
+@tindex Environment variable, TZ
+@tindex UMASK_DIR environment variable
+@tindex Environment variable, UMASK_DIR
+@tindex UMASK environment variable
+@tindex Environment variable, UMASK
+@tindex USER environment variable
+@tindex Environment variable, USER
+
+@multitable @columnfractions .2 .8
+@item @code{CCX} @tab Set this to your C++ compiler when running configure.
+@item @code{CC} @tab Set this to your C compiler when running configure.
+@item @code{CFLAGS} @tab Flags for your C compiler when running configure.
+@item @code{CXXFLAGS} @tab Flags for your C++ compiler when running configure.
+@item @code{DBI_USER} @tab The default user name for Perl DBI.
+@item @code{DBI_TRACE} @tab Used when tracing Perl DBI.
+@item @code{HOME} @tab The default path for the @code{mysql} history file is @file{$HOME/.mysql_history}.
+@item @code{LD_RUN_PATH} @tab Used to specify where your @code{libmysqlclient.so} is.
+@item @code{MYSQL_DEBUG} @tab Debug-trace options when debugging.
+@item @code{MYSQL_HISTFILE} @tab The path to the @code{mysql} history file.
+@item @code{MYSQL_HOST} @tab Default host name used by the @code{mysql} command-line prompt.
+@item @code{MYSQL_PWD} @tab The default password when connecting to @code{mysqld}. Note that use of this is insecure!
+@item @code{MYSQL_TCP_PORT} @tab The default TCP/IP port.
+@item @code{MYSQL_UNIX_PORT} @tab The default socket; used for connections to @code{localhost}.
+@item @code{PATH} @tab Used by the shell to finds the MySQL programs.
+@item @code{TMPDIR} @tab The directory where temporary tables/files are created.
+@item @code{TZ} @tab This should be set to your local time zone. @xref{Timezone problems}.
+@item @code{UMASK_DIR} @tab The user-directory creation mask when creating directories. Note that this is ANDed with @code{UMASK}!
+@item @code{UMASK} @tab The user-file creation mask when creating files.
+@item @code{USER} @tab The default user on Windows to use when connecting to @code{mysqld}.
+@end multitable
+
+
+
+
+@node Regexp, Unireg, Environment variables, Top
+@appendix Description of MySQL regular expression syntax
+
@cindex regex
@cindex regular expression syntax, described
@cindex syntax, regular expression
-@node Regexp, Unireg, Porting, Top
-@appendix Description of MySQL regular expression syntax
A regular expression (regex) is a powerful way of specifying a complex search.
-@strong{MySQL} uses Henry Spencer's implementation of regular
+MySQL uses Henry Spencer's implementation of regular
expressions, which is aimed at conformance with POSIX
-1003.2. @strong{MySQL} uses the extended version.
+1003.2. MySQL uses the extended version.
This is a simplistic reference that skips the details. To get more exact
information, see Henry Spencer's @code{regex(7)} manual page that is
@@ -52708,13 +53193,17 @@ mysql> select "a xword a" REGEXP "[[:<:]]word[[:>:]]"; -> 0
mysql> select "weeknights" REGEXP "^(wee|week)(knights|nights)$"; -> 1
@end example
-@cindex Unireg, described
-@cindex interface builder
+
+
+
@node Unireg, GPL license, Regexp, Top
@appendix What is Unireg?
+@cindex Unireg, described
+@cindex interface builder
+
Unireg is our tty interface builder, but it uses a low-level connection
-to our ISAM (which is used by @strong{MySQL}) and because of this it is
+to our ISAM (which is used by MySQL) and because of this it is
very quick. It has existed since 1979 (on Unix in C since ~1986).
Unireg has the following components:
@@ -52725,7 +53214,7 @@ One table viewer with updates/browsing.
@item
Multi table viewer (with one scrolling region).
@item
-Table creator. (With lots of column tags you can't create with @strong{MySQL})
+Table creator. (With lots of column tags you can't create with MySQL)
This is WYSIWYG (for a tty). You design a screen and Unireg prompts for
the column specification.
@item
@@ -52750,13 +53239,13 @@ The @code{convform} utility. Converts @file{.frm} and text files between
different character sets.
@item
The @code{myisampack} utility. Packs an ISAM table (makes it 50-80%
-smaller). The table can be read by @strong{MySQL} like an ordinary
+smaller). The table can be read by MySQL like an ordinary
table. Only one record has to be decompressed per access. Cannot handle
@code{BLOB} or @code{TEXT} columns or updates (yet).
@end itemize
We update most of our production databases with the Unireg interface and
-serve web pages through @strong{MySQL} (and in some extreme cases the Unireg
+serve web pages through MySQL (and in some extreme cases the Unireg
report generator).
Unireg takes about 3M of disk space and works on at least the following
@@ -52767,19 +53256,23 @@ Unireg is currently only available in Swedish and Finnish.
The price tag for Unireg is 10,000 Swedish kr (about $1500 US), but this
includes support. Unireg is distributed as a binary. (But all the ISAM
-sources can be found in @strong{MySQL}). Usually we compile the binary for the
+sources can be found in MySQL). Usually we compile the binary for the
customer at their site.
-All new development is concentrated to @strong{MySQL}.
+All new development is concentrated to MySQL.
@page
@c This node name is special
+
+
@node GPL license, LGPL license, Unireg, Top
@appendix GNU GENERAL PUBLIC LICENSE
-@center Version 2, June 1991
-@c This file is intended to be included in another file.
+@cindex GPL, General Public License
+@cindex GPL, GNU General Public License
+
+@center Version 2, June 1991
@display
Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc.
@@ -52789,7 +53282,7 @@ Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@end display
-@unnumberedsec Preamble
+@appendixsec Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
@@ -52840,9 +53333,10 @@ patent must be licensed for everyone's free use or not licensed at all.
modification follow.
@iftex
-@unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+@appendixsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@end iftex
@ifinfo
+@center GNU GENERAL PUBLIC LICENSE
@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@end ifinfo
@@ -53102,7 +53596,7 @@ POSSIBILITY OF SUCH DAMAGES.
@end ifinfo
@page
-@unnumberedsec Appendix: How to Apply These Terms to Your New Programs
+@appendixsec How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
@@ -53170,10 +53664,15 @@ Public License instead of this License.
@page
-@node LGPL license, Function Index, GPL license, Top
+
+
+
+@node LGPL license, Placeholder, GPL license, Top
@appendix GNU LESSER GENERAL PUBLIC LICENSE
+
@cindex LGPL, Lesser General Public License
@cindex LGPL, GNU Library General Public License
+
@center Version 2.1, February 1999
@display
@@ -53188,7 +53687,7 @@ as the successor of the GNU Library Public License, version 2, hence the
version number 2.1.]
@end display
-@appendixsubsec Preamble
+@appendixsec Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
@@ -53291,7 +53790,7 @@ former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
@iftex
-@appendixsubsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+@appendixsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@end iftex
@ifinfo
@center GNU LESSER GENERAL PUBLIC LICENSE
@@ -53687,7 +54186,7 @@ DAMAGES.
@end ifinfo
@page
-@appendixsubsec How to Apply These Terms to Your New Libraries
+@appendixsec How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
@@ -53736,15 +54235,707 @@ Ty Coon, President of Vice
That's all there is to it!
-@node Function Index, Concept Index, LGPL license, Top
+
+
+
+@node Placeholder, Function Index, LGPL license, Top
+@appendix Pieces of the manual in transit
+
+@menu
+* Installing binary:: Installing a MySQL Binary Distribution
+* Perl support:: Perl Installation Comments
+* Group by functions:: Functions for Use with @code{GROUP BY} Clauses
+@end menu
+
+
+@node Installing binary, Perl support, Placeholder, Placeholder
+@appendixsec Installing a MySQL Binary Distribution
+
+@cindex installing, binary distribution
+@cindex binary distributions, installing
+
+@menu
+* Linux-RPM:: Linux RPM files
+* Building clients:: Building client programs
+@end menu
+
+You need the following tools to install a MySQL binary distribution:
+
+@itemize @bullet
+@item
+GNU @code{gunzip} to uncompress the distribution.
+
+@item
+A reasonable @code{tar} to unpack the distribution. GNU @code{tar} is
+known to work. Sun @code{tar} is known to have problems.
+@end itemize
+
+@cindex RPM, defined
+@cindex RedHat Package Manager
+An alternative installation method under Linux is to use RPM (RedHat Package
+Manager) distributions. @xref{Linux-RPM}.
+
+@c texi2html fails to split chapters if I use strong for all of this.
+If you run into problems, @strong{PLEASE ALWAYS USE} @code{mysqlbug} when
+posting questions to @email{mysql@@lists.mysql.com}. Even if the problem
+isn't a bug, @code{mysqlbug} gathers system information that will help others
+solve your problem. By not using @code{mysqlbug}, you lessen the likelihood
+of getting a solution to your problem! You will find @code{mysqlbug} in the
+@file{bin} directory after you unpack the distribution. @xref{Bug reports}.
+
+@cindex commands, for binary distribution
+The basic commands you must execute to install and use a MySQL
+binary distribution are:
+
+@example
+shell> groupadd mysql
+shell> useradd -g mysql mysql
+shell> cd /usr/local
+shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
+shell> ln -s mysql-VERSION-OS mysql
+shell> cd mysql
+shell> scripts/mysql_install_db
+shell> chown -R root /usr/local/mysql
+shell> chown -R mysql /usr/local/mysql/data
+shell> chgrp -R mysql /usr/local/mysql
+shell> chown -R root /usr/local/mysql/bin
+shell> bin/safe_mysqld --user=mysql &
+@end example
+
+@cindex adding, new users
+@cindex new users, adding
+@cindex users, adding
+
+You can add new users using the @code{bin/mysql_setpermission} script if
+you install the @code{DBI} and @code{Msql-Mysql-modules} Perl modules.
+
+A more detailed description follows.
+
+To install a binary distribution, follow the steps below, then proceed
+to @ref{Post-installation}, for post-installation setup and testing:
+
+@enumerate
+@item
+Pick the directory under which you want to unpack the distribution, and move
+into it. In the example below, we unpack the distribution under
+@file{/usr/local} and create a directory @file{/usr/local/mysql} into which
+MySQL is installed. (The following instructions therefore assume
+you have permission to create files in @file{/usr/local}. If that directory
+is protected, you will need to perform the installation as @code{root}.)
+
+@item
+Obtain a distribution file from one of the sites listed in
+@ref{Getting MySQL, , Getting MySQL}.
+
+MySQL binary distributions are provided as compressed @code{tar}
+archives and have names like @file{mysql-VERSION-OS.tar.gz}, where
+@code{VERSION} is a number (for example, @code{3.21.15}), and @code{OS}
+indicates the type of operating system for which the distribution is intended
+(for example, @code{pc-linux-gnu-i586}).
+
+@item
+If you see a binary distribution marked with the @code{-max} prefix, this
+means that the binary has support for transaction-safe tables and other
+features. @xref{mysqld-max, , @code{mysqld-max}}. Note that all binaries
+are built from the same MySQL source distribution.
+
+@item
+Add a user and group for @code{mysqld} to run as:
+
+@example
+shell> groupadd mysql
+shell> useradd -g mysql mysql
+@end example
+
+These commands add the @code{mysql} group and the @code{mysql} user. The
+syntax for @code{useradd} and @code{groupadd} may differ slightly on different
+versions of Unix. They may also be called @code{adduser} and @code{addgroup}.
+You may wish to call the user and group something else instead of @code{mysql}.
+
+@item
+Change into the intended installation directory:
+
+@example
+shell> cd /usr/local
+@end example
+
+@item
+Unpack the distribution and create the installation directory:
+
+@example
+shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
+shell> ln -s mysql-VERSION-OS mysql
+@end example
+
+The first command creates a directory named @file{mysql-VERSION-OS}. The
+second command makes a symbolic link to that directory. This lets you refer
+more easily to the installation directory as @file{/usr/local/mysql}.
+
+@item
+Change into the installation directory:
+
+@example
+shell> cd mysql
+@end example
+
+You will find several files and subdirectories in the @code{mysql} directory.
+The most important for installation purposes are the @file{bin} and
+@file{scripts} subdirectories.
+
+@table @file
+@item bin
+@tindex PATH environment variable
+@tindex environment variable, PATH
+This directory contains client programs and the server
+You should add the full pathname of this directory to your
+@code{PATH} environment variable so that your shell finds the MySQL
+programs properly. @xref{Environment variables}.
+
+@item scripts
+This directory contains the @code{mysql_install_db} script used to initialize
+the @code{mysql} database containing the grant tables that store the server
+access permissions.
+@end table
+
+@item
+If you would like to use @code{mysqlaccess} and have the MySQL
+distribution in some non-standard place, you must change the location where
+@code{mysqlaccess} expects to find the @code{mysql} client. Edit the
+@file{bin/mysqlaccess} script at approximately line 18. Search for a line
+that looks like this:
+
+@example
+$MYSQL = '/usr/local/bin/mysql'; # path to mysql executable
+@end example
+
+Change the path to reflect the location where @code{mysql} actually is
+stored on your system. If you do not do this, you will get a @code{Broken
+pipe} error when you run @code{mysqlaccess}.
+
+@item
+Create the MySQL grant tables (necessary only if you haven't
+installed MySQL before):
+@example
+shell> scripts/mysql_install_db
+@end example
+
+Note that MySQL versions older than Version 3.22.10 started the
+MySQL server when you run @code{mysql_install_db}. This is no
+longer true!
+
+@item
+Change ownership of binaries to @code{root} and ownership of the data
+directory to the user that you will run @code{mysqld} as:
+
+@example
+shell> chown -R root /usr/local/mysql
+shell> chown -R mysql /usr/local/mysql/data
+shell> chgrp -R mysql /usr/local/mysql
+@end example
+
+The first command changes the @code{owner} attribute of the files to the
+@code{root} user, the second one changes the @code{owner} attribute of the
+data directory to the @code{mysql} user, and the third one changes the
+@code{group} attribute to the @code{mysql} group.
+
+@item
+If you want to install support for the Perl @code{DBI}/@code{DBD} interface,
+see @ref{Perl support}.
+
+@item
+If you would like MySQL to start automatically when you boot your
+machine, you can copy @code{support-files/mysql.server} to the location where
+your system has its startup files. More information can be found in the
+@code{support-files/mysql.server} script itself and in
+@ref{Automatic start}.
+
+@end enumerate
+
+After everything has been unpacked and installed, you should initialize
+and test your distribution.
+
+You can start the MySQL server with the following command:
+
+@example
+shell> bin/safe_mysqld --user=mysql &
+@end example
+
+@xref{safe_mysqld, , @code{safe_mysqld}}.
+
+@xref{Post-installation}.
+
+
+
+
+
+
+
+@node Perl support, Group by functions, Installing binary, Placeholder
+@appendixsec Perl Installation Comments
+
+@cindex Perl, installing
+@cindex installing, Perl
+
+@menu
+* Perl installation:: Installing Perl on Unix
+* ActiveState Perl:: Installing ActiveState Perl on Windows
+* Windows Perl:: Installing the MySQL Perl distribution on Windows
+* Perl support problems:: Problems using the Perl @code{DBI}/@code{DBD} interface
+@end menu
+
+
+@node Perl installation, ActiveState Perl, Perl support, Perl support
+@appendixsubsec Installing Perl on Unix
+
+Perl support for MySQL is provided by means of the
+@code{DBI}/@code{DBD} client interface. @xref{Perl}. The Perl
+@code{DBD}/@code{DBI} client code requires Perl Version 5.004 or later. The
+interface @strong{will not work} if you have an older version of Perl.
+
+MySQL Perl support also requires that you've installed
+MySQL client programming support. If you installed MySQL
+from RPM files, client programs are in the client RPM, but client programming
+support is in the developer RPM. Make sure you've installed the latter RPM.
+
+As of Version 3.22.8, Perl support is distributed separately from the main
+MySQL distribution. If you want to install Perl support, the files
+you will need can be obtained from
+@uref{http://www.mysql.com/Downloads/Contrib/}.
+
+The Perl distributions are provided as compressed @code{tar} archives and
+have names like @file{MODULE-VERSION.tar.gz}, where @code{MODULE} is the
+module name and @code{VERSION} is the version number. You should get the
+@code{Data-Dumper}, @code{DBI}, and @code{Msql-Mysql-modules} distributions
+and install them in that order. The installation procedure is shown below.
+The example shown is for the @code{Data-Dumper} module, but the procedure is
+the same for all three distributions:
+
+@enumerate
+@item
+Unpack the distribution into the current directory:
+@example
+shell> gunzip < Data-Dumper-VERSION.tar.gz | tar xvf -
+@end example
+This command creates a directory named @file{Data-Dumper-VERSION}.
+
+@item
+Change into the top-level directory of the unpacked distribution:
+@example
+shell> cd Data-Dumper-VERSION
+@end example
+
+@item
+Build the distribution and compile everything:
+@example
+shell> perl Makefile.PL
+shell> make
+shell> make test
+shell> make install
+@end example
+@end enumerate
+
+The @code{make test} command is important because it verifies that the
+module is working. Note that when you run that command during the
+@code{Msql-Mysql-modules} installation to exercise the interface code, the
+MySQL server must be running or the test will fail.
+
+It is a good idea to rebuild and reinstall the @code{Msql-Mysql-modules}
+distribution whenever you install a new release of MySQL,
+particularly if you notice symptoms such as all your @code{DBI} scripts
+dumping core after you upgrade MySQL.
+
+If you don't have the right to install Perl modules in the system directory
+or if you to install local Perl modules, the following reference may help
+you:
+
+@example
+@uref{http://www.iserver.com/support/contrib/perl5/modules.html}
+@end example
+
+Look under the heading
+@code{Installing New Modules that Require Locally Installed Modules}.
+
+
+@node ActiveState Perl, Windows Perl, Perl installation, Perl support
+@appendixsubsec Installing ActiveState Perl on Windows
+
+@cindex installing, Perl on Windows
+@cindex Perl, installing on Windows
+@cindex ActiveState Perl
+
+To install the MySQL @code{DBD} module with ActiveState Perl on
+Windows, you should do the following:
+
+@itemize @bullet
+@item
+Get ActiveState Perl from
+@uref{http://www.activestate.com/Products/ActivePerl/index.html}
+and install it.
+
+@item
+Open a DOS shell.
+
+@item
+If required, set the HTTP_proxy variable. For example, you might try:
+
+@example
+set HTTP_proxy=my.proxy.com:3128
+@end example
+
+@item
+Start the PPM program:
+
+@example
+C:\> c:\perl\bin\ppm.pl
+@end example
+
+@item
+If you have not already done so, install @code{DBI}:
+
+@example
+ppm> install DBI
+@end example
+
+@item
+If this succeeds, run the following command:
+
+@example
+install ftp://ftp.de.uu.net/pub/CPAN/authors/id/JWIED/DBD-mysql-1.2212.x86.ppd
+@end example
+@end itemize
+
+The above should work at least with ActiveState Perl Version 5.6.
+
+If you can't get the above to work, you should instead install the
+@strong{MyODBC} driver and connect to MySQL server through
+ODBC:
+
+@example
+use DBI;
+$dbh= DBI->connect("DBI:ODBC:$dsn","$user","$password") ||
+ die "Got error $DBI::errstr when connecting to $dsn\n";
+@end example
+
+
+@node Windows Perl, Perl support problems, ActiveState Perl, Perl support
+@appendixsubsec Installing the MySQL Perl Distribution on Windows
+
+The MySQL Perl distribution contains @code{DBI},
+@code{DBD:MySQL} and @code{DBD:ODBC}.
+
+@itemize @bullet
+@item
+Get the Perl distribution for Windows from
+@uref{http://www.mysql.com/download.html}.
+
+@item
+Unzip the distribution in @code{C:} so that you get a @file{C:\PERL} directory.
+
+@item
+Add the directory @file{C:\PERL\BIN} to your path.
+
+@item
+Add the directory @file{C:\PERL\BIN\MSWIN32-x86-thread} or
+@file{C:\PERL\BIN\MSWIN32-x86} to your path.
+
+@item
+Test that @code{perl} works by executing @code{perl -v} in a DOS shell.
+@end itemize
+
+
+@node Perl support problems, , Windows Perl, Perl support
+@appendixsubsec Problems Using the Perl @code{DBI}/@code{DBD} Interface
+
+@cindex problems, installing Perl
+@cindex Perl DBI/DBD, installation problems
+
+If Perl reports that it can't find the @file{../mysql/mysql.so} module,
+then the problem is probably that Perl can't locate the shared library
+@file{libmysqlclient.so}.
+
+You can fix this by any of the following methods:
+
+@itemize @bullet
+@item
+Compile the @code{Msql-Mysql-modules} distribution with @code{perl
+Makefile.PL -static -config} rather than @code{perl Makefile.PL}.
+
+@item
+Copy @code{libmysqlclient.so} to the directory where your other shared
+libraries are located (probably @file{/usr/lib} or @file{/lib}).
+
+@item
+On Linux you can add the pathname of the directory where
+@file{libmysqlclient.so} is located to the @file{/etc/ld.so.conf} file.
+
+@tindex LD_RUN_PATH environment variable
+@tindex Environment variable, LD_RUN_PATH
+@item
+Add the pathname of the directory where @file{libmysqlclient.so} is located
+to the @code{LD_RUN_PATH} environment variable.
+@end itemize
+
+If you get the following errors from @code{DBD-mysql},
+you are probably using @code{gcc} (or using an old binary compiled with
+@code{gcc}):
+
+@example
+/usr/bin/perl: can't resolve symbol '__moddi3'
+/usr/bin/perl: can't resolve symbol '__divdi3'
+@end example
+
+Add @code{-L/usr/lib/gcc-lib/... -lgcc} to the link command when the
+@file{mysql.so} library gets built (check the output from @code{make} for
+@file{mysql.so} when you compile the Perl client). The @code{-L} option
+should specify the pathname of the directory where @file{libgcc.a} is located
+on your system.
+
+Another cause of this problem may be that Perl and MySQL aren't both
+compiled with @code{gcc}. In this case, you can solve the mismatch by
+compiling both with @code{gcc}.
+
+If you get the following error from @code{Msql-Mysql-modules}
+when you run the tests:
+
+@example
+t/00base............install_driver(mysql) failed: Can't load '../blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql: ../blib/arch/auto/DBD/mysql/mysql.so: undefined symbol: uncompress at /usr/lib/perl5/5.00503/i586-linux/DynaLoader.pm line 169.
+@end example
+
+it means that you need to include the compression library, -lz, to the
+link line. This can be doing the following change in the file
+@file{lib/DBD/mysql/Install.pm}:
+
+@example
+$sysliblist .= " -lm";
+
+to
+
+$sysliblist .= " -lm -lz";
+@end example
+
+After this, you MUST run 'make realclean' and then proceed with the
+installation from the beginning.
+
+If you want to use the Perl module on a system that doesn't support dynamic
+linking (like SCO) you can generate a static version of Perl that includes
+@code{DBI} and @code{DBD-mysql}. The way this works is that you generate a
+version of Perl with the @code{DBI} code linked in and install it on top of
+your current Perl. Then you use that to build a version of Perl that
+additionally has the @code{DBD} code linked in, and install that.
+
+On SCO, you must have the following environment variables set:
+
+@example
+shell> LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib:/usr/progressive/lib
+or
+shell> LD_LIBRARY_PATH=/usr/lib:/lib:/usr/local/lib:/usr/ccs/lib:/usr/progressive/lib:/usr/skunk/lib
+shell> LIBPATH=/usr/lib:/lib:/usr/local/lib:/usr/ccs/lib:/usr/progressive/lib:/usr/skunk/lib
+shell> MANPATH=scohelp:/usr/man:/usr/local1/man:/usr/local/man:/usr/skunk/man:
+@end example
+
+First, create a Perl that includes a statically linked @code{DBI} by running
+these commands in the directory where your @code{DBI} distribution is
+located:
+
+@example
+shell> perl Makefile.PL -static -config
+shell> make
+shell> make install
+shell> make perl
+@end example
+
+Then you must install the new Perl. The output of @code{make perl} will
+indicate the exact @code{make} command you will need to execute to perform
+the installation. On SCO, this is @code{make -f Makefile.aperl inst_perl
+MAP_TARGET=perl}.
+
+Next, use the just-created Perl to create another Perl that also includes a
+statically-linked @code{DBD::mysql} by running these commands in the
+directory where your @code{Msql-Mysql-modules} distribution is located:
+
+@example
+shell> perl Makefile.PL -static -config
+shell> make
+shell> make install
+shell> make perl
+@end example
+
+Finally, you should install this new Perl. Again, the output of @code{make
+perl} indicates the command to use.
+
+
+@node Group by functions, , Perl support, Placeholder
+@appendixsec Functions for Use with @code{GROUP BY} Clauses
+
+@findex GROUP BY functions
+@findex functions, GROUP BY
+
+If you use a group function in a statement containing no @code{GROUP BY}
+clause, it is equivalent to grouping on all rows.
+
+@table @code
+@findex COUNT()
+@item COUNT(expr)
+Returns a count of the number of non-@code{NULL} values in the rows
+retrieved by a @code{SELECT} statement:
+
+@example
+mysql> select student.student_name,COUNT(*)
+ from student,course
+ where student.student_id=course.student_id
+ GROUP BY student_name;
+
+@end example
+
+@code{COUNT(*)} is somewhat different in that it returns a count of
+the number of rows retrieved, whether or not they contain @code{NULL}
+values.
+
+@code{COUNT(*)} is optimized to
+return very quickly if the @code{SELECT} retrieves from one table, no
+other columns are retrieved, and there is no @code{WHERE} clause.
+For example:
+
+@example
+mysql> select COUNT(*) from student;
+@end example
+
+@findex COUNT(DISTINCT)
+@findex DISTINCT
+@item COUNT(DISTINCT expr,[expr...])
+Returns a count of the number of different non-@code{NULL} values:
+
+@example
+mysql> select COUNT(DISTINCT results) from student;
+@end example
+
+In MySQL you can get the number of distinct expression
+combinations that don't contain NULL by giving a list of expressions.
+In ANSI SQL you would have to do a concatenation of all expressions
+inside @code{CODE(DISTINCT ..)}.
+
+@findex AVG()
+@item AVG(expr)
+Returns the average value of @code{expr}:
+
+@example
+mysql> select student_name, AVG(test_score)
+ from student
+ GROUP BY student_name;
+@end example
+
+@findex MIN()
+@findex MAX()
+@item MIN(expr)
+@itemx MAX(expr)
+Returns the minimum or maximum value of @code{expr}. @code{MIN()} and
+@code{MAX()} may take a string argument; in such cases they return the
+minimum or maximum string value. @xref{MySQL indexes}.
+
+@example
+mysql> select student_name, MIN(test_score), MAX(test_score)
+ from student
+ GROUP BY student_name;
+@end example
+
+@findex SUM()
+@item SUM(expr)
+Returns the sum of @code{expr}. Note that if the return set has no rows,
+it returns NULL!
+
+@findex STD()
+@findex STDDEV()
+@cindex Oracle compatibility
+@cindex compatibility, with Oracle
+@item STD(expr)
+@itemx STDDEV(expr)
+Returns the standard deviation of @code{expr}. This is an extension to
+ANSI SQL. The @code{STDDEV()} form of this function is provided for Oracle
+compatibility.
+
+@findex BIT_OR()
+@item BIT_OR(expr)
+Returns the bitwise @code{OR} of all bits in @code{expr}. The calculation is
+performed with 64-bit (@code{BIGINT}) precision.
+
+@findex BIT_AND()
+@item BIT_AND(expr)
+Returns the bitwise @code{AND} of all bits in @code{expr}. The calculation is
+performed with 64-bit (@code{BIGINT}) precision.
+@end table
+
+@cindex @code{GROUP BY}, extensions to ANSI SQL
+MySQL has extended the use of @code{GROUP BY}. You can use columns or
+calculations in the @code{SELECT} expressions that don't appear in
+the @code{GROUP BY} part. This stands for @emph{any possible value for this
+group}. You can use this to get better performance by avoiding sorting and
+grouping on unnecessary items. For example, you don't need to group on
+@code{customer.name} in the following query:
+
+@example
+mysql> select order.custid,customer.name,max(payments)
+ from order,customer
+ where order.custid = customer.custid
+ GROUP BY order.custid;
+@end example
+
+In ANSI SQL, you would have to add @code{customer.name} to the @code{GROUP
+BY} clause. In MySQL, the name is redundant if you don't run in
+ANSI mode.
+
+@strong{Don't use this feature} if the columns you omit from the
+@code{GROUP BY} part aren't unique in the group! You will get
+unpredictable results.
+
+In some cases, you can use @code{MIN()} and @code{MAX()} to obtain a specific
+column value even if it isn't unique. The following gives the value of
+@code{column} from the row containing the smallest value in the @code{sort}
+column:
+
+@example
+substr(MIN(concat(rpad(sort,6,' '),column)),7)
+@end example
+
+@xref{example-Maximum-column-group-row}.
+
+@cindex @code{ORDER BY}, aliases in
+@cindex aliases, in @code{ORDER BY} clauses
+@cindex @code{GROUP BY}, aliases in
+@cindex aliases, in @code{GROUP BY} clauses
+@cindex expression aliases
+@cindex aliases, for expressions
+Note that if you are using MySQL Version 3.22 (or earlier) or if
+you are trying to follow ANSI SQL, you can't use expressions in @code{GROUP
+BY} or @code{ORDER BY} clauses. You can work around this limitation by
+using an alias for the expression:
+
+@example
+mysql> SELECT id,FLOOR(value/100) AS val FROM tbl_name
+ GROUP BY id,val ORDER BY val;
+@end example
+
+In MySQL Version 3.23 you can do:
+
+@example
+mysql> SELECT id,FLOOR(value/100) FROM tbl_name ORDER BY RAND();
+@end example
+
+
+@node Function Index, Concept Index, Placeholder, Top
@unnumbered SQL command, type and function index
@printindex fn
@page
+
+
@node Concept Index, , Function Index, Top
@unnumbered Concept Index
@printindex cp
+
+
+
+
@bye
diff --git a/bdb/lock/lock_region.c b/bdb/lock/lock_region.c
index 4bd4ee4b765..5ca91a9951d 100644
--- a/bdb/lock/lock_region.c
+++ b/bdb/lock/lock_region.c
@@ -291,6 +291,7 @@ __lock_init(dbenv, lt)
sizeof(struct __db_lock), MUTEX_ALIGN, &lp)) != 0)
goto mem_err;
lp->status = DB_LSTAT_FREE;
+ lp->gen=0;
if ((ret = __db_shmutex_init(dbenv, &lp->mutex,
R_OFFSET(&lt->reginfo, &lp->mutex) + DB_FCNTL_OFF_LOCK,
MUTEX_SELF_BLOCK, &lt->reginfo,
diff --git a/client/Makefile.am b/client/Makefile.am
index 91e64123ed4..559cb27f01e 100644
--- a/client/Makefile.am
+++ b/client/Makefile.am
@@ -40,20 +40,15 @@ mysqltest_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
mysqlbinlog_SOURCES = mysqlbinlog.cc
mysqlbinlog_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
sql_src=log_event.h log_event.cc
-mysys_src=mysys_priv.h
# Fix for mit-threads
DEFS = -DUNDEF_THREADS_HACK
link_sources:
for f in $(sql_src) ; do \
- rm -f $$f; \
- @LN_CP_F@ ../sql/$$f $$f; \
- done; \
- for f in $(mysys_src); do \
- rm -f $$f; \
- @LN_CP_F@ ../mysys/$$f $$f; \
- done;
+ rm -f $(srcdir)/$$f; \
+ @LN_CP_F@ $(top_srcdir)/sql/$$f $(srcdir)/$$f; \
+ done;
thread_test.o: thread_test.c
$(COMPILE) -c @MT_INCLUDES@ $(INCLUDES) $<
diff --git a/client/mysql.cc b/client/mysql.cc
index 436675ebc15..ec8b6689dcd 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -80,7 +80,7 @@ extern "C" {
#undef bcmp // Fix problem with new readline
#undef bzero
-#ifdef __WIN__
+#if defined( __WIN__) || defined(OS2)
#include <conio.h>
#else
#include <readline/readline.h>
@@ -596,7 +596,7 @@ static int get_options(int argc, char **argv)
set_all_changeable_vars(changeable_vars);
while ((c=getopt_long(argc,argv,
- "?ABCD:LfgGHXinNoqrstTU::vVw::WEe:h:O:P:S:u:#::p::",
+ (char*) "?ABCD:LfgGHXinNoqrstTU::vVw::WEe:h:O:P:S:u:#::p::",
long_options, &option_index)) != EOF)
{
switch(c) {
@@ -795,10 +795,20 @@ static int get_options(int argc, char **argv)
return(0);
}
+#if defined(OS2)
+static char* readline( char* prompt)
+{
+#if defined(OS2)
+ static char linebuffer[254];
+#endif
+ puts( prompt);
+ return gets( linebuffer);
+}
+#endif
static int read_lines(bool execute_commands)
{
-#ifdef __WIN__
+#if defined( __WIN__) || defined(OS2)
char linebuffer[254];
#endif
char *line;
@@ -818,7 +828,7 @@ static int read_lines(bool execute_commands)
}
else
{
-#ifdef __WIN__
+#if defined( __WIN__) || defined(OS2)
if (opt_outfile && glob_buffer.is_empty())
fflush(OUTFILE);
tee_fputs(glob_buffer.is_empty() ? "mysql> " :
@@ -1513,7 +1523,7 @@ com_go(String *buffer,char *line __attribute__((unused)))
static void init_pager()
{
-#ifndef __WIN__
+#if !defined( __WIN__) && !defined( OS2)
if (!opt_nopager)
{
if (!(PAGER= popen(pager, "w")))
@@ -1529,7 +1539,7 @@ static void init_pager()
static void end_pager()
{
-#ifndef __WIN__
+#if !defined( __WIN__) && !defined( OS2)
if (!opt_nopager)
pclose(PAGER);
#endif
@@ -2452,6 +2462,9 @@ void tee_fprintf(FILE *file, const char *fmt, ...)
va_start(args, fmt);
(void) vfprintf(file, fmt, args);
+#ifdef OS2
+ fflush( file);
+#endif
if (opt_outfile)
(void) vfprintf(OUTFILE, fmt, args);
va_end(args);
@@ -2461,6 +2474,9 @@ void tee_fprintf(FILE *file, const char *fmt, ...)
void tee_fputs(const char *s, FILE *file)
{
fputs(s, file);
+#ifdef OS2
+ fflush( file);
+#endif
if (opt_outfile)
fputs(s, OUTFILE);
}
@@ -2470,6 +2486,9 @@ void tee_puts(const char *s, FILE *file)
{
fputs(s, file);
fputs("\n", file);
+#ifdef OS2
+ fflush( file);
+#endif
if (opt_outfile)
{
fputs(s, OUTFILE);
@@ -2480,11 +2499,14 @@ void tee_puts(const char *s, FILE *file)
void tee_putc(int c, FILE *file)
{
putc(c, file);
+#ifdef OS2
+ fflush( file);
+#endif
if (opt_outfile)
putc(c, OUTFILE);
}
-#ifdef __WIN__
+#if defined( __WIN__) || defined( OS2)
#include <time.h>
#else
#include <sys/times.h>
@@ -2494,7 +2516,7 @@ void tee_putc(int c, FILE *file)
static ulong start_timer(void)
{
-#ifdef __WIN__
+#if defined( __WIN__) || defined( OS2)
return clock();
#else
struct tms tms_tmp;
diff --git a/client/mysqladmin.c b/client/mysqladmin.c
index 3570cefc4ae..e95d6492949 100644
--- a/client/mysqladmin.c
+++ b/client/mysqladmin.c
@@ -132,7 +132,7 @@ static struct option long_options[] = {
{0, 0, 0, 0}
};
-CHANGEABLE_VAR changeable_vars[] = {
+static CHANGEABLE_VAR changeable_vars[] = {
{ "connect_timeout", (long*) &opt_connect_timeout, 0, 0, 3600*12, 0, 1},
{ "shutdown_timeout", (long*) &opt_shutdown_timeout, SHUTDOWN_DEF_TIMEOUT, 0,
3600*12, 0, 1},
@@ -152,7 +152,8 @@ int main(int argc,char *argv[])
load_defaults("my",load_default_groups,&argc,&argv);
set_all_changeable_vars( changeable_vars );
- while ((c=getopt_long(argc,argv,"h:i:p::u:#::P:sS:Ct:fq?vVw::WrEO:",
+ while ((c=getopt_long(argc,argv,
+ (char*) "h:i:p::u:#::P:sS:Ct:fq?vVw::WrEO:",
long_options, &option_index)) != EOF)
{
switch(c) {
@@ -1121,14 +1122,15 @@ static void wait_pidfile(char *pidfile)
uint count=0;
system_filename(buff,pidfile);
- while ((fd = open(buff, O_RDONLY)) >= 0 && count++ < opt_shutdown_timeout)
+ while ((fd = my_open(buff, O_RDONLY, MYF(0))) >= 0 &&
+ count++ < opt_shutdown_timeout)
{
- close(fd);
+ my_close(fd,MYF(0));
sleep(1);
}
if (fd >= 0)
{
- close(fd);
+ my_close(fd,MYF(0));
fprintf(stderr,
"Warning; Aborted waiting on pid file: '%s' after %d seconds\n",
buff, count-1);
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index db28184f3e7..289f5aa517f 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -21,9 +21,8 @@
#include <m_string.h>
#include <my_sys.h>
#include <getopt.h>
-#include <my_pthread.h>
-#include <thr_alarm.h>
#include <mysql.h>
+#include <time.h>
#include "log_event.h"
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES)
@@ -113,7 +112,7 @@ static void die(const char* fmt, ...)
static void print_version()
{
- printf("%s Ver 1.5 for %s at %s\n",my_progname,SYSTEM_TYPE, MACHINE_TYPE);
+ printf("%s Ver 1.6 for %s at %s\n",my_progname,SYSTEM_TYPE, MACHINE_TYPE);
}
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 5aa9addfe76..b296d24290d 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -85,11 +85,11 @@ static int first_error=0;
extern ulong net_buffer_length;
static DYNAMIC_STRING extended_row;
#include "sslopt-vars.h"
-FILE *result_file;
+FILE *md_result_file;
-enum options {OPT_FTB=256, OPT_LTB, OPT_ENC, OPT_O_ENC, OPT_ESC, OPT_KEYWORDS,
- OPT_LOCKS, OPT_DROP, OPT_OPTIMIZE, OPT_DELAYED, OPT_TABLES,
- OPT_CHARSETS_DIR, OPT_DEFAULT_CHARSET};
+enum md_options {OPT_FTB=256, OPT_LTB, OPT_ENC, OPT_O_ENC, OPT_ESC,
+ OPT_KEYWORDS, OPT_LOCKS, OPT_DROP, OPT_OPTIMIZE, OPT_DELAYED,
+ OPT_TABLES, MD_OPT_CHARSETS_DIR, MD_OPT_DEFAULT_CHARSET};
static struct option long_options[] =
{
@@ -98,12 +98,12 @@ static struct option long_options[] =
{"add-drop-table", no_argument, 0, OPT_DROP},
{"add-locks", no_argument, 0, OPT_LOCKS},
{"allow-keywords", no_argument, 0, OPT_KEYWORDS},
- {"character-sets-dir",required_argument,0, OPT_CHARSETS_DIR},
+ {"character-sets-dir",required_argument,0, MD_OPT_CHARSETS_DIR},
{"complete-insert", no_argument, 0, 'c'},
{"compress", no_argument, 0, 'C'},
{"databases", no_argument, 0, 'B'},
{"debug", optional_argument, 0, '#'},
- {"default-character-set", required_argument, 0, OPT_DEFAULT_CHARSET},
+ {"default-character-set", required_argument, 0, MD_OPT_DEFAULT_CHARSET},
{"delayed-insert", no_argument, 0, OPT_DELAYED},
{"extended-insert", no_argument, 0, 'e'},
{"fields-terminated-by", required_argument, 0, (int) OPT_FTB},
@@ -145,7 +145,7 @@ static struct option long_options[] =
static const char *load_default_groups[]= { "mysqldump","client",0 };
-CHANGEABLE_VAR changeable_vars[] = {
+CHANGEABLE_VAR md_changeable_vars[] = {
{ "max_allowed_packet", (long*) &max_allowed_packet,24*1024*1024,4096,
24*1024L*1024L,MALLOC_OVERHEAD,1024},
{ "net_buffer_length", (long*) &net_buffer_length,1024*1024L-1025,4096,
@@ -265,10 +265,10 @@ puts("\
print_defaults("my",load_default_groups);
printf("\nPossible variables for option --set-variable (-O) are:\n");
- for (i=0 ; changeable_vars[i].name ; i++)
+ for (i=0 ; md_changeable_vars[i].name ; i++)
printf("%-20s current value: %lu\n",
- changeable_vars[i].name,
- (ulong) *changeable_vars[i].varptr);
+ md_changeable_vars[i].name,
+ (ulong) *md_changeable_vars[i].varptr);
} /* usage */
@@ -290,9 +290,9 @@ static int get_options(int *argc,char ***argv)
int c,option_index;
my_bool tty_password=0;
- result_file=stdout;
+ md_result_file=stdout;
load_defaults("my",load_default_groups,argc,argv);
- set_all_changeable_vars(changeable_vars);
+ set_all_changeable_vars(md_changeable_vars);
while ((c=getopt_long(*argc,*argv,
"#::p::h:u:O:P:r:S:T:EBaAcCdefFlnqtvVw:?Ix",
long_options, &option_index)) != EOF)
@@ -307,10 +307,10 @@ static int get_options(int *argc,char ***argv)
case 'A':
opt_alldbs=1;
break;
- case OPT_DEFAULT_CHARSET:
+ case MD_OPT_DEFAULT_CHARSET:
default_charset= optarg;
break;
- case OPT_CHARSETS_DIR:
+ case MD_OPT_CHARSETS_DIR:
charsets_dir= optarg;
break;
case 'f':
@@ -332,7 +332,7 @@ static int get_options(int *argc,char ***argv)
break;
#endif
case 'O':
- if (set_changeable_var(optarg, changeable_vars))
+ if (set_changeable_var(optarg, md_changeable_vars))
{
usage();
return(1);
@@ -355,7 +355,7 @@ static int get_options(int *argc,char ***argv)
opt_mysql_port= (unsigned int) atoi(optarg);
break;
case 'r':
- if (!(result_file = my_fopen(optarg, O_WRONLY | O_BINARY,
+ if (!(md_result_file = my_fopen(optarg, O_WRONLY | O_BINARY,
MYF(MY_WME))))
exit(1);
break;
@@ -602,7 +602,7 @@ static uint getTableStructure(char *table, char* db)
char *strpos, *table_name;
const char *delayed;
char name_buff[NAME_LEN+3],table_buff[NAME_LEN+3];
- FILE *sql_file = result_file;
+ FILE *sql_file = md_result_file;
DBUG_ENTER("getTableStructure");
delayed= opt_delayed ? " DELAYED " : "";
@@ -973,15 +973,14 @@ static void dumpTable(uint numFields, char *table)
}
else
{
- fprintf(result_file,"\n#\n# Dumping data for table '%s'\n", table);
+ fprintf(md_result_file,"\n#\n# Dumping data for table '%s'\n", table);
sprintf(query, "SELECT * FROM %s", quote_name(table,table_buff));
if (where)
{
- fprintf(result_file,"-- WHERE: %s\n",where);
+ fprintf(md_result_file,"-- WHERE: %s\n",where);
strxmov(strend(query), " WHERE ",where,NullS);
}
- fputs("\n\n", result_file);
-
+ fputs("\n\n", md_result_file);
if (mysql_query(sock, query))
{
DBerror(sock, "when retrieving data from server");
@@ -1007,7 +1006,7 @@ static void dumpTable(uint numFields, char *table)
}
if (opt_lock)
- fprintf(result_file,"LOCK TABLES %s WRITE;\n",
+ fprintf(md_result_file,"LOCK TABLES %s WRITE;\n",
quote_name(table,table_buff));
total_length=net_buffer_length; /* Force row break */
@@ -1021,7 +1020,7 @@ static void dumpTable(uint numFields, char *table)
ulong *lengths=mysql_fetch_lengths(res);
rownr++;
if (!extended_insert)
- fputs(insert_pat,result_file);
+ fputs(insert_pat,md_result_file);
mysql_field_seek(res,0);
for (i = 0; i < mysql_num_fields(res); i++)
@@ -1075,17 +1074,17 @@ static void dumpTable(uint numFields, char *table)
else
{
if (i)
- fputc(',',result_file);
+ fputc(',',md_result_file);
if (row[i])
{
if (!IS_NUM_FIELD(field))
- unescape(result_file, row[i], lengths[i]);
+ unescape(md_result_file, row[i], lengths[i]);
else
- fputs(row[i],result_file);
+ fputs(row[i],md_result_file);
}
else
{
- fputs("NULL",result_file);
+ fputs("NULL",md_result_file);
}
}
}
@@ -1098,25 +1097,25 @@ static void dumpTable(uint numFields, char *table)
if (total_length + row_length < net_buffer_length)
{
total_length += row_length;
- fputc(',',result_file); /* Always row break */
- fputs(extended_row.str,result_file);
+ fputc(',',md_result_file); /* Always row break */
+ fputs(extended_row.str,md_result_file);
}
else
{
if (row_break)
- fputs(";\n", result_file);
+ fputs(";\n", md_result_file);
row_break=1; /* This is first row */
- fputs(insert_pat,result_file);
- fputs(extended_row.str,result_file);
+ fputs(insert_pat,md_result_file);
+ fputs(extended_row.str,md_result_file);
total_length = row_length+init_length;
}
}
else
- fputs(");\n", result_file);
+ fputs(");\n", md_result_file);
}
if (extended_insert && row_break)
- fputs(";\n", result_file); /* If not empty table */
- fflush(result_file);
+ fputs(";\n", md_result_file); /* If not empty table */
+ fflush(md_result_file);
if (mysql_errno(sock))
{
sprintf(query,"%s: Error %d: %s when dumping table '%s' at row: %ld\n",
@@ -1130,7 +1129,7 @@ static void dumpTable(uint numFields, char *table)
return;
}
if (opt_lock)
- fputs("UNLOCK TABLES;\n", result_file);
+ fputs("UNLOCK TABLES;\n", md_result_file);
mysql_free_result(res);
}
} /* dumpTable */
@@ -1206,11 +1205,11 @@ static int init_dumping(char *database)
{
if (opt_databases || opt_alldbs)
{
- fprintf(result_file,"\n#\n# Current Database: %s\n#\n", database);
+ fprintf(md_result_file,"\n#\n# Current Database: %s\n#\n", database);
if (!opt_create_db)
- fprintf(result_file,"\nCREATE DATABASE /*!32312 IF NOT EXISTS*/ %s;\n",
+ fprintf(md_result_file,"\nCREATE DATABASE /*!32312 IF NOT EXISTS*/ %s;\n",
database);
- fprintf(result_file,"\nUSE %s;\n", database);
+ fprintf(md_result_file,"\nUSE %s;\n", database);
}
}
if (extended_insert)
@@ -1224,6 +1223,7 @@ static int dump_all_tables_in_db(char *database)
{
char *table;
uint numrows;
+ char table_buff[NAME_LEN+3];
if (init_dumping(database))
return 1;
@@ -1233,7 +1233,7 @@ static int dump_all_tables_in_db(char *database)
init_dynamic_string(&query, "LOCK TABLES ", 256, 1024);
for (numrows=0 ; (table = getTableName(1)) ; numrows++)
{
- dynstr_append(&query, table);
+ dynstr_append(&query, quote_name(table,table_buff));
dynstr_append(&query, " READ /*!32311 LOCAL */,");
}
if (numrows && mysql_real_query(sock, query.str, query.length-1))
@@ -1263,6 +1263,7 @@ static int dump_all_tables_in_db(char *database)
static int dump_selected_tables(char *db, char **table_names, int tables)
{
uint numrows;
+ char table_buff[NAME_LEN+3];
if (init_dumping(db))
return 1;
@@ -1274,7 +1275,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
init_dynamic_string(&query, "LOCK TABLES ", 256, 1024);
for (i=0 ; i < tables ; i++)
{
- dynstr_append(&query, table_names[i]);
+ dynstr_append(&query, quote_name(table_names[i],table_buff));
dynstr_append(&query, " READ /*!32311 LOCAL */,");
}
if (mysql_real_query(sock, query.str, query.length-1))
@@ -1342,7 +1343,7 @@ int main(int argc, char **argv)
if (dbConnect(current_host, current_user, opt_password))
exit(EX_MYSQLERR);
if (!path)
- write_heder(result_file, *argv);
+ write_heder(md_result_file, *argv);
if (opt_first_slave)
{
@@ -1378,9 +1379,9 @@ int main(int argc, char **argv)
}
}
dbDisconnect(current_host);
- fputs("\n", result_file);
- if (result_file != stdout)
- my_fclose(result_file, MYF(0));
+ fputs("\n", md_result_file);
+ if (md_result_file != stdout)
+ my_fclose(md_result_file, MYF(0));
my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
if (extended_insert)
dynstr_free(&extended_row);
diff --git a/client/mysqlimport.c b/client/mysqlimport.c
index 79f0a8d584e..cbdedf56cbe 100644
--- a/client/mysqlimport.c
+++ b/client/mysqlimport.c
@@ -41,7 +41,7 @@ static char *field_escape(char *to,const char *from,uint length);
static char *add_load_option(char *ptr,const char *object,
const char *statement);
-static my_bool verbose=0,lock_tables=0,ignore_errors=0,delete=0,
+static my_bool verbose=0,lock_tables=0,ignore_errors=0,opt_delete=0,
replace=0,silent=0,ignore=0,opt_compress=0,opt_local_file=0;
static MYSQL mysql_connection;
@@ -54,8 +54,8 @@ static uint opt_mysql_port=0;
static my_string opt_mysql_unix_port=0;
#include "sslopt-vars.h"
-enum options {OPT_FTB=256, OPT_LTB, OPT_ENC, OPT_O_ENC, OPT_ESC,
- OPT_LOW_PRIORITY, OPT_CHARSETS_DIR, OPT_DEFAULT_CHARSET};
+enum mi_options {OPT_FTB=256, OPT_LTB, OPT_ENC, OPT_O_ENC, OPT_ESC,
+ OPT_LOW_PRIORITY, OPT_CHARSETS_DIR, OPT_DEFAULT_CHARSET};
static struct option long_options[] =
{
@@ -173,7 +173,8 @@ static int get_options(int *argc, char ***argv)
int c, option_index;
my_bool tty_password=0;
- while ((c=getopt_long(*argc,*argv,"#::p::c:h:u:P:S:CdfilLrsvV?IW",
+ while ((c=getopt_long(*argc,*argv,
+ (char*) "#::p::c:h:u:P:S:CdfilLrsvV?IW",
long_options, &option_index)) != EOF)
{
switch(c) {
@@ -190,7 +191,7 @@ static int get_options(int *argc, char ***argv)
charsets_dir= optarg;
break;
case 'd':
- delete= 1;
+ opt_delete= 1;
break;
case 'f':
ignore_errors= 1;
@@ -313,7 +314,7 @@ static int write_to_table(char *filename, MYSQL *sock)
else
my_load_path(hard_path, filename, NULL); /* filename includes the path */
- if (delete)
+ if (opt_delete)
{
if (verbose)
fprintf(stdout, "Deleting the old data from table %s\n", tablename);
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 236b0e1dc9b..f269dd373c6 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -51,7 +51,11 @@
#include <mysql.h>
#include <mysql_version.h>
#include <m_ctype.h>
-#include <my_config.h>
+#ifdef OS2
+#include <config-os2.h>
+#else
+ #include <my_config.h>
+#endif
#include <my_dir.h>
#include <hash.h>
#include <mysqld_error.h>
@@ -247,13 +251,12 @@ static int eval_result = 0;
/* Disable functions that only exist in MySQL 4.0 */
#if MYSQL_VERSION_ID < 40000
-static void mysql_enable_rpl_parse(MYSQL* mysql) {}
-static void mysql_disable_rpl_parse(MYSQL* mysql) {}
-static int mysql_rpl_parse_enabled(MYSQL* mysql) { return 1; }
-static int mysql_rpl_probe(MYSQL *mysql) { return 1; }
+static void mysql_enable_rpl_parse(MYSQL* mysql __attribute__((unused))) {}
+static void mysql_disable_rpl_parse(MYSQL* mysql __attribute__((unused))) {}
+static int mysql_rpl_parse_enabled(MYSQL* mysql __attribute__((unused))) { return 1; }
+static int mysql_rpl_probe(MYSQL *mysql __attribute__((unused))) { return 1; }
#endif
-
static void do_eval(DYNAMIC_STRING* query_eval, const char* query)
{
const char* p;
@@ -829,6 +832,17 @@ int do_sleep(struct st_query* q)
if (!*p)
die("Missing argument in sleep\n");
t.tv_usec = 0;
+
+#ifdef OS2
+
+ if (opt_sleep)
+ DosSleep( opt_sleep * 1000);
+ else
+ DosSleep( atof( p) * 1000);
+
+ return 0;
+
+#else
if (opt_sleep)
t.tv_sec = opt_sleep;
else
@@ -858,6 +872,7 @@ int do_sleep(struct st_query* q)
}
t.tv_usec *= dec_mul;
return select(0,0,0,0, &t);
+#endif
}
static void get_file_name(char *filename, struct st_query* q)
@@ -1889,8 +1904,8 @@ static VAR* var_init(VAR* v, const char* name, int name_len, const char* val,
static void var_free(void* v)
{
- my_free(((VAR*)v)->str_val, MYF(MY_WME));
- my_free(v, MYF(MY_WME));
+ my_free(((VAR*) v)->str_val, MYF(MY_WME));
+ my_free((char*) v, MYF(MY_WME));
}
@@ -2751,7 +2766,7 @@ uint replace_strings(REPLACE *rep, my_string *start,uint *max_length,
{
reg1 REPLACE *rep_pos;
reg2 REPLACE_STRING *rep_str;
- my_string to,end,pos,new;
+ my_string to,end,pos,new_str;
end=(to= *start) + *max_length-1;
rep_pos=rep+1;
@@ -2763,10 +2778,10 @@ uint replace_strings(REPLACE *rep, my_string *start,uint *max_length,
if (to == end)
{
(*max_length)+=8192;
- if (!(new=my_realloc(*start,*max_length,MYF(MY_WME))))
+ if (!(new_str=my_realloc(*start,*max_length,MYF(MY_WME))))
return (uint) -1;
- to=new+(to - *start);
- end=(*start=new)+ *max_length-1;
+ to=new_str+(to - *start);
+ end=(*start=new_str)+ *max_length-1;
}
*to++= *from++;
}
@@ -2778,10 +2793,10 @@ uint replace_strings(REPLACE *rep, my_string *start,uint *max_length,
if (to == end)
{
(*max_length)*=2;
- if (!(new=my_realloc(*start,*max_length,MYF(MY_WME))))
+ if (!(new_str=my_realloc(*start,*max_length,MYF(MY_WME))))
return (uint) -1;
- to=new+(to - *start);
- end=(*start=new)+ *max_length-1;
+ to=new_str+(to - *start);
+ end=(*start=new_str)+ *max_length-1;
}
*to++= *pos;
}
diff --git a/config.guess b/config.guess
index eb88894019f..a3369c0f908 100755
--- a/config.guess
+++ b/config.guess
@@ -790,7 +790,7 @@ EOF
i?86:DYNIX/ptx:4*:*)
echo i386-sequent-sysv4
exit 0 ;;
- i?86:UNIX_SV:4.2MP:2.*)
+ i*86:UNIX_SV:4.2MP:2.*)
# Unixware is an offshoot of SVR4, but it has its own version
# number series starting with 2...
# I am not positive that other SVR4 systems won't match this,
@@ -798,64 +798,24 @@ EOF
# Use sysv4.2uw... so that sysv4* matches it.
echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
exit 0 ;;
- i?86:UnixWare:5:7) # Unixware 7.0.0t (uname -v reports 7) has native threads
- # uname -m incorrectly reports CPU type (uname -m reports i386 always)
- # compiler supports following optimization flags:i386,i486,pentium,pentium_pro and blended
- # compiler does NOT support: i586,i686,Pentium,Pentium Pro,pentiumpro,pentium_II or Pentium II
- if /bin/uname machine 2>/dev/null >/dev/null ; then
- (/bin/uname machine|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
- (/bin/uname machine|egrep 'Pentium' >/dev/null) && UNAME_MACHINE=pentium
- (/bin/uname machine|egrep 'Pentium Pro' >/dev/null) && UNAME_MACHINE=pentium_pro
- (/bin/uname machine|egrep 'Pentium II' >/dev/null) && UNAME_MACHINE=pentium_II
- echo ${UNAME_MACHINE}-pc-unixware7.0.0
- else
- echo ${UNAME_MACHINE}-pc-unixware7.0.0
- fi
- exit 0 ;;
- i?86:UnixWare:5:7.0.1) # Unixware 7.0.1 (uname -v reports 7.0.1) has POSIX threads
- # uname -m incorrectly reports CPU type (uname -m reports i386 always)
- # compiler supports following optimization flags:i386,i486,pentium,pentium_pro and blended
- # compiler does NOT support: i586,i686,Pentium,Pentium Pro,pentiumpro,pentium_II or Pentium II
- if /bin/uname machine 2>/dev/null >/dev/null ; then
- (/bin/uname machine|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
- (/bin/uname machine|egrep 'Pentium' >/dev/null) && UNAME_MACHINE=pentium
- (/bin/uname machine|egrep 'Pentium Pro' >/dev/null) && UNAME_MACHINE=pentium_pro
- (/bin/uname machine|egrep 'Pentium II' >/dev/null) && UNAME_MACHINE=pentium_II
- echo ${UNAME_MACHINE}-pc-unixware7.0.1
- else
- echo ${UNAME_MACHINE}-pc-unixware7.0.1
- fi
- exit 0 ;;
- # SysVr5/Unixware7
- i?86:*:5*:* | i?86:SYSTEM_V:5*:*)
- if uname -a | grep SCO >/dev/null 2>/dev/null ; then
- (/bin/uname -s|egrep UnixWare >/dev/null) && UNAME_VER=uw${UNAME_VERSION}
- if /bin/uname -X 2>/dev/null >/dev/null ; then
- (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
- (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) && UNAME_MACHINE=i586
- fi
- echo ${UNAME_MACHINE}-sco-sysv${UNAME_RELEASE}${UNAME_VER}
- else
- echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}
- fi
- exit 0 ;;
-
- i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
+ i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+ UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
- echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE}
+ echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
else
- echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
+ echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
fi
exit 0 ;;
- i?86:*:5:7*)
- UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
- (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
- (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) && UNAME_MACHINE=i586
- (/bin/uname -X|egrep '^Machine.*Pent.*II' >/dev/null) && UNAME_MACHINE=i686
- (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) && UNAME_MACHINE=i585
- echo ${UNAME_MACHINE}-${UNAME_SYSTEM}${UNAME_VERSION}-sysv${UNAME_RELEASE}
+ i*86:*:5:[78]*)
+ case `/bin/uname -X | grep "^Machine"` in
+ *486*) UNAME_MACHINE=i486 ;;
+ *Pentium) UNAME_MACHINE=i586 ;;
+ *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+ esac
+ echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+
exit 0 ;;
- i?86:*:3.2:*)
+ i*86:*:3.2:*)
if test -f /usr/options/cb.name; then
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
diff --git a/config.sub b/config.sub
index 8f28d3f7be8..70716b4e206 100755
--- a/config.sub
+++ b/config.sub
@@ -45,23 +45,66 @@
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
# It is wrong to echo any other type of specification.
-if [ x$1 = x ]
-then
- echo Configuration name missing. 1>&2
- echo "Usage: $0 CPU-MFR-OPSYS" 1>&2
- echo "or $0 ALIAS" 1>&2
- echo where ALIAS is a recognized configuration type. 1>&2
- exit 1
-fi
+me=`echo "$0" | sed -e 's,.*/,,'`
-# First pass through any local machine types.
-case $1 in
- *local*)
- echo $1
- exit 0
- ;;
- *)
- ;;
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+ $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit 0 ;;
+ --version | -v )
+ echo "$version" ; exit 0 ;;
+ --help | --h* | -h )
+ echo "$usage"; exit 0 ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help"
+ exit 1 ;;
+
+ *local*)
+ # First pass through any local machine types.
+ echo $1
+ exit 0;;
+
+ * )
+ break ;;
+ esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+ exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+ exit 1;;
esac
# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
@@ -168,27 +211,40 @@ esac
case $basic_machine in
# Recognize the basic CPU types without company name.
# Some are omitted here because they have special meanings below.
- tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \
- | arme[lb] | pyramid | mn10200 | mn10300 | tron | a29k \
+ tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc \
+ | arm | arme[lb] | arm[bl]e | armv[2345] | armv[345][lb] | strongarm | xscale \
+ | pyramid | mn10200 | mn10300 | tron | a29k \
| 580 | i960 | h8300 \
+ | x86 | ppcbe | mipsbe | mipsle | shbe | shle \
| hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \
- | alpha | alphaev[4-7] | alphaev56 | alphapca5[67] \
- | we32k | ns16k | clipper | i370 | sh | powerpc | powerpcle \
- | 1750a | dsp16xx | pdp11 | mips16 | mips64 | mipsel | mips64el \
+ | hppa64 \
+ | alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \
+ | alphaev6[78] \
+ | we32k | ns16k | clipper | i370 | sh | sh[34] \
+ | powerpc | powerpcle \
+ | 1750a | dsp16xx | pdp10 | pdp11 \
+ | mips16 | mips64 | mipsel | mips64el \
| mips64orion | mips64orionel | mipstx39 | mipstx39el \
| mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \
- | mips64vr5000 | miprs64vr5000el \
- | sparc | sparclet | sparclite | sparc64 | sparcv9 | v850 | c4x \
- | thumb | d10v)
+ | mips64vr5000 | mips64vr5000el | mcore | s390 | s390x \
+ | sparc | sparclet | sparclite | sparc64 | sparcv9 | sparcv9b \
+ | v850 | c4x \
+ | thumb | d10v | d30v | fr30 | avr | openrisc | tic80 \
+ | pj | pjl | h8500 | z8k)
basic_machine=$basic_machine-unknown
;;
- m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | h8500 | w65)
+ m6811 | m68hc11 | m6812 | m68hc12)
+ # Motorola 68HC11/12.
+ basic_machine=$basic_machine-unknown
+ os=-none
+ ;;
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
;;
# We use `pc' rather than `unknown'
# because (1) that's what they normally are, and
# (2) the word "unknown" tends to confuse beginning users.
- i[34567]86)
+ i*86 | x86_64)
basic_machine=$basic_machine-pc
;;
# Object if more than one company name word.
@@ -197,23 +253,31 @@ case $basic_machine in
exit 1
;;
# Recognize the basic CPU types with company name.
- vax-* | tahoe-* | i[34567]86-* | i860-* | m32r-* | m68k-* | m68000-* \
- | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \
+ # FIXME: clean up the formatting here.
+ vax-* | tahoe-* | i*86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \
+ | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | c[123]* \
+ | arm-* | armbe-* | armle-* | armv*-* | strongarm-* | xscale-* \
| mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
| power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \
| xmp-* | ymp-* \
- | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* | hppa2.0n-* \
- | alpha-* | alphaev[4-7]-* | alphaev56-* | alphapca5[67]-* \
+ | x86-* | ppcbe-* | mipsbe-* | mipsle-* | shbe-* | shle-* \
+ | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \
+ | hppa2.0n-* | hppa64-* \
+ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphapca5[67]-* \
+ | alphaev6[78]-* \
| we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \
| clipper-* | orion-* \
- | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
- | sparc64-* | sparcv9-* | sparc86x-* | mips16-* | mips64-* | mipsel-* \
+ | sparclite-* | pdp10-* | pdp11-* | sh-* | sh[34]-* | sh[34]eb-* \
+ | powerpc-* | powerpcle-* | sparc64-* | sparcv9-* | sparcv9b-* | sparc86x-* \
+ | mips16-* | mips64-* | mipsel-* \
| mips64el-* | mips64orion-* | mips64orionel-* \
| mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \
- | mipstx39-* | mipstx39el-* \
- | f301-* | armv*-* | t3e-* \
+ | mipstx39-* | mipstx39el-* | mcore-* \
+ | f30[01]-* | f700-* | s390-* | s390x-* | sv1-* | t3e-* \
+ | [cjt]90-* \
| m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \
- | thumb-* | v850-* | d30v-* | tic30-* | c30-* | ia64-* )
+ | thumb-* | v850-* | d30v-* | tic30-* | tic80-* | c30-* | fr30-* \
+ | bs2000-* | tic54x-* | c54x-* | x86_64-* | pj-* | pjl-*)
;;
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
@@ -431,22 +495,21 @@ case $basic_machine in
;;
i370-ibm* | ibm*)
basic_machine=i370-ibm
- os=-mvs
;;
# I'm not sure what "Sysv32" means. Should this be sysv3.2?
- i[34567]86v32)
+ i*86v32)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv32
;;
- i[34567]86v4*)
+ i*86v4*)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv4
;;
- i[34567]86v)
+ i*86v)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv
;;
- i[34567]86sol2)
+ i*86sol2)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-solaris2
;;
@@ -577,9 +640,16 @@ case $basic_machine in
basic_machine=i960-intel
os=-mon960
;;
+ nonstopux)
+ basic_machine=mips-compaq
+ os=-nonstopux
+ ;;
np1)
basic_machine=np1-gould
;;
+ nsr-tandem)
+ basic_machine=nsr-tandem
+ ;;
op50n-* | op60c-*)
basic_machine=hppa1.1-oki
os=-proelf
@@ -609,28 +679,28 @@ case $basic_machine in
pc532 | pc532-*)
basic_machine=ns32k-pc532
;;
- pentium | p5 | k5 | k6 | nexen)
+ pentium | p5 | k5 | k6 | nexgen)
basic_machine=i586-pc
;;
- pentiumpro | p6 | 6x86)
+ pentiumpro | p6 | 6x86 | athlon)
basic_machine=i686-pc
;;
pentiumii | pentium2)
- basic_machine=i786-pc
+ basic_machine=i686-pc
;;
- pentium-* | p5-* | k5-* | k6-* | nexen-*)
+ pentium-* | p5-* | k5-* | k6-* | nexgen-*)
basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
- pentiumpro-* | p6-* | 6x86-*)
+ pentiumpro-* | p6-* | 6x86-* | athlon-*)
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentiumii-* | pentium2-*)
- basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pn)
basic_machine=pn-gould
;;
- power) basic_machine=rs6000-ibm
+ power) basic_machine=power-ibm
;;
ppc) basic_machine=powerpc-unknown
;;
@@ -645,6 +715,10 @@ case $basic_machine in
ps2)
basic_machine=i386-ibm
;;
+ pw32)
+ basic_machine=i586-unknown
+ os=-pw32
+ ;;
rom68k)
basic_machine=m68k-rom68k
os=-coff
@@ -855,6 +929,9 @@ case $basic_machine in
basic_machine=c4x-none
os=-coff
;;
+ *-unknown)
+ # Make sure to match an already-canonicalized machine name.
+ ;;
*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
exit 1
@@ -917,14 +994,29 @@ case $os in
| -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -chorusos* | -chorusrdb* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
- | -interix* | -uwin* | -rhapsody* | -darwin* | -openstep* | -oskit*)
+ | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* | -os2*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
+ -qnx*)
+ case $basic_machine in
+ x86-* | i*86-*)
+ ;;
+ *)
+ os=-nto$os
+ ;;
+ esac
+ ;;
+ -nto*)
+ os=-nto-qnx
+ ;;
-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
| -windows* | -osx | -abug | -netware* | -os9* | -beos* \
- | -macos* | -mpw* | -magic* | -mon960* | -lnews*)
+ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
;;
-mac*)
os=`echo $os | sed -e 's|mac|macos|'`
@@ -1225,3 +1317,11 @@ case $basic_machine in
esac
echo $basic_machine$os
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/configure.in b/configure.in
index 71089e47963..cac4a3f5f85 100644
--- a/configure.in
+++ b/configure.in
@@ -264,7 +264,16 @@ case "$target_os" in
;;
esac
;;
- sysv5uw7*)
+ sysv5UnixWare*)
+ if test "$GCC" != "yes"; then
+ # We are using built-in inline function
+ CFLAGS="$CFLAGS -Kalloca"
+ CXX="$CXX -DNO_CPLUSPLUS_ALLOCA"
+ else
+ CXX="$CXX -DNO_CPLUSPLUS_ALLOCA"
+ fi
+ ;;
+ sysv5OpenUNIX8*)
if test "$GCC" != "yes"; then
# We are using built-in inline function
CFLAGS="$CFLAGS -Kalloca"
@@ -274,7 +283,6 @@ case "$target_os" in
fi
;;
esac
-
AC_SUBST(CC)
AC_SUBST(CFLAGS)
AC_SUBST(CXX)
@@ -1023,7 +1031,7 @@ fi
if test "$with_named_thread" = "no"
then
AC_MSG_CHECKING("SCO UnixWare7 native threads")
- if expr "$SYSTEM_TYPE" : ".*unixware7*" > /dev/null
+ if expr "$SYSTEM_TYPE" : ".*UnixWare*" > /dev/null
then
if test -f /usr/lib/libthread.so -o -f /usr/lib/libthreadT.so
then
@@ -1053,6 +1061,45 @@ then
fi
fi
+# Hack for Caldera OpenUNIX8
+#
+if test "$with_named_thread" = "no"
+then
+ AC_MSG_CHECKING("OpenUNIX8 native threads")
+ if expr "$SYSTEM_TYPE" : ".*OpenUNIX*" > /dev/null
+ then
+ if test -f /usr/lib/libthread.so -o -f /usr/lib/libthreadT.so
+ then
+ MYSQL_REMOVE_SOCKET_FROM_LIBS_HACK
+ with_named_thread="-Kthread -lsocket -lnsl"
+ if expr "$SYSTEM_TYPE" : ".*unixware7.0.0" > /dev/null
+ then
+# AC_DEFINE(HAVE_OpenUNIX8_THREADS)
+ AC_DEFINE(HAVE_UNIXWARE7_THREADS)
+ else
+# AC_DEFINE(HAVE_OpenUNIX8_POSIX)
+ AC_DEFINE(HAVE_UNIXWARE7_POSIX)
+ fi
+ # We must have cc
+ AC_MSG_CHECKING("for gcc")
+ if expr "$CC" : ".*gcc.*"
+ then
+ { echo "configure: error: On OpenUNIX8 and UnixWare7 MySQL must be compiled with cc. See the Installation chapter in the Reference Manual." 1>&2; exit 1; };
+ else
+# CC="$CC -Kthread -DOpenUNIX8";
+# CXX="$CXX -Kthread -DOpenUNIX8";
+ CC="$CC -Kthread -DUNIXWARE_7";
+ CXX="$CXX -Kthread -DUNIXWARE_7";
+ fi
+ AC_MSG_RESULT("yes")
+ else
+ { echo "configure: error: Can't find thread libs on Caldera OpenUNIX 8. See the Installation chapter in the Reference Manual." 1>&2; exit 1; };
+ fi
+ else
+ AC_MSG_RESULT("no")
+ fi
+fi
+
# Hack for Siemens UNIX
if test "$with_named_thread" = "no" -a "$with_mit_threads" = "no"
then
@@ -1414,7 +1461,7 @@ AC_CHECK_FUNCS(alarm bmove \
getrusage getpwuid getcwd getrlimit getwd index stpcpy locking longjmp \
perror pread realpath readlink rename \
socket strnlen madvise mkstemp \
- strtol strtoul strtoull snprintf tempnam thr_setconcurrency \
+ strtol strtoul strtoll strtoull snprintf tempnam thr_setconcurrency \
gethostbyaddr_r gethostbyname_r getpwnam \
bfill bzero bcmp strstr strpbrk strerror \
tell atod memcpy memmove \
@@ -1452,7 +1499,8 @@ then
CXXFLAGS="$CXXFLAGS -Werror"
fi
AC_TRY_COMPILE(
-[#if !defined(SCO) && !defined(__osf__)
+[#undef inline
+#if !defined(SCO) && !defined(__osf__)
#define _REENTRANT
#endif
#include <pthread.h>
@@ -1484,7 +1532,8 @@ then
CXXFLAGS="$CXXFLAGS -Werror"
fi
AC_TRY_COMPILE(
-[#if !defined(SCO) && !defined(__osf__)
+[#undef inline
+#if !defined(SCO) && !defined(__osf__)
#define _REENTRANT
#endif
#include <pthread.h>
@@ -1515,7 +1564,8 @@ then
CXXFLAGS="$CXXFLAGS -Werror"
fi
AC_TRY_COMPILE(
-[#if !defined(SCO) && !defined(__osf__)
+[#undef inline
+#if !defined(SCO) && !defined(__osf__)
#define _REENTRANT
#endif
#include <pthread.h>
@@ -1526,7 +1576,7 @@ AC_TRY_COMPILE(
#include <netdb.h>],
[int skr;
- skr = gethostbyname_r((const char *) 0, (struct hostent*) 0, (hostent_data*) 0);],
+ skr = gethostbyname_r((const char *) 0, (struct hostent*) 0, (struct hostent_data*) 0);],
mysql_cv_gethostname_arg=hostent_data, mysql_cv_gethostname_arg=char))
AC_LANG_RESTORE
CXXFLAGS="$ac_save_CXXFLAGS"
diff --git a/dbug/dbug.c b/dbug/dbug.c
index f600b281007..cfe4ca161c6 100644
--- a/dbug/dbug.c
+++ b/dbug/dbug.c
@@ -307,6 +307,7 @@ static char *static_strtok(char *s1,pchar chr);
* Macros and defines for testing file accessibility under UNIX and MSDOS.
*/
+#undef EXISTS
#if !defined(HAVE_ACCESS) || defined(MSDOS)
#define EXISTS(pathname) (FALSE) /* Assume no existance */
#define Writable(name) (TRUE)
@@ -489,8 +490,7 @@ static CODE_STATE static_code_state = { 0,0,"?func","?file",NULL,0,NULL,
*
*/
-void _db_push_ (control)
-const char *control;
+void _db_push_ (const char *control)
{
reg1 char *scan;
reg2 struct link *temp;
@@ -691,15 +691,14 @@ void _db_pop_ ()
*
*/
-void _db_enter_ (_func_, _file_, _line_, _sfunc_, _sfile_, _slevel_,
- _sframep_)
-const char *_func_;
-const char *_file_;
-uint _line_;
-const char **_sfunc_;
-const char **_sfile_;
-uint *_slevel_;
-char ***_sframep_ __attribute__((unused));
+void _db_enter_ (
+const char *_func_,
+const char *_file_,
+uint _line_,
+const char **_sfunc_,
+const char **_sfile_,
+uint *_slevel_,
+char ***_sframep_ __attribute__((unused)))
{
reg1 CODE_STATE *state;
@@ -777,11 +776,11 @@ char ***_sframep_ __attribute__((unused));
*
*/
-void _db_return_ (_line_, _sfunc_, _sfile_, _slevel_)
-uint _line_;
-const char **_sfunc_;
-const char **_sfile_;
-uint *_slevel_;
+void _db_return_ (
+uint _line_,
+const char **_sfunc_,
+const char **_sfile_,
+uint *_slevel_)
{
CODE_STATE *state;
@@ -851,9 +850,9 @@ uint *_slevel_;
*
*/
-void _db_pargs_ (_line_, keyword)
-uint _line_;
-const char *keyword;
+void _db_pargs_ (
+uint _line_,
+const char *keyword)
{
CODE_STATE *state=code_state();
state->u_line = _line_;
@@ -934,10 +933,11 @@ void _db_doprnt_ (const char *format,...)
* Is used to examine corrputed memory or arrays.
*/
-void _db_dump_(_line_,keyword,memory,length)
-uint _line_,length;
-const char *keyword;
-const char *memory;
+void _db_dump_(
+uint _line_,
+const char *keyword,
+const char *memory,
+uint length)
{
int pos;
char dbuff[90];
@@ -1004,11 +1004,11 @@ const char *memory;
*
*/
-static struct link *ListParse (ctlp)
-char *ctlp;
+static struct link *ListParse (
+char *ctlp)
{
REGISTER char *start;
- REGISTER struct link *new;
+ REGISTER struct link *new_malloc;
REGISTER struct link *head;
head = NULL;
@@ -1020,10 +1020,10 @@ char *ctlp;
if (*ctlp == ',') {
*ctlp++ = EOS;
}
- new = (struct link *) DbugMalloc (sizeof (struct link));
- new -> str = StrDup (start);
- new -> next_link = head;
- head = new;
+ new_malloc = (struct link *) DbugMalloc (sizeof (struct link));
+ new_malloc -> str = StrDup (start);
+ new_malloc -> next_link = head;
+ head = new_malloc;
}
return (head);
}
@@ -1052,9 +1052,9 @@ char *ctlp;
*
*/
-static BOOLEAN InList (linkp, cp)
-struct link *linkp;
-const char *cp;
+static BOOLEAN InList (
+struct link *linkp,
+const char *cp)
{
REGISTER struct link *scan;
REGISTER BOOLEAN result;
@@ -1098,7 +1098,7 @@ const char *cp;
static void PushState ()
{
- REGISTER struct state *new;
+ REGISTER struct state *new_malloc;
if (!init_done)
{
@@ -1106,19 +1106,19 @@ static void PushState ()
init_done=TRUE;
}
(void) code_state(); /* Alloc memory */
- new = (struct state *) DbugMalloc (sizeof (struct state));
- new -> flags = 0;
- new -> delay = 0;
- new -> maxdepth = MAXDEPTH;
- new -> sub_level=0;
- new -> out_file = stderr;
- new -> prof_file = (FILE*) 0;
- new -> functions = NULL;
- new -> p_functions = NULL;
- new -> keywords = NULL;
- new -> processes = NULL;
- new -> next_state = stack;
- stack=new;
+ new_malloc = (struct state *) DbugMalloc (sizeof (struct state));
+ new_malloc -> flags = 0;
+ new_malloc -> delay = 0;
+ new_malloc -> maxdepth = MAXDEPTH;
+ new_malloc -> sub_level=0;
+ new_malloc -> out_file = stderr;
+ new_malloc -> prof_file = (FILE*) 0;
+ new_malloc -> functions = NULL;
+ new_malloc -> p_functions = NULL;
+ new_malloc -> keywords = NULL;
+ new_malloc -> processes = NULL;
+ new_malloc -> next_state = stack;
+ stack=new_malloc;
}
@@ -1216,8 +1216,8 @@ static BOOLEAN DoProfile ()
*
*/
-BOOLEAN _db_keyword_ (keyword)
-const char *keyword;
+BOOLEAN _db_keyword_ (
+const char *keyword)
{
REGISTER BOOLEAN result;
CODE_STATE *state;
@@ -1256,8 +1256,8 @@ const char *keyword;
*
*/
-static void Indent (indent)
-int indent;
+static void Indent (
+int indent)
{
REGISTER int count;
@@ -1289,8 +1289,8 @@ int indent;
*
*/
-static void FreeList (linkp)
-struct link *linkp;
+static void FreeList (
+struct link *linkp)
{
REGISTER struct link *old;
@@ -1325,13 +1325,13 @@ struct link *linkp;
*/
-static char *StrDup (str)
-const char *str;
+static char *StrDup (
+const char *str)
{
- reg1 char *new;
- new = DbugMalloc ((int) strlen (str) + 1);
- (void) strcpy (new, str);
- return (new);
+ reg1 char *new_malloc;
+ new_malloc = DbugMalloc ((int) strlen (str) + 1);
+ (void) strcpy (new_malloc, str);
+ return (new_malloc);
}
@@ -1354,8 +1354,8 @@ const char *str;
*
*/
-static void DoPrefix (_line_)
-uint _line_;
+static void DoPrefix (
+uint _line_)
{
CODE_STATE *state;
state=code_state();
@@ -1365,7 +1365,7 @@ uint _line_;
#ifdef THREAD
(void) fprintf (_db_fp_, "%-7s: ", my_thread_name());
#else
- (void) fprintf (_db_fp_, "%5d: ", getpid ());
+ (void) fprintf (_db_fp_, "%5d: ", (int) getpid ());
#endif
}
if (stack -> flags & NUMBER_ON) {
@@ -1419,7 +1419,7 @@ static void DBUGOpenFile (const char *name,int append)
}
else
{
- if (!Writable(name))
+ if (!Writable((char*)name))
{
(void) fprintf (stderr, ERR_OPEN, _db_process_, name);
perror ("");
@@ -1528,8 +1528,8 @@ static FILE *OpenProfile (const char *name)
*
*/
-static void CloseFile (fp)
-FILE *fp;
+static void CloseFile (
+FILE *fp)
{
if (fp != stderr && fp != stdout) {
if (fclose (fp) == EOF) {
@@ -1590,14 +1590,14 @@ static void DbugExit (const char *why)
*
*/
-static char *DbugMalloc (size)
-int size;
+static char *DbugMalloc (
+int size)
{
- register char *new;
+ register char *new_malloc;
- if (!(new = malloc ((unsigned int) size)))
+ if (!(new_malloc = (char*) malloc ((unsigned int) size)))
DbugExit ("out of memory");
- return (new);
+ return (new_malloc);
}
@@ -1606,9 +1606,9 @@ int size;
* separator (to allow directory-paths in dos).
*/
-static char *static_strtok (s1, separator)
-char *s1;
-pchar separator;
+static char *static_strtok (
+char *s1,
+pchar separator)
{
static char *end = NULL;
reg1 char *rtnval,*cpy;
@@ -1692,8 +1692,8 @@ static char *BaseName (const char *pathname)
#ifndef Writable
-static BOOLEAN Writable (pathname)
-char *pathname;
+static BOOLEAN Writable (
+char *pathname)
{
REGISTER BOOLEAN granted;
REGISTER char *lastslash;
@@ -1746,8 +1746,8 @@ char *pathname;
*/
#ifndef ChangeOwner
-static void ChangeOwner (pathname)
-char *pathname;
+static void ChangeOwner (
+char *pathname)
{
if (chown (pathname, getuid (), getgid ()) == -1)
{
@@ -1847,8 +1847,8 @@ EXPORT void _db_longjmp_ ()
#define HZ (50) /* Probably in some header somewhere */
#endif
-static int DelayArg (value)
-int value;
+static int DelayArg (
+int value)
{
uint delayarg = 0;
@@ -1868,8 +1868,8 @@ int value;
*/
#if ! defined(Delay) && ! defined(AMIGA)
-static int Delay (ticks)
-int ticks;
+static int Delay (
+int ticks)
{
return ticks;
}
@@ -1969,12 +1969,13 @@ void _db_unlock_file()
* own for whatever system that you have.
*/
-#ifdef HAVE_GETRUSAGE
+#ifndef THREAD
+#if defined(HAVE_GETRUSAGE)
#include <sys/param.h>
#include <sys/resource.h>
-/* extern int getrusage(int, struct rusage *); */
+/* extern int getrusage(int, struct rusage *); */
/*
* Returns the user time in milliseconds used by this process so
@@ -1989,15 +1990,13 @@ static unsigned long Clock ()
return ((ru.ru_utime.tv_sec * 1000) + (ru.ru_utime.tv_usec / 1000));
}
-#else
-#if defined(MSDOS) || defined(__WIN__)
+#elif defined(MSDOS) || defined(__WIN__) || defined(OS2)
static ulong Clock()
{
return clock()*(1000/CLOCKS_PER_SEC);
}
-#else
-#ifdef amiga
+#elif defined (amiga)
struct DateStamp { /* Yes, this is a hack, but doing it right */
long ds_Days; /* is incredibly ugly without splitting this */
@@ -2030,19 +2029,13 @@ static unsigned long Clock ()
}
return (millisec);
}
-
#else
-
-#ifndef THREAD
static unsigned long Clock ()
{
return (0);
}
-#endif
-#endif /* amiga */
-#endif /* MSDOS || __WIN__ */
#endif /* RUSAGE */
-
+#endif /* THREADS */
#ifdef NO_VARARGS
diff --git a/dbug/factorial.c b/dbug/factorial.c
index 191c0468356..0dda5c7459e 100644
--- a/dbug/factorial.c
+++ b/dbug/factorial.c
@@ -4,8 +4,8 @@
#include <global.h>
-int factorial (value)
-register int value;
+int factorial (
+register int value)
{
DBUG_ENTER ("factorial");
DBUG_PRINT ("find", ("find %d factorial", value));
diff --git a/heap/heapdef.h b/heap/heapdef.h
index 19c3b7d7792..938cb55c0eb 100644
--- a/heap/heapdef.h
+++ b/heap/heapdef.h
@@ -34,9 +34,9 @@ if (!(info->update & HA_STATE_AKTIV))\
/* Find pos for record and update it in info->current_ptr */
#define _hp_find_record(info,pos) (info)->current_ptr= _hp_find_block(&(info)->s->block,pos)
-typedef struct st_hash_info
+typedef struct st_hp_hash_info
{
- struct st_hash_info *next_key;
+ struct st_hp_hash_info *next_key;
byte *ptr_to_rec;
} HASH_INFO;
diff --git a/include/config-os2.h b/include/config-os2.h
new file mode 100644
index 00000000000..172a04a9f01
--- /dev/null
+++ b/include/config-os2.h
@@ -0,0 +1,822 @@
+/* Copyright (C) 2000 MySQL AB & Yuri Dario
+ All the above parties has a full, independent copyright to
+ the following code, including the right to use the code in
+ any manner without any demands from the other parties.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/* Defines for OS2 to make it compatible for MySQL */
+
+#ifndef __CONFIG_OS2_H__
+#define __CONFIG_OS2_H__
+
+#include <os2.h>
+#include <math.h>
+#include <io.h>
+
+/* Define to name of system eg solaris*/
+#define SYSTEM_TYPE "IBM OS/2 Warp"
+/* Define to machine type name eg sun10 */
+#define MACHINE_TYPE "i686"
+/* Name of package */
+#define PACKAGE "mysql"
+/* Version number of package */
+#define VERSION MYSQL_SERVER_VERSION
+/* Default socket */
+#define MYSQL_UNIX_ADDR "\\socket\\MySQL"
+
+#define FN_LIBCHAR '\\'
+#define FN_ROOTDIR "\\"
+#define MY_NFILE 1024 /* This is only used to save filenames */
+
+#define HAVE_ACCESS
+
+#define DEFAULT_MYSQL_HOME "c:\\mysql"
+#define DEFAULT_BASEDIR "C:\\"
+#define SHAREDIR "share"
+#define DEFAULT_CHARSET_HOME "C:/mysql/"
+#define _POSIX_PATH_MAX 255
+#define DWORD ULONG
+
+#define O_SHARE 0x1000 /* Open file in sharing mode */
+#define FILE_BINARY O_BINARY /* my_fopen in binary mode */
+#define S_IROTH S_IREAD /* for my_lib */
+
+#define O_NONBLOCK 0x10
+
+#define NO_OPEN_3 /* For my_create() */
+#define SIGQUIT SIGTERM /* No SIGQUIT */
+#define SIGALRM 14 /* Alarm */
+
+#define NO_FCNTL_NONBLOCK
+
+#define EFBIG E2BIG
+//#define ENFILE EMFILE
+//#define ENAMETOOLONG (EOS2ERR+2)
+//#define ETIMEDOUT 145
+//#define EPIPE 146
+#define EROFS 147
+
+#define sleep(A) DosSleep((A)*1000)
+#define closesocket(A) soclose(A)
+
+#define F_OK 0
+#define W_OK 2
+
+#define bzero(x,y) memset((x),'\0',(y))
+#define bcopy(x,y,z) memcpy((y),(x),(z))
+#define bcmp(x,y,z) memcmp((y),(x),(z))
+
+#define F_RDLCK 4 /* Read lock. */
+#define F_WRLCK 2 /* Write lock. */
+#define F_UNLCK 0 /* Remove lock. */
+
+#define S_IFMT 0xF000 /* Mask for file type */
+#define F_TO_EOF 0L /* Param to lockf() to lock rest of file */
+
+#ifdef __cplusplus
+extern "C"
+#endif
+double _cdecl rint( double nr);
+
+DWORD TlsAlloc( void);
+BOOL TlsFree( DWORD);
+PVOID TlsGetValue( DWORD);
+BOOL TlsSetValue( DWORD, PVOID);
+
+/* support for > 2GB file size */
+#define SIZEOF_OFF_T 8
+#define lseek(A,B,C) _lseek64( A, B, C)
+#define tell(A) _lseek64( A, 0, SEEK_CUR)
+
+/* Some typedefs */
+typedef ulonglong os_off_t;
+
+/* config.h. Generated automatically by configure. */
+/* config.h.in. Generated automatically from configure.in by autoheader. */
+
+/* Define if using alloca.c. */
+/* #undef C_ALLOCA */
+
+/* Define to empty if the keyword does not work. */
+/* #undef const */
+
+/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
+ This function is required for alloca.c support on those systems. */
+/* #undef CRAY_STACKSEG_END */
+
+/* Define if you have alloca, as a function or macro. */
+#define HAVE_ALLOCA 1
+
+/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
+//#define HAVE_ALLOCA_H 1
+
+/* Define if you don't have vprintf but do have _doprnt. */
+/* #undef HAVE_DOPRNT */
+
+/* Define if you have a working `mmap' system call. */
+/* #undef HAVE_MMAP */
+
+/* Define if system calls automatically restart after interruption
+ by a signal. */
+/* #undef HAVE_RESTARTABLE_SYSCALLS */
+
+/* Define if your struct stat has st_rdev. */
+#define HAVE_ST_RDEV 1
+
+/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
+//#define HAVE_SYS_WAIT_H 1
+
+/* Define if you don't have tm_zone but do have the external array
+ tzname. */
+#define HAVE_TZNAME 1
+
+/* Define if utime(file, NULL) sets file's timestamp to the present. */
+#define HAVE_UTIME_NULL 1
+
+/* Define if you have the vprintf function. */
+#define HAVE_VPRINTF 1
+
+/* Define as __inline if that's what the C compiler calls it. */
+/* #undef inline */
+
+/* Define to `long' if <sys/types.h> doesn't define. */
+/* #undef off_t */
+
+/* Define as the return type of signal handlers (int or void). */
+#define RETSIGTYPE void
+
+/* Define to `unsigned' if <sys/types.h> doesn't define. */
+/* #undef size_t */
+
+/* If using the C implementation of alloca, define if you know the
+ direction of stack growth for your system; otherwise it will be
+ automatically deduced at run-time.
+ STACK_DIRECTION > 0 => grows toward higher addresses
+ STACK_DIRECTION < 0 => grows toward lower addresses
+ STACK_DIRECTION = 0 => direction of growth unknown
+ */
+#define STACK_DIRECTION -1
+
+/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */
+/* #undef STAT_MACROS_BROKEN */
+
+/* Define if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define if you can safely include both <sys/time.h> and <time.h>. */
+#define TIME_WITH_SYS_TIME 1
+
+/* Define if your <sys/time.h> declares struct tm. */
+/* #undef TM_IN_SYS_TIME */
+
+/* Define if your processor stores words with the most significant
+ byte first (like Motorola and SPARC, unlike Intel and VAX). */
+/* #undef WORDS_BIGENDIAN */
+
+/* Version of .frm files */
+#define DOT_FRM_VERSION 6
+
+/* READLINE: */
+#define FIONREAD_IN_SYS_IOCTL 1
+
+/* READLINE: Define if your system defines TIOCGWINSZ in sys/ioctl.h. */
+/* #undef GWINSZ_IN_SYS_IOCTL */
+
+/* Do we have FIONREAD */
+#define FIONREAD_IN_SYS_IOCTL 1
+
+/* atomic_add() from <asm/atomic.h> (Linux only) */
+/* #undef HAVE_ATOMIC_ADD */
+
+/* atomic_sub() from <asm/atomic.h> (Linux only) */
+/* #undef HAVE_ATOMIC_SUB */
+
+/* bool is not defined by all C++ compilators */
+#define HAVE_BOOL 1
+
+/* Have berkeley db installed */
+//#define HAVE_BERKELEY_DB 1
+
+/* DSB style signals ? */
+/* #undef HAVE_BSD_SIGNALS */
+
+/* Can netinet be included */
+/* #undef HAVE_BROKEN_NETINET_INCLUDES */
+
+/* READLINE: */
+/* #undef HAVE_BSD_SIGNALS */
+
+/* ZLIB and compress: */
+#define HAVE_COMPRESS 1
+
+/* Define if we are using OSF1 DEC threads */
+/* #undef HAVE_DEC_THREADS */
+
+/* Define if we are using OSF1 DEC threads on 3.2 */
+/* #undef HAVE_DEC_3_2_THREADS */
+
+/* fp_except from ieeefp.h */
+/* #undef HAVE_FP_EXCEPT */
+
+/* READLINE: */
+/* #undef HAVE_GETPW_DECLS */
+
+/* Solaris define gethostbyname_r with 5 arguments. glibc2 defines
+ this with 6 arguments */
+/* #undef HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE */
+
+/* In OSF 4.0f the 3'd argument to gethostname_r is hostent_data * */
+/* #undef HAVE_GETHOSTBYNAME_R_RETURN_INT */
+
+/* Define if int8, int16 and int32 types exist */
+/* #undef HAVE_INT_8_16_32 */
+
+/* Define if have -lwrap */
+/* #undef HAVE_LIBWRAP */
+
+/* Define if we are using Xavier Leroy's LinuxThreads */
+/* #undef HAVE_LINUXTHREADS */
+
+/* Do we use user level threads */
+/* #undef HAVE_mit_thread */
+
+/* For some non posix threads */
+/* #undef HAVE_NONPOSIX_PTHREAD_GETSPECIFIC */
+
+/* For some non posix threads */
+/* #undef HAVE_NONPOSIX_PTHREAD_MUTEX_INIT */
+
+/* READLINE: */
+#define HAVE_POSIX_SIGNALS 1
+
+/* sigwait with one argument */
+/* #undef HAVE_NONPOSIX_SIGWAIT */
+
+/* pthread_attr_setscope */
+#define HAVE_PTHREAD_ATTR_SETSCOPE 1
+
+/* POSIX readdir_r */
+/* #undef HAVE_READDIR_R */
+
+/* POSIX sigwait */
+/* #undef HAVE_SIGWAIT */
+
+/* crypt */
+#define HAVE_CRYPT 1
+
+/* Solaris define gethostbyaddr_r with 7 arguments. glibc2 defines
+ this with 8 arguments */
+/* #undef HAVE_SOLARIS_STYLE_GETHOST */
+
+/* Timespec has a ts_sec instead of tv_sev */
+#define HAVE_TIMESPEC_TS_SEC 1
+
+/* Have the tzname variable */
+#define HAVE_TZNAME 1
+
+/* Define if the system files define uchar */
+/* #undef HAVE_UCHAR */
+
+/* Define if the system files define uint */
+/* #undef HAVE_UINT */
+
+/* Define if the system files define ulong */
+/* #undef HAVE_ULONG */
+
+/* UNIXWARE7 threads are not posix */
+/* #undef HAVE_UNIXWARE7_THREADS */
+
+/* new UNIXWARE7 threads that are not yet posix */
+/* #undef HAVE_UNIXWARE7_POSIX */
+
+/* READLINE: */
+/* #undef HAVE_USG_SIGHOLD */
+
+/* Define if want -lwrap */
+/* #undef LIBWRAP */
+
+/* mysql client protocoll version */
+#define PROTOCOL_VERSION 10
+
+/* Define if qsort returns void */
+#define QSORT_TYPE_IS_VOID 1
+
+/* Define as the return type of qsort (int or void). */
+#define RETQSORTTYPE void
+
+/* Define as the base type of the last arg to accept */
+#define SOCKET_SIZE_TYPE int
+
+/* Last argument to get/setsockopt */
+/* #undef SOCKOPT_OPTLEN_TYPE */
+
+/* #undef SPEED_T_IN_SYS_TYPES */
+/* #undef SPRINTF_RETURNS_PTR */
+#define SPRINTF_RETURNS_INT 1
+/* #undef SPRINTF_RETURNS_GARBAGE */
+
+/* #undef STRUCT_DIRENT_HAS_D_FILENO */
+#define STRUCT_DIRENT_HAS_D_INO 1
+
+/* Define if you want to have threaded code. This may be undef on client code */
+#define THREAD 1
+
+/* Should be client be thread safe */
+/* #undef THREAD_SAFE_CLIENT */
+
+/* READLINE: */
+/* #undef TIOCSTAT_IN_SYS_IOCTL */
+
+/* Use multi-byte character routines */
+/* #undef USE_MB */
+/* #undef USE_MB_IDENT */
+
+/* Use MySQL RAID */
+/* #undef USE_RAID */
+
+/* Use strcoll() functions when comparing and sorting. */
+/* #undef USE_STRCOLL */
+
+/* READLINE: */
+#define VOID_SIGHANDLER 1
+
+/* The number of bytes in a char. */
+#define SIZEOF_CHAR 1
+
+/* The number of bytes in a int. */
+#define SIZEOF_INT 4
+
+/* The number of bytes in a long. */
+#define SIZEOF_LONG 4
+
+/* The number of bytes in a long long. */
+#define SIZEOF_LONG_LONG 8
+
+/* Define if you have the alarm function. */
+#define HAVE_ALARM 1
+
+/* Define if you have the atod function. */
+/* #undef HAVE_ATOD */
+
+/* Define if you have the bcmp function. */
+#define HAVE_BCMP 1
+
+/* Define if you have the bfill function. */
+/* #undef HAVE_BFILL */
+
+/* Define if you have the bmove function. */
+/* #undef HAVE_BMOVE */
+
+/* Define if you have the bzero function. */
+#define HAVE_BZERO 1
+
+/* Define if you have the chsize function. */
+#define HAVE_CHSIZE 1
+
+/* Define if you have the cuserid function. */
+//#define HAVE_CUSERID 1
+
+/* Define if you have the dlerror function. */
+#define HAVE_DLERROR 1
+
+/* Define if you have the dlopen function. */
+#define HAVE_DLOPEN 1
+
+/* Define if you have the fchmod function. */
+/* #undef HAVE_FCHMOD */
+
+/* Define if you have the fcntl function. */
+//#define HAVE_FCNTL 1
+
+/* Define if you have the fconvert function. */
+/* #undef HAVE_FCONVERT */
+
+/* Define if you have the finite function. */
+/* #undef HAVE_FINITE */
+
+/* Define if you have the fpresetsticky function. */
+/* #undef HAVE_FPRESETSTICKY */
+
+/* Define if you have the fpsetmask function. */
+/* #undef HAVE_FPSETMASK */
+
+/* Define if you have the fseeko function. */
+/* #undef HAVE_FSEEKO */
+
+/* Define if you have the ftruncate function. */
+//#define HAVE_FTRUNCATE 1
+
+/* Define if you have the getcwd function. */
+#define HAVE_GETCWD 1
+
+/* Define if you have the gethostbyaddr_r function. */
+/* #undef HAVE_GETHOSTBYADDR_R */
+
+/* Define if you have the gethostbyname_r function. */
+/* #undef HAVE_GETHOSTBYNAME_R */
+
+/* Define if you have the getpagesize function. */
+#define HAVE_GETPAGESIZE 1
+
+/* Define if you have the getpass function. */
+//#define HAVE_GETPASS 1
+
+/* Define if you have the getpassphrase function. */
+/* #undef HAVE_GETPASSPHRASE */
+
+/* Define if you have the getpwnam function. */
+//#define HAVE_GETPWNAM 1
+
+/* Define if you have the getpwuid function. */
+//#define HAVE_GETPWUID 1
+
+/* Define if you have the getrlimit function. */
+/* #undef HAVE_GETRLIMIT */
+
+/* Define if you have the getrusage function. */
+/* #undef HAVE_GETRUSAGE */
+
+/* Define if you have the getwd function. */
+#define HAVE_GETWD 1
+
+/* Define if you have the index function. */
+#define HAVE_INDEX 1
+
+/* Define if you have the initgroups function. */
+/* #undef HAVE_INITGROUPS */
+
+/* Define if you have the localtime_r function. */
+#define HAVE_LOCALTIME_R 1
+
+/* Define if you have the locking function. */
+/* #undef HAVE_LOCKING */
+
+/* Define if you have the longjmp function. */
+#define HAVE_LONGJMP 1
+
+/* Define if you have the lrand48 function. */
+/* #undef HAVE_LRAND48 */
+
+/* Define if you have the lstat function. */
+/* #undef HAVE_LSTAT */
+
+/* Define if you have the madvise function. */
+/* #undef HAVE_MADVISE */
+
+/* Define if you have the memcpy function. */
+#define HAVE_MEMCPY 1
+
+/* Define if you have the memmove function. */
+#define HAVE_MEMMOVE 1
+
+/* Define if you have the mkstemp function. */
+//#define HAVE_MKSTEMP 1
+
+/* Define if you have the mlockall function. */
+/* #undef HAVE_MLOCKALL */
+
+/* Define if you have the perror function. */
+#define HAVE_PERROR 1
+
+/* Define if you have the poll function. */
+/* #undef HAVE_POLL */
+
+/* Define if you have the pread function. */
+/* #undef HAVE_PREAD */
+
+/* Define if you have the pthread_attr_create function. */
+/* #undef HAVE_PTHREAD_ATTR_CREATE */
+
+/* Define if you have the pthread_attr_setprio function. */
+#define HAVE_PTHREAD_ATTR_SETPRIO 1
+
+/* Define if you have the pthread_attr_setschedparam function. */
+/* #undef HAVE_PTHREAD_ATTR_SETSCHEDPARAM */
+
+/* Define if you have the pthread_attr_setstacksize function. */
+#define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
+
+/* Define if you have the pthread_condattr_create function. */
+/* #undef HAVE_PTHREAD_CONDATTR_CREATE */
+
+/* Define if you have the pthread_getsequence_np function. */
+/* #undef HAVE_PTHREAD_GETSEQUENCE_NP */
+
+/* Define if you have the pthread_init function. */
+/* #undef HAVE_PTHREAD_INIT */
+
+/* Define if you have the pthread_rwlock_rdlock function. */
+/* #undef HAVE_PTHREAD_RWLOCK_RDLOCK */
+
+/* Define if you have the pthread_setprio function. */
+#define HAVE_PTHREAD_SETPRIO 1
+
+/* Define if you have the pthread_setprio_np function. */
+/* #undef HAVE_PTHREAD_SETPRIO_NP */
+
+/* Define if you have the pthread_setschedparam function. */
+/* #undef HAVE_PTHREAD_SETSCHEDPARAM */
+
+/* Define if you have the pthread_sigmask function. */
+#define HAVE_PTHREAD_SIGMASK 1
+
+/* Define if you have the putenv function. */
+#define HAVE_PUTENV 1
+
+/* Define if you have the readlink function. */
+/* #undef HAVE_READLINK */
+
+/* Define if you have the realpath function. */
+/* #undef HAVE_REALPATH */
+
+/* Define if you have the rename function. */
+#define HAVE_RENAME 1
+
+/* Define if you have the rint function. */
+#define HAVE_RINT 1
+
+/* Define if you have the rwlock_init function. */
+/* #undef HAVE_RWLOCK_INIT */
+
+/* Define if you have the select function. */
+#define HAVE_SELECT 1
+
+/* Define if you have the setenv function. */
+/* #undef HAVE_SETENV */
+
+/* Define if you have the setlocale function. */
+#define HAVE_SETLOCALE 1
+
+/* Define if you have the setupterm function. */
+/* #undef HAVE_SETUPTERM */
+
+/* Define if you have the sighold function. */
+/* #undef HAVE_SIGHOLD */
+
+/* Define if you have the sigset function. */
+/* #undef HAVE_SIGSET */
+
+/* Define if you have the sigthreadmask function. */
+/* #undef HAVE_SIGTHREADMASK */
+
+/* Define if you have the snprintf function. */
+//#define HAVE_SNPRINTF 1
+
+/* Define if you have the socket function. */
+#define HAVE_SOCKET 1
+
+/* Define if you have the stpcpy function. */
+/* #undef HAVE_STPCPY */
+
+/* Define if you have the strcasecmp function. */
+/* #undef HAVE_STRCASECMP */
+
+/* Define if you have the strcoll function. */
+#define HAVE_STRCOLL 1
+
+/* Define if you have the strerror function. */
+#define HAVE_STRERROR 1
+
+/* Define if you have the strnlen function. */
+/* #undef HAVE_STRNLEN */
+
+/* Define if you have the strpbrk function. */
+#define HAVE_STRPBRK 1
+
+/* Define if you have the strstr function. */
+#define HAVE_STRSTR 1
+
+/* Define if you have the strtok_r function. */
+/* #undef HAVE_STRTOK_R */
+
+/* Define if you have the strtol function. */
+#define HAVE_STRTOL 1
+
+/* Define if you have the strtoul function. */
+#define HAVE_STRTOUL 1
+
+/* Define if you have the strtoull function. */
+/* #undef HAVE_STRTOULL */
+
+/* Define if you have the tcgetattr function. */
+#define HAVE_TCGETATTR 1
+
+/* Define if you have the tell function. */
+#define HAVE_TELL 1
+
+/* Define if you have the tempnam function. */
+#define HAVE_TEMPNAM 1
+
+/* Define if you have the thr_setconcurrency function. */
+/* #undef HAVE_THR_SETCONCURRENCY */
+
+/* Define if you have the vidattr function. */
+/* #undef HAVE_VIDATTR */
+
+/* Define if you have the <alloca.h> header file. */
+//#define HAVE_ALLOCA_H 1
+
+/* Define if you have the <arpa/inet.h> header file. */
+#define HAVE_ARPA_INET_H 1
+
+/* Define if you have the <asm/termbits.h> header file. */
+/* #undef HAVE_ASM_TERMBITS_H */
+
+/* Define if you have the <crypt.h> header file. */
+#define HAVE_CRYPT_H 1
+
+/* Define if you have the <curses.h> header file. */
+//#define HAVE_CURSES_H 1
+
+/* Define if you have the <dirent.h> header file. */
+//#define HAVE_DIRENT_H 1
+
+/* Define if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define if you have the <float.h> header file. */
+#define HAVE_FLOAT_H 1
+
+/* Define if you have the <floatingpoint.h> header file. */
+/* #undef HAVE_FLOATINGPOINT_H */
+
+/* Define if you have the <grp.h> header file. */
+//#define HAVE_GRP_H 1
+
+/* Define if you have the <ieeefp.h> header file. */
+/* #undef HAVE_IEEEFP_H */
+
+/* Define if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define if you have the <locale.h> header file. */
+#define HAVE_LOCALE_H 1
+
+/* Define if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define if you have the <ndir.h> header file. */
+/* #undef HAVE_NDIR_H */
+
+/* Define if you have the <netinet/in.h> header file. */
+#define HAVE_NETINET_IN_H 1
+
+/* Define if you have the <paths.h> header file. */
+/* #undef HAVE_PATHS_H */
+
+/* Define if you have the <pwd.h> header file. */
+//#define HAVE_PWD_H 1
+
+/* Define if you have the <sched.h> header file. */
+/* #undef HAVE_SCHED_H */
+
+/* Define if you have the <select.h> header file. */
+/* #undef HAVE_SELECT_H */
+
+/* Define if you have the <stdarg.h> header file. */
+#define HAVE_STDARG_H 1
+
+/* Define if you have the <stddef.h> header file. */
+#define HAVE_STDDEF_H 1
+
+/* Define if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define if you have the <strings.h> header file. */
+//#define HAVE_STRINGS_H 1
+
+/* Define if you have the <synch.h> header file. */
+/* #undef HAVE_SYNCH_H */
+
+/* Define if you have the <sys/dir.h> header file. */
+//#define HAVE_SYS_DIR_H 1
+
+/* Define if you have the <sys/file.h> header file. */
+//#define HAVE_SYS_FILE_H 1
+
+/* Define if you have the <sys/ioctl.h> header file. */
+#define HAVE_SYS_IOCTL_H 1
+
+/* Define if you have the <sys/mman.h> header file. */
+/* #undef HAVE_SYS_MMAN_H */
+
+/* Define if you have the <sys/ndir.h> header file. */
+/* #undef HAVE_SYS_NDIR_H */
+
+/* Define if you have the <sys/pte.h> header file. */
+/* #undef HAVE_SYS_PTE_H */
+
+/* Define if you have the <sys/ptem.h> header file. */
+/* #undef HAVE_SYS_PTEM_H */
+
+/* Define if you have the <sys/select.h> header file. */
+#define HAVE_SYS_SELECT_H 1
+
+/* Define if you have the <sys/socket.h> header file. */
+#define HAVE_SYS_SOCKET_H 1
+
+/* Define if you have the <sys/stream.h> header file. */
+/* #undef HAVE_SYS_STREAM_H */
+
+/* Define if you have the <sys/timeb.h> header file. */
+#define HAVE_SYS_TIMEB_H 1
+
+/* Define if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define if you have the <sys/un.h> header file. */
+#define HAVE_SYS_UN_H 1
+
+/* Define if you have the <sys/utime.h> header file. */
+#define HAVE_SYS_UTIME_H 1
+
+/* Define if you have the <sys/vadvise.h> header file. */
+/* #undef HAVE_SYS_VADVISE_H */
+
+/* Define if you have the <sys/wait.h> header file. */
+//#define HAVE_SYS_WAIT_H 1
+
+/* Define if you have the <term.h> header file. */
+/* #undef HAVE_TERM_H */
+
+/* Define if you have the <termbits.h> header file. */
+/* #undef HAVE_TERMBITS_H */
+
+/* Define if you have the <termcap.h> header file. */
+//#define HAVE_TERMCAP_H 1
+
+/* Define if you have the <termio.h> header file. */
+//#define HAVE_TERMIO_H 1
+
+/* Define if you have the <termios.h> header file. */
+//#define HAVE_TERMIOS_H 1
+
+/* Define if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define if you have the <utime.h> header file. */
+#define HAVE_UTIME_H 1
+
+/* Define if you have the <varargs.h> header file. */
+#define HAVE_VARARGS_H 1
+
+/* Define if you have the bind library (-lbind). */
+/* #undef HAVE_LIBBIND */
+
+/* Define if you have the c_r library (-lc_r). */
+/* #undef HAVE_LIBC_R */
+
+/* Define if you have the compat library (-lcompat). */
+/* #undef HAVE_LIBCOMPAT */
+
+/* Define if you have the crypt library (-lcrypt). */
+#define HAVE_LIBCRYPT 1
+
+/* Define if you have the dl library (-ldl). */
+#define HAVE_LIBDL 1
+
+/* Define if you have the gen library (-lgen). */
+/* #undef HAVE_LIBGEN */
+
+/* Define if you have the m library (-lm). */
+#define HAVE_LIBM 1
+
+/* Define if you have the nsl library (-lnsl). */
+/* #undef HAVE_LIBNSL */
+
+/* Define if you have the nsl_r library (-lnsl_r). */
+/* #undef HAVE_LIBNSL_R */
+
+/* Define if you have the pthread library (-lpthread). */
+/* #undef HAVE_LIBPTHREAD */
+
+/* Define if you have the socket library (-lsocket). */
+/* #undef HAVE_LIBSOCKET */
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+/* #undef _FILE_OFFSET_BITS */
+
+/* Define to make fseeko etc. visible, on some hosts. */
+/* #undef _LARGEFILE_SOURCE */
+
+/* Define for large files, on AIX-style hosts. */
+/* #undef _LARGE_FILES */
+
+#endif // __CONFIG_OS2_H__
diff --git a/include/config-win.h b/include/config-win.h
index 3791c337cb3..4e4088f07dd 100644
--- a/include/config-win.h
+++ b/include/config-win.h
@@ -287,7 +287,6 @@ inline double ulonglong2double(ulonglong value)
#define FN_ROOTDIR "\\"
#define FN_NETWORK_DRIVES /* Uses \\ to indicate network drives */
#define FN_NO_CASE_SENCE /* Files are not case-sensitive */
-#define FN_LOWER_CASE TRUE /* Files are represented in lower case */
#define MY_NFILE 1024
#define DO_NOT_REMOVE_THREAD_WRAPPERS
diff --git a/include/errmsg.h b/include/errmsg.h
index 427174ffa53..ecc9761a391 100644
--- a/include/errmsg.h
+++ b/include/errmsg.h
@@ -29,7 +29,11 @@ extern const char *client_errors[]; /* Error messages */
#define CR_MIN_ERROR 2000 /* For easier client code */
#define CR_MAX_ERROR 2999
+#if defined(OS2) && defined( MYSQL_SERVER)
+#define CER(X) client_errors[(X)-CR_MIN_ERROR]
+#else
#define ER(X) client_errors[(X)-CR_MIN_ERROR]
+#endif
#define CLIENT_ERRMAP 2 /* Errormap used by my_error() */
#define CR_UNKNOWN_ERROR 2000
diff --git a/include/global.h b/include/global.h
index d40c5373812..0915047fddb 100644
--- a/include/global.h
+++ b/include/global.h
@@ -43,14 +43,14 @@
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
#include <config-win.h>
+#elif defined(OS2)
+#include <config-os2.h>
#else
#include <my_config.h>
-#endif
-#if defined(__cplusplus)
-#if defined(inline)
+#if defined(__cplusplus) && defined(inline)
#undef inline /* fix configure problem */
#endif
-#endif /* _cplusplus */
+#endif /* _WIN32... */
/* Fix problem with S_ISLNK() on Linux */
#if defined(HAVE_LINUXTHREADS)
@@ -76,7 +76,7 @@
#define __STDC_EXT__ 1 /* To get large file support on hpux */
#endif
-#if defined(THREAD) && !defined(__WIN__)
+#if defined(THREAD) && !defined(__WIN__) && !defined(OS2)
#ifndef _POSIX_PTHREAD_SEMANTICS
#define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */
#endif
@@ -226,7 +226,9 @@
#define POSIX_MISTAKE 1 /* regexp: Fix stupid spec error */
#define USE_REGEX 1 /* We want the use the regex library */
/* Do not define for ultra sparcs */
+#ifndef OS2
#define USE_BMOVE512 1 /* Use this unless the system bmove is faster */
+#endif
/* Paranoid settings. Define I_AM_PARANOID if you are paranoid */
#ifdef I_AM_PARANOID
@@ -477,7 +479,11 @@ extern double my_atof(const char*);
#endif
#undef remove /* Crashes MySQL on SCO 5.0.0 */
#ifndef __WIN__
+#ifdef OS2
+#define closesocket(A) soclose(A)
+#else
#define closesocket(A) close(A)
+#endif
#ifndef ulonglong2double
#define ulonglong2double(A) ((double) (A))
#define my_off_t2double(A) ((double) (A))
@@ -566,9 +572,13 @@ typedef long my_ptrdiff_t;
#ifndef NEAR
#define NEAR /* Who needs segments ? */
#define FAR /* On a good machine */
+#ifndef HUGE_PTR
#define HUGE_PTR
#endif
-#ifndef STDCALL
+#endif
+#if defined(__IBMC__) || defined(__IBMCPP__)
+#define STDCALL _System _Export
+#elif !defined( STDCALL)
#define STDCALL
#endif
@@ -636,10 +646,25 @@ typedef ulonglong my_off_t;
typedef unsigned long my_off_t;
#endif
#define MY_FILEPOS_ERROR (~(my_off_t) 0)
-#ifndef __WIN__
+#if !defined(__WIN__) && !defined(OS2)
typedef off_t os_off_t;
#endif
+#if defined(__WIN__)
+#define socket_errno WSAGetLastError()
+#define SOCKET_EINTR WSAEINTR
+#define SOCKET_EAGAIN WSAEINPROGRESS
+#elif defined(OS2)
+#define socket_errno sock_errno()
+#define closesocket(A) soclose(A)
+#else /* Unix */
+#define socket_errno errno
+#define closesocket(A) close(A)
+#define SOCKET_EINTR EINTR
+#define SOCKET_EAGAIN EAGAIN
+#define SOCKET_EWOULDBLOCK EWOULDBLOCK
+#endif
+
typedef uint8 int7; /* Most effective integer 0 <= x <= 127 */
typedef short int15; /* Most effective integer 0 <= x <= 32767 */
typedef char *my_string; /* String of characters */
diff --git a/include/heap.h b/include/heap.h
index 9c67a84a2dd..813df2a7ddd 100644
--- a/include/heap.h
+++ b/include/heap.h
@@ -113,13 +113,13 @@ typedef struct st_heap_share
LIST open_list;
} HP_SHARE;
-struct st_hash_info;
+struct st_hp_hash_info;
typedef struct st_heap_info
{
HP_SHARE *s;
byte *current_ptr;
- struct st_hash_info *current_hash_ptr;
+ struct st_hp_hash_info *current_hash_ptr;
ulong current_record,next_block;
int lastinx,errkey;
int mode; /* Mode of file (READONLY..) */
diff --git a/include/m_string.h b/include/m_string.h
index 84c42e0c8b9..7eb2f1fe690 100644
--- a/include/m_string.h
+++ b/include/m_string.h
@@ -82,7 +82,7 @@
# define bmove_allign(A,B,C) memcpy((A),(B),(C))
#endif
-#ifdef __cplusplus
+#if defined(__cplusplus) && !defined(OS2)
extern "C" {
#endif
@@ -238,7 +238,7 @@ extern ulonglong strtoull(const char *str, char **ptr, int base);
#endif
#endif
-#ifdef __cplusplus
+#if defined(__cplusplus) && !defined(OS2)
}
#endif
#endif
diff --git a/include/my_pthread.h b/include/my_pthread.h
index 487e8d07e5e..14ccd93a96c 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -25,13 +25,23 @@
#define ETIME ETIMEDOUT /* For FreeBSD */
#endif
-#ifdef __cplusplus
+#ifdef __cplusplus
extern "C" {
-#endif
+#endif /* __cplusplus */
+
+#if defined(__WIN__) || defined(OS2)
-#if defined(__WIN__)
+#ifdef OS2
+typedef ULONG HANDLE;
+typedef ULONG DWORD;
+typedef int sigset_t;
+#endif
+#ifdef OS2
+typedef HMTX pthread_mutex_t;
+#else
typedef CRITICAL_SECTION pthread_mutex_t;
+#endif
typedef HANDLE pthread_t;
typedef struct thread_attr {
DWORD dwStackSize ;
@@ -50,19 +60,30 @@ typedef struct st_pthread_link {
typedef struct {
uint32 waiting;
+#ifdef OS2
+ HEV semaphore;
+#else
HANDLE semaphore;
+#endif
} pthread_cond_t;
+#ifndef OS2
struct timespec { /* For pthread_cond_timedwait() */
time_t tv_sec;
long tv_nsec;
};
+#endif
typedef int pthread_mutexattr_t;
#define win_pthread_self my_thread_var->pthread_self
+#ifdef OS2
+#define pthread_handler_decl(A,B) void * _Optlink A(void *B)
+typedef void * (_Optlink *pthread_handler)(void *);
+#else
#define pthread_handler_decl(A,B) void * __cdecl A(void *B)
typedef void * (__cdecl *pthread_handler)(void *);
+#endif
void win_pthread_init(void);
int win_pthread_setspecific(void *A,void *B,uint length);
@@ -82,12 +103,14 @@ struct tm *localtime_r(const time_t *timep,struct tm *tmp);
void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/
+#ifndef OS2
#define ETIMEDOUT 145 /* Win32 doesn't have this */
#define getpid() GetCurrentThreadId()
+#endif
#define pthread_self() win_pthread_self
-#define HAVE_LOCALTIME_R
-#define _REENTRANT
-#define HAVE_PTHREAD_ATTR_SETSTACKSIZE
+#define HAVE_LOCALTIME_R 1
+#define _REENTRANT 1
+#define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
#ifdef USE_TLS /* For LIBMYSQL.DLL */
#undef SAFE_MUTEX /* This will cause conflicts */
@@ -109,13 +132,23 @@ void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/
#endif /* USE_TLS */
#define pthread_equal(A,B) ((A) == (B))
+#ifdef OS2
+int pthread_mutex_init (pthread_mutex_t *, const pthread_mutexattr_t *);
+int pthread_mutex_lock (pthread_mutex_t *);
+int pthread_mutex_unlock (pthread_mutex_t *);
+int pthread_mutex_destroy (pthread_mutex_t *);
+#define my_pthread_setprio(A,B) DosSetPriority(PRTYS_THREAD,PRTYC_NOCHANGE, B, A)
+#define pthread_kill(A,B) raise(B)
+#else
#define pthread_mutex_init(A,B) InitializeCriticalSection(A)
#define pthread_mutex_lock(A) (EnterCriticalSection(A),0)
#define pthread_mutex_unlock(A) LeaveCriticalSection(A)
#define pthread_mutex_destroy(A) DeleteCriticalSection(A)
#define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B))
-/* Dummy defines for easier code */
#define pthread_kill(A,B) pthread_dummy(0)
+#endif /* OS2 */
+
+/* Dummy defines for easier code */
#define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
#define my_pthread_attr_setprio(A,B) pthread_attr_setprio(A,B)
#define pthread_attr_setscope(A,B)
@@ -315,12 +348,15 @@ extern void my_pthread_attr_setprio(pthread_attr_t *attr, int priority);
#undef HAVE_GETHOSTBYADDR_R /* No definition */
#endif
-#ifndef HAVE_NONPOSIX_PTHREAD_GETSPECIFIC
+#if defined(OS2)
+#define my_pthread_getspecific(T,A) ((T) &(A))
+#define pthread_setspecific(A,B) win_pthread_setspecific(&(A),(B),sizeof(A))
+#elif !defined( HAVE_NONPOSIX_PTHREAD_GETSPECIFIC)
#define my_pthread_getspecific(A,B) ((A) pthread_getspecific(B))
#else
#define my_pthread_getspecific(A,B) ((A) my_pthread_getspecific_imp(B))
void *my_pthread_getspecific_imp(pthread_key_t key);
-#endif
+#endif /* OS2 */
#ifndef HAVE_LOCALTIME_R
struct tm *localtime_r(const time_t *clock, struct tm *res);
@@ -539,12 +575,14 @@ extern int pthread_dummy(int);
struct st_my_thread_var
{
int thr_errno;
- pthread_cond_t suspend, *current_cond;
- pthread_mutex_t mutex, *current_mutex;
+ pthread_cond_t suspend;
+ pthread_mutex_t mutex;
+ pthread_mutex_t * volatile current_mutex;
+ pthread_cond_t * volatile current_cond;
pthread_t pthread_self;
long id;
int cmp_length;
- volatile int abort;
+ int volatile abort;
#ifndef DBUG_OFF
gptr dbug;
char name[THREAD_NAME_SIZE+1];
@@ -581,7 +619,7 @@ extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const));
#endif /* HAVE_ATOMIC_ADD */
#endif /* thread_safe_increment */
-#ifdef __cplusplus
+#ifdef __cplusplus
}
#endif
#endif /* _my_ptread_h */
diff --git a/include/my_sys.h b/include/my_sys.h
index 591c3237c05..b70d123a66a 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -127,6 +127,7 @@ extern uint sf_malloc_prehunc,sf_malloc_endhunc,sf_malloc_quick;
extern ulonglong safemalloc_mem_limit;
#else
#define my_checkmalloc() (0)
+#undef TERMINATE
#define TERMINATE(A) {}
#define QUICK_SAFEMALLOC
#define NORMAL_SAFEMALLOC
diff --git a/include/mysql_com.h b/include/mysql_com.h
index 126bb454501..ce134fcab2c 100644
--- a/include/mysql_com.h
+++ b/include/mysql_com.h
@@ -235,10 +235,4 @@ void my_thread_end(void);
#define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */
-#ifdef __WIN__
-#define socket_errno WSAGetLastError()
-#else
-#define socket_errno errno
-#endif
-
#endif
diff --git a/include/mysqld_error.h b/include/mysqld_error.h
index c921beafa4a..b81e10308ff 100644
--- a/include/mysqld_error.h
+++ b/include/mysqld_error.h
@@ -212,11 +212,12 @@
#define ER_CREATE_DB_WITH_READ_LOCK 1209
#define ER_WRONG_ARGUMENTS 1210
#define ER_NO_PERMISSION_TO_CREATE_USER 1211
-#define ER_CONNECT_TO_MASTER 1212
-#define ER_QUERY_ON_MASTER 1213
-#define ER_ERROR_WHEN_EXECUTING_COMMAND 1214
-#define ER_WRONG_USAGE 1215
-#define ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT 1216
-#define ER_CANT_UPDATE_WITH_READLOCK 1217
-#define ER_MIXING_NOT_ALLOWED 1218
-#define ER_ERROR_MESSAGES 219
+#define ER_UNION_TABLES_IN_DIFFERENT_DIR 1212
+#define ER_CONNECT_TO_MASTER 1213
+#define ER_QUERY_ON_MASTER 1214
+#define ER_ERROR_WHEN_EXECUTING_COMMAND 1215
+#define ER_WRONG_USAGE 1216
+#define ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT 1217
+#define ER_CANT_UPDATE_WITH_READLOCK 1218
+#define ER_MIXING_NOT_ALLOWED 1219
+#define ER_ERROR_MESSAGES 220
diff --git a/include/thr_alarm.h b/include/thr_alarm.h
index da68b9fce07..1f3fed1d29b 100644
--- a/include/thr_alarm.h
+++ b/include/thr_alarm.h
@@ -65,7 +65,7 @@ typedef struct st_thr_alarm_entry
rf_SetTimer crono;
} thr_alarm_entry;
-#elif defined(__EMX__)
+#elif defined(__EMX__) || defined(OS2)
typedef struct st_thr_alarm_entry
{
diff --git a/innobase/btr/btr0btr.c b/innobase/btr/btr0btr.c
index af2029bf1e8..6da323867fb 100644
--- a/innobase/btr/btr0btr.c
+++ b/innobase/btr/btr0btr.c
@@ -1738,8 +1738,8 @@ btr_node_ptr_delete(
btr_cur_position(UT_LIST_GET_FIRST(tree->tree_indexes), node_ptr,
&cursor);
- compressed = btr_cur_pessimistic_delete(&err, TRUE, &cursor, mtr);
-
+ compressed = btr_cur_pessimistic_delete(&err, TRUE, &cursor, FALSE,
+ mtr);
ut_a(err == DB_SUCCESS);
if (!compressed) {
diff --git a/innobase/btr/btr0cur.c b/innobase/btr/btr0cur.c
index 47a67d425cd..7783f618d6d 100644
--- a/innobase/btr/btr0cur.c
+++ b/innobase/btr/btr0cur.c
@@ -80,6 +80,9 @@ btr_rec_free_updated_extern_fields(
X-latched */
rec_t* rec, /* in: record */
upd_t* update, /* in: update vector */
+ ibool do_not_free_inherited,/* in: TRUE if called in a
+ rollback and we do not want to free
+ inherited fields */
mtr_t* mtr); /* in: mini-transaction handle which contains
an X-latch to record page and to the tree */
@@ -813,7 +816,7 @@ calculate_sizes_again:
/* The record is so big that we have to store some fields
externally on separate database pages */
- big_rec_vec = dtuple_convert_big_rec(index, entry);
+ big_rec_vec = dtuple_convert_big_rec(index, entry, NULL, 0);
if (big_rec_vec == NULL) {
@@ -1021,7 +1024,7 @@ btr_cur_pessimistic_insert(
/* The record is so big that we have to store some fields
externally on separate database pages */
- big_rec_vec = dtuple_convert_big_rec(index, entry);
+ big_rec_vec = dtuple_convert_big_rec(index, entry, NULL, 0);
if (big_rec_vec == NULL) {
@@ -1242,6 +1245,7 @@ btr_cur_update_in_place(
rec_t* rec;
dulint roll_ptr;
trx_t* trx;
+ ibool was_delete_marked;
/* Only clustered index records are updated using this function */
ut_ad((cursor->index)->type & DICT_CLUSTERED);
@@ -1270,6 +1274,8 @@ btr_cur_update_in_place(
/* FIXME: in a mixed tree, all records may not have enough ordering
fields for btr search: */
+
+ was_delete_marked = rec_get_deleted_flag(rec);
row_upd_rec_in_place(rec, update);
@@ -1279,6 +1285,13 @@ btr_cur_update_in_place(
btr_cur_update_in_place_log(flags, rec, index, update, trx, roll_ptr,
mtr);
+ if (was_delete_marked && !rec_get_deleted_flag(rec)) {
+ /* The new updated record owns its possible externally
+ stored fields */
+
+ btr_cur_unmark_extern_fields(rec, mtr);
+ }
+
return(DB_SUCCESS);
}
@@ -1434,6 +1447,13 @@ btr_cur_optimistic_update(
ut_a(rec); /* <- We calculated above the insert would fit */
+ if (!rec_get_deleted_flag(rec)) {
+ /* The new inserted record owns its possible externally
+ stored fields */
+
+ btr_cur_unmark_extern_fields(rec, mtr);
+ }
+
/* Restore the old explicit lock state on the record */
lock_rec_restore_from_page_infimum(rec, page);
@@ -1655,11 +1675,15 @@ btr_cur_pessimistic_update(
if (flags & BTR_NO_UNDO_LOG_FLAG) {
/* We are in a transaction rollback undoing a row
update: we must free possible externally stored fields
- which got new values in the update */
+ which got new values in the update, if they are not
+ inherited values. They can be inherited if we have
+ updated the primary key to another value, and then
+ update it back again. */
ut_a(big_rec_vec == NULL);
- btr_rec_free_updated_extern_fields(index, rec, update, mtr);
+ btr_rec_free_updated_extern_fields(index, rec, update,
+ TRUE, mtr);
}
/* We have to set appropriate extern storage bits in the new
@@ -1676,8 +1700,8 @@ btr_cur_pessimistic_update(
page_get_free_space_of_empty() / 2)
|| (rec_get_converted_size(new_entry) >= REC_MAX_DATA_SIZE)) {
- big_rec_vec = dtuple_convert_big_rec(index, new_entry);
-
+ big_rec_vec = dtuple_convert_big_rec(index, new_entry,
+ ext_vect, n_ext_vect);
if (big_rec_vec == NULL) {
mem_heap_free(heap);
@@ -1694,6 +1718,13 @@ btr_cur_pessimistic_update(
lock_rec_restore_from_page_infimum(rec, page);
rec_set_field_extern_bits(rec, ext_vect, n_ext_vect, mtr);
+ if (!rec_get_deleted_flag(rec)) {
+ /* The new inserted record owns its possible externally
+ stored fields */
+
+ btr_cur_unmark_extern_fields(rec, mtr);
+ }
+
btr_cur_compress_if_useful(cursor, mtr);
err = DB_SUCCESS;
@@ -1725,6 +1756,13 @@ btr_cur_pessimistic_update(
rec_set_field_extern_bits(rec, ext_vect, n_ext_vect, mtr);
+ if (!rec_get_deleted_flag(rec)) {
+ /* The new inserted record owns its possible externally
+ stored fields */
+
+ btr_cur_unmark_extern_fields(rec, mtr);
+ }
+
lock_rec_restore_from_page_infimum(rec, page);
/* If necessary, restore also the correct lock state for a new,
@@ -2183,6 +2221,7 @@ btr_cur_pessimistic_delete(
if compression does not occur, the cursor
stays valid: it points to successor of
deleted record on function exit */
+ ibool in_rollback,/* in: TRUE if called in rollback */
mtr_t* mtr) /* in: mtr */
{
page_t* page;
@@ -2218,7 +2257,8 @@ btr_cur_pessimistic_delete(
}
btr_rec_free_externally_stored_fields(cursor->index,
- btr_cur_get_rec(cursor), mtr);
+ btr_cur_get_rec(cursor), in_rollback, mtr);
+
if ((page_get_n_recs(page) < 2)
&& (dict_tree_get_page(btr_cur_get_tree(cursor))
!= buf_frame_get_page_no(page))) {
@@ -2517,6 +2557,199 @@ btr_estimate_number_of_different_key_vals(
/*================== EXTERNAL STORAGE OF BIG FIELDS ===================*/
/***********************************************************************
+Sets the ownership bit of an externally stored field in a record. */
+static
+void
+btr_cur_set_ownership_of_extern_field(
+/*==================================*/
+ rec_t* rec, /* in: clustered index record */
+ ulint i, /* in: field number */
+ ibool val, /* in: value to set */
+ mtr_t* mtr) /* in: mtr */
+{
+ byte* data;
+ ulint local_len;
+ ulint byte_val;
+
+ data = rec_get_nth_field(rec, i, &local_len);
+
+ ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE);
+
+ local_len -= BTR_EXTERN_FIELD_REF_SIZE;
+
+ byte_val = mach_read_from_1(data + local_len + BTR_EXTERN_LEN);
+
+ if (val) {
+ byte_val = byte_val & (~BTR_EXTERN_OWNER_FLAG);
+ } else {
+ byte_val = byte_val | BTR_EXTERN_OWNER_FLAG;
+ }
+
+ mlog_write_ulint(data + local_len + BTR_EXTERN_LEN, byte_val,
+ MLOG_1BYTE, mtr);
+}
+
+/***********************************************************************
+Marks not updated extern fields as not-owned by this record. The ownership
+is transferred to the updated record which is inserted elsewhere in the
+index tree. In purge only the owner of externally stored field is allowed
+to free the field. */
+
+void
+btr_cur_mark_extern_inherited_fields(
+/*=================================*/
+ rec_t* rec, /* in: record in a clustered index */
+ upd_t* update, /* in: update vector */
+ mtr_t* mtr) /* in: mtr */
+{
+ ibool is_updated;
+ ulint n;
+ ulint j;
+ ulint i;
+
+ n = rec_get_n_fields(rec);
+
+ for (i = 0; i < n; i++) {
+ if (rec_get_nth_field_extern_bit(rec, i)) {
+
+ /* Check it is not in updated fields */
+ is_updated = FALSE;
+
+ if (update) {
+ for (j = 0; j < upd_get_n_fields(update);
+ j++) {
+ if (upd_get_nth_field(update, j)
+ ->field_no == i) {
+ is_updated = TRUE;
+ }
+ }
+ }
+
+ if (!is_updated) {
+ btr_cur_set_ownership_of_extern_field(rec, i,
+ FALSE, mtr);
+ }
+ }
+ }
+}
+
+/***********************************************************************
+The complement of the previous function: in an update entry may inherit
+some externally stored fields from a record. We must mark them as inherited
+in entry, so that they are not freed in a rollback. */
+
+void
+btr_cur_mark_dtuple_inherited_extern(
+/*=================================*/
+ dtuple_t* entry, /* in: updated entry to be inserted to
+ clustered index */
+ ulint* ext_vec, /* in: array of extern fields in the
+ original record */
+ ulint n_ext_vec, /* in: number of elements in ext_vec */
+ upd_t* update) /* in: update vector */
+{
+ dfield_t* dfield;
+ ulint byte_val;
+ byte* data;
+ ulint len;
+ ibool is_updated;
+ ulint j;
+ ulint i;
+
+ if (ext_vec == NULL) {
+
+ return;
+ }
+
+ for (i = 0; i < n_ext_vec; i++) {
+
+ /* Check ext_vec[i] is in updated fields */
+ is_updated = FALSE;
+
+ for (j = 0; j < upd_get_n_fields(update); j++) {
+ if (upd_get_nth_field(update, j)->field_no
+ == ext_vec[i]) {
+ is_updated = TRUE;
+ }
+ }
+
+ if (!is_updated) {
+ dfield = dtuple_get_nth_field(entry, ext_vec[i]);
+
+ data = dfield_get_data(dfield);
+ len = dfield_get_len(dfield);
+
+ len -= BTR_EXTERN_FIELD_REF_SIZE;
+
+ byte_val = mach_read_from_1(data + len
+ + BTR_EXTERN_LEN);
+
+ byte_val = byte_val | BTR_EXTERN_INHERITED_FLAG;
+
+ mach_write_to_1(data + len + BTR_EXTERN_LEN, byte_val);
+ }
+ }
+}
+
+/***********************************************************************
+Marks all extern fields in a record as owned by the record. This function
+should be called if the delete mark of a record is removed: a not delete
+marked record always owns all its extern fields. */
+
+void
+btr_cur_unmark_extern_fields(
+/*=========================*/
+ rec_t* rec, /* in: record in a clustered index */
+ mtr_t* mtr) /* in: mtr */
+{
+ ulint n;
+ ulint i;
+
+ n = rec_get_n_fields(rec);
+
+ for (i = 0; i < n; i++) {
+ if (rec_get_nth_field_extern_bit(rec, i)) {
+
+ btr_cur_set_ownership_of_extern_field(rec, i,
+ TRUE, mtr);
+ }
+ }
+}
+
+/***********************************************************************
+Marks all extern fields in a dtuple as owned by the record. */
+
+void
+btr_cur_unmark_dtuple_extern_fields(
+/*================================*/
+ dtuple_t* entry, /* in: clustered index entry */
+ ulint* ext_vec, /* in: array of numbers of fields
+ which have been stored externally */
+ ulint n_ext_vec) /* in: number of elements in ext_vec */
+{
+ dfield_t* dfield;
+ ulint byte_val;
+ byte* data;
+ ulint len;
+ ulint i;
+
+ for (i = 0; i < n_ext_vec; i++) {
+ dfield = dtuple_get_nth_field(entry, ext_vec[i]);
+
+ data = dfield_get_data(dfield);
+ len = dfield_get_len(dfield);
+
+ len -= BTR_EXTERN_FIELD_REF_SIZE;
+
+ byte_val = mach_read_from_1(data + len + BTR_EXTERN_LEN);
+
+ byte_val = byte_val & (~BTR_EXTERN_OWNER_FLAG);
+
+ mach_write_to_1(data + len + BTR_EXTERN_LEN, byte_val);
+ }
+}
+
+/***********************************************************************
Stores the positions of the fields marked as extern storage in the update
vector, and also those fields who are marked as extern storage in rec
and not mentioned in updated fields. We use this function to remember
@@ -2766,7 +2999,9 @@ btr_store_big_rec_extern_fields(
/***********************************************************************
Frees the space in an externally stored field to the file space
-management. */
+management if the field in data is owned the externally stored field,
+in a rollback we may have the additional condition that the field must
+not be inherited. */
void
btr_free_externally_stored_field(
@@ -2777,6 +3012,9 @@ btr_free_externally_stored_field(
+ reference to the externally
stored part */
ulint local_len, /* in: length of data */
+ ibool do_not_free_inherited,/* in: TRUE if called in a
+ rollback and we do not want to free
+ inherited fields */
mtr_t* local_mtr) /* in: mtr containing the latch to
data an an X-latch to the index
tree */
@@ -2828,6 +3066,26 @@ btr_free_externally_stored_field(
return;
}
+ if (mach_read_from_1(data + local_len + BTR_EXTERN_LEN)
+ & BTR_EXTERN_OWNER_FLAG) {
+ /* This field does not own the externally
+ stored field: do not free! */
+
+ mtr_commit(&mtr);
+
+ return;
+ }
+
+ if (do_not_free_inherited
+ && mach_read_from_1(data + local_len + BTR_EXTERN_LEN)
+ & BTR_EXTERN_INHERITED_FLAG) {
+ /* Rollback and inherited field: do not free! */
+
+ mtr_commit(&mtr);
+
+ return;
+ }
+
page = buf_page_get(space_id, page_no, RW_X_LATCH, &mtr);
buf_page_dbg_add_level(page, SYNC_EXTERN_STORAGE);
@@ -2872,6 +3130,9 @@ btr_rec_free_externally_stored_fields(
dict_index_t* index, /* in: index of the data, the index
tree MUST be X-latched */
rec_t* rec, /* in: record */
+ ibool do_not_free_inherited,/* in: TRUE if called in a
+ rollback and we do not want to free
+ inherited fields */
mtr_t* mtr) /* in: mini-transaction handle which contains
an X-latch to record page and to the index
tree */
@@ -2896,7 +3157,8 @@ btr_rec_free_externally_stored_fields(
if (rec_get_nth_field_extern_bit(rec, i)) {
data = rec_get_nth_field(rec, i, &len);
- btr_free_externally_stored_field(index, data, len, mtr);
+ btr_free_externally_stored_field(index, data, len,
+ do_not_free_inherited, mtr);
}
}
}
@@ -2912,6 +3174,9 @@ btr_rec_free_updated_extern_fields(
X-latched */
rec_t* rec, /* in: record */
upd_t* update, /* in: update vector */
+ ibool do_not_free_inherited,/* in: TRUE if called in a
+ rollback and we do not want to free
+ inherited fields */
mtr_t* mtr) /* in: mini-transaction handle which contains
an X-latch to record page and to the tree */
{
@@ -2938,7 +3203,8 @@ btr_rec_free_updated_extern_fields(
if (rec_get_nth_field_extern_bit(rec, ufield->field_no)) {
data = rec_get_nth_field(rec, ufield->field_no, &len);
- btr_free_externally_stored_field(index, data, len, mtr);
+ btr_free_externally_stored_field(index, data, len,
+ do_not_free_inherited, mtr);
}
}
}
diff --git a/innobase/btr/btr0sea.c b/innobase/btr/btr0sea.c
index ac4e7c5ba3f..616f8911aba 100644
--- a/innobase/btr/btr0sea.c
+++ b/innobase/btr/btr0sea.c
@@ -769,6 +769,11 @@ btr_search_guess_on_hash(
buf_page_make_young(page);
}
+ /* Increment the page get statistics though we did not really
+ fix the page: for user info only */
+
+ buf_pool->n_page_gets++;
+
return(TRUE);
/*-------------------------------------------*/
diff --git a/innobase/buf/buf0buf.c b/innobase/buf/buf0buf.c
index 3fabe6c6d0e..f485088a5b7 100644
--- a/innobase/buf/buf0buf.c
+++ b/innobase/buf/buf0buf.c
@@ -349,6 +349,10 @@ buf_pool_create(
buf_pool->n_pages_written = 0;
buf_pool->n_pages_created = 0;
+ buf_pool->n_page_gets = 0;
+ buf_pool->n_page_gets_old = 0;
+ buf_pool->n_pages_read_old = 0;
+
/* 2. Initialize flushing fields
---------------------------- */
UT_LIST_INIT(buf_pool->flush_list);
@@ -667,6 +671,7 @@ buf_page_get_gen(
#ifndef UNIV_LOG_DEBUG
ut_ad(!ibuf_inside() || ibuf_page(space, offset));
#endif
+ buf_pool->n_page_gets++;
loop:
mutex_enter_fast(&(buf_pool->mutex));
@@ -846,6 +851,8 @@ buf_page_optimistic_get_func(
ut_ad(mtr && guess);
ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH));
+ buf_pool->n_page_gets++;
+
block = buf_block_align(guess);
mutex_enter(&(buf_pool->mutex));
@@ -976,6 +983,8 @@ buf_page_get_known_nowait(
ut_ad(mtr);
ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH));
+ buf_pool->n_page_gets++;
+
block = buf_block_align(guess);
mutex_enter(&(buf_pool->mutex));
@@ -1643,6 +1652,18 @@ buf_print_io(void)
printf("Pages read %lu, created %lu, written %lu\n",
buf_pool->n_pages_read, buf_pool->n_pages_created,
buf_pool->n_pages_written);
+
+ if (buf_pool->n_page_gets > buf_pool->n_page_gets_old) {
+ printf("Buffer pool hit rate %lu / 1000\n",
+ 1000
+ - ((1000 *
+ (buf_pool->n_pages_read - buf_pool->n_pages_read_old))
+ / (buf_pool->n_page_gets - buf_pool->n_page_gets_old)));
+ }
+
+ buf_pool->n_page_gets_old = buf_pool->n_page_gets;
+ buf_pool->n_pages_read_old = buf_pool->n_pages_read;
+
mutex_exit(&(buf_pool->mutex));
}
diff --git a/innobase/buf/buf0flu.c b/innobase/buf/buf0flu.c
index c87c92ed7e3..25c74f21fd3 100644
--- a/innobase/buf/buf0flu.c
+++ b/innobase/buf/buf0flu.c
@@ -28,7 +28,7 @@ Created 11/11/1995 Heikki Tuuri
flushed along with the original page. */
#define BUF_FLUSH_AREA ut_min(BUF_READ_AHEAD_AREA,\
- buf_pool->curr_size / 16)
+ buf_pool->curr_size / 16)
/**********************************************************************
Validates the flush list. */
diff --git a/innobase/data/data0data.c b/innobase/data/data0data.c
index 4172fb9c8ce..97db9d72f98 100644
--- a/innobase/data/data0data.c
+++ b/innobase/data/data0data.c
@@ -395,7 +395,12 @@ dtuple_convert_big_rec(
the entry enough, i.e., if there are
too many short fields in entry */
dict_index_t* index, /* in: index */
- dtuple_t* entry) /* in: index entry */
+ dtuple_t* entry, /* in: index entry */
+ ulint* ext_vec,/* in: array of externally stored fields,
+ or NULL: if a field already is externally
+ stored, then we cannot move it to the vector
+ this function returns */
+ ulint n_ext_vec)/* in: number of elements is ext_vec */
{
mem_heap_t* heap;
big_rec_t* vector;
@@ -404,7 +409,9 @@ dtuple_convert_big_rec(
ulint n_fields;
ulint longest;
ulint longest_i;
+ ibool is_externally_stored;
ulint i;
+ ulint j;
size = rec_get_converted_size(entry);
@@ -431,9 +438,23 @@ dtuple_convert_big_rec(
for (i = dict_index_get_n_unique_in_tree(index);
i < dtuple_get_n_fields(entry); i++) {
+ /* Skip over fields which already are externally
+ stored */
+
+ is_externally_stored = FALSE;
+
+ if (ext_vec) {
+ for (j = 0; j < n_ext_vec; j++) {
+ if (ext_vec[j] == i) {
+ is_externally_stored = TRUE;
+ }
+ }
+ }
+
/* Skip over fields which are ordering in some index */
- if (dict_field_get_col(
+ if (!is_externally_stored &&
+ dict_field_get_col(
dict_index_get_nth_field(index, i))
->ord_part == 0) {
diff --git a/innobase/fil/fil0fil.c b/innobase/fil/fil0fil.c
index 5c783627721..b386f224d11 100644
--- a/innobase/fil/fil0fil.c
+++ b/innobase/fil/fil0fil.c
@@ -19,6 +19,7 @@ Created 10/25/1995 Heikki Tuuri
#include "log0log.h"
#include "log0recv.h"
#include "fsp0fsp.h"
+#include "srv0srv.h"
/*
IMPLEMENTATION OF THE LOW-LEVEL FILE SYSTEM
@@ -1152,6 +1153,7 @@ fil_aio_wait(
ut_ad(fil_validate());
if (os_aio_use_native_aio) {
+ srv_io_thread_op_info[segment] = "native aio handle";
#ifdef WIN_ASYNC_IO
ret = os_aio_windows_handle(segment, 0, &fil_node, &message,
&type);
@@ -1161,12 +1163,16 @@ fil_aio_wait(
ut_a(0);
#endif
} else {
+ srv_io_thread_op_info[segment] = "simulated aio handle";
+
ret = os_aio_simulated_handle(segment, (void**) &fil_node,
&message, &type);
}
ut_a(ret);
-
+
+ srv_io_thread_op_info[segment] = "complete io for fil node";
+
mutex_enter(&(system->mutex));
fil_node_complete_io(fil_node, fil_system, type);
@@ -1178,9 +1184,10 @@ fil_aio_wait(
/* Do the i/o handling */
if (buf_pool_is_block(message)) {
-
+ srv_io_thread_op_info[segment] = "complete io for buf page";
buf_page_io_complete(message);
} else {
+ srv_io_thread_op_info[segment] = "complete io for log";
log_io_complete(message);
}
}
diff --git a/innobase/ibuf/ibuf0ibuf.c b/innobase/ibuf/ibuf0ibuf.c
index fd7b415551f..fa1c630dc08 100644
--- a/innobase/ibuf/ibuf0ibuf.c
+++ b/innobase/ibuf/ibuf0ibuf.c
@@ -2341,7 +2341,7 @@ ibuf_delete_rec(
root = ibuf_tree_root_get(ibuf_data, space, mtr);
btr_cur_pessimistic_delete(&err, TRUE, btr_pcur_get_btr_cur(pcur),
- mtr);
+ FALSE, mtr);
ut_a(err == DB_SUCCESS);
#ifdef UNIV_IBUF_DEBUG
diff --git a/innobase/include/btr0cur.h b/innobase/include/btr0cur.h
index ffae434a5d9..f56a5662253 100644
--- a/innobase/include/btr0cur.h
+++ b/innobase/include/btr0cur.h
@@ -353,6 +353,7 @@ btr_cur_pessimistic_delete(
if compression does not occur, the cursor
stays valid: it points to successor of
deleted record on function exit */
+ ibool in_rollback,/* in: TRUE if called in rollback */
mtr_t* mtr); /* in: mtr */
/***************************************************************
Parses a redo log record of updating a record in-place. */
@@ -418,6 +419,52 @@ btr_estimate_number_of_different_key_vals(
/* out: estimated number of key values */
dict_index_t* index); /* in: index */
/***********************************************************************
+Marks not updated extern fields as not-owned by this record. The ownership
+is transferred to the updated record which is inserted elsewhere in the
+index tree. In purge only the owner of externally stored field is allowed
+to free the field. */
+
+void
+btr_cur_mark_extern_inherited_fields(
+/*=================================*/
+ rec_t* rec, /* in: record in a clustered index */
+ upd_t* update, /* in: update vector */
+ mtr_t* mtr); /* in: mtr */
+/***********************************************************************
+The complement of the previous function: in an update entry may inherit
+some externally stored fields from a record. We must mark them as inherited
+in entry, so that they are not freed in a rollback. */
+
+void
+btr_cur_mark_dtuple_inherited_extern(
+/*=================================*/
+ dtuple_t* entry, /* in: updated entry to be inserted to
+ clustered index */
+ ulint* ext_vec, /* in: array of extern fields in the
+ original record */
+ ulint n_ext_vec, /* in: number of elements in ext_vec */
+ upd_t* update); /* in: update vector */
+/***********************************************************************
+Marks all extern fields in a record as owned by the record. This function
+should be called if the delete mark of a record is removed: a not delete
+marked record always owns all its extern fields. */
+
+void
+btr_cur_unmark_extern_fields(
+/*=========================*/
+ rec_t* rec, /* in: record in a clustered index */
+ mtr_t* mtr); /* in: mtr */
+/***********************************************************************
+Marks all extern fields in a dtuple as owned by the record. */
+
+void
+btr_cur_unmark_dtuple_extern_fields(
+/*================================*/
+ dtuple_t* entry, /* in: clustered index entry */
+ ulint* ext_vec, /* in: array of numbers of fields
+ which have been stored externally */
+ ulint n_ext_vec); /* in: number of elements in ext_vec */
+/***********************************************************************
Stores the fields in big_rec_vec to the tablespace and puts pointers to
them in rec. The fields are stored on pages allocated from leaf node
file segment of the index tree. */
@@ -435,7 +482,9 @@ btr_store_big_rec_extern_fields(
rec and to the tree */
/***********************************************************************
Frees the space in an externally stored field to the file space
-management. */
+management if the field in data is owned the externally stored field,
+in a rollback we may have the additional condition that the field must
+not be inherited. */
void
btr_free_externally_stored_field(
@@ -446,6 +495,9 @@ btr_free_externally_stored_field(
+ reference to the externally
stored part */
ulint local_len, /* in: length of data */
+ ibool do_not_free_inherited,/* in: TRUE if called in a
+ rollback and we do not want to free
+ inherited fields */
mtr_t* local_mtr); /* in: mtr containing the latch to
data an an X-latch to the index
tree */
@@ -458,6 +510,9 @@ btr_rec_free_externally_stored_fields(
dict_index_t* index, /* in: index of the data, the index
tree MUST be X-latched */
rec_t* rec, /* in: record */
+ ibool do_not_free_inherited,/* in: TRUE if called in a
+ rollback and we do not want to free
+ inherited fields */
mtr_t* mtr); /* in: mini-transaction handle which contains
an X-latch to record page and to the index
tree */
@@ -620,10 +675,21 @@ and sleep this many microseconds in between */
on that page */
#define BTR_EXTERN_LEN 12 /* 8 bytes containing the
length of the externally
- stored part of the BLOB */
+ stored part of the BLOB.
+ The 2 highest bits are
+ reserved to the flags below. */
/*--------------------------------------*/
#define BTR_EXTERN_FIELD_REF_SIZE 20
+/* The highest bit of BTR_EXTERN_LEN (i.e., the highest bit of the byte
+at lowest address) is set to 1 if this field does not 'own' the externally
+stored field; only the owner field is allowed to free the field in purge!
+If the 2nd highest bit is 1 then it means that the externally stored field
+was inherited from an earlier version of the row. In rollback we are not
+allowed to free an inherited external field. */
+
+#define BTR_EXTERN_OWNER_FLAG 128
+#define BTR_EXTERN_INHERITED_FLAG 64
extern ulint btr_cur_n_non_sea;
diff --git a/innobase/include/buf0buf.h b/innobase/include/buf0buf.h
index 8b22561adf8..66071030402 100644
--- a/innobase/include/buf0buf.h
+++ b/innobase/include/buf0buf.h
@@ -771,6 +771,17 @@ struct buf_pool_struct{
ulint n_pages_written;/* number write operations */
ulint n_pages_created;/* number of pages created in the pool
with no read */
+ ulint n_page_gets; /* number of page gets performed;
+ also successful seraches through
+ the adaptive hash index are
+ counted as page gets; this field
+ is NOT protected by the buffer
+ pool mutex */
+ ulint n_page_gets_old;/* n_page_gets when buf_print was
+ last time called: used to calculate
+ hit rate */
+ ulint n_pages_read_old;/* n_pages_read when buf_print was
+ last time called */
/* 2. Page flushing algorithm fields */
UT_LIST_BASE_NODE_T(buf_block_t) flush_list;
diff --git a/innobase/include/data0data.h b/innobase/include/data0data.h
index f695e0989a5..c314281d758 100644
--- a/innobase/include/data0data.h
+++ b/innobase/include/data0data.h
@@ -329,7 +329,12 @@ dtuple_convert_big_rec(
the entry enough, i.e., if there are
too many short fields in entry */
dict_index_t* index, /* in: index */
- dtuple_t* entry); /* in: index entry */
+ dtuple_t* entry, /* in: index entry */
+ ulint* ext_vec,/* in: array of externally stored fields,
+ or NULL: if a field already is externally
+ stored, then we cannot move it to the vector
+ this function returns */
+ ulint n_ext_vec);/* in: number of elements is ext_vec */
/******************************************************************
Puts back to entry the data stored in vector. Note that to ensure the
fields in entry can accommodate the data, vector must have been created
diff --git a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
index e635964e5ec..3f014adb76c 100644
--- a/innobase/include/srv0srv.h
+++ b/innobase/include/srv0srv.h
@@ -62,7 +62,15 @@ extern int srv_query_thread_priority;
/*-------------------------------------------*/
+extern ulint srv_n_rows_inserted;
+extern ulint srv_n_rows_updated;
+extern ulint srv_n_rows_deleted;
+extern ulint srv_n_rows_read;
+
extern ibool srv_print_innodb_monitor;
+extern ibool srv_print_innodb_lock_monitor;
+extern ibool srv_print_innodb_tablespace_monitor;
+
extern ulint srv_n_spin_wait_rounds;
extern ulint srv_spin_wait_delay;
extern ibool srv_priority_boost;
@@ -105,13 +113,19 @@ extern mutex_t* kernel_mutex_temp;/* mutex protecting the server, trx structs,
it from dynamic memory to get it to the
same DRAM page as other hotspot semaphores */
#define kernel_mutex (*kernel_mutex_temp)
+
+#define SRV_MAX_N_IO_THREADS 100
+/* Array of English strings describing the current state of an
+i/o handler thread */
+extern char* srv_io_thread_op_info[];
+
typedef struct srv_sys_struct srv_sys_t;
/* The server system */
extern srv_sys_t* srv_sys;
-/* Alternatives for fiel flush option in Unix; see the InnoDB manual about
+/* Alternatives for the field flush option in Unix; see the InnoDB manual about
what these mean */
#define SRV_UNIX_FDATASYNC 1
#define SRV_UNIX_O_DSYNC 2
diff --git a/innobase/include/trx0sys.h b/innobase/include/trx0sys.h
index e26f7e19850..0295cd6abff 100644
--- a/innobase/include/trx0sys.h
+++ b/innobase/include/trx0sys.h
@@ -315,6 +315,9 @@ struct trx_sys_struct{
/* List of active and committed in
memory transactions, sorted on trx id,
biggest first */
+ UT_LIST_BASE_NODE_T(trx_t) mysql_trx_list;
+ /* List of transactions created
+ for MySQL */
UT_LIST_BASE_NODE_T(trx_rseg_t) rseg_list;
/* List of rollback segment objects */
trx_rseg_t* latest_rseg; /* Latest rollback segment in the
diff --git a/innobase/include/trx0trx.h b/innobase/include/trx0trx.h
index f67ba43162d..fdef041e929 100644
--- a/innobase/include/trx0trx.h
+++ b/innobase/include/trx0trx.h
@@ -130,6 +130,14 @@ void
trx_mark_sql_stat_end(
/*==================*/
trx_t* trx); /* in: trx handle */
+/**************************************************************************
+Marks the latest SQL statement ended but does not start a new transaction
+if the trx is not started. */
+
+void
+trx_mark_sql_stat_end_do_not_start_new(
+/*===================================*/
+ trx_t* trx); /* in: trx handle */
/************************************************************************
Assigns a read view for a consistent read query. All the consistent reads
within the same transaction will get the same read view, which is created
@@ -236,6 +244,14 @@ trx_commit_step(
/*============*/
/* out: query thread to run next, or NULL */
que_thr_t* thr); /* in: query thread */
+/**************************************************************************
+Prints info about a transaction to the standard output. The caller must
+own the kernel mutex. */
+
+void
+trx_print(
+/*======*/
+ trx_t* trx); /* in: transaction */
/* Signal to a transaction */
@@ -270,6 +286,9 @@ rolling back after a database recovery */
struct trx_struct{
/* All the next fields are protected by the kernel mutex, except the
undo logs which are protected by undo_mutex */
+ char* op_info; /* English text describing the
+ current operation, or an empty
+ string */
ulint type; /* TRX_USER, TRX_PURGE */
ulint conc_state; /* state of the trx from the point
of view of concurrency control:
@@ -284,6 +303,8 @@ struct trx_struct{
table */
dulint table_id; /* table id if the preceding field is
TRUE */
+ void* mysql_thd; /* MySQL thread handle corresponding
+ to this trx, or NULL */
os_thread_id_t mysql_thread_id;/* id of the MySQL thread associated
with this transaction object */
ulint n_mysql_tables_in_use; /* number of Innobase tables
@@ -302,6 +323,9 @@ struct trx_struct{
of a duplicate key error */
UT_LIST_NODE_T(trx_t)
trx_list; /* list of transactions */
+ UT_LIST_NODE_T(trx_t)
+ mysql_trx_list; /* list of transactions created for
+ MySQL */
/*------------------------------*/
mutex_t undo_mutex; /* mutex protecting the fields in this
section (down to undo_no_arr), EXCEPT
diff --git a/innobase/include/ut0ut.h b/innobase/include/ut0ut.h
index e1813e763bd..4366b832ff6 100644
--- a/innobase/include/ut0ut.h
+++ b/innobase/include/ut0ut.h
@@ -11,7 +11,9 @@ Created 1/20/1994 Heikki Tuuri
#include "univ.i"
#include <time.h>
+#ifndef MYSQL_SERVER
#include <ctype.h>
+#endif
typedef time_t ib_time_t;
diff --git a/innobase/lock/lock0lock.c b/innobase/lock/lock0lock.c
index 5f8f538f392..819c559ceb4 100644
--- a/innobase/lock/lock0lock.c
+++ b/innobase/lock/lock0lock.c
@@ -13,6 +13,7 @@ Created 5/7/1996 Heikki Tuuri
#endif
#include "usr0sess.h"
+#include "trx0purge.h"
/* When releasing transaction locks, this specifies how often we release
the kernel mutex for a moment to give also others access to it */
@@ -3184,7 +3185,7 @@ lock_table_print(
ut_ad(mutex_own(&kernel_mutex));
ut_a(lock_get_type(lock) == LOCK_TABLE);
- printf("\nTABLE LOCK table %s trx id %lu %lu",
+ printf("TABLE LOCK table %s trx id %lu %lu",
lock->un_member.tab_lock.table->name,
(lock->trx)->id.high, (lock->trx)->id.low);
@@ -3220,6 +3221,8 @@ lock_rec_print(
ulint page_no;
ulint i;
ulint count = 0;
+ ulint len;
+ char buf[200];
mtr_t mtr;
ut_ad(mutex_own(&kernel_mutex));
@@ -3228,7 +3231,7 @@ lock_rec_print(
space = lock->un_member.rec_lock.space;
page_no = lock->un_member.rec_lock.page_no;
- printf("\nRECORD LOCKS space id %lu page no %lu n bits %lu",
+ printf("RECORD LOCKS space id %lu page no %lu n bits %lu",
space, page_no, lock_rec_get_n_bits(lock));
printf(" table %s index %s trx id %lu %lu",
@@ -3251,10 +3254,10 @@ lock_rec_print(
printf(" waiting");
}
- printf("\n");
-
mtr_start(&mtr);
+ printf("\n");
+
/* If the page is not in the buffer pool, we cannot load it
because we have the kernel mutex and ibuf operations would
break the latching order */
@@ -3280,12 +3283,14 @@ lock_rec_print(
printf("Record lock, heap no %lu ", i);
if (page) {
- rec_print(page_find_rec_with_heap_no(page, i));
+ len = rec_sprintf(buf, 190,
+ page_find_rec_with_heap_no(page, i));
+ buf[len] = '\0';
+ printf("%s", buf);
}
- count++;
-
printf("\n");
+ count++;
}
if (count >= 3) {
@@ -3342,12 +3347,32 @@ lock_print_info(void)
ulint nth_lock = 0;
ulint i;
mtr_t mtr;
+
+ printf(
+ "Purge done for all trx's with n:o < %lu %lu, undo n:o < %lu %lu\n",
+ ut_dulint_get_high(purge_sys->purge_trx_no),
+ ut_dulint_get_low(purge_sys->purge_trx_no),
+ ut_dulint_get_high(purge_sys->purge_undo_no),
+ ut_dulint_get_low(purge_sys->purge_undo_no));
- lock_mutex_enter_kernel();
+ lock_mutex_enter_kernel();
- printf("LOCK INFO:\n");
- printf("Number of locks in the record hash table %lu\n",
+ printf("Total number of lock structs in row lock hash table %lu\n",
lock_get_n_rec_locks());
+
+ /* First print info on non-active transactions */
+
+ trx = UT_LIST_GET_FIRST(trx_sys->mysql_trx_list);
+
+ while (trx) {
+ if (trx->conc_state == TRX_NOT_STARTED) {
+ printf("---");
+ trx_print(trx);
+ }
+
+ trx = UT_LIST_GET_NEXT(mysql_trx_list, trx);
+ }
+
loop:
trx = UT_LIST_GET_FIRST(trx_sys->trx_list);
@@ -3367,11 +3392,21 @@ loop:
}
if (nth_lock == 0) {
- printf("\nLOCKS FOR TRANSACTION ID %lu %lu\n", trx->id.high,
- trx->id.low);
+ printf("---");
+ trx_print(trx);
+
+ if (trx->read_view) {
+ printf(
+ "Trx read view will not see trx with id >= %lu %lu, sees < %lu %lu\n",
+ ut_dulint_get_high(trx->read_view->low_limit_id),
+ ut_dulint_get_low(trx->read_view->low_limit_id),
+ ut_dulint_get_high(trx->read_view->up_limit_id),
+ ut_dulint_get_low(trx->read_view->up_limit_id));
+ }
+
if (trx->que_state == TRX_QUE_LOCK_WAIT) {
printf(
- "################# TRX IS WAITING FOR THE LOCK: ###\n");
+ "------------------TRX IS WAITING FOR THE LOCK:\n");
if (lock_get_type(trx->wait_lock) == LOCK_REC) {
lock_rec_print(trx->wait_lock);
@@ -3380,10 +3415,15 @@ loop:
}
printf(
- "##################################################\n");
+ "------------------\n");
}
}
+ if (!srv_print_innodb_lock_monitor) {
+ nth_trx++;
+ goto loop;
+ }
+
i = 0;
lock = UT_LIST_GET_FIRST(trx->trx_locks);
@@ -3431,9 +3471,9 @@ loop:
nth_lock++;
- if (nth_lock >= 25) {
+ if (nth_lock >= 10) {
printf(
- "25 LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n");
+ "10 LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n");
nth_trx++;
nth_lock = 0;
diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c
index 0525fd7b59a..d4d30f6aabc 100644
--- a/innobase/os/os0file.c
+++ b/innobase/os/os0file.c
@@ -1577,6 +1577,7 @@ os_aio_windows_handle(
void** message2,
ulint* type) /* out: OS_FILE_WRITE or ..._READ */
{
+ ulint orig_seg = segment;
os_aio_array_t* array;
os_aio_slot_t* slot;
ulint n;
@@ -1602,10 +1603,14 @@ os_aio_windows_handle(
n = array->n_slots / array->n_segments;
if (array == os_aio_sync_array) {
+ srv_io_thread_op_info[orig_seg] = "wait windows aio for 1 page";
+
ut_ad(pos < array->n_slots);
os_event_wait(array->events[pos]);
i = pos;
} else {
+ srv_io_thread_op_info[orig_seg] =
+ "wait windows aio for n pages";
i = os_event_wait_multiple(n, (array->events) + segment * n);
}
@@ -1615,6 +1620,7 @@ os_aio_windows_handle(
ut_a(slot->reserved);
+ srv_io_thread_op_info[orig_seg] = "get windows aio return value";
ret = GetOverlappedResult(slot->file, &(slot->control), &len, TRUE);
*message1 = slot->message1;
@@ -1887,6 +1893,8 @@ consecutive_loop:
}
}
+ srv_io_thread_op_info[global_segment] = "doing file i/o";
+
/* Do the i/o with ordinary, synchronous i/o functions: */
if (slot->type == OS_FILE_WRITE) {
ret = os_file_write(slot->name, slot->file, combined_buf,
@@ -1897,7 +1905,8 @@ consecutive_loop:
}
ut_a(ret);
-
+ srv_io_thread_op_info[global_segment] = "file i/o done";
+
/* printf("aio: %lu consecutive %lu:th segment, first offs %lu blocks\n",
n_consecutive, global_segment, slot->offset
/ UNIV_PAGE_SIZE); */
@@ -1953,6 +1962,8 @@ wait_for_io:
os_mutex_exit(array->mutex);
+ srv_io_thread_op_info[global_segment] = "waiting for i/o request";
+
os_event_wait(os_aio_segment_wait_events[global_segment]);
goto restart;
@@ -2023,7 +2034,12 @@ os_aio_print(void)
ulint n_reserved;
ulint i;
- printf("Pending normal aio reads:\n");
+ for (i = 0; i < srv_n_file_io_threads; i++) {
+ printf("I/O thread %lu state: %s\n", i,
+ srv_io_thread_op_info[i]);
+ }
+
+ printf("Pending normal aio reads: ");
array = os_aio_read_array;
loop:
@@ -2041,21 +2057,21 @@ loop:
if (slot->reserved) {
n_reserved++;
- printf("Reserved slot, messages %lx %lx\n",
+ /* printf("Reserved slot, messages %lx %lx\n",
(ulint)slot->message1,
(ulint)slot->message2);
- ut_a(slot->len > 0);
+ */ ut_a(slot->len > 0);
}
}
ut_a(array->n_reserved == n_reserved);
- printf("Total of %lu reserved aio slots\n", n_reserved);
+ printf("%lu\n", n_reserved);
os_mutex_exit(array->mutex);
if (array == os_aio_read_array) {
- printf("Pending aio writes:\n");
+ printf("Pending aio writes: ");
array = os_aio_write_array;
@@ -2063,21 +2079,21 @@ loop:
}
if (array == os_aio_write_array) {
- printf("Pending insert buffer aio reads:\n");
+ printf("Pending insert buffer aio reads: ");
array = os_aio_ibuf_array;
goto loop;
}
if (array == os_aio_ibuf_array) {
- printf("Pending log writes or reads:\n");
+ printf("Pending log writes or reads: ");
array = os_aio_log_array;
goto loop;
}
if (array == os_aio_log_array) {
- printf("Pending synchronous reads or writes:\n");
+ printf("Pending synchronous reads or writes: ");
array = os_aio_sync_array;
goto loop;
diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c
index 9bbc45a5c9a..373ee4ac4bd 100644
--- a/innobase/row/row0mysql.c
+++ b/innobase/row/row0mysql.c
@@ -462,6 +462,8 @@ row_insert_for_mysql(
ut_ad(trx);
ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
+ trx->op_info = "inserting";
+
if (node == NULL) {
row_get_prebuilt_insert_row(prebuilt);
node = prebuilt->ins_node;
@@ -499,6 +501,8 @@ run_again:
goto run_again;
}
+ trx->op_info = "";
+
return(err);
}
@@ -506,12 +510,15 @@ run_again:
prebuilt->table->stat_n_rows++;
+ srv_n_rows_inserted++;
+
if (prebuilt->table->stat_n_rows == 0) {
/* Avoid wrap-over */
prebuilt->table->stat_n_rows--;
}
row_update_statistics_if_needed(prebuilt);
+ trx->op_info = "";
return((int) err);
}
@@ -627,6 +634,8 @@ row_update_for_mysql(
ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
UT_NOT_USED(mysql_rec);
+ trx->op_info = "updating or deleting";
+
node = prebuilt->upd_node;
clust_index = dict_table_get_first_index(table);
@@ -700,6 +709,7 @@ run_again:
if (err == DB_RECORD_NOT_FOUND) {
trx->error_state = DB_SUCCESS;
+ trx->op_info = "";
return((int) err);
}
@@ -710,6 +720,8 @@ run_again:
goto run_again;
}
+ trx->op_info = "";
+
return(err);
}
@@ -719,10 +731,16 @@ run_again:
if (prebuilt->table->stat_n_rows > 0) {
prebuilt->table->stat_n_rows--;
}
- }
+
+ srv_n_rows_deleted++;
+ } else {
+ srv_n_rows_updated++;
+ }
row_update_statistics_if_needed(prebuilt);
+ trx->op_info = "";
+
return((int) err);
}
@@ -798,6 +816,8 @@ row_create_table_for_mysql(
ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
+ trx->op_info = "creating table";
+
/* Serialize data dictionary operations with dictionary mutex:
no deadlocks can occur then in these operations */
@@ -825,16 +845,22 @@ row_create_table_for_mysql(
trx_general_rollback_for_mysql(trx, FALSE, NULL);
if (err == DB_OUT_OF_FILE_SPACE) {
- row_drop_table_for_mysql(table->name, trx, TRUE);
+ row_drop_table_for_mysql(table->name, trx, TRUE);
} else {
- assert(err == DB_DUPLICATE_KEY);
- fprintf(stderr,
+ assert(err == DB_DUPLICATE_KEY);
+ fprintf(stderr,
"InnoDB: Error: table %s already exists in InnoDB internal\n"
"InnoDB: data dictionary. Have you deleted the .frm file\n"
"InnoDB: and not used DROP TABLE? Have you used DROP DATABASE\n"
- "InnoDB: for InnoDB tables in MySQL version <= 3.23.39?\n"
+ "InnoDB: for InnoDB tables in MySQL version <= 3.23.42?\n"
"InnoDB: See the Restrictions section of the InnoDB manual.\n",
table->name);
+ fprintf(stderr,
+ "InnoDB: You can drop the orphaned table inside InnoDB by\n"
+ "InnoDB: creating an InnoDB table with the same name in another\n"
+ "InnoDB: database and moving the .frm file to the current database.\n"
+ "InnoDB: Then MySQL thinks the table exists, and DROP TABLE will\n"
+ "InnoDB: succeed.\n");
}
trx->error_state = DB_SUCCESS;
@@ -852,11 +878,32 @@ row_create_table_for_mysql(
srv_print_innodb_monitor = TRUE;
}
+
+ keywordlen = ut_strlen("innodb_lock_monitor");
+
+ if (namelen >= keywordlen
+ && 0 == ut_memcmp(table->name + namelen - keywordlen,
+ "innodb_lock_monitor", keywordlen)) {
+
+ srv_print_innodb_monitor = TRUE;
+ srv_print_innodb_lock_monitor = TRUE;
+ }
+
+ keywordlen = ut_strlen("innodb_tablespace_monitor");
+
+ if (namelen >= keywordlen
+ && 0 == ut_memcmp(table->name + namelen - keywordlen,
+ "innodb_tablespace_monitor", keywordlen)) {
+
+ srv_print_innodb_tablespace_monitor = TRUE;
+ }
}
mutex_exit(&(dict_sys->mutex));
que_graph_free((que_t*) que_node_get_parent(thr));
-
+
+ trx->op_info = "";
+
return((int) err);
}
@@ -879,6 +926,8 @@ row_create_index_for_mysql(
ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
+ trx->op_info = "creating index";
+
/* Serialize data dictionary operations with dictionary mutex:
no deadlocks can occur then in these operations */
@@ -915,6 +964,8 @@ row_create_index_for_mysql(
que_graph_free((que_t*) que_node_get_parent(thr));
+ trx->op_info = "";
+
return((int) err);
}
@@ -945,7 +996,9 @@ row_drop_table_for_mysql(
ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
ut_a(name != NULL);
-
+
+ trx->op_info = "dropping table";
+
namelen = ut_strlen(name);
keywordlen = ut_strlen("innodb_monitor");
@@ -957,6 +1010,26 @@ row_drop_table_for_mysql(
stop monitor prints */
srv_print_innodb_monitor = FALSE;
+ srv_print_innodb_lock_monitor = FALSE;
+ }
+
+ keywordlen = ut_strlen("innodb_lock_monitor");
+
+ if (namelen >= keywordlen
+ && 0 == ut_memcmp(name + namelen - keywordlen,
+ "innodb_lock_monitor", keywordlen)) {
+
+ srv_print_innodb_monitor = FALSE;
+ srv_print_innodb_lock_monitor = FALSE;
+ }
+
+ keywordlen = ut_strlen("innodb_tablespace_monitor");
+
+ if (namelen >= keywordlen
+ && 0 == ut_memcmp(name + namelen - keywordlen,
+ "innodb_tablespace_monitor", keywordlen)) {
+
+ srv_print_innodb_tablespace_monitor = FALSE;
}
/* We use the private SQL parser of Innobase to generate the
@@ -1071,6 +1144,8 @@ funct_exit:
que_graph_free(graph);
+ trx->op_info = "";
+
return((int) err);
}
@@ -1099,6 +1174,8 @@ row_rename_table_for_mysql(
ut_a(old_name != NULL);
ut_a(new_name != NULL);
+ trx->op_info = "renaming table";
+
str1 =
"PROCEDURE RENAME_TABLE_PROC () IS\n"
"BEGIN\n"
@@ -1168,6 +1245,8 @@ funct_exit:
que_graph_free(graph);
+ trx->op_info = "";
+
return((int) err);
}
@@ -1279,6 +1358,8 @@ row_check_table_for_mysql(
ulint n_rows;
ulint n_rows_in_table;
ulint ret = DB_SUCCESS;
+
+ prebuilt->trx->op_info = "checking table";
index = dict_table_get_first_index(table);
@@ -1311,5 +1392,7 @@ row_check_table_for_mysql(
index = dict_table_get_next_index(index);
}
+ prebuilt->trx->op_info = "";
+
return(ret);
}
diff --git a/innobase/row/row0purge.c b/innobase/row/row0purge.c
index ec880d3fe04..43bc166347a 100644
--- a/innobase/row/row0purge.c
+++ b/innobase/row/row0purge.c
@@ -132,7 +132,7 @@ row_purge_remove_clust_if_poss_low(
success = btr_cur_optimistic_delete(btr_cur, &mtr);
} else {
ut_ad(mode == BTR_MODIFY_TREE);
- btr_cur_pessimistic_delete(&err, FALSE, btr_cur, &mtr);
+ btr_cur_pessimistic_delete(&err, FALSE, btr_cur, FALSE, &mtr);
if (err == DB_SUCCESS) {
success = TRUE;
@@ -254,8 +254,8 @@ row_purge_remove_sec_if_poss_low(
success = btr_cur_optimistic_delete(btr_cur, &mtr);
} else {
ut_ad(mode == BTR_MODIFY_TREE);
- btr_cur_pessimistic_delete(&err, FALSE, btr_cur, &mtr);
-
+ btr_cur_pessimistic_delete(&err, FALSE, btr_cur,
+ FALSE, &mtr);
if (err == DB_SUCCESS) {
success = TRUE;
} else if (err == DB_OUT_OF_FILE_SPACE) {
@@ -437,7 +437,7 @@ skip_secondaries:
data_field_len = ufield->new_val.len;
btr_free_externally_stored_field(index, data_field,
- data_field_len, &mtr);
+ data_field_len, FALSE, &mtr);
mtr_commit(&mtr);
}
}
diff --git a/innobase/row/row0sel.c b/innobase/row/row0sel.c
index 0ad6b7084e2..d041e34a558 100644
--- a/innobase/row/row0sel.c
+++ b/innobase/row/row0sel.c
@@ -2488,6 +2488,8 @@ row_search_for_mysql(
printf("N tables locked %lu\n", trx->mysql_n_tables_locked);
*/
if (direction == 0) {
+ trx->op_info = "starting index read";
+
prebuilt->n_rows_fetched = 0;
prebuilt->n_fetch_cached = 0;
prebuilt->fetch_cache_first = 0;
@@ -2497,6 +2499,8 @@ row_search_for_mysql(
row_prebuild_sel_graph(prebuilt);
}
} else {
+ trx->op_info = "fetching rows";
+
if (prebuilt->n_rows_fetched == 0) {
prebuilt->fetch_direction = direction;
}
@@ -2519,6 +2523,9 @@ row_search_for_mysql(
prebuilt->n_rows_fetched++;
+ srv_n_rows_read++;
+ trx->op_info = "";
+
return(DB_SUCCESS);
}
@@ -2529,6 +2536,7 @@ row_search_for_mysql(
cache, but the cache was not full at the time of the
popping: no more rows can exist in the result set */
+ trx->op_info = "";
return(DB_RECORD_NOT_FOUND);
}
@@ -2560,6 +2568,7 @@ row_search_for_mysql(
/* printf("%s record not found 1\n", index->name); */
+ trx->op_info = "";
return(DB_RECORD_NOT_FOUND);
}
@@ -2599,6 +2608,9 @@ row_search_for_mysql(
/* printf("%s shortcut\n", index->name); */
+ srv_n_rows_read++;
+
+ trx->op_info = "";
return(DB_SUCCESS);
} else if (shortcut == SEL_EXHAUSTED) {
@@ -2607,6 +2619,7 @@ row_search_for_mysql(
/* printf("%s record not found 2\n",
index->name); */
+ trx->op_info = "";
return(DB_RECORD_NOT_FOUND);
}
@@ -2980,6 +2993,8 @@ lock_wait_or_error:
/* printf("Using index %s cnt %lu ret value %lu err\n", index->name,
cnt, err); */
+ trx->op_info = "";
+
return(err);
normal_return:
@@ -2995,5 +3010,11 @@ normal_return:
/* printf("Using index %s cnt %lu ret value %lu\n", index->name,
cnt, err); */
+ if (ret == DB_SUCCESS) {
+ srv_n_rows_read++;
+ }
+
+ trx->op_info = "";
+
return(ret);
}
diff --git a/innobase/row/row0uins.c b/innobase/row/row0uins.c
index 47807877779..27d1fbcb9ba 100644
--- a/innobase/row/row0uins.c
+++ b/innobase/row/row0uins.c
@@ -89,7 +89,7 @@ retry:
&(node->pcur), &mtr);
ut_a(success);
- btr_cur_pessimistic_delete(&err, FALSE, btr_cur, &mtr);
+ btr_cur_pessimistic_delete(&err, FALSE, btr_cur, TRUE, &mtr);
/* The delete operation may fail if we have little
file space left: TODO: easiest to crash the database
@@ -174,7 +174,7 @@ row_undo_ins_remove_sec_low(
} else {
ut_ad(mode == BTR_MODIFY_TREE);
- btr_cur_pessimistic_delete(&err, FALSE, btr_cur, &mtr);
+ btr_cur_pessimistic_delete(&err, FALSE, btr_cur, TRUE, &mtr);
}
btr_pcur_close(&pcur);
diff --git a/innobase/row/row0umod.c b/innobase/row/row0umod.c
index 0221c51b985..a7c8957d61a 100644
--- a/innobase/row/row0umod.c
+++ b/innobase/row/row0umod.c
@@ -179,7 +179,11 @@ row_undo_mod_remove_clust_low(
} else {
ut_ad(mode == BTR_MODIFY_TREE);
- btr_cur_pessimistic_delete(&err, FALSE, btr_cur, mtr);
+ /* Note that since this operation is analogous to purge,
+ we can free also inherited externally stored fields:
+ hence the last FALSE in the call below */
+
+ btr_cur_pessimistic_delete(&err, FALSE, btr_cur, FALSE, mtr);
/* The delete operation may fail if we have little
file space left: TODO: easiest to crash the database
@@ -356,7 +360,8 @@ row_undo_mod_del_mark_or_remove_sec_low(
} else {
ut_ad(mode == BTR_MODIFY_TREE);
- btr_cur_pessimistic_delete(&err, FALSE, btr_cur, &mtr);
+ btr_cur_pessimistic_delete(&err, FALSE, btr_cur,
+ TRUE, &mtr);
/* The delete operation may fail if we have little
file space left: TODO: easiest to crash the database
@@ -423,22 +428,22 @@ row_undo_mod_del_unmark_sec(
found = row_search_index_entry(index, entry, BTR_MODIFY_LEAF, &pcur,
&mtr);
if (!found) {
- err_buf = mem_alloc(1000);
- dtuple_sprintf(err_buf, 900, entry);
-
- fprintf(stderr, "InnoDB: error in sec index entry del undo in\n"
- "InnoDB: index %s table %s\n", index->name,
- index->table->name);
- fprintf(stderr, "InnoDB: tuple %s\n", err_buf);
+ err_buf = mem_alloc(1000);
+ dtuple_sprintf(err_buf, 900, entry);
- rec_sprintf(err_buf, 900, btr_pcur_get_rec(&pcur));
- fprintf(stderr, "InnoDB: record %s\n", err_buf);
+ fprintf(stderr, "InnoDB: error in sec index entry del undo in\n"
+ "InnoDB: index %s table %s\n", index->name,
+ index->table->name);
+ fprintf(stderr, "InnoDB: tuple %s\n", err_buf);
- fprintf(stderr, "InnoDB: Make a detailed bug report and send it\n");
- fprintf(stderr, "InnoDB: to mysql@lists.mysql.com\n");
+ rec_sprintf(err_buf, 900, btr_pcur_get_rec(&pcur));
+ fprintf(stderr, "InnoDB: record %s\n", err_buf);
- mem_free(err_buf);
+ fprintf(stderr,
+ "InnoDB: Make a detailed bug report and send it\n");
+ fprintf(stderr, "InnoDB: to mysql@lists.mysql.com\n");
+ mem_free(err_buf);
} else {
btr_cur = btr_pcur_get_btr_cur(&pcur);
diff --git a/innobase/row/row0upd.c b/innobase/row/row0upd.c
index 67a5925a3f5..3fa98db3a02 100644
--- a/innobase/row/row0upd.c
+++ b/innobase/row/row0upd.c
@@ -840,32 +840,31 @@ row_upd_sec_index_entry(
rec = btr_cur_get_rec(btr_cur);
if (!found) {
+ err_buf = mem_alloc(1000);
+ dtuple_sprintf(err_buf, 900, entry);
- err_buf = mem_alloc(1000);
- dtuple_sprintf(err_buf, 900, entry);
+ fprintf(stderr, "InnoDB: error in sec index entry update in\n"
+ "InnoDB: index %s table %s\n", index->name,
+ index->table->name);
+ fprintf(stderr, "InnoDB: tuple %s\n", err_buf);
- fprintf(stderr, "InnoDB: error in sec index entry update in\n"
- "InnoDB: index %s table %s\n", index->name,
- index->table->name);
- fprintf(stderr, "InnoDB: tuple %s\n", err_buf);
+ rec_sprintf(err_buf, 900, rec);
+ fprintf(stderr, "InnoDB: record %s\n", err_buf);
- rec_sprintf(err_buf, 900, rec);
- fprintf(stderr, "InnoDB: record %s\n", err_buf);
+ fprintf(stderr,
+ "InnoDB: Make a detailed bug report and send it\n");
+ fprintf(stderr, "InnoDB: to mysql@lists.mysql.com\n");
- fprintf(stderr, "InnoDB: Make a detailed bug report and send it\n");
- fprintf(stderr, "InnoDB: to mysql@lists.mysql.com\n");
-
- mem_free(err_buf);
+ mem_free(err_buf);
} else {
-
- /* Delete mark the old index record; it can already be
- delete marked if we return after a lock wait in
- row_ins_index_entry below */
-
- if (!rec_get_deleted_flag(rec)) {
- err = btr_cur_del_mark_set_sec_rec(0, btr_cur, TRUE, thr,
- &mtr);
- }
+ /* Delete mark the old index record; it can already be
+ delete marked if we return after a lock wait in
+ row_ins_index_entry below */
+
+ if (!rec_get_deleted_flag(rec)) {
+ err = btr_cur_del_mark_set_sec_rec(0, btr_cur, TRUE,
+ thr, &mtr);
+ }
}
btr_pcur_close(&pcur);
@@ -907,7 +906,7 @@ row_upd_sec_step(
|| (node->state == UPD_NODE_UPDATE_SOME_SEC));
ut_ad(!(node->index->type & DICT_CLUSTERED));
- if ((node->state == UPD_NODE_UPDATE_ALL_SEC)
+ if (node->state == UPD_NODE_UPDATE_ALL_SEC
|| row_upd_changes_ord_field(node->row, node->index,
node->update)) {
err = row_upd_sec_index_entry(node, thr);
@@ -933,15 +932,13 @@ row_upd_clust_rec_by_insert(
dict_index_t* index, /* in: clustered index of the record */
que_thr_t* thr, /* in: query thread */
mtr_t* mtr) /* in: mtr; gets committed here */
-{
+{
+ mem_heap_t* heap;
btr_pcur_t* pcur;
btr_cur_t* btr_cur;
trx_t* trx;
dict_table_t* table;
- mem_heap_t* heap;
dtuple_t* entry;
- ulint* ext_vec;
- ulint n_ext_vec;
ulint err;
ut_ad(node);
@@ -961,17 +958,20 @@ row_upd_clust_rec_by_insert(
return(err);
}
+ /* Mark as not-owned the externally stored fields which the new
+ row inherits from the delete marked record: purge should not
+ free those externally stored fields even if the delete marked
+ record is removed from the index tree, or updated. */
+
+ btr_cur_mark_extern_inherited_fields(btr_cur_get_rec(btr_cur),
+ node->update, mtr);
}
mtr_commit(mtr);
node->state = UPD_NODE_INSERT_CLUSTERED;
- heap = mem_heap_create(1024);
-
- ext_vec = mem_heap_alloc(heap,
- sizeof(ulint) * dtuple_get_n_fields(node->row));
- n_ext_vec = 0;
+ heap = mem_heap_create(500);
entry = row_build_index_entry(node->row, index, heap);
@@ -979,10 +979,23 @@ row_upd_clust_rec_by_insert(
row_upd_index_entry_sys_field(entry, index, DATA_TRX_ID, trx->id);
+ /* If we return from a lock wait, for example, we may have
+ extern fields marked as not-owned in entry (marked if the
+ if-branch above). We must unmark them. */
+
+ btr_cur_unmark_dtuple_extern_fields(entry, node->ext_vec,
+ node->n_ext_vec);
+ /* We must mark non-updated extern fields in entry as inherited,
+ so that a possible rollback will not free them */
+
+ btr_cur_mark_dtuple_inherited_extern(entry, node->ext_vec,
+ node->n_ext_vec,
+ node->update);
+
err = row_ins_index_entry(index, entry, node->ext_vec,
node->n_ext_vec, thr);
- mem_heap_free(heap);
-
+ mem_heap_free(heap);
+
return(err);
}
diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
index 8dd9c9f3feb..ba556e1c050 100644
--- a/innobase/srv/srv0srv.c
+++ b/innobase/srv/srv0srv.c
@@ -111,7 +111,14 @@ ibool srv_print_buf_io = FALSE;
ibool srv_print_log_io = FALSE;
ibool srv_print_latch_waits = FALSE;
+ulint srv_n_rows_inserted = 0;
+ulint srv_n_rows_updated = 0;
+ulint srv_n_rows_deleted = 0;
+ulint srv_n_rows_read = 0;
+
ibool srv_print_innodb_monitor = FALSE;
+ibool srv_print_innodb_lock_monitor = FALSE;
+ibool srv_print_innodb_tablespace_monitor = FALSE;
/* The parameters below are obsolete: */
@@ -137,6 +144,11 @@ ulint srv_test_n_reserved_rnds = ULINT_MAX;
ulint srv_test_array_size = ULINT_MAX;
ulint srv_test_n_mutexes = ULINT_MAX;
+/* Array of English strings describing the current state of an
+i/o handler thread */
+
+char* srv_io_thread_op_info[SRV_MAX_N_IO_THREADS];
+
/*
IMPLEMENTATION OF THE SERVER MAIN PROGRAM
=========================================
@@ -1926,23 +1938,25 @@ loop:
}
background_loop:
- /* In this loop we run background operations while the server
+ /* In this loop we run background operations when the server
is quiet */
current_time = time(NULL);
- if (srv_print_innodb_monitor
- && difftime(current_time, last_monitor_time) > 8) {
+ if (difftime(current_time, last_monitor_time) > 15) {
+
+ last_monitor_time = time(NULL);
+
+ if (srv_print_innodb_monitor) {
- printf("================================\n");
- last_monitor_time = time(NULL);
+ printf("=====================================\n");
ut_print_timestamp(stdout);
printf(" INNODB MONITOR OUTPUT\n"
- "================================\n");
- printf("--------------------------\n"
- "LOCKS HELD BY TRANSACTIONS\n"
- "--------------------------\n");
+ "=====================================\n");
+ printf("------------\n"
+ "TRANSACTIONS\n"
+ "------------\n");
lock_print_info();
printf("-----------------------------------------------\n"
"CURRENT SEMAPHORES RESERVED AND SEMAPHORE WAITS\n"
@@ -1955,11 +1969,40 @@ background_loop:
"BUFFER POOL\n"
"-----------\n");
buf_print_io();
+ printf("--------------\n"
+ "ROW OPERATIONS\n"
+ "--------------\n");
+ printf(
+ "Number of rows inserted %lu, updated %lu, deleted %lu, read %lu\n",
+ srv_n_rows_inserted,
+ srv_n_rows_updated,
+ srv_n_rows_deleted,
+ srv_n_rows_read);
+ printf("Server activity counter %lu\n", srv_activity_count);
printf("----------------------------\n"
"END OF INNODB MONITOR OUTPUT\n"
"============================\n");
- }
+ }
+
+ if (srv_print_innodb_tablespace_monitor) {
+ printf("================================================\n");
+
+ ut_print_timestamp(stdout);
+
+ printf(" INNODB TABLESPACE MONITOR OUTPUT\n"
+ "================================================\n");
+
+ fsp_print(0);
+ fprintf(stderr, "Validating tablespace\n");
+ fsp_validate(0);
+ fprintf(stderr, "Validation ok\n");
+ printf("---------------------------------------\n"
+ "END OF INNODB TABLESPACE MONITOR OUTPUT\n"
+ "=======================================\n");
+ }
+ }
+
mutex_enter(&kernel_mutex);
if (srv_activity_count != old_activity_count) {
mutex_exit(&kernel_mutex);
@@ -2009,8 +2052,18 @@ background_loop:
}
mutex_exit(&kernel_mutex);
+ if (srv_print_innodb_monitor) {
+ ut_print_timestamp(stdout);
+ printf(" InnoDB (main thread) starts buffer pool flush\n");
+ }
+
n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
+ if (srv_print_innodb_monitor) {
+ ut_print_timestamp(stdout);
+ printf(" InnoDB flushed %lu pages\n", n_pages_flushed);
+ }
+
mutex_enter(&kernel_mutex);
if (srv_activity_count != old_activity_count) {
mutex_exit(&kernel_mutex);
@@ -2038,12 +2091,7 @@ background_loop:
/* mem_print_new_info();
*/
-/*
- fsp_print(0);
- fprintf(stderr, "Validating tablespace\n");
- fsp_validate(0);
- fprintf(stderr, "Validation ok\n");
-*/
+
#ifdef UNIV_SEARCH_PERF_STAT
/* btr_search_print_info(); */
#endif
diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
index b3f5dbb28b5..c4002767226 100644
--- a/innobase/srv/srv0start.c
+++ b/innobase/srv/srv0start.c
@@ -67,8 +67,6 @@ os_file_t files[1000];
mutex_t ios_mutex;
ulint ios;
-#define SRV_MAX_N_IO_THREADS 1000
-
ulint n[SRV_MAX_N_IO_THREADS + 5];
os_thread_id_t thread_ids[SRV_MAX_N_IO_THREADS + 5];
@@ -591,6 +589,11 @@ innobase_start_or_create_for_mysql(void)
return((int) err);
}
+ /* Restrict the maximum number of file i/o threads */
+ if (srv_n_file_io_threads > SRV_MAX_N_IO_THREADS) {
+ srv_n_file_io_threads = SRV_MAX_N_IO_THREADS;
+ }
+
#if !(defined(WIN_ASYNC_IO) || defined(POSIX_ASYNC_IO))
/* In simulated aio we currently have use only for 4 threads */
diff --git a/innobase/sync/sync0arr.c b/innobase/sync/sync0arr.c
index 48d043e1e04..4183f3f1c4c 100644
--- a/innobase/sync/sync0arr.c
+++ b/innobase/sync/sync0arr.c
@@ -438,22 +438,48 @@ sync_array_cell_print(
/*==================*/
sync_cell_t* cell) /* in: sync cell */
{
- char* str = NULL;
- ulint type;
+ mutex_t* mutex;
+ rw_lock_t* rwlock;
+ char* str = NULL;
+ ulint type;
type = cell->request_type;
if (type == SYNC_MUTEX) {
str = "MUTEX ENTER";
- } else if (type == RW_LOCK_EX) {
- str = "X-LOCK";
- } else if (type == RW_LOCK_SHARED) {
- str = "S-LOCK";
+ mutex = (mutex_t*)cell->wait_object;
+
+ printf("Mutex created in file %s line %lu",
+ mutex->cfile_name, mutex->cline);
+ } else if (type == RW_LOCK_EX || type == RW_LOCK_SHARED) {
+
+ if (type == RW_LOCK_EX) {
+ str = "X-LOCK";
+ } else {
+ str = "S_LOCK";
+ }
+
+ rwlock = (rw_lock_t*)cell->wait_object;
+
+ printf("Rw-latch created in file %s line %lu",
+ rwlock->cfile_name, rwlock->cline);
+ if (rwlock->writer != RW_LOCK_NOT_LOCKED) {
+ printf(" writer reserved with %lu", rwlock->writer);
+ }
+
+ if (rwlock->writer == RW_LOCK_EX) {
+ printf(" reserv. thread id %lu",
+ (ulint)rwlock->writer_thread);
+ }
+
+ if (rwlock->reader_count > 0) {
+ printf(" readers %lu", rwlock->reader_count);
+ }
} else {
ut_error;
}
- printf("%lx waited for by thread %lu op. %s file %s line %lu ",
+ printf(" at addr %lx waited for by thread %lu op. %s file %s line %lu ",
(ulint)cell->wait_object,
(ulint)cell->thread,
str, cell->file, cell->line);
diff --git a/innobase/trx/trx0roll.c b/innobase/trx/trx0roll.c
index 6b74c0d0d51..2adeb1cf57c 100644
--- a/innobase/trx/trx0roll.c
+++ b/innobase/trx/trx0roll.c
@@ -98,6 +98,8 @@ trx_rollback_for_mysql(
return(DB_SUCCESS);
}
+
+ trx->op_info = "rollback";
/* Tell Innobase server that there might be work for
utility threads: */
@@ -111,6 +113,8 @@ trx_rollback_for_mysql(
srv_active_wake_master_thread();
+ trx->op_info = "";
+
return(err);
}
@@ -129,6 +133,8 @@ trx_rollback_last_sql_stat_for_mysql(
return(DB_SUCCESS);
}
+
+ trx->op_info = "rollback of SQL statement";
/* Tell Innobase server that there might be work for
utility threads: */
@@ -144,6 +150,8 @@ trx_rollback_last_sql_stat_for_mysql(
srv_active_wake_master_thread();
+ trx->op_info = "";
+
return(err);
}
diff --git a/innobase/trx/trx0sys.c b/innobase/trx/trx0sys.c
index b056975d28a..0b8664013d7 100644
--- a/innobase/trx/trx0sys.c
+++ b/innobase/trx/trx0sys.c
@@ -510,7 +510,8 @@ trx_sys_init_at_db_start(void)
MLOG_8BYTES, &mtr),
TRX_SYS_TRX_ID_WRITE_MARGIN),
2 * TRX_SYS_TRX_ID_WRITE_MARGIN);
-
+
+ UT_LIST_INIT(trx_sys->mysql_trx_list);
trx_lists_init_at_db_start();
if (UT_LIST_GET_LEN(trx_sys->trx_list) > 0) {
diff --git a/innobase/trx/trx0trx.c b/innobase/trx/trx0trx.c
index 14108c677eb..5d8c57edf34 100644
--- a/innobase/trx/trx0trx.c
+++ b/innobase/trx/trx0trx.c
@@ -24,6 +24,12 @@ Created 3/26/1996 Heikki Tuuri
#include "thr0loc.h"
#include "btr0sea.h"
+
+/* Copy of the prototype for innobase_mysql_print_thd: this
+ copy must be equal to the one in mysql/sql/ha_innobase.cc ! */
+void innobase_mysql_print_thd(void* thd);
+
+
/* Dummy session used currently in MySQL interface */
sess_t* trx_dummy_sess = NULL;
@@ -58,11 +64,15 @@ trx_create(
trx = mem_alloc(sizeof(trx_t));
+ trx->op_info = "";
+
trx->type = TRX_USER;
trx->conc_state = TRX_NOT_STARTED;
trx->dict_operation = FALSE;
+ trx->mysql_thd = NULL;
+
trx->n_mysql_tables_in_use = 0;
trx->mysql_n_tables_locked = 0;
@@ -129,6 +139,8 @@ trx_allocate_for_mysql(void)
trx_n_mysql_transactions++;
+ UT_LIST_ADD_FIRST(mysql_trx_list, trx_sys->mysql_trx_list, trx);
+
mutex_exit(&kernel_mutex);
trx->mysql_thread_id = os_thread_get_curr_id();
@@ -144,11 +156,11 @@ trx_search_latch_release_if_reserved(
/*=================================*/
trx_t* trx) /* in: transaction */
{
- if (trx->has_search_latch) {
- rw_lock_s_unlock(&btr_search_latch);
+ if (trx->has_search_latch) {
+ rw_lock_s_unlock(&btr_search_latch);
- trx->has_search_latch = FALSE;
- }
+ trx->has_search_latch = FALSE;
+ }
}
/************************************************************************
@@ -209,6 +221,8 @@ trx_free_for_mysql(
mutex_enter(&kernel_mutex);
+ UT_LIST_REMOVE(mysql_trx_list, trx_sys->mysql_trx_list, trx);
+
trx_free(trx);
ut_a(trx_n_mysql_transactions > 0);
@@ -641,7 +655,7 @@ shortcut:
ut_ad(UT_LIST_GET_LEN(trx->wait_thrs) == 0);
ut_ad(UT_LIST_GET_LEN(trx->trx_locks) == 0);
- UT_LIST_REMOVE(trx_list, trx_sys->trx_list, trx);
+ UT_LIST_REMOVE(trx_list, trx_sys->trx_list, trx);
}
/************************************************************************
@@ -1268,6 +1282,8 @@ trx_commit_for_mysql(
sig to the transaction, we must here make sure that trx has been
started. */
+ trx->op_info = "committing";
+
trx_start_if_not_started(trx);
mutex_enter(&kernel_mutex);
@@ -1276,6 +1292,8 @@ trx_commit_for_mysql(
mutex_exit(&kernel_mutex);
+ trx->op_info = "";
+
return(0);
}
@@ -1295,3 +1313,78 @@ trx_mark_sql_stat_end(
mutex_exit(&kernel_mutex);
}
+
+/**************************************************************************
+Marks the latest SQL statement ended but does not start a new transaction
+if the trx is not started. */
+
+void
+trx_mark_sql_stat_end_do_not_start_new(
+/*===================================*/
+ trx_t* trx) /* in: trx handle */
+{
+ mutex_enter(&kernel_mutex);
+
+ trx->last_sql_stat_start.least_undo_no = trx->undo_no;
+
+ mutex_exit(&kernel_mutex);
+}
+
+/**************************************************************************
+Prints info about a transaction to the standard output. The caller must
+own the kernel mutex. */
+
+void
+trx_print(
+/*======*/
+ trx_t* trx) /* in: transaction */
+{
+ printf("TRANSACTION %lu %lu, OS thread id %lu",
+ ut_dulint_get_high(trx->id),
+ ut_dulint_get_low(trx->id),
+ (ulint)trx->mysql_thread_id);
+
+ if (ut_strlen(trx->op_info) > 0) {
+ printf(" %s", trx->op_info);
+ }
+
+ if (trx->type != TRX_USER) {
+ printf(" purge trx");
+ }
+
+ switch (trx->conc_state) {
+ case TRX_NOT_STARTED: printf(", not started"); break;
+ case TRX_ACTIVE: printf(", active"); break;
+ case TRX_COMMITTED_IN_MEMORY: printf(", committed in memory");
+ break;
+ default: printf(" state %lu", trx->conc_state);
+ }
+
+ switch (trx->que_state) {
+ case TRX_QUE_RUNNING: printf(", runs or sleeps"); break;
+ case TRX_QUE_LOCK_WAIT: printf(", lock wait"); break;
+ case TRX_QUE_ROLLING_BACK: printf(", rolling back"); break;
+ case TRX_QUE_COMMITTING: printf(", committing"); break;
+ default: printf(" que state %lu", trx->que_state);
+ }
+
+ if (0 < UT_LIST_GET_LEN(trx->trx_locks)) {
+ printf(", has %lu lock struct(s)",
+ UT_LIST_GET_LEN(trx->trx_locks));
+ }
+
+ if (trx->has_search_latch) {
+ printf(", holds adaptive hash latch");
+ }
+
+ if (ut_dulint_cmp(trx->undo_no, ut_dulint_zero) != 0) {
+ printf(", undo log entries %lu",
+ ut_dulint_get_low(trx->undo_no));
+ }
+
+ printf("\n");
+
+ if (trx->mysql_thd != NULL) {
+ innobase_mysql_print_thd(trx->mysql_thd);
+ }
+}
diff --git a/isam/isamchk.c b/isam/isamchk.c
index bb9b7bfa16b..3aa1cf4e3c2 100644
--- a/isam/isamchk.c
+++ b/isam/isamchk.c
@@ -44,7 +44,7 @@ SET_STACK_SIZE(9000) /* Minimum stack size for program */
#define T_SORT_RECORDS 4096
#define T_SORT_INDEX 8192
#define T_WAIT_FOREVER 16384
-#define T_REP_BY_SORT 32768
+#define T_REP_BY_SORT 32768L
#define O_NEW_INDEX 1 /* Bits set in out_flag */
@@ -74,17 +74,17 @@ SET_STACK_SIZE(9000) /* Minimum stack size for program */
#define UPDATE_STAT 2
#define UPDATE_SORT 4
-typedef struct st_sort_key_blocks { /* Used when sorting */
+typedef struct st_isam_sort_key_blocks { /* Used when sorting */
uchar *buff,*end_pos;
uchar lastkey[N_MAX_POSSIBLE_KEY_BUFF];
uint last_length;
int inited;
-} SORT_KEY_BLOCKS;
+} ISAM_SORT_KEY_BLOCKS;
-typedef struct st_sort_info {
+typedef struct st_isam_sort_info {
N_INFO *info;
enum data_file_type new_data_file_type;
- SORT_KEY_BLOCKS *key_block,*key_block_end;
+ ISAM_SORT_KEY_BLOCKS *key_block,*key_block_end;
uint key,find_length;
ulong pos,max_pos,filepos,start_recpos,filelength,dupp,max_records,unique,
buff_length;
@@ -92,9 +92,9 @@ typedef struct st_sort_info {
char *record,*buff;
N_KEYDEF *keyinfo;
N_KEYSEG *keyseg;
-} SORT_INFO;
+} ISAM_SORT_INFO;
-enum options {OPT_CHARSETS_DIR=256};
+enum ic_options {OPT_CHARSETS_DIR_IC=256};
static ulong use_buffers=0,read_buffer_length=0,write_buffer_length=0,
sort_buffer_length=0,sort_key_blocks=0,crc=0,unique_count=0;
@@ -120,7 +120,7 @@ static const char *type_names[]=
static char temp_filename[FN_REFLEN], *isam_file_name, *default_charset;
static IO_CACHE read_cache;
-static SORT_INFO sort_info;
+static ISAM_SORT_INFO sort_info;
static int tmpfile_createflag=O_RDWR | O_TRUNC | O_EXCL;
static const char *load_default_groups[]= { "isamchk",0 };
@@ -137,8 +137,8 @@ static int chk_del(N_INFO *info,uint testflag);
static int check_k_link(N_INFO *info,uint nr);
static int chk_size(N_INFO *info);
static int chk_key(N_INFO *info);
-static int chk_index(N_INFO *info,N_KEYDEF *keyinfo,ulong page,uchar *buff,
- ulong *keys,uint level);
+static int chk_index(N_INFO *info, N_KEYDEF *keyinfo, ulong page, uchar *buff,
+ ulong *keys, uint level);
static uint isam_key_length(N_INFO *info,N_KEYDEF *keyinfo);
static unsigned long calc_checksum(ulong count);
static int chk_data_link(N_INFO *info,int extend);
@@ -171,12 +171,12 @@ static int sort_key_cmp(const void *not_used, const void *a,const void *b);
static int sort_key_write(const void *a);
static ulong get_record_for_key(N_INFO *info,N_KEYDEF *keyinfo,
uchar *key);
-static int sort_insert_key(reg1 SORT_KEY_BLOCKS *key_block,uchar *key,
+static int sort_insert_key(reg1 ISAM_SORT_KEY_BLOCKS *key_block,uchar *key,
ulong prev_block);
static int sort_delete_record(void);
static void usage(void);
static int flush_pending_blocks(void);
-static SORT_KEY_BLOCKS *alloc_key_blocks(uint blocks,uint buffer_length);
+static ISAM_SORT_KEY_BLOCKS *alloc_key_blocks(uint blocks,uint buffer_length);
static int test_if_almost_full(N_INFO *info);
static int recreate_database(N_INFO **info,char *filename);
static void save_integer(byte *pos,uint pack_length,ulong value);
@@ -186,9 +186,7 @@ static int update_state_info(N_INFO *info,uint update);
/* Main program */
-int main(argc,argv)
-int argc;
-char **argv;
+int main( int argc, char **argv)
{
int error;
MY_INIT(argv[0]);
@@ -255,7 +253,7 @@ static CHANGEABLE_VAR changeable_vars[] = {
static struct option long_options[] =
{
{"analyze", no_argument, 0, 'a'},
- {"character-sets-dir", required_argument, 0, OPT_CHARSETS_DIR},
+ {"character-sets-dir", required_argument, 0, OPT_CHARSETS_DIR_IC},
#ifndef DBUG_OFF
{"debug", required_argument, 0, '#'},
#endif
@@ -284,7 +282,7 @@ static struct option long_options[] =
static void print_version(void)
{
- printf("%s Ver 5.16 for %s at %s\n",my_progname,SYSTEM_TYPE,
+ printf("%s Ver 5.17 for %s at %s\n",my_progname,SYSTEM_TYPE,
MACHINE_TYPE);
}
@@ -598,7 +596,7 @@ static void get_options(register int *argc,register char ***argv)
case 'C':
default_charset=optarg;
break;
- case OPT_CHARSETS_DIR:
+ case OPT_CHARSETS_DIR_IC:
charsets_dir = optarg;
break;
case 'b':
@@ -706,9 +704,7 @@ static void get_options(register int *argc,register char ***argv)
/* Check delete links */
-static int chk_del(info,test_flag)
-reg1 N_INFO *info;
-uint test_flag;
+static int chk_del( reg1 N_INFO *info, uint test_flag)
{
reg2 ulong i;
uint j,delete_link_length;
@@ -793,9 +789,7 @@ wrong:
/* Kontrollerar l{nkarna i nyckelfilen */
-static int check_k_link(info,nr)
-register N_INFO *info;
-uint nr;
+static int check_k_link( register N_INFO *info, uint nr)
{
ulong next_link,records;
DBUG_ENTER("check_k_link");
@@ -898,8 +892,7 @@ static int chk_size(register N_INFO *info)
/* Kontrollerar nycklarna */
-static int chk_key(info)
-register N_INFO *info;
+static int chk_key( register N_INFO *info)
{
uint key;
ulong keys,all_keydata,all_totaldata,key_totlength,length,
@@ -988,12 +981,8 @@ register N_INFO *info;
/* Check if index is ok */
-static int chk_index(info,keyinfo,page,buff,keys,level)
-N_INFO *info;
-N_KEYDEF *keyinfo;
-ulong page,*keys;
-uchar *buff;
-uint level;
+static int chk_index(N_INFO *info, N_KEYDEF *keyinfo, ulong page, uchar *buff,
+ ulong *keys,uint level)
{
int flag;
uint used_length,comp_flag,nod_flag;
@@ -1129,9 +1118,7 @@ ulong count;
/* Calc length of key in normal isam */
-static uint isam_key_length(info,keyinfo)
-N_INFO *info;
-reg1 N_KEYDEF *keyinfo;
+static uint isam_key_length( N_INFO *info, reg1 N_KEYDEF *keyinfo)
{
uint length;
N_KEYSEG *keyseg;
@@ -2962,8 +2949,7 @@ static int sort_key_cmp(const void *not_used __attribute__((unused)),
} /* sort_key_cmp */
-static int sort_key_write(a)
-const void *a;
+static int sort_key_write( const void *a)
{
int cmp=sort_info.key_block->inited ?
_nisam_key_cmp(sort_info.keyseg,sort_info.key_block->lastkey,(uchar*) a,
@@ -2997,10 +2983,7 @@ const void *a;
/* get pointer to record from a key */
-static ulong get_record_for_key(info,keyinfo,key)
-N_INFO *info;
-N_KEYDEF *keyinfo;
-uchar *key;
+static ulong get_record_for_key( N_INFO *info, N_KEYDEF *keyinfo, uchar *key)
{
return _nisam_dpos(info,0,key+_nisam_keylength(keyinfo,key));
} /* get_record_for_key */
@@ -3008,10 +2991,8 @@ uchar *key;
/* Insert a key in sort-key-blocks */
-static int sort_insert_key(key_block,key,prev_block)
-reg1 SORT_KEY_BLOCKS *key_block;
-uchar *key;
-ulong prev_block;
+static int sort_insert_key(reg1 ISAM_SORT_KEY_BLOCKS *key_block,
+ uchar *key, ulong prev_block)
{
uint a_length,t_length,nod_flag;
ulong filepos;
@@ -3140,7 +3121,7 @@ static int flush_pending_blocks()
uint nod_flag,length;
ulong filepos;
N_INFO *info;
- SORT_KEY_BLOCKS *key_block;
+ ISAM_SORT_KEY_BLOCKS *key_block;
DBUG_ENTER("flush_pending_blocks");
filepos= NI_POS_ERROR; /* if empty file */
@@ -3169,16 +3150,15 @@ static int flush_pending_blocks()
/* alloc space and pointers for key_blocks */
-static SORT_KEY_BLOCKS *alloc_key_blocks(blocks,buffer_length)
-uint blocks,buffer_length;
+static ISAM_SORT_KEY_BLOCKS *alloc_key_blocks(uint blocks, uint buffer_length)
{
reg1 uint i;
- SORT_KEY_BLOCKS *block;
+ ISAM_SORT_KEY_BLOCKS *block;
DBUG_ENTER("alloc_key_blocks");
- if (!(block=(SORT_KEY_BLOCKS*) my_malloc((sizeof(SORT_KEY_BLOCKS)+
- buffer_length+IO_SIZE)*blocks,
- MYF(0))))
+ if (!(block=(ISAM_SORT_KEY_BLOCKS*) my_malloc((sizeof(ISAM_SORT_KEY_BLOCKS)+
+ buffer_length+IO_SIZE)*blocks,
+ MYF(0))))
{
print_error("Not Enough memory for sort-key-blocks");
return(0);
@@ -3253,8 +3233,7 @@ void print_error(const char *fmt,...)
/* Check if file is almost full */
-static int test_if_almost_full(info)
-N_INFO *info;
+static int test_if_almost_full(N_INFO *info)
{
double diff= 0.9;
if (info->s->base.options & HA_OPTION_COMPRESS_RECORD)
@@ -3274,9 +3253,7 @@ N_INFO *info;
/* Recreate table with bigger more alloced record-data */
-static int recreate_database(org_info,filename)
-N_INFO **org_info;
-char *filename;
+static int recreate_database(N_INFO **org_info, char *filename)
{
int error;
N_INFO info;
@@ -3369,10 +3346,7 @@ end:
/* Store long in 1,2,3 or 4 bytes */
-static void save_integer(pos,pack_length,value)
-byte *pos;
-uint pack_length;
-ulong value;
+static void save_integer( byte *pos, uint pack_length, ulong value)
{
switch (pack_length) {
case 4: int4store(pos,value); break;
@@ -3386,8 +3360,7 @@ ulong value;
/* write suffix to data file if neaded */
-static int write_data_suffix(info)
-N_INFO *info;
+static int write_data_suffix( N_INFO *info)
{
if (info->s->base.options & HA_OPTION_COMPRESS_RECORD &&
sort_info.fix_datafile)
@@ -3407,9 +3380,7 @@ N_INFO *info;
/* Update state and isamchk_time of indexfile */
-static int update_state_info(info,update)
-N_INFO *info;
-uint update;
+static int update_state_info( N_INFO *info, uint update)
{
ISAM_SHARE *share=info->s;
uint base_pos=uint2korr(info->s->state.header.base_pos);
diff --git a/isam/isamlog.c b/isam/isamlog.c
index 675a56e8fd9..6fc5d98cc76 100644
--- a/isam/isamlog.c
+++ b/isam/isamlog.c
@@ -1,15 +1,15 @@
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
@@ -29,7 +29,7 @@
#define FILENAME(A) (A ? A->show_name : "Unknown")
-struct file_info {
+struct isamlog_file_info {
long process;
int filenr,id;
my_string name,show_name,record;
@@ -46,7 +46,7 @@ struct test_if_open_param {
struct st_access_param
{
ulong min_accessed;
- struct file_info *found;
+ struct isamlog_file_info *found;
};
#define NO_FILEPOS (ulong) ~0L
@@ -56,21 +56,22 @@ static void get_options(int *argc,char ***argv);
static int examine_log(my_string file_name,char **table_names);
static int read_string(IO_CACHE *file,gptr *to,uint length);
static int file_info_compare(void *a,void *b);
-static int test_if_open(struct file_info *key,element_count count,
+static int test_if_open(struct isamlog_file_info *key,element_count count,
struct test_if_open_param *param);
static void fix_blob_pointers(N_INFO *isam,byte *record);
static uint set_maximum_open_files(uint);
-static int test_when_accessed(struct file_info *key,element_count count,
+static int test_when_accessed(struct isamlog_file_info *key,element_count count,
struct st_access_param *access_param);
-static void file_info_free(struct file_info *info);
+static void file_info_free(struct isamlog_file_info *info);
static int close_some_file(TREE *tree);
-static int reopen_closed_file(TREE *tree,struct file_info *file_info);
-static int find_record_with_key(struct file_info *file_info,byte *record);
+static int reopen_closed_file(TREE *tree,struct isamlog_file_info *file_info);
+static int find_record_with_key(struct isamlog_file_info *file_info,
+ byte *record);
static void printf_log(const char *str,...);
-static bool cmp_filename(struct file_info *file_info,my_string name);
+static bool cmp_filename(struct isamlog_file_info *file_info,my_string name);
static uint verbose=0,update=0,test_info=0,max_files=0,re_open_count=0,
- recover=0,prefix_remove=0;
+ recover=0,prefix_remove=0,opt_processes=0;
static my_string log_filename=0,filepath=0,write_filename=0,record_pos_file=0;
static ulong com_count[10][3],number_of_commands=(ulong) ~0L,start_offset=0,
record_pos= NO_FILEPOS,isamlog_filepos,isamlog_process;
@@ -78,9 +79,7 @@ static const char *command_name[]=
{"open","write","update","delete","close","extra","lock","re-open",NullS};
-int main(argc,argv)
-int argc;
-char **argv;
+int main(int argc, char **argv)
{
int error,i,first;
ulong total_count,total_error,total_recover;
@@ -92,11 +91,11 @@ char **argv;
max_files=(set_maximum_open_files(min(max_files,8))-6)/2;
if (update)
- printf("Trying to %s isamfiles according to log '%s'\n",
+ printf("Trying to %s ISAM files according to log '%s'\n",
(recover ? "recover" : "update"),log_filename);
error= examine_log(log_filename,argv);
if (update && ! error)
- puts("isamfile:s updated successfully");
+ puts("Tables updated successfully");
total_count=total_error=total_recover=0;
for (i=first=0 ; command_name[i] ; i++)
{
@@ -128,17 +127,15 @@ char **argv;
} /* main */
-static void get_options(argc,argv)
-register int *argc;
-register char ***argv;
+static void get_options(register int *argc, register char ***argv)
{
int help,version;
- const char *usage;
- char *pos, option;
+ const char *pos,*usage;
+ char option;
help=0;
- usage="Usage: %s [-?iruvIV] [-c #] [-f #] [-F filepath/] [-o #] [-R file recordpos] [-w write_file] [log-filename [table ...]] \n";
- pos= (char*) "";
+ usage="Usage: %s [-?iruvIPV] [-c #] [-f #] [-F filepath/] [-o #] [-R file recordpos] [-w write_file] [log-filename [table ...]] \n";
+ pos= "";
while (--*argc > 0 && *(pos = *(++*argv)) == '-' ) {
while (*++pos)
@@ -147,7 +144,7 @@ register char ***argv;
switch((option=*pos)) {
case '#':
DBUG_PUSH (++pos);
- pos= (char*) " "; /* Skipp rest of arg */
+ pos=" "; /* Skipp rest of arg */
break;
case 'c':
if (! *++pos)
@@ -158,7 +155,7 @@ register char ***argv;
pos= *(++*argv);
}
number_of_commands=(ulong) atol(pos);
- pos= (char*) " ";
+ pos=" ";
break;
case 'u':
update=1;
@@ -172,7 +169,7 @@ register char ***argv;
pos= *(++*argv);
}
max_files=(uint) atoi(pos);
- pos= (char*) " ";
+ pos=" ";
break;
case 'i':
test_info=1;
@@ -186,7 +183,7 @@ register char ***argv;
pos= *(++*argv);
}
start_offset=(ulong) atol(pos);
- pos= (char*) " ";
+ pos=" ";
break;
case 'p':
if (! *++pos)
@@ -202,6 +199,9 @@ register char ***argv;
update=1;
recover++;
break;
+ case 'P':
+ opt_processes=1;
+ break;
case 'R':
if (! *++pos)
{
@@ -210,11 +210,11 @@ register char ***argv;
else
pos= *(++*argv);
}
- record_pos_file=pos;
+ record_pos_file=(char*) pos;
if (!--*argc)
goto err;
record_pos=(ulong) atol(*(++*argv));
- pos= (char*) " ";
+ pos= " ";
break;
case 'v':
verbose++;
@@ -227,8 +227,8 @@ register char ***argv;
else
pos= *(++*argv);
}
- write_filename=pos;
- pos= (char*) " ";
+ write_filename=(char*) pos;
+ pos=" ";
break;
case 'F':
if (! *++pos)
@@ -238,20 +238,20 @@ register char ***argv;
else
pos= *(++*argv);
}
- filepath=pos;
- pos= (char*) " ";
+ filepath= (char*) pos;
+ pos=" ";
break;
case 'V':
version=1;
/* Fall through */
case 'I':
case '?':
- printf("%s Ver 3.2 for %s at %s\n",my_progname,SYSTEM_TYPE,
+ printf("%s Ver 3.3 for %s at %s\n",my_progname,SYSTEM_TYPE,
MACHINE_TYPE);
- puts("TCX Datakonsult AB, by Monty, for your professional use\n");
+ puts("By Monty, for your professional use\n");
if (version)
break;
- puts("Write info about whats in a nisam log file.");
+ puts("Write info about whats in a ISAM log file.");
printf("If no file name is given %s is used\n",log_filename);
puts("");
printf(usage,my_progname);
@@ -261,6 +261,7 @@ register char ***argv;
puts(" -o \"offset\" -p # \"remove # components from path\"");
puts(" -r \"recover\" -R \"file recordposition\"");
puts(" -u \"update\" -v \"verbose\" -w \"write file\"");
+ puts(" -P \"processes\"");
puts("\nOne can give a second and a third '-v' for more verbose.");
puts("Normaly one does a update (-u).");
puts("If a recover is done all writes and all possibly updates and deletes is done\nand errors are only counted.");
@@ -281,7 +282,7 @@ register char ***argv;
}
if (*argc >= 1)
{
- log_filename=pos;
+ log_filename=(char*) pos;
(*argc)--;
(*argv)++;
}
@@ -308,7 +309,8 @@ static int examine_log(my_string file_name, char **table_names)
FILE *write_file;
enum ha_extra_function extra_command;
TREE tree;
- struct file_info file_info,*curr_file_info;
+ struct isamlog_file_info file_info,*curr_file_info;
+ char llbuff[22],llbuff2[22];
DBUG_ENTER("examine_log");
if ((file=my_open(file_name,O_RDONLY,MYF(MY_WME))) < 0)
@@ -336,8 +338,11 @@ static int examine_log(my_string file_name, char **table_names)
isamlog_filepos=my_b_tell(&cache)-9L;
file_info.filenr=uint2korr(head+1);
isamlog_process=file_info.process=(long) uint4korr(head+3);
+ if (!opt_processes)
+ file_info.process=0;
result=uint2korr(head+7);
- if ((curr_file_info=(struct file_info*) tree_search(&tree,&file_info)))
+ if ((curr_file_info=(struct isamlog_file_info*)
+ tree_search(&tree,&file_info)))
{
curr_file_info->accessed=access_time;
if (update && curr_file_info->used && curr_file_info->closed)
@@ -352,7 +357,7 @@ static int examine_log(my_string file_name, char **table_names)
}
command=(uint) head[0];
if (command < sizeof(com_count)/sizeof(com_count[0][0])/3 &&
- (!curr_file_info || curr_file_info->used))
+ (!table_names[0] || (curr_file_info && curr_file_info->used)))
{
com_count[command][0]++;
if (result)
@@ -360,12 +365,15 @@ static int examine_log(my_string file_name, char **table_names)
}
switch ((enum nisam_log_commands) command) {
case LOG_OPEN:
- com_count[command][0]--; /* Must be counted explicite */
- if (result)
- com_count[command][1]--;
+ if (!table_names[0])
+ {
+ com_count[command][0]--; /* Must be counted explicite */
+ if (result)
+ com_count[command][1]--;
+ }
if (curr_file_info)
- printf("\nWarning: %s is opened twice with same process and filenumber\n",
+ printf("\nWarning: %s is opened with same process and filenumber\nMaybe you should use the -P option ?\n",
curr_file_info->show_name);
if (my_b_read(&cache,(byte*) head,2))
goto err;
@@ -376,11 +384,17 @@ static int examine_log(my_string file_name, char **table_names)
goto err;
{
uint i;
- char *pos=file_info.name,*to;
+ char *pos,*to;
+
+ /* Fix if old DOS files to new format */
+ for (pos=file_info.name; (pos=strchr(pos,'\\')) ; pos++)
+ *pos= '/';
+
+ pos=file_info.name;
for (i=0 ; i < prefix_remove ; i++)
{
char *next;
- if (!(next=strchr(pos,FN_LIBCHAR)))
+ if (!(next=strchr(pos,'/')))
break;
pos=next+1;
}
@@ -426,7 +440,7 @@ static int examine_log(my_string file_name, char **table_names)
files_open--;
}
if (!(file_info.isam= nisam_open(isam_file_name,O_RDWR,
- HA_OPEN_WAIT_IF_LOCKED)))
+ HA_OPEN_WAIT_IF_LOCKED)))
goto com_err;
if (!(file_info.record=my_malloc(file_info.isam->s->base.reclength,
MYF(MY_WME))))
@@ -438,7 +452,7 @@ static int examine_log(my_string file_name, char **table_names)
if (file_info.used)
{
if (verbose && !record_pos_file)
- printf_log("%s: open",file_info.show_name);
+ printf_log("%s: open -> %d",file_info.show_name, file_info.filenr);
com_count[command][0]++;
if (result)
com_count[command][1]++;
@@ -453,7 +467,6 @@ static int examine_log(my_string file_name, char **table_names)
{
if (!curr_file_info->closed)
files_open--;
- file_info_free(curr_file_info);
VOID(tree_delete(&tree,(gptr) curr_file_info));
}
break;
@@ -464,14 +477,17 @@ static int examine_log(my_string file_name, char **table_names)
if (verbose && !record_pos_file &&
(!table_names[0] || (curr_file_info && curr_file_info->used)))
printf_log("%s: %s(%d) -> %d",FILENAME(curr_file_info),
- command_name[command], extra_command,result);
+ command_name[command], (int) extra_command,result);
if (update && curr_file_info && !curr_file_info->closed)
{
if (nisam_extra(curr_file_info->isam,extra_command) != (int) result)
{
+ fflush(stdout);
VOID(fprintf(stderr,
- "Warning: error %d, expected %d on command %s at %lx\n",
- my_errno,result,command_name[command],isamlog_filepos));
+ "Warning: error %d, expected %d on command %s at %s\n",
+ my_errno,result,command_name[command],
+ llstr(isamlog_filepos,llbuff)));
+ fflush(stderr);
}
}
break;
@@ -501,6 +517,9 @@ static int examine_log(my_string file_name, char **table_names)
goto com_err;
if (ni_result)
com_count[command][2]++; /* Mark error */
+ if (verbose)
+ printf_log("error: Got result %d from mi_delete instead of %d",
+ ni_result, result);
}
}
break;
@@ -539,6 +558,8 @@ static int examine_log(my_string file_name, char **table_names)
result=0;
goto com_err;
}
+ if (verbose)
+ printf_log("error: Didn't find row to update with mi_rrnd");
if (recover == 1 || result ||
find_record_with_key(curr_file_info,buff))
{
@@ -553,6 +574,9 @@ static int examine_log(my_string file_name, char **table_names)
{
if (!recover)
goto com_err;
+ if (verbose)
+ printf_log("error: Got result %d from mi_update instead of %d",
+ ni_result, result);
if (ni_result)
com_count[command][2]++; /* Mark error */
}
@@ -570,9 +594,10 @@ static int examine_log(my_string file_name, char **table_names)
}
if (! recover && filepos != curr_file_info->isam->lastpos)
{
- printf("Warning: Wrote at position: %ld, should have been %ld",
- curr_file_info->isam->lastpos,(long) filepos);
- goto com_err;
+ printf("error: Wrote at position: %s, should have been %s",
+ llstr(curr_file_info->isam->lastpos,llbuff),
+ llstr(filepos,llbuff2));
+ goto end;
}
}
}
@@ -597,6 +622,7 @@ static int examine_log(my_string file_name, char **table_names)
VOID(fprintf(stderr,
"Error: found unknown command %d in logfile, aborted\n",
command));
+ fflush(stderr);
goto end;
}
}
@@ -609,11 +635,16 @@ static int examine_log(my_string file_name, char **table_names)
DBUG_RETURN(0);
err:
+ fflush(stdout);
VOID(fprintf(stderr,"Got error %d when reading from logfile\n",my_errno));
+ fflush(stderr);
goto end;
com_err:
- VOID(fprintf(stderr,"Got error %d, expected %d on command %s at %lx\n",
- my_errno,result,command_name[command],isamlog_filepos));
+ fflush(stdout);
+ VOID(fprintf(stderr,"Got error %d, expected %d on command %s at %s\n",
+ my_errno,result,command_name[command],
+ llstr(isamlog_filepos,llbuff)));
+ fflush(stderr);
end:
end_key_cache();
delete_tree(&tree);
@@ -625,10 +656,7 @@ static int examine_log(my_string file_name, char **table_names)
}
-static int read_string(file,to,length)
-IO_CACHE *file;
-reg1 gptr *to;
-reg2 uint length;
+static int read_string(IO_CACHE *file, reg1 gptr *to, reg2 uint length)
{
DBUG_ENTER("read_string");
@@ -647,24 +675,22 @@ reg2 uint length;
} /* read_string */
-static int file_info_compare(a,b)
-void *a;
-void *b;
+static int file_info_compare(void *a, void *b)
{
long lint;
- if ((lint=((struct file_info*) a)->process -
- ((struct file_info*) b)->process))
+ if ((lint=((struct isamlog_file_info*) a)->process -
+ ((struct isamlog_file_info*) b)->process))
return lint < 0L ? -1 : 1;
- return ((struct file_info*) a)->filenr - ((struct file_info*) b)->filenr;
+ return (((struct isamlog_file_info*) a)->filenr -
+ ((struct isamlog_file_info*) b)->filenr);
}
/* ARGSUSED */
-static int test_if_open (key,count,param)
-struct file_info *key;
-element_count count __attribute__((unused));
-struct test_if_open_param *param;
+static int test_if_open (struct isamlog_file_info *key,
+ element_count count __attribute__((unused)),
+ struct test_if_open_param *param)
{
if (!strcmp(key->name,param->name) && key->id > param->max_id)
param->max_id=key->id;
@@ -672,9 +698,7 @@ struct test_if_open_param *param;
}
-static void fix_blob_pointers(info,record)
-N_INFO *info;
-byte *record;
+static void fix_blob_pointers( N_INFO *info, byte *record)
{
byte *pos;
N_BLOB *blob,*end;
@@ -689,8 +713,7 @@ byte *record;
}
}
-static uint set_maximum_open_files(maximum_files)
-uint maximum_files;
+static uint set_maximum_open_files(uint maximum_files)
{
#if defined(HAVE_GETRUSAGE) && defined(RLIMIT_NOFILE)
struct rlimit rlimit;
@@ -725,10 +748,9 @@ uint maximum_files;
/* close the file with hasn't been accessed for the longest time */
/* ARGSUSED */
-static int test_when_accessed (key,count,access_param)
-struct file_info *key;
-element_count count __attribute__((unused));
-struct st_access_param *access_param;
+static int test_when_accessed (struct isamlog_file_info *key,
+ element_count count __attribute__((unused)),
+ struct st_access_param *access_param)
{
if (key->accessed < access_param->min_accessed && ! key->closed)
{
@@ -739,9 +761,9 @@ struct st_access_param *access_param;
}
-static void file_info_free(fileinfo)
-struct file_info *fileinfo;
+static void file_info_free(struct isamlog_file_info *fileinfo)
{
+ DBUG_ENTER("file_info_free");
if (update)
{
if (!fileinfo->closed)
@@ -751,12 +773,12 @@ struct file_info *fileinfo;
}
my_free(fileinfo->name,MYF(0));
my_free(fileinfo->show_name,MYF(0));
+ DBUG_VOID_RETURN;
}
-static int close_some_file(tree)
-TREE *tree;
+static int close_some_file(TREE *tree)
{
struct st_access_param access_param;
@@ -774,9 +796,7 @@ TREE *tree;
}
-static int reopen_closed_file(tree,fileinfo)
-TREE *tree;
-struct file_info *fileinfo;
+static int reopen_closed_file(TREE *tree, struct isamlog_file_info *fileinfo)
{
char name[FN_REFLEN];
if (close_some_file(tree))
@@ -794,9 +814,8 @@ struct file_info *fileinfo;
/* Try to find record with uniq key */
-static int find_record_with_key(file_info,record)
-struct file_info *file_info;
-byte *record;
+static int find_record_with_key(struct isamlog_file_info *file_info,
+ byte *record)
{
uint key;
N_INFO *info=file_info->isam;
@@ -817,10 +836,11 @@ byte *record;
static void printf_log(const char *format,...)
{
+ char llbuff[21];
va_list args;
va_start(args,format);
if (verbose > 2)
- printf("%9ld:",isamlog_filepos);
+ printf("%9s:",llstr(isamlog_filepos,llbuff));
if (verbose > 1)
printf("%5ld ",isamlog_process); /* Write process number */
(void) vprintf((char*) format,args);
@@ -829,9 +849,7 @@ static void printf_log(const char *format,...)
}
-static bool cmp_filename(file_info,name)
-struct file_info *file_info;
-my_string name;
+static bool cmp_filename(struct isamlog_file_info *file_info,my_string name)
{
if (!file_info)
return 1;
diff --git a/isam/test1.c b/isam/test1.c
index 1ec5d8b0318..33c61a53d4a 100644
--- a/isam/test1.c
+++ b/isam/test1.c
@@ -21,9 +21,7 @@ static void get_options(int argc, char *argv[]);
static int rec_pointer_size=0,verbose=0,remove_ant=0,pack_keys=1,flags[50],
packed_field=FIELD_SKIPP_PRESPACE;
-int main(argc,argv)
-int argc;
-char *argv[];
+int main(int argc, char *argv[])
{
N_INFO *file;
int i,j,error,deleted,found;
@@ -145,9 +143,7 @@ err:
/* l{ser optioner */
/* OBS! intierar endast DEBUG - ingen debuggning h{r ! */
-static void get_options(argc,argv)
-int argc;
-char *argv[];
+static void get_options(int argc, char *argv[])
{
char *pos;
diff --git a/isam/test2.c b/isam/test2.c
index 6ed041ad8c5..def6a4d3d5c 100644
--- a/isam/test2.c
+++ b/isam/test2.c
@@ -53,13 +53,11 @@ static char record[300],record2[300],key[100],key2[100],
/* Test program */
-int main(argc,argv)
-int argc;
-char *argv[];
+int main(int argc, char *argv[])
{
uint i;
int j,n1,n2,n3,error,k;
- uint write_count,update,dupp_keys,delete,start,length,blob_pos,
+ uint write_count,update,dupp_keys,opt_delete,start,length,blob_pos,
reclength,ant;
ulong lastpos,range_records,records;
N_INFO *file;
@@ -138,7 +136,7 @@ char *argv[];
else
recinfo[6].base.type= FIELD_LAST;
- write_count=update=dupp_keys=delete=0;
+ write_count=update=dupp_keys=opt_delete=0;
blob_buffer=0;
for (i=999 ; i>0 ; i--) key1[i]=0;
@@ -232,7 +230,7 @@ char *argv[];
printf("error: %d; can't delete record: \"%s\"\n", my_errno,read_record);
goto err;
}
- delete++;
+ opt_delete++;
key1[atoi(read_record+keyinfo[0].seg[0].base.start)]--;
key3[atoi(read_record+keyinfo[2].seg[0].base.start)]=0;
}
@@ -346,9 +344,9 @@ char *argv[];
}
while (nisam_rnext(file,read_record3,0) == 0 && ant < write_count+10)
ant++;
- if (ant != write_count - delete)
+ if (ant != write_count - opt_delete)
{
- printf("next: I found: %d records of %d\n",ant,write_count - delete);
+ printf("next: I found: %d records of %d\n",ant,write_count - opt_delete);
goto end;
}
if (nisam_rlast(file,read_record2,0) ||
@@ -362,7 +360,7 @@ char *argv[];
ant=1;
while (nisam_rprev(file,read_record3,0) == 0 && ant < write_count+10)
ant++;
- if (ant != write_count - delete)
+ if (ant != write_count - opt_delete)
{
printf("prev: I found: %d records of %d\n",ant,write_count);
goto end;
@@ -414,7 +412,7 @@ char *argv[];
if (nisam_rkey(file,read_record,0,key,0,HA_READ_KEY_EXACT)) goto err;
if (nisam_rnext(file,read_record3,0)) goto err;
if (nisam_delete(file,read_record3)) goto err;
- delete++;
+ opt_delete++;
ant=1;
while (nisam_rnext(file,read_record3,0) == 0 &&
bcmp(read_record3+start,key,length) == 0) ant++;
@@ -431,7 +429,7 @@ char *argv[];
if (nisam_rprev(file,read_record3,0)) goto err;
if (nisam_rprev(file,read_record3,0)) goto err;
if (nisam_delete(file,read_record3)) goto err;
- delete++;
+ opt_delete++;
ant=1;
while (nisam_rprev(file,read_record3,0) == 0 &&
bcmp(read_record3+start,key,length) == 0) ant++;
@@ -447,7 +445,7 @@ char *argv[];
DBUG_PRINT("progpos",("first - delete - next -> last"));
if (nisam_rkey(file,read_record3,0,key,0,HA_READ_KEY_EXACT)) goto err;
if (nisam_delete(file,read_record3)) goto err;
- delete++;
+ opt_delete++;
ant=1;
if (nisam_rnext(file,read_record,0))
goto err; /* Skall finnas poster */
@@ -463,7 +461,7 @@ char *argv[];
DBUG_PRINT("progpos",("last - delete - prev -> first"));
if (nisam_rprev(file,read_record3,0)) goto err;
if (nisam_delete(file,read_record3)) goto err;
- delete++;
+ opt_delete++;
ant=0;
while (nisam_rprev(file,read_record3,0) == 0 &&
bcmp(read_record3+start,key,length) == 0) ant++;
@@ -555,11 +553,11 @@ char *argv[];
printf("- nisam_info\n");
nisam_info(file,&info,0);
- if (info.records != write_count-delete || info.deleted > delete + update
+ if (info.records != write_count-opt_delete || info.deleted > opt_delete + update
|| info.keys != keys)
{
puts("Wrong info from nisam_info");
- printf("Got: records: %ld delete: %ld i_keys: %d\n",
+ printf("Got: records: %ld opt_delete: %ld i_keys: %d\n",
info.records,info.deleted,info.keys);
}
if (verbose)
@@ -591,10 +589,10 @@ char *argv[];
while ((error=nisam_rrnd(file,record,NI_POS_ERROR)) >= 0 &&
ant < write_count + 10)
ant+= error ? 0 : 1;
- if (ant != write_count-delete)
+ if (ant != write_count-opt_delete)
{
printf("rrnd with cache: I can only find: %d records of %d\n",
- ant,write_count-delete);
+ ant,write_count-opt_delete);
goto end;
}
if (nisam_extra(file,HA_EXTRA_NO_CACHE))
@@ -648,14 +646,14 @@ char *argv[];
printf("can't delete record: %s\n",read_record);
goto err;
}
- delete++;
+ opt_delete++;
}
}
if (my_errno != HA_ERR_END_OF_FILE && my_errno != HA_ERR_RECORD_DELETED)
printf("error: %d from nisam_rrnd\n",my_errno);
- if (write_count != delete)
+ if (write_count != opt_delete)
{
- printf("Deleted only %d of %d records\n",write_count,delete);
+ printf("Deleted only %d of %d records\n",write_count,opt_delete);
goto err;
}
end:
@@ -663,7 +661,7 @@ end:
goto err;
nisam_panic(HA_PANIC_CLOSE); /* Should close log */
printf("\nFollowing test have been made:\n");
- printf("Write records: %d\nUpdate records: %d\nSame-key-read: %d\nDelete records: %d\n", write_count,update,dupp_keys,delete);
+ printf("Write records: %d\nUpdate records: %d\nSame-key-read: %d\nDelete records: %d\n", write_count,update,dupp_keys,opt_delete);
if (rec_pointer_size)
printf("Record pointer size: %d\n",rec_pointer_size);
if (key_cacheing)
@@ -692,9 +690,7 @@ err:
/* l{ser optioner */
/* OBS! intierar endast DEBUG - ingen debuggning h{r ! */
-static void get_options(argc,argv)
-int argc;
-char *argv[];
+static void get_options( int argc, char *argv[])
{
char *pos,*progname;
DEBUGGER_OFF;
@@ -785,8 +781,7 @@ char *argv[];
/* Ge ett randomv{rde inom ett intervall 0 <=x <= n */
-static uint rnd(max_value)
-uint max_value;
+static uint rnd( uint max_value)
{
return (uint) ((rand() & 32767)/32767.0*max_value);
} /* rnd */
@@ -794,9 +789,7 @@ uint max_value;
/* G|r en record av skiftande length */
-static void fix_length(rec,length)
-byte *rec;
-uint length;
+static void fix_length( byte *rec, uint length)
{
bmove(rec+STANDAR_LENGTH,
"0123456789012345678901234567890123456789012345678901234567890",
@@ -807,8 +800,7 @@ uint length;
/* Put maybe a blob in record */
-static void put_blob_in_record(blob_pos,blob_buffer)
-char *blob_pos,**blob_buffer;
+static void put_blob_in_record(char *blob_pos, char **blob_buffer)
{
ulong i,length;
if (use_blob)
@@ -836,10 +828,7 @@ char *blob_pos,**blob_buffer;
}
-static void copy_key(info,inx,rec,key_buff)
-N_INFO *info;
-uint inx;
-uchar *rec,*key_buff;
+static void copy_key( N_INFO *info, uint inx, uchar *rec, uchar *key_buff)
{
N_KEYSEG *keyseg;
diff --git a/isam/test_all.res b/isam/test_all.res
index 756a05f869c..f6280dd9f98 100644
--- a/isam/test_all.res
+++ b/isam/test_all.res
@@ -11,16 +11,16 @@ test2 -L -K -W -P
- Read key (first) - next - delete - next -> last
- Read last of key - prev - delete - prev -> first
- Test if: Read rrnd - same
-- Test ni_records_in_range
-- ni_info
-- ni_extra(CACHE) + ni_rrnd.... + ni_extra(NO_CACHE)
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
- Removing keys
Following test have been made:
-Write records: 915
-Update records: 82
+Write records: 907
+Update records: 87
Same-key-read: 6
-Delete records: 915
+Delete records: 907
Key cacheing used
Write cacheing used
Locking used
@@ -37,16 +37,16 @@ test2 -L -K -W -P -A
- Read key (first) - next - delete - next -> last
- Read last of key - prev - delete - prev -> first
- Test if: Read rrnd - same
-- Test ni_records_in_range
-- ni_info
-- ni_extra(CACHE) + ni_rrnd.... + ni_extra(NO_CACHE)
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
- Removing keys
Following test have been made:
-Write records: 915
-Update records: 82
+Write records: 907
+Update records: 87
Same-key-read: 6
-Delete records: 915
+Delete records: 907
Key cacheing used
Write cacheing used
Asyncron io with locking used
@@ -62,16 +62,16 @@ test2 -L -K -W -P -S -R1 -m500
- Test read key-part
- Read key (first) - next - delete - next -> last
- Test if: Read rrnd - same
-- Test ni_records_in_range
-- ni_info
-- ni_extra(CACHE) + ni_rrnd.... + ni_extra(NO_CACHE)
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
- Removing keys
Following test have been made:
-Write records: 484
-Update records: 48
-Same-key-read: 3
-Delete records: 484
+Write records: 475
+Update records: 44
+Same-key-read: 4
+Delete records: 475
Record pointer size: 1
Key cacheing used
Write cacheing used
@@ -79,8 +79,31 @@ Locking used
test2 -L -K -R1 -m2000 ; Should give error 135
- Creating isam-file
- Writing key:s
-Error: 135 in write at record: 1122
-got error: 135 when using NISAM-database
+- Delete
+- Update
+- Same key: first - next -> last - prev -> first
+- All keys: first - next -> last - prev -> first
+- Test if: Read first - next - prev - prev - next == first
+- Test if: Read last - prev - next - next - prev == last
+- Test read key-part
+- Read key (first) - next - delete - next -> last
+- Read last of key - prev - delete - prev -> first
+- Read first - delete - next -> last
+- Read last - delete - prev -> first
+- Test if: Read rrnd - same
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
+- Removing keys
+
+Following test have been made:
+Write records: 1647
+Update records: 125
+Same-key-read: 8
+Delete records: 1647
+Record pointer size: 1
+Key cacheing used
+Locking used
test2 -L -K -P -S -R3 -m50 -b1000000
- Creating isam-file
- Writing key:s
@@ -92,9 +115,9 @@ test2 -L -K -P -S -R3 -m50 -b1000000
- Test if: Read last - prev - next - next - prev == last
- Test read key-part
- Test if: Read rrnd - same
-- Test ni_records_in_range
-- ni_info
-- ni_extra(CACHE) + ni_rrnd.... + ni_extra(NO_CACHE)
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
- Removing keys
Following test have been made:
@@ -118,16 +141,16 @@ test2 -L -B
- Read key (first) - next - delete - next -> last
- Read last of key - prev - delete - prev -> first
- Test if: Read rrnd - same
-- Test ni_records_in_range
-- ni_info
-- ni_extra(CACHE) + ni_rrnd.... + ni_extra(NO_CACHE)
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
- Removing keys
Following test have been made:
-Write records: 912
-Update records: 81
+Write records: 903
+Update records: 86
Same-key-read: 5
-Delete records: 912
+Delete records: 903
Locking used
blobs used
test2 -L -K -W -P -m50 -l
@@ -141,9 +164,9 @@ test2 -L -K -W -P -m50 -l
- Test if: Read last - prev - next - next - prev == last
- Test read key-part
- Test if: Read rrnd - same
-- Test ni_records_in_range
-- ni_info
-- ni_extra(CACHE) + ni_rrnd.... + ni_extra(NO_CACHE)
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
- Removing keys
Following test have been made:
@@ -155,13 +178,13 @@ Key cacheing used
Write cacheing used
Locking used
Commands Used count Errors Recover errors
-open 3 0 0
-write 150 0 0
-update 15 0 0
-delete 150 0 0
-close 3 0 0
-extra 18 0 0
-Total 339 0 0
+open 14 0 0
+write 700 0 0
+update 70 0 0
+delete 700 0 0
+close 14 0 0
+extra 84 0 0
+Total 1582 0 0
test2 -L -K -W -P -m50 -l -b100
- Creating isam-file
- Writing key:s
@@ -173,9 +196,9 @@ test2 -L -K -W -P -m50 -l -b100
- Test if: Read last - prev - next - next - prev == last
- Test read key-part
- Test if: Read rrnd - same
-- Test ni_records_in_range
-- ni_info
-- ni_extra(CACHE) + ni_rrnd.... + ni_extra(NO_CACHE)
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
- Removing keys
Following test have been made:
@@ -187,13 +210,13 @@ Key cacheing used
Write cacheing used
Locking used
Commands Used count Errors Recover errors
-open 4 0 0
-write 200 0 0
-update 20 0 0
-delete 200 0 0
-close 4 0 0
-extra 24 0 0
-Total 452 0 0
+open 15 0 0
+write 750 0 0
+update 75 0 0
+delete 750 0 0
+close 15 0 0
+extra 90 0 0
+Total 1695 0 0
time test2
- Creating isam-file
- Writing key:s
@@ -207,18 +230,16 @@ time test2
- Read key (first) - next - delete - next -> last
- Read last of key - prev - delete - prev -> first
- Test if: Read rrnd - same
-- Test ni_records_in_range
-- ni_info
-- ni_extra(CACHE) + ni_rrnd.... + ni_extra(NO_CACHE)
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
- Removing keys
Following test have been made:
-Write records: 915
-Update records: 82
+Write records: 907
+Update records: 87
Same-key-read: 6
-Delete records: 915
-4.77user 6.81system 0:15.07elapsed 76%CPU (0avgtext+0avgdata 0maxresident)k
-0inputs+0outputs (0major+0minor)pagefaults 0swaps
+Delete records: 907
time test2 -K
- Creating isam-file
- Writing key:s
@@ -232,19 +253,17 @@ time test2 -K
- Read key (first) - next - delete - next -> last
- Read last of key - prev - delete - prev -> first
- Test if: Read rrnd - same
-- Test ni_records_in_range
-- ni_info
-- ni_extra(CACHE) + ni_rrnd.... + ni_extra(NO_CACHE)
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
- Removing keys
Following test have been made:
-Write records: 915
-Update records: 82
+Write records: 907
+Update records: 87
Same-key-read: 6
-Delete records: 915
+Delete records: 907
Key cacheing used
-6.09user 4.33system 0:11.66elapsed 89%CPU (0avgtext+0avgdata 0maxresident)k
-0inputs+0outputs (0major+0minor)pagefaults 0swaps
time test2 -L
- Creating isam-file
- Writing key:s
@@ -258,19 +277,17 @@ time test2 -L
- Read key (first) - next - delete - next -> last
- Read last of key - prev - delete - prev -> first
- Test if: Read rrnd - same
-- Test ni_records_in_range
-- ni_info
-- ni_extra(CACHE) + ni_rrnd.... + ni_extra(NO_CACHE)
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
- Removing keys
Following test have been made:
-Write records: 915
-Update records: 82
+Write records: 907
+Update records: 87
Same-key-read: 6
-Delete records: 915
+Delete records: 907
Locking used
-5.01user 5.20system 0:10.86elapsed 94%CPU (0avgtext+0avgdata 0maxresident)k
-0inputs+0outputs (0major+0minor)pagefaults 0swaps
time test2 -L -K
- Creating isam-file
- Writing key:s
@@ -284,20 +301,18 @@ time test2 -L -K
- Read key (first) - next - delete - next -> last
- Read last of key - prev - delete - prev -> first
- Test if: Read rrnd - same
-- Test ni_records_in_range
-- ni_info
-- ni_extra(CACHE) + ni_rrnd.... + ni_extra(NO_CACHE)
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
- Removing keys
Following test have been made:
-Write records: 915
-Update records: 82
+Write records: 907
+Update records: 87
Same-key-read: 6
-Delete records: 915
+Delete records: 907
Key cacheing used
Locking used
-5.63user 0.97system 0:07.85elapsed 84%CPU (0avgtext+0avgdata 0maxresident)k
-0inputs+0outputs (0major+0minor)pagefaults 0swaps
time test2 -L -K -W
- Creating isam-file
- Writing key:s
@@ -311,21 +326,19 @@ time test2 -L -K -W
- Read key (first) - next - delete - next -> last
- Read last of key - prev - delete - prev -> first
- Test if: Read rrnd - same
-- Test ni_records_in_range
-- ni_info
-- ni_extra(CACHE) + ni_rrnd.... + ni_extra(NO_CACHE)
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
- Removing keys
Following test have been made:
-Write records: 915
-Update records: 82
+Write records: 907
+Update records: 87
Same-key-read: 6
-Delete records: 915
+Delete records: 907
Key cacheing used
Write cacheing used
Locking used
-5.28user 1.32system 0:08.86elapsed 74%CPU (0avgtext+0avgdata 0maxresident)k
-0inputs+0outputs (0major+0minor)pagefaults 0swaps
time test2 -L -K -W -S
- Creating isam-file
- Writing key:s
@@ -339,18 +352,16 @@ time test2 -L -K -W -S
- Read key (first) - next - delete - next -> last
- Read last of key - prev - delete - prev -> first
- Test if: Read rrnd - same
-- Test ni_records_in_range
-- ni_info
-- ni_extra(CACHE) + ni_rrnd.... + ni_extra(NO_CACHE)
+- Test nisam_records_in_range
+- nisam_info
+- nisam_extra(CACHE) + nisam_rrnd.... + nisam_extra(NO_CACHE)
- Removing keys
Following test have been made:
-Write records: 915
-Update records: 82
+Write records: 907
+Update records: 87
Same-key-read: 6
-Delete records: 915
+Delete records: 907
Key cacheing used
Write cacheing used
Locking used
-5.32user 0.62system 0:06.13elapsed 96%CPU (0avgtext+0avgdata 0maxresident)k
-0inputs+0outputs (0major+0minor)pagefaults 0swaps
diff --git a/libmysql/get_password.c b/libmysql/get_password.c
index d61c40a9559..989de9dd11a 100644
--- a/libmysql/get_password.c
+++ b/libmysql/get_password.c
@@ -35,7 +35,7 @@
#include <pwd.h>
#endif /* HAVE_PWD_H */
#else /* ! HAVE_GETPASS */
-#ifndef __WIN__
+#if !defined( __WIN__) && !defined(OS2)
#include <sys/ioctl.h>
#ifdef HAVE_TERMIOS_H /* For tty-password */
#include <termios.h>
@@ -62,9 +62,8 @@
#define getpass(A) getpassphrase(A)
#endif
-#ifdef __WIN__
-/* were just going to fake it here and get input from
- the keyboard */
+#if defined( __WIN__) || defined(OS2)
+/* were just going to fake it here and get input from the keyboard */
char *get_tty_password(char *opt_message)
{
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index a59100903db..753bc1f7883 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -77,8 +77,7 @@ my_string mysql_unix_port=0;
#include <errno.h>
#define ERRNO errno
#define SOCKET_ERROR -1
-#define closesocket(A) close(A)
-#endif
+#endif /* __WIN__ */
static void mysql_once_init(void);
static MYSQL_DATA *read_rows (MYSQL *mysql,MYSQL_FIELD *fields,
@@ -149,7 +148,7 @@ static MYSQL* spawn_init(MYSQL* parent, const char* host,
static int connect2(my_socket s, const struct sockaddr *name, uint namelen,
uint timeout)
{
-#if defined(__WIN__)
+#if defined(__WIN__) || defined(OS2)
return connect(s, (struct sockaddr*) name, namelen);
#else
int flags, res, s_err;
@@ -510,7 +509,7 @@ struct passwd *getpwuid(uid_t);
char* getlogin(void);
#endif
-#if !defined(MSDOS) && ! defined(VMS) && !defined(__WIN__)
+#if !defined(MSDOS) && ! defined(VMS) && !defined(__WIN__) && !defined(OS2)
static void read_user_name(char *name)
{
DBUG_ENTER("read_user_name");
diff --git a/libmysql/net.c b/libmysql/net.c
index 0fc5cf8b50c..036a941ffae 100644
--- a/libmysql/net.c
+++ b/libmysql/net.c
@@ -40,7 +40,6 @@
#include <signal.h>
#include <errno.h>
#include <sys/types.h>
-#include <assert.h>
#ifdef MYSQL_SERVER
ulong max_allowed_packet=65536;
@@ -81,9 +80,15 @@ void sql_print_error(const char *format,...);
#define RETRY_COUNT mysqld_net_retry_count
extern ulong mysqld_net_retry_count;
#else
+
+#ifdef OS2 /* avoid name conflict */
+#define thr_alarm_t thr_alarm_t_net
+#define ALARM ALARM_net
+#endif
+
typedef my_bool thr_alarm_t;
typedef my_bool ALARM;
-#define thr_alarm_init(A) (*A)=0
+#define thr_alarm_init(A) (*(A))=0
#define thr_alarm_in_use(A) (*(A))
#define thr_end_alarm(A)
#define thr_alarm(A,B,C) local_thr_alarm((A),(B),(C))
@@ -134,7 +139,7 @@ int my_net_init(NET *net, Vio* vio)
if (vio != 0) /* If real connection */
{
net->fd = vio_fd(vio); /* For perl DBI/DBD */
-#if defined(MYSQL_SERVER) && !defined(___WIN__) && !defined(__EMX__)
+#if defined(MYSQL_SERVER) && !defined(___WIN__) && !defined(__EMX__) && !defined(OS2)
if (!(test_flags & TEST_BLOCKING))
vio_blocking(vio, FALSE);
#endif
@@ -336,7 +341,7 @@ net_real_write(NET *net,const char *packet,ulong len)
int length;
char *pos,*end;
thr_alarm_t alarmed;
-#if !defined(__WIN__)
+#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2)
ALARM alarm_buff;
#endif
uint retry_count=0;
@@ -394,7 +399,7 @@ net_real_write(NET *net,const char *packet,ulong len)
if ((int) (length=vio_write(net->vio,pos,(int) (end-pos))) <= 0)
{
my_bool interrupted = vio_should_retry(net->vio);
-#if (!defined(__WIN__) && !defined(__EMX__))
+#if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2))
if ((interrupted || length==0) && !thr_alarm_in_use(&alarmed))
{
if (!thr_alarm(&alarmed,(uint) net_write_timeout,&alarm_buff))
@@ -491,8 +496,8 @@ static void my_net_skip_rest(NET *net, ulong remain, thr_alarm_t *alarmed)
if ((int) (length=vio_read(net->vio,(char*) net->buff,remain)) <= 0L)
{
my_bool interrupted = vio_should_retry(net->vio);
- if (!thr_got_alarm(&alarmed) && interrupted)
- { /* Probably in MIT threads */
+ if (!thr_got_alarm(alarmed) && interrupted)
+ { /* Probably in MIT threads */
if (retry_count++ < RETRY_COUNT)
continue;
}
@@ -519,7 +524,7 @@ my_real_read(NET *net, ulong *complen)
uint i,retry_count=0;
ulong len=packet_error;
thr_alarm_t alarmed;
-#if (!defined(__WIN__) && !defined(__EMX__)) || defined(MYSQL_SERVER)
+#if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2)) || defined(MYSQL_SERVER)
ALARM alarm_buff;
#endif
my_bool net_blocking=vio_is_blocking(net->vio);
@@ -546,7 +551,7 @@ my_real_read(NET *net, ulong *complen)
DBUG_PRINT("info",("vio_read returned %d, errno: %d",
length, vio_errno(net->vio)));
-#if (!defined(__WIN__) && !defined(__EMX__)) || defined(MYSQL_SERVER)
+#if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2)) || defined(MYSQL_SERVER)
/*
We got an error that there was no data on the socket. We now set up
an alarm to not 'read forever', change the socket to non blocking
diff --git a/ltconfig b/ltconfig
index 10d6a395719..18af7c4dce8 100755
--- a/ltconfig
+++ b/ltconfig
@@ -742,6 +742,12 @@ else
wl='-Qoption ld '
;;
+ sysv5UnixWare* | sysv5OpenUNIX*)
+ pic_flag='-KPIC'
+ link_static_flag='-Bstatic'
+ wl='-Wl,'
+ ;;
+
sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
pic_flag='-KPIC'
link_static_flag='-Bstatic'
@@ -1496,6 +1502,18 @@ else
export_dynamic_flag_spec='-Bexport'
;;
+ sysv5UnixWare* | sysv5OpenUNIX*)
+ no_undefined_flag=' -z text'
+ # $CC -shared without GNU ld will not create a library from C++
+ # object files and a static libstdc++, better avoid it by now
+ archive_cmds='$UW7_compile_command -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linkopts'
+ archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linkopts~$rm $lib.exp'
+ hardcode_libdir_flag_spec=
+ hardcode_shlibpath_var=no
+ runpath_var='LD_RUN_PATH'
+ ;;
+
sysv5*)
no_undefined_flag=' -z text'
# $CC -shared without GNU ld will not create a library from C++
@@ -2097,6 +2115,13 @@ sunos4*)
need_version=yes
;;
+sysv5UnixWare* | sysv5OpenUNIX*)
+ version_type=linux
+ soname_spec='${libname}${release}.so$major'
+ library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
version_type=linux
library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
diff --git a/merge/_locking.c b/merge/_locking.c
index f90b41e2375..81582da1312 100644
--- a/merge/_locking.c
+++ b/merge/_locking.c
@@ -20,9 +20,7 @@
#include "mrgdef.h"
-int mrg_lock_database(info,lock_type)
-MRG_INFO *info;
-int lock_type;
+int mrg_lock_database(MRG_INFO *info,int lock_type)
{
int error,new_error;
MRG_TABLE *file;
diff --git a/merge/close.c b/merge/close.c
index 45aa889ef0c..2b769ade8e9 100644
--- a/merge/close.c
+++ b/merge/close.c
@@ -18,8 +18,7 @@
#include "mrgdef.h"
-int mrg_close(info)
-register MRG_INFO *info;
+int mrg_close(register MRG_INFO *info)
{
int error=0,new_error;
MRG_TABLE *file;
diff --git a/merge/create.c b/merge/create.c
index e7086210237..fd2c16f9ea2 100644
--- a/merge/create.c
+++ b/merge/create.c
@@ -23,8 +23,7 @@
a NULL-pointer last
*/
-int mrg_create(name,table_names)
-const char *name,**table_names;
+int mrg_create(const char *name, const char**table_names)
{
int save_errno;
uint errpos;
diff --git a/merge/extra.c b/merge/extra.c
index 343806dbfad..c4f048a4385 100644
--- a/merge/extra.c
+++ b/merge/extra.c
@@ -22,9 +22,9 @@
#include "mrgdef.h"
-int mrg_extra(info,function)
-MRG_INFO *info;
-enum ha_extra_function function;
+int mrg_extra(
+MRG_INFO *info,
+enum ha_extra_function function)
{
MRG_TABLE *file;
diff --git a/merge/open.c b/merge/open.c
index 05f194b42d4..7b5e571b9ad 100644
--- a/merge/open.c
+++ b/merge/open.c
@@ -30,10 +30,10 @@
*/
-MRG_INFO *mrg_open(name,mode,handle_locking)
-const char *name;
-int mode;
-int handle_locking;
+MRG_INFO *mrg_open(
+const char *name,
+int mode,
+int handle_locking)
{
int save_errno,i,errpos;
uint files,dir_length,length, options;
diff --git a/merge/panic.c b/merge/panic.c
index c3820fe468d..cf333e3a9bf 100644
--- a/merge/panic.c
+++ b/merge/panic.c
@@ -24,8 +24,8 @@
done for all single user files to get changes in database */
-int mrg_panic(flag)
-enum ha_panic_function flag;
+int mrg_panic(
+enum ha_panic_function flag)
{
int error=0;
LIST *list_element,*next_open;
diff --git a/merge/rsame.c b/merge/rsame.c
index a18f1771c37..4ebf25b21c1 100644
--- a/merge/rsame.c
+++ b/merge/rsame.c
@@ -17,10 +17,10 @@
#include "mrgdef.h"
-int mrg_rsame(info,record,inx)
-MRG_INFO *info;
-byte *record;
-int inx; /* not used, should be 0 */
+int mrg_rsame(
+MRG_INFO *info,
+byte *record,
+int inx) /* not used, should be 0 */
{
if (inx)
{
diff --git a/merge/update.c b/merge/update.c
index 64900b82116..9fcb82089e4 100644
--- a/merge/update.c
+++ b/merge/update.c
@@ -18,9 +18,9 @@
#include "mrgdef.h"
-int mrg_update(info,oldrec,newrec)
-register MRG_INFO *info;
-const byte *oldrec,*newrec;
+int mrg_update(
+register MRG_INFO *info,
+const byte *oldrec, const byte *newrec)
{
if (!info->current_table)
{
diff --git a/myisam/ft_eval.c b/myisam/ft_eval.c
index a8e4d8e8881..9466104100a 100644
--- a/myisam/ft_eval.c
+++ b/myisam/ft_eval.c
@@ -19,6 +19,8 @@
#include <getopt.h>
static void print_error(int exit_code, const char *fmt,...);
+static void get_options(int argc, char *argv[]);
+static int create_record(char *pos, FILE *file);
int main(int argc,char *argv[])
{
@@ -110,7 +112,7 @@ err:
}
-void get_options(int argc,char *argv[])
+static void get_options(int argc,char *argv[])
{
int c;
char *options=(char*) "Vh#:qSs:";
@@ -123,7 +125,7 @@ void get_options(int argc,char *argv[])
{
FILE *f; char s[HA_FT_MAXLEN]; int i=0,n=SWL_INIT;
- if(!(stopwordlist=malloc(n*sizeof(char *))))
+ if(!(stopwordlist=(const char**) malloc(n*sizeof(char *))))
print_error(1,"malloc(%d)",n*sizeof(char *));
if(!(f=fopen(optarg,"r")))
print_error(1,"fopen(%s)",optarg);
@@ -165,7 +167,7 @@ void get_options(int argc,char *argv[])
return;
} /* get options */
-int create_record(char *pos, FILE *file)
+static int create_record(char *pos, FILE *file)
{ uint tmp; char *ptr;
bzero((char *)pos,MAX_REC_LENGTH);
diff --git a/myisam/ft_eval.h b/myisam/ft_eval.h
index 5d7f41ab04d..d87b6be9c7c 100644
--- a/myisam/ft_eval.h
+++ b/myisam/ft_eval.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+/* Copyright (C) 2000 MySQL AB & Sergei A. Golubchik
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -35,9 +35,6 @@ MI_COLUMNDEF recinfo[3];
MI_KEYDEF keyinfo[2];
MI_KEYSEG keyseg[10];
-void get_options(int argc,char *argv[]);
-int create_record(char *, FILE *);
-
#define SWL_INIT 500
#define SWL_PLUS 50
diff --git a/myisam/ft_search.c b/myisam/ft_search.c
index 711c03722a5..c5a43734d9a 100644
--- a/myisam/ft_search.c
+++ b/myisam/ft_search.c
@@ -54,7 +54,7 @@ FT_DOCLIST *ft_init_search(void *info, uint keynr, byte *query,
int ft_read_next(FT_DOCLIST *handler, char *record)
{
- MI_INFO *info=handler->info;
+ MI_INFO *info= (MI_INFO *) handler->info;
if (++handler->curdoc >= handler->ndocs)
{
diff --git a/myisam/ft_test1.c b/myisam/ft_test1.c
index dfe8e30383b..5093b591fb2 100644
--- a/myisam/ft_test1.c
+++ b/myisam/ft_test1.c
@@ -30,8 +30,9 @@ static int create_flag=0,error=0;
#define MAX_REC_LENGTH 300
static char record[MAX_REC_LENGTH],read_record[MAX_REC_LENGTH];
-void get_options(int argc,char *argv[]);
static int run_test(const char *filename);
+static void get_options(int argc, char *argv[]);
+static void create_record(char *, int);
int main(int argc,char *argv[])
{
@@ -46,8 +47,6 @@ static MI_COLUMNDEF recinfo[3];
static MI_KEYDEF keyinfo[2];
static MI_KEYSEG keyseg[10];
-void create_record(char *, int);
-
static int run_test(const char *filename)
{
MI_INFO *file;
@@ -235,7 +234,7 @@ void create_record(char *pos, int n)
/* Read options */
-void get_options(int argc,char *argv[])
+static void get_options(int argc,char *argv[])
{
int c;
const char *options="hVvsNSKFU#:";
diff --git a/myisam/ftdefs.h b/myisam/ftdefs.h
index 6721d136678..1a017d3c73a 100644
--- a/myisam/ftdefs.h
+++ b/myisam/ftdefs.h
@@ -48,7 +48,7 @@
#define LWS_TF (count)
#define LWS_BINARY (count>0)
#define LWS_SQUARE (count*count)
-#define LWS_LOG (count?(log(count)+1):0)
+#define LWS_LOG (count?(log( (double) count)+1):0)
/*--------------------------------------------------------------*/
#define PRENORM_NONE (p->weight)
#define PRENORM_MAX (p->weight/docstat.max)
diff --git a/myisam/mi_cache.c b/myisam/mi_cache.c
index 0aae316f23d..6c23916c645 100644
--- a/myisam/mi_cache.c
+++ b/myisam/mi_cache.c
@@ -76,7 +76,7 @@ int _mi_read_cache(IO_CACHE *info, byte *buff, my_off_t pos, uint length,
DBUG_PRINT("error",
("Error %d reading next-multi-part block (Got %d bytes)",
my_errno, info->error));
- if (!my_errno)
+ if (!my_errno || my_errno == -1)
my_errno=HA_ERR_WRONG_IN_RECORD;
DBUG_RETURN(1);
}
@@ -93,7 +93,7 @@ int _mi_read_cache(IO_CACHE *info, byte *buff, my_off_t pos, uint length,
DBUG_PRINT("error",
("Error %d reading new block (Got %d bytes)",
my_errno, (int) read_length));
- if (!my_errno)
+ if (!my_errno || my_errno == -1)
my_errno=HA_ERR_WRONG_IN_RECORD;
DBUG_RETURN(1);
}
diff --git a/myisam/mi_check.c b/myisam/mi_check.c
index e5557e5f842..09f5dcc1ec9 100644
--- a/myisam/mi_check.c
+++ b/myisam/mi_check.c
@@ -460,7 +460,7 @@ int chk_key(MI_CHECK *param, register MI_INFO *info)
/* Check that there isn't a row with auto_increment = 0 in the table */
mi_extra(info,HA_EXTRA_KEYREAD);
bzero(info->lastkey,keyinfo->seg->length);
- if (!mi_rkey(info, info->rec_buff, key, info->lastkey,
+ if (!mi_rkey(info, info->rec_buff, key, (const byte*) info->lastkey,
keyinfo->seg->length, HA_READ_KEY_EXACT))
{
/* Don't count this as a real warning, as myisamchk can't correct it */
@@ -710,7 +710,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend)
puts("- check record links");
}
- if (!(record= (byte*) my_alloca(info->s->base.pack_reclength)))
+ if (!(record= (byte*) my_malloc(info->s->base.pack_reclength,MYF(0))))
{
mi_check_print_error(param,"Not Enough memory");
DBUG_RETURN(-1);
@@ -926,8 +926,9 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend)
if (block_info.rec_len < (uint) info->s->min_pack_length ||
block_info.rec_len > (uint) info->s->max_pack_length)
{
- mi_check_print_error(param,"Found block with wrong recordlength: %d at %s",
- block_info.rec_len, llstr(start_recpos,llbuff));
+ mi_check_print_error(param,
+ "Found block with wrong recordlength: %d at %s",
+ block_info.rec_len, llstr(start_recpos,llbuff));
got_error=1;
break;
}
@@ -936,7 +937,8 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend)
goto err;
if (_mi_pack_rec_unpack(info,record,info->rec_buff,block_info.rec_len))
{
- mi_check_print_error(param,"Found wrong record at %s", llstr(start_recpos,llbuff));
+ mi_check_print_error(param,"Found wrong record at %s",
+ llstr(start_recpos,llbuff));
got_error=1;
}
if (static_row_size)
@@ -1084,12 +1086,12 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend)
printf("Lost space: %12s Linkdata: %10s\n",
llstr(empty,llbuff),llstr(link_used,llbuff2));
}
- my_afree((gptr) record);
+ my_free((gptr) record,MYF(0));
DBUG_RETURN (error);
err:
- mi_check_print_error(param,"got error: %d when reading datafile",my_errno);
+ mi_check_print_error(param,"got error: %d when reading datafile at record: %s",my_errno, llstr(records,llbuff));
err2:
- my_afree((gptr) record);
+ my_free((gptr) record,MYF(0));
param->retry_without_quick=1;
DBUG_RETURN(1);
} /* chk_data_link */
@@ -1111,6 +1113,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
SORT_INFO *sort_info= &param->sort_info;
DBUG_ENTER("mi_repair");
+ sort_info->buff=sort_info->record=0;
start_records=info->state->records;
new_header_length=(param->testflag & T_UNPACK) ? 0L :
share->pack.header_length;
@@ -1199,7 +1202,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
del=info->state->del;
info->state->records=info->state->del=share->state.split=0;
info->state->empty=0;
- if (sort_info->new_data_file_type != COMPRESSED_RECORD && !rep_quick)
+ if (!rep_quick)
share->state.checksum=0;
info->update= (short) (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
for (i=0 ; i < info->s->base.keys ; i++)
@@ -1338,9 +1341,7 @@ err:
}
mi_mark_crashed_on_repair(info);
}
- if (sort_info->record)
- my_free(sort_info->record,MYF(0));
-
+ my_free(sort_info->record,MYF(MY_ALLOW_ZERO_PTR));
my_free(sort_info->buff,MYF(MY_ALLOW_ZERO_PTR));
VOID(end_io_cache(&param->read_cache));
info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
@@ -1874,8 +1875,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
sort_param.sort_info=sort_info;
del=info->state->del;
- if (sort_info->new_data_file_type != COMPRESSED_RECORD &&
- ! rep_quick)
+ if (! rep_quick)
share->state.checksum=0;
rec_per_key_part= param->rec_per_key_part;
@@ -2093,8 +2093,10 @@ static int sort_key_read(SORT_INFO *sort_info, void *key)
"Found too many records; Can`t continue");
DBUG_RETURN(1);
}
- sort_info->real_key_length=info->s->rec_reflength+_mi_make_key(info,
- sort_info->key,key,sort_info->record,sort_info->filepos);
+ sort_info->real_key_length=(info->s->rec_reflength+
+ _mi_make_key(info, sort_info->key,
+ (uchar*) key, sort_info->record,
+ sort_info->filepos));
DBUG_RETURN(sort_write_record(sort_info));
} /* sort_key_read */
@@ -2474,6 +2476,7 @@ static int sort_get_next_record(SORT_INFO *sort_info)
llstr(sort_info->pos,llbuff));
continue;
}
+ info->checksum=mi_checksum(info,sort_info->record);
if (!sort_info->fix_datafile)
sort_info->filepos=sort_info->pos;
sort_info->max_pos=(sort_info->pos=block_info.filepos+
@@ -2552,6 +2555,7 @@ int sort_write_record(SORT_INFO *sort_info)
DBUG_RETURN(1);
}
sort_info->filepos+=block_length;
+ info->s->state.checksum+=info->checksum;
break;
case COMPRESSED_RECORD:
reclength=info->packed_length;
@@ -2564,6 +2568,7 @@ int sort_write_record(SORT_INFO *sort_info)
mi_check_print_error(param,"%d when writing to datafile",my_errno);
DBUG_RETURN(1);
}
+ info->s->state.checksum+=info->checksum;
sort_info->filepos+=reclength+length;
break;
}
diff --git a/myisam/mi_packrec.c b/myisam/mi_packrec.c
index be7f9dcae0a..68d546b2010 100644
--- a/myisam/mi_packrec.c
+++ b/myisam/mi_packrec.c
@@ -962,7 +962,7 @@ int _mi_read_rnd_pack_record(MI_INFO *info, byte *buf,
b_type=_mi_pack_get_block_info(info,&block_info,info->dfile,filepos,
info->rec_buff);
if (b_type)
- goto err;
+ goto err; /* Error code is already set */
#ifndef DBUG_OFF
if (block_info.rec_len > share->max_pack_length)
{
diff --git a/myisam/mi_test1.c b/myisam/mi_test1.c
index 59b9ceb266e..ae09bd4142e 100644
--- a/myisam/mi_test1.c
+++ b/myisam/mi_test1.c
@@ -18,8 +18,7 @@
#include "myisam.h"
#include <getopt.h>
-#include <m_ctype.h>
-
+#include <m_string.h>
#define MAX_REC_LENGTH 1024
diff --git a/myisam/mi_test2.c b/myisam/mi_test2.c
index 746042554c8..b66b02afdf9 100644
--- a/myisam/mi_test2.c
+++ b/myisam/mi_test2.c
@@ -59,11 +59,11 @@ static MI_KEYSEG glob_keyseg[MYISAM_KEYS][MAX_PARTS];
/* Test program */
-int main(int argc, char **argv)
+int main(int argc, char *argv[])
{
uint i;
int j,n1,n2,n3,error,k;
- uint write_count,update,dupp_keys,delete,start,length,blob_pos,
+ uint write_count,update,dupp_keys,opt_delete,start,length,blob_pos,
reclength,ant,found_parts;
my_off_t lastpos;
ha_rows range_records,records;
@@ -180,7 +180,7 @@ int main(int argc, char **argv)
recinfo[6].null_pos=0;
}
- write_count=update=dupp_keys=delete=0;
+ write_count=update=dupp_keys=opt_delete=0;
blob_buffer=0;
for (i=1000 ; i>0 ; i--) key1[i]=0;
@@ -280,14 +280,14 @@ int main(int argc, char **argv)
printf("can't find key1: \"%s\"\n",key);
goto err;
}
- if (delete == (uint) remove_count) /* While testing */
+ if (opt_delete == (uint) remove_count) /* While testing */
goto end;
if (mi_delete(file,read_record))
{
printf("error: %d; can't delete record: \"%s\"\n", my_errno,read_record);
goto err;
}
- delete++;
+ opt_delete++;
key1[atoi(read_record+keyinfo[0].seg[0].start)]--;
key3[atoi(read_record+keyinfo[2].seg[0].start)]=0;
}
@@ -418,10 +418,10 @@ int main(int argc, char **argv)
}
while ((error=mi_rnext(file,read_record3,0)) == 0 && ant < write_count+10)
ant++;
- if (ant != write_count - delete || error != HA_ERR_END_OF_FILE)
+ if (ant != write_count - opt_delete || error != HA_ERR_END_OF_FILE)
{
printf("next: I found: %d records of %d (error: %d)\n",
- ant, write_count - delete, error);
+ ant, write_count - opt_delete, error);
goto end;
}
if (mi_rlast(file,read_record2,0) ||
@@ -435,7 +435,7 @@ int main(int argc, char **argv)
ant=1;
while (mi_rprev(file,read_record3,0) == 0 && ant < write_count+10)
ant++;
- if (ant != write_count - delete)
+ if (ant != write_count - opt_delete)
{
printf("prev: I found: %d records of %d\n",ant,write_count);
goto end;
@@ -495,7 +495,7 @@ int main(int argc, char **argv)
if (mi_rkey(file,read_record,0,key,0,HA_READ_KEY_EXACT)) goto err;
if (mi_rnext(file,read_record3,0)) goto err;
if (mi_delete(file,read_record3)) goto err;
- delete++;
+ opt_delete++;
ant=1;
while (mi_rnext(file,read_record3,0) == 0 &&
bcmp(read_record3+start,key,length) == 0) ant++;
@@ -513,7 +513,7 @@ int main(int argc, char **argv)
if (mi_rprev(file,read_record3,0)) goto err;
if (mi_rprev(file,read_record3,0)) goto err;
if (mi_delete(file,read_record3)) goto err;
- delete++;
+ opt_delete++;
ant=1;
while (mi_rprev(file,read_record3,0) == 0 &&
bcmp(read_record3+start,key,length) == 0) ant++;
@@ -530,7 +530,7 @@ int main(int argc, char **argv)
DBUG_PRINT("progpos",("first - delete - next -> last"));
if (mi_rkey(file,read_record3,0,key,0,HA_READ_KEY_EXACT)) goto err;
if (mi_delete(file,read_record3)) goto err;
- delete++;
+ opt_delete++;
ant=1;
if (mi_rnext(file,read_record,0))
goto err; /* Skall finnas poster */
@@ -547,7 +547,7 @@ int main(int argc, char **argv)
DBUG_PRINT("progpos",("last - delete - prev -> first"));
if (mi_rprev(file,read_record3,0)) goto err;
if (mi_delete(file,read_record3)) goto err;
- delete++;
+ opt_delete++;
ant=0;
while (mi_rprev(file,read_record3,0) == 0 &&
bcmp(read_record3+start,key,length) == 0) ant++;
@@ -641,7 +641,7 @@ int main(int argc, char **argv)
if (!silent)
printf("- mi_info\n");
mi_status(file,&info,HA_STATUS_VARIABLE | HA_STATUS_CONST);
- if (info.records != write_count-delete || info.deleted > delete + update
+ if (info.records != write_count-opt_delete || info.deleted > opt_delete + update
|| info.keys != keys)
{
puts("Wrong info from mi_info");
@@ -678,10 +678,10 @@ int main(int argc, char **argv)
while ((error=mi_rrnd(file,record,HA_OFFSET_ERROR)) != HA_ERR_END_OF_FILE &&
ant < write_count + 10)
ant+= error ? 0 : 1;
- if (ant != write_count-delete)
+ if (ant != write_count-opt_delete)
{
printf("rrnd with cache: I can only find: %d records of %d\n",
- ant,write_count-delete);
+ ant,write_count-opt_delete);
goto end;
}
if (mi_extra(file,HA_EXTRA_NO_CACHE))
@@ -695,10 +695,10 @@ int main(int argc, char **argv)
while ((error=mi_scan(file,record)) != HA_ERR_END_OF_FILE &&
ant < write_count + 10)
ant+= error ? 0 : 1;
- if (ant != write_count-delete)
+ if (ant != write_count-opt_delete)
{
printf("scan with cache: I can only find: %d records of %d\n",
- ant,write_count-delete);
+ ant,write_count-opt_delete);
goto end;
}
@@ -724,7 +724,7 @@ int main(int argc, char **argv)
lastpos=info.recpos;
if (error == 0)
{
- if (delete == (uint) remove_count) /* While testing */
+ if (opt_delete == (uint) remove_count) /* While testing */
goto end;
if (mi_rsame(file,read_record,-1))
{
@@ -751,19 +751,19 @@ int main(int argc, char **argv)
if (mi_delete(file,read_record))
{
printf("can't delete record: %6.6s, delete_count: %d\n",
- read_record, delete);
+ read_record, opt_delete);
goto err;
}
- delete++;
+ opt_delete++;
}
else
found_parts++;
}
if (my_errno != HA_ERR_END_OF_FILE && my_errno != HA_ERR_RECORD_DELETED)
printf("error: %d from mi_rrnd\n",my_errno);
- if (write_count != delete)
+ if (write_count != opt_delete)
{
- printf("Deleted only %d of %d records (%d parts)\n",delete,write_count,
+ printf("Deleted only %d of %d records (%d parts)\n",opt_delete,write_count,
found_parts);
goto err;
}
@@ -774,7 +774,7 @@ end:
if (!silent)
{
printf("\nFollowing test have been made:\n");
- printf("Write records: %d\nUpdate records: %d\nSame-key-read: %d\nDelete records: %d\n", write_count,update,dupp_keys,delete);
+ printf("Write records: %d\nUpdate records: %d\nSame-key-read: %d\nDelete records: %d\n", write_count,update,dupp_keys,opt_delete);
if (rec_pointer_size)
printf("Record pointer size: %d\n",rec_pointer_size);
if (key_cacheing)
diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c
index fa07d19ddbd..6f782b2f80f 100644
--- a/myisam/myisamchk.c
+++ b/myisam/myisamchk.c
@@ -39,7 +39,6 @@ static uint decode_bits;
static char **default_argv;
static const char *load_default_groups[]= { "myisamchk", 0 };
static const char *set_charset_name;
-static uint8 set_charset_number;
static CHARSET_INFO *set_charset;
static const char *type_names[]=
@@ -206,7 +205,7 @@ static struct option long_options[] =
static void print_version(void)
{
- printf("%s Ver 1.49 for %s at %s\n",my_progname,SYSTEM_TYPE,
+ printf("%s Ver 1.51 for %s at %s\n",my_progname,SYSTEM_TYPE,
MACHINE_TYPE);
}
@@ -606,9 +605,10 @@ static int myisamchk(MI_CHECK *param, my_string filename)
(((ulonglong) 1L << share->base.keys)-1)) ||
test_if_almost_full(info) ||
info->s->state.header.file_version[3] != myisam_file_magic[3] ||
- (set_charset && set_charset_number != share->state.header.language)))
+ (set_charset && set_charset->number != share->state.header.language)))
{
- check_param.language=set_charset_number;
+ if (set_charset)
+ check_param.language=set_charset->number;
if (recreate_table(&check_param, &info,filename))
{
VOID(fprintf(stderr,
@@ -949,7 +949,7 @@ static void descript(MI_CHECK *param, register MI_INFO *info, my_string name)
share->base.raid_chunks,
share->base.raid_chunksize);
}
- if (share->options & HA_OPTION_CHECKSUM)
+ if (share->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD))
printf("Checksum: %23s\n",llstr(info->s->state.checksum,llbuff));
;
if (share->options & HA_OPTION_DELAY_KEY_WRITE)
diff --git a/myisam/myisamlog.c b/myisam/myisamlog.c
index 78c3faa72ed..fb199c22765 100644
--- a/myisam/myisamlog.c
+++ b/myisam/myisamlog.c
@@ -21,7 +21,7 @@
#endif
#include "myisamdef.h"
-#include "my_tree.h"
+#include <my_tree.h>
#include <stdarg.h>
#ifdef HAVE_GETRUSAGE
#include <sys/resource.h>
@@ -251,12 +251,12 @@ static void get_options(register int *argc, register char ***argv)
/* Fall through */
case 'I':
case '?':
- printf("%s Ver 1.3 for %s at %s\n",my_progname,SYSTEM_TYPE,
+ printf("%s Ver 1.4 for %s at %s\n",my_progname,SYSTEM_TYPE,
MACHINE_TYPE);
puts("By Monty, for your professional use\n");
if (version)
break;
- puts("Write info about whats in a myisam log file.");
+ puts("Write info about whats in a MyISAM log file.");
printf("If no file name is given %s is used\n",log_filename);
puts("");
printf(usage,my_progname);
@@ -266,7 +266,7 @@ static void get_options(register int *argc, register char ***argv)
puts(" -o \"offset\" -p # \"remove # components from path\"");
puts(" -r \"recover\" -R \"file recordposition\"");
puts(" -u \"update\" -v \"verbose\" -w \"write file\"");
- puts(" -D \"myisam compileled with DBUG\" -P \"processes\"");
+ puts(" -D \"myisam compiled with DBUG\" -P \"processes\"");
puts("\nOne can give a second and a third '-v' for more verbose.");
puts("Normaly one does a update (-u).");
puts("If a recover is done all writes and all possibly updates and deletes is done\nand errors are only counted.");
@@ -376,10 +376,8 @@ static int examine_log(my_string file_name, char **table_names)
}
if (curr_file_info)
- {
printf("\nWarning: %s is opened with same process and filenumber\nMaybe you should use the -P option ?\n",
curr_file_info->show_name);
- }
if (my_b_read(&cache,(byte*) head,2))
goto err;
file_info.name=0;
@@ -490,8 +488,7 @@ static int examine_log(my_string file_name, char **table_names)
command_name[command], (int) extra_command,result);
if (update && curr_file_info && !curr_file_info->closed)
{
- if (mi_extra(curr_file_info->isam,
- (int) extra_command) != (int) result)
+ if (mi_extra(curr_file_info->isam, extra_command) != (int) result)
{
fflush(stdout);
VOID(fprintf(stderr,
diff --git a/myisam/myisampack.c b/myisam/myisampack.c
index ee8ef0bb360..62d9b8e886d 100644
--- a/myisam/myisampack.c
+++ b/myisam/myisampack.c
@@ -230,12 +230,12 @@ int main(int argc, char **argv)
#endif
}
-enum options {OPT_CHARSETS_DIR=256};
+enum options {OPT_CHARSETS_DIR_MP=256};
static struct option long_options[] =
{
{"backup", no_argument, 0, 'b'},
- {"character-sets-dir",required_argument,0, OPT_CHARSETS_DIR},
+ {"character-sets-dir",required_argument,0, OPT_CHARSETS_DIR_MP},
{"debug", optional_argument, 0, '#'},
{"force", no_argument, 0, 'f'},
{"join", required_argument, 0, 'j'},
@@ -252,7 +252,7 @@ static struct option long_options[] =
static void print_version(void)
{
- printf("%s Ver 1.9 for %s on %s\n",my_progname,SYSTEM_TYPE,MACHINE_TYPE);
+ printf("%s Ver 1.10 for %s on %s\n",my_progname,SYSTEM_TYPE,MACHINE_TYPE);
}
static void usage(void)
@@ -335,7 +335,7 @@ static void get_options(int *argc,char ***argv)
case '#':
DBUG_PUSH(optarg ? optarg : "d:t:o");
break;
- case OPT_CHARSETS_DIR:
+ case OPT_CHARSETS_DIR_MP:
charsets_dir = optarg;
break;
case 'V': print_version(); exit(0);
@@ -1169,7 +1169,7 @@ static int make_huff_tree(HUFF_TREE *huff_tree, HUFF_COUNTS *huff_counts)
{
uint i,found,bits_packed,first,last;
my_off_t bytes_packed;
- HUFF_ELEMENT *a,*b,*new;
+ HUFF_ELEMENT *a,*b,*new_huff_el;
first=last=0;
if (huff_counts->tree_buff)
@@ -1249,23 +1249,23 @@ static int make_huff_tree(HUFF_TREE *huff_tree, HUFF_COUNTS *huff_counts)
{
if (huff_counts->counts[i])
{
- new=huff_tree->element_buffer+(found++);
- new->count=huff_counts->counts[i];
- new->a.leaf.null=0;
- new->a.leaf.element_nr=i;
- queue.root[found]=(byte*) new;
+ new_huff_el=huff_tree->element_buffer+(found++);
+ new_huff_el->count=huff_counts->counts[i];
+ new_huff_el->a.leaf.null=0;
+ new_huff_el->a.leaf.element_nr=i;
+ queue.root[found]=(byte*) new_huff_el;
}
}
while (found < 2)
{ /* Our huff_trees request at least 2 elements */
- new=huff_tree->element_buffer+(found++);
- new->count=0;
- new->a.leaf.null=0;
+ new_huff_el=huff_tree->element_buffer+(found++);
+ new_huff_el->count=0;
+ new_huff_el->a.leaf.null=0;
if (last)
- new->a.leaf.element_nr=huff_tree->min_chr=last-1;
+ new_huff_el->a.leaf.element_nr=huff_tree->min_chr=last-1;
else
- new->a.leaf.element_nr=huff_tree->max_chr=last+1;
- queue.root[found]=(byte*) new;
+ new_huff_el->a.leaf.element_nr=huff_tree->max_chr=last+1;
+ queue.root[found]=(byte*) new_huff_el;
}
}
queue.elements=found;
@@ -1277,13 +1277,13 @@ static int make_huff_tree(HUFF_TREE *huff_tree, HUFF_COUNTS *huff_counts)
{
a=(HUFF_ELEMENT*) queue_remove(&queue,0);
b=(HUFF_ELEMENT*) queue.root[1];
- new=huff_tree->element_buffer+found+i;
- new->count=a->count+b->count;
- bits_packed+=(uint) (new->count & 7);
- bytes_packed+=new->count/8;
- new->a.nod.left=a; /* lesser in left */
- new->a.nod.right=b;
- queue.root[1]=(byte*) new;
+ new_huff_el=huff_tree->element_buffer+found+i;
+ new_huff_el->count=a->count+b->count;
+ bits_packed+=(uint) (new_huff_el->count & 7);
+ bytes_packed+=new_huff_el->count/8;
+ new_huff_el->a.nod.left=a; /* lesser in left */
+ new_huff_el->a.nod.right=b;
+ queue.root[1]=(byte*) new_huff_el;
queue_replaced(&queue);
}
huff_tree->root=(HUFF_ELEMENT*) queue.root[1];
@@ -1306,14 +1306,14 @@ static int compare_tree(void* cmp_arg __attribute__((unused)),
static int save_counts_in_queue(byte *key, element_count count,
HUFF_TREE *tree)
{
- HUFF_ELEMENT *new;
+ HUFF_ELEMENT *new_huff_el;
- new=tree->element_buffer+(tree->elements++);
- new->count=count;
- new->a.leaf.null=0;
- new->a.leaf.element_nr= (uint) (key- tree->counts->tree_buff) /
+ new_huff_el=tree->element_buffer+(tree->elements++);
+ new_huff_el->count=count;
+ new_huff_el->a.leaf.null=0;
+ new_huff_el->a.leaf.element_nr= (uint) (key- tree->counts->tree_buff) /
tree->counts->field_length;
- queue.root[tree->elements]=(byte*) new;
+ queue.root[tree->elements]=(byte*) new_huff_el;
return 0;
}
@@ -1355,14 +1355,14 @@ static my_off_t calc_packed_length(HUFF_COUNTS *huff_counts,
_downheap(&queue,i);
for (i=0 ; i < found-1 ; i++)
{
- HUFF_ELEMENT *a,*b,*new;
+ HUFF_ELEMENT *a,*b,*new_huff_el;
a=(HUFF_ELEMENT*) queue_remove(&queue,0);
b=(HUFF_ELEMENT*) queue.root[1];
- new=element_buffer+i;
- new->count=a->count+b->count;
- bits_packed+=(uint) (new->count & 7);
- bytes_packed+=new->count/8;
- queue.root[1]=(byte*) new;
+ new_huff_el=element_buffer+i;
+ new_huff_el->count=a->count+b->count;
+ bits_packed+=(uint) (new_huff_el->count & 7);
+ bytes_packed+=new_huff_el->count/8;
+ queue.root[1]=(byte*) new_huff_el;
queue_replaced(&queue);
}
DBUG_RETURN(bytes_packed+(bits_packed+7)/8);
@@ -1673,7 +1673,7 @@ static int compress_isam_file(MRG_INFO *mrg, HUFF_COUNTS *huff_counts)
max_calc_length+=huff_counts[i].tree->height;
else if (huff_counts[i].field_type == FIELD_BLOB ||
huff_counts[i].field_type == FIELD_VARCHAR)
- max_calc_length=huff_counts[i].tree->height*huff_counts[i].max_length + huff_counts[i].length_bits +1;
+ max_calc_length+=huff_counts[i].tree->height*huff_counts[i].max_length + huff_counts[i].length_bits +1;
else
max_calc_length+=
(huff_counts[i].field_length - huff_counts[i].max_zero_fill)*
diff --git a/myisam/sort.c b/myisam/sort.c
index 384c778ab54..e79d199fc03 100644
--- a/myisam/sort.c
+++ b/myisam/sort.c
@@ -28,6 +28,9 @@
#include <queues.h>
/* static variabels */
+#undef MIN_SORT_MEMORY
+#undef MYF_RW
+#undef DISK_BUFFER_SIZE
#define MERGEBUFF 15
#define MERGEBUFF2 31
@@ -36,10 +39,10 @@
#define DISK_BUFFER_SIZE (IO_SIZE*16)
typedef struct st_buffpek {
- my_off_t file_pos; /* position to buffer */
- ha_rows count; /* keys in buffer */
- uchar *base,*key; /* Pekare inom sort_key - indexdel */
- uint mem_count; /* keys left in memory */
+ my_off_t file_pos; /* Where we are in the sort file */
+ ha_rows count; /* Number of rows in table */
+ uchar *base,*key; /* Key pointers */
+ uint mem_count; /* numbers of keys in memory */
uint max_keys; /* Max keys in buffert */
} BUFFPEK;
@@ -419,7 +422,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file,
sort_length));
if (error == -1)
goto err; /* purecov: inspected */
- queue_insert(&queue,(void*) buffpek);
+ queue_insert(&queue,(char*) buffpek);
}
while (queue.elements > 1)
diff --git a/myisammrg/myrg_delete.c b/myisammrg/myrg_delete.c
index a470b4876cf..9ac32655172 100644
--- a/myisammrg/myrg_delete.c
+++ b/myisammrg/myrg_delete.c
@@ -18,9 +18,9 @@
#include "mymrgdef.h"
-int myrg_delete(info,record)
-MYRG_INFO *info;
-const byte *record;
+int myrg_delete(
+MYRG_INFO *info,
+const byte *record)
{
if (!info->current_table)
{
diff --git a/myisammrg/myrg_locking.c b/myisammrg/myrg_locking.c
index fc03df9bf63..c89acca3918 100644
--- a/myisammrg/myrg_locking.c
+++ b/myisammrg/myrg_locking.c
@@ -20,9 +20,9 @@
#include "mymrgdef.h"
-int myrg_lock_database(info,lock_type)
-MYRG_INFO *info;
-int lock_type;
+int myrg_lock_database(
+MYRG_INFO *info,
+int lock_type)
{
int error,new_error;
MYRG_TABLE *file;
diff --git a/myisammrg/myrg_open.c b/myisammrg/myrg_open.c
index ce2c97e1276..9fa89b315ff 100644
--- a/myisammrg/myrg_open.c
+++ b/myisammrg/myrg_open.c
@@ -30,10 +30,10 @@
*/
-MYRG_INFO *myrg_open(name,mode,handle_locking)
-const char *name;
-int mode;
-int handle_locking;
+MYRG_INFO *myrg_open(
+const char *name,
+int mode,
+int handle_locking)
{
int save_errno,i,errpos;
uint files,dir_length,length,options;
@@ -65,7 +65,6 @@ int handle_locking;
end[-1]='\0';
if (buff[0] && buff[0] != '#') /* Skipp empty lines and comments */
{
- last_isam=isam;
if (!test_if_hard_path(buff))
{
VOID(strmake(name_buff+dir_length,buff,
@@ -75,14 +74,14 @@ int handle_locking;
if (!(isam=mi_open(buff,mode,test(handle_locking))))
goto err;
files++;
+ last_isam=isam;
+ if (info.reclength && info.reclength != isam->s->base.reclength)
+ {
+ my_errno=HA_ERR_WRONG_IN_RECORD;
+ goto err;
+ }
+ info.reclength=isam->s->base.reclength;
}
- last_isam=isam;
- if (info.reclength && info.reclength != isam->s->base.reclength)
- {
- my_errno=HA_ERR_WRONG_IN_RECORD;
- goto err;
- }
- info.reclength=isam->s->base.reclength;
}
if (!(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO)+
files*sizeof(MYRG_TABLE),
diff --git a/myisammrg/myrg_panic.c b/myisammrg/myrg_panic.c
index 8b6169c896b..99a1f6828d1 100644
--- a/myisammrg/myrg_panic.c
+++ b/myisammrg/myrg_panic.c
@@ -24,8 +24,7 @@
done for all single user files to get changes in database */
-int myrg_panic(flag)
-enum ha_panic_function flag;
+int myrg_panic(enum ha_panic_function flag)
{
int error=0;
LIST *list_element,*next_open;
diff --git a/mysql-test/misc/select.tst b/mysql-test/misc/select.tst
deleted file mode 100644
index ed7f110f91a..00000000000
--- a/mysql-test/misc/select.tst
+++ /dev/null
@@ -1,4015 +0,0 @@
-# enkel sökning
-#
-use ok;
-#set option sql_big_tables=1;
-
-select period from ok_system;
-select * from ok_system;
-select ok_system.* from ok_system;
-
-# sökning med ej nyckel
-#
-select station.ok_namn from station where föreningsnr = 58 and ok_namn like "%LJUGARN%";
-select ok_namn from station where ok_namn like "%leden" ;
-
-# sökning med ej nyckel samt sortering och limit
-#
-select station.ok_namn from station where föreningsnr = 57+1 order by ok_namn;
-select stationsnr from station where föreningsnr = 58 order by ok_namn;
-select ok_namn from station order by ok_namn desc limit 10;
-select ok_namn from station order by ok_namn desc limit 5;
-select ok_namn from station order by ok_namn desc limit 5,5;
-
-# Sökning med nyckel = constant på icke unik nyckel
-# Här läses databasen direkt med read-next på ok_namn
-#
-select station.ok_namn from station where ok_namn = 'JÄRLÅSMACKEN AB';
-select station.ok_namn from station where ok_namn LIKE 'JÄRLÅSMACKEN A_';
-select station.ok_namn from station where ok_namn LIKE 'JÄRL_SMACKEN A_';
-select station.ok_namn from station where ok_namn LIKE 'JÄRLÅSMACKEN AB%';
-select station.ok_namn from station where ok_namn LIKE 'J%AB';
-select station.ok_namn from station where ok_namn LIKE 'JÄRLÅSMACKEN AB_';
-select station.ok_namn from station where ok_namn LIKE 'b_s%';
-
-#
-# Test av USE INDEX and IGNORE INDEX
-#
-explain select station.ok_namn from station where ok_namn = 'JÄRLÅSMACKEN AB';
-explain select ok_namn from station ignore index (ok_namn) where ok_namn = 'JÄRLÅSMACKEN AB';
-explain select ok_namn from station use index (stationsnr) where ok_namn = 'JÄRLÅSMACKEN AB';
-explain select ok_namn from station use index (ok_namn) where ok_namn = 'JÄRLÅSMACKEN AB';
-explain select ok_namn from station use index (stationsnr,ok_namn) where ok_namn = 'JÄRLÅSMACKEN AB';
-
-# Följande skall ge fel
-explain select ok_namn from station ignore index (ok_namn,not_used);
-explain select ok_namn from station use index (not_used);
-
-
-# Test av sortering på på använd nyckel (ingen sortering behövs)
-#
-select station.ok_namn from station where ok_namn >= 'JÄRLÅSMACKEN AB' and ok_namn <= 'JÄRLÅSMACKEN AB' order by ok_namn;
-select stationsnr,ok_namn from station where ok_namn="" or ok_namn = "." order by ok_namn ;
-
-# sökning med nyckel = constant med flera träffar
-# Här läses databasen direkt med read-next på ok_namn ifall få träffar
-#
-select stationsnr,ok_namn from station where föreningsnr = 37 and ok_namn = 'ÖSTERSUND';
-
-
-# sökning med eller-nivåer på nyckel
-# Ifall man kan begränsa nyckel till ett antal intervall sökes endast de
-# möjliga intervallen igenom.
-#
-select stationsnr from station where stationsnr=250501 or stationsnr="250502";
-select stationsnr from station where stationsnr=250501 or stationsnr=250502 or stationsnr >= 250505 and stationsnr <= 250601 or stationsnr between 250501 and 250502;
-
-
-# sökning med nyckel LIKE constant
-# Ifall LIKE begreppet börjar på en bokstav används nyckeln
-#
-select stationsnr,ok_namn from station where föreningsnr = 37 and ok_namn like 'f%';
-select ok_namn from station where ok_namn like "L%" and ok_namn = "ok";
-select ok_namn from station where (ok_namn like "L%" and ok_namn = "Lund");
-select stationsnr,ok_namn from station where stationsnr like "25050%";
-select stationsnr,ok_namn from station where stationsnr like "25050_";
-
-# Sökning med distinct
-# ifall distinct endast är på en riktig tabell görs en automatisk group över
-# alla fält. I andra fall skapas alltid en temporär databas.
-# Ifall endast sorteringsfält från huvudregistret, sorteras detta först innan
-# den distinkta tabellen skapas.
-#
-select distinct föreningsnr from station ;
-select distinct föreningsnr from station order by föreningsnr;
-select distinct föreningsnr from station order by föreningsnr desc;
-select distinct station.ok_namn,period from station,ok_system where föreningsnr = 58 and ok_namn like "O%";
-select distinct ok_namn from station where föreningsnr = 34 order by ok_namn;
-select distinct ok_namn from station limit 10;
-select distinct ok_namn from station having ok_namn like "A%" limit 10;
-select distinct substring(ok_namn,1,3) from station where ok_namn like "A%";
-select distinct substring(ok_namn,1,3) as a from station having a like "A%" order by a limit 10 ;
-select distinct substring(ok_namn,1,3) from station where ok_namn like "A%" limit 10;
-select distinct substring(ok_namn,1,3) as a from station having a like "A%" limit 10;
-SET OPTION SQL_BIG_TABLES=1;
-select distinct concat(ok_namn," ",ok_namn) as namn from station,station_period where station.stationsnr=station_period.stationsnr order by namn limit 10;
-SET OPTION SQL_BIG_TABLES=0;
-select distinct concat(ok_namn," ",ok_namn) from station,station_period where station.stationsnr=station_period.stationsnr order by ok_namn limit 10;
-select distinct co from station limit 10;
-
-#
-# Force use of remove_dupp
-#
-select distinct ok_namn,count(*) from station group by föreningsnr,ok_namn;
-SET OPTION SQL_BIG_TABLES=1; # Force use of MyISAM
-select distinct ok_namn,count(*) from station group by föreningsnr,ok_namn;
-SET OPTION SQL_BIG_TABLES=0;
-select distinct ok_namn,repeat("a",length(ok_namn)),count(*) from station group by föreningsnr,ok_namn;
-
-# En order by som borde använda merge i filesort!
-select distinct föreningsnr,rtrim(space(512+föreningsnr)) from station_period order by 1,2;
-
-# Sökning med distinct och order och flera register
-# Ifall result-posten är liten skapas en unik nyckel i temporärbasen som
-# täcker hela posten. I annat fall görs en jämförelse alla-mot-alla för att
-# eliminera dubletterna :(
-# Detta specifica exempel tar tyvärr station_period som huvudtabell. Fixas
-# genom att
-# sätta nyckel på föreningsnr.
-
-select distinct ok_namn from station,station_period where station.föreningsnr = 34 and station.stationsnr=station_period.stationsnr order by ok_namn;
-
-#
-# Here the last ok_namn is optimized away from the order by
-#
-explain select station_period.stationsnr,ok_namn from station,station_period where station.föreningsnr = 34 and station.stationsnr=station_period.stationsnr order by station_period.stationsnr,ok_namn;
-
-# Sökning med konstantregister (systemregister samt nyckel = konstant)
-# Alla konstantregister läses i början och härefter läses resten normalt.
-#
-select period from ok_system;
-select period from ok_system where period=1900;
-select ok_namn,period from ok_system,station where stationsnr = 011401 order by period;
-
-
-# Sökning med konstantregister och flera nyckeldelar (posterna läses 1 gång vid
-# start av sökningen)
-#
-select ok_namn,period from station,station_period where station.stationsnr = 011401 and station.stationsnr=station_period.stationsnr and station_period.period=9501;
-explain select ok_namn,period from station,station_period where station.stationsnr = 011401 and station_period.stationsnr=station.stationsnr and 9501 = station_period.period;
-
-# Sökning med ett konstantregister och flera poster i andra register
-#
-select ok_namn,period from station,ok_system where föreningsnr*10 = 37*10;
-
-# Sökning med register referens och sökning på ej nyckel
-# (Här är station_period huvudregister)
-#
-select ok_namn,period,priv_inköp,ftg_inköp from station,station_period where station.stationsnr=station_period.stationsnr and period >= 9401 and period <= 9402 and station.föreningsnr = 34 order by ok_namn,period, priv_inköp;
-
-
-# Sökning med intervall på ett register med full nyckel på referensregister
-# (Här är station huvudregister och endast stationerna i stationsnummer
-# intervallet kontrolleras)
-#
-select station.stationsnr,ok_namn,period,priv_inköp,ftg_inköp from station,station_period where station.stationsnr>= 250501 and station.stationsnr <= 250505 and station.stationsnr=station_period.stationsnr and period = 9401 and station.föreningsnr = 34;
-
-#
-# Test of stright join to force a full join
-#
-select STRAIGHT_JOIN station.föreningsnr,föreningsnamn from forening,station where station.föreningsnr=forening.föreningsnr group by station.föreningsnr;
-
-select SQL_SMALL_RESULT station.föreningsnr,föreningsnamn from forening,station where station.föreningsnr=forening.föreningsnr group by station.föreningsnr;
-
-#Full join (samt alias)
-select * from ok_system,ok_system ok_system2;
-select station.stationsnr,station2.stationsnr from station,station station2 where station.stationsnr >= 250501 and station.stationsnr <= 250505 and station2.stationsnr >= 250501 and station2.stationsnr <= 250505;
-
-#
-# test of left join
-#
-select station.föreningsnr,föreningsnamn from station left join forening using (föreningsnr) where forening.föreningsnr is null;
-explain select station.föreningsnr,föreningsnamn from station left join forening using (föreningsnr) where forening.föreningsnr is null;
-explain select station.föreningsnr,föreningsnamn from forening left join station using (föreningsnr) where station.föreningsnr is null;
-
-#
-# Join med formler
-#
-
-select distinct station.föreningsnr,forening.föreningsnr from station,forening where station.föreningsnr=forening.föreningsnr+1;
-explain select distinct station.föreningsnr,forening.föreningsnr from station,forening where station.föreningsnr=forening.föreningsnr+1;
-
-# Sökning med 'eller' med samma referens-begrepp
-# Först görs en intervall sökning i det första registret och sedan refereras
-# det andra med nyckel med en 'test ifall nyckelanvänding' för varje post
-#
-select station.stationsnr,station.föreningsnr,ok_namn,period from station_period,station where station.stationsnr = 250501 and station.stationsnr=station_period.stationsnr and period = 9401 or station.stationsnr = 250502 and station.stationsnr=station_period.stationsnr and period = 9402;
-select station.stationsnr,station.föreningsnr,ok_namn,period from station_period,station where (station.stationsnr = 250501 or station.stationsnr = 250502) and station.stationsnr=station_period.stationsnr and period>=9401 and period<=9402;
-select station.stationsnr,station.föreningsnr,ok_namn,period from station_period,station where (station_period.stationsnr = 250501 or station_period.stationsnr = 250502) and station.stationsnr=station_period.stationsnr and period>=9401 and period<=9402;
-
-# Test of many paren levels
-#
-select period from ok_system where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909) ;
-select period from ok_system where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6)));
-
-select a.stationsnr from station as a,station b where ((a.stationsnr = 250501 and a.stationsnr=b.stationsnr) or a.stationsnr=250502 or a.stationsnr=250503 or (a.stationsnr=250505 and a.stationsnr<=b.stationsnr and b.stationsnr>=a.stationsnr)) and a.stationsnr=b.stationsnr;
-
-select stationsnr from station where stationsnr in (250502,98005,98006,250503,250605,250606) and stationsnr >=250502 and stationsnr not in (250605,250606);
-
-select stationsnr from station where stationsnr between 250502 and 250504;
-
-select ok_namn from station where (((ok_namn like "_%L%" ) or (ok_namn like "%ok%")) and ( ok_namn like "L%" or ok_namn like "G%")) and ok_namn like "L%" ;
-
-
-# Group on one table
-# optimizer: sort table by group and send rows.
-#
-select count(*) from ok_system ;
-select föreningsnr,count(*),sum(stationsnr) from station group by föreningsnr ;
-select föreningsnr,count(*) from station group by föreningsnr order by föreningsnr desc limit 5;
-select count(*),min(stationsnamn),max(stationsnamn),sum(stationsnr),avg(stationsnr),std(stationsnr) from station where föreningsnr = 34 and stationsnamn<>"";
-select föreningsnr,count(*),min(stationsnamn),max(stationsnamn),sum(stationsnr),avg(stationsnr),std(stationsnr) from station group by föreningsnr limit 3;
-select föreningsnr,stationsnr,count(priv_inköp),sum(priv_inköp),min(priv_inköp),max(priv_inköp),avg(priv_inköp) from station_period where föreningsnr = 34 group by föreningsnr,stationsnr ;
-select /*! SQL_SMALL_RESULT */ föreningsnr,stationsnr,count(priv_inköp),sum(priv_inköp),min(priv_inköp),max(priv_inköp),avg(priv_inköp) from station_period where föreningsnr = 34 group by föreningsnr,stationsnr ;
-select föreningsnr,count(priv_inköp),sum(priv_inköp),min(priv_inköp),max(priv_inköp),avg(priv_inköp) from station_period group by föreningsnr ;
-select distinct mod(föreningsnr,10) from forening group by föreningsnr;
-select distinct 1 from forening group by föreningsnr;
-select count(distinct stationsnr) from station;
-select föreningsnr,count(distinct stationsnr) from station group by föreningsnr;
-select föreningsnr,count(*) from station group by föreningsnr;
-select föreningsnr,count(distinct concat(stationsnr,repeat(65,1000))) from station group by föreningsnr;
-select föreningsnr,count(distinct concat(stationsnr,repeat(65,200))) from station group by föreningsnr;
-select föreningsnr,count(distinct floor(stationsnr/100)) from station group by föreningsnr;
-select föreningsnr,count(distinct concat(repeat(65,1000),floor(stationsnr/100))) from station group by föreningsnr;
-
-#
-# group with where on a key field
-#
-select sum(stationsnr) from station where ok_namn="." group by stationsnr limit 10;
-select stationsnr,count(*) from station_drvm where stationsnr=098001 group by stationsnr;
-select stationsnr,count(*) from station_drvm where stationsnr=098004 and ftg>10 group by stationsnr;
-select count(*) from station_drvm where stationsnr=98001 and ftg=1;
-select stationsnr,count(*) from station_drvm where stationsnr=98001 and ftg=1 group by stationsnr;
-select stationsnr,count(*) from station_drvm where stationsnr>=98004 and stationsnr <=98005 group by stationsnr;
-select station.stationsnr,count(*) from station,station_drvm where station.stationsnr=98004 and station_drvm.stationsnr=station.stationsnr group by station_drvm.stationsnr;
-
-# Group with extra not group fields.
-#
-select föreningsnr|0,föreningsnamn from forening group by 1 ;
-select station.föreningsnr,föreningsnamn,count(*) from station,forening where station.föreningsnr=forening.föreningsnr group by station.föreningsnr order by föreningsnamn;
-
-#
-# Calculation with group functions
-#
-
-select sum(Period)/count(*) from ok_system ;
-select föreningsnr,count(priv_inköp) as "count",sum(priv_inköp) as "sum" ,sum(priv_inköp)/count(priv_inköp)-avg(priv_inköp) as "diff",(0+count(priv_inköp))*föreningsnr as func from station_period group by föreningsnr ;
-select föreningsnr,sum(priv_inköp)/count(priv_inköp) as avg from station_period group by föreningsnr having avg > 70000000 order by avg;
-
-# Group with order on not first table
-# optimizer: sort table by group and write group records to tmp table.
-# sort tmp_table and send rows.
-#
-select föreningsnr,count(*) from station group by föreningsnr order by 2 desc ;
-select föreningsnr,count(*) from station where föreningsnr > 40 group by föreningsnr order by 2 desc ;
-select station.stationsnamn,station.stationsnr,count(priv_inköp),sum(priv_inköp),min(priv_inköp),max(priv_inköp),avg(priv_inköp) from station_period,station where station_period.föreningsnr = 34 and station.stationsnr = station_period.stationsnr group by stationsnr,station.stationsnamn ;
-
-
-# group by with many tables
-# optimizer: create tmp table with group-by uniq index.
-# write with update to tmp table.
-# sort tmp table according to order (or group if no order)
-# send rows
-#
-select station_period.föreningsnr,ok_namn,sum(priv_inköp) from station_period,station where station.stationsnr = station_period.stationsnr and station_period.föreningsnr = 58 group by föreningsnr,ok_namn ;
-select station.föreningsnr,count(*),min(ok_namn),max(ok_namn),sum(priv_inköp),avg(priv_inköp) from station,station_period where station_period.föreningsnr >= 30 and station_period.föreningsnr <= 58 and station_period.stationsnr = station.stationsnr and 1+1=2 group by station.föreningsnr;
-
-
-# group with many tables and long group on many tables. group on formula
-#optimizer: create tmp table with neaded fields
-# sort tmp table by group and calculate sums to new table
-# if different order by than group, sort tmp table
-# send rows
-
-select station_period.föreningsnr+0,station_period.stationsnr,ok_namn,sum(priv_inköp) from station_period,station where station.stationsnr = station_period.stationsnr and station_period.föreningsnr = 34 group by 1,station_period.stationsnr,ok_namn,ok_namn,ok_namn,ok_namn,ok_namn order by stationsnr;
-
-
-# WHERE const folding
-# optimize: If there is a "field = const" part in the where, change all
-# instances of field in the and level to const.
-# All instances of const = const are checked once and removed.
-
-#Where -> station_period.stationsnr = 98005 and station.stationsnr = 98005
-select sum(priv_inköp) from station_period,station where station.stationsnr = station_period.stationsnr and station_period.föreningsnr = 58 and station_period.stationsnr = 98004 and station.stationsnr = 98005 or station.stationsnr = station_period.stationsnr and station_period.stationsnr = 98005 and station.stationsnr = 98005 ;
-
-select station.stationsnr,sum(priv_inköp) from station_period,station where station.stationsnr = station_period.stationsnr and station_period.föreningsnr = 58 and station_period.stationsnr = 98004 and station.stationsnr = 98005 or station.stationsnr = station_period.stationsnr and station_period.stationsnr = 98005 and station.stationsnr = 98005 or station_period.stationsnr = station.stationsnr and station.stationsnr = 98004 group by station.stationsnr ;
-
-explain select ok_namn from station where 1>2 or 2>3;
-explain select ok_namn from station where stationsnr=stationsnr;
-
-#
-# HAVING
-#
-select föreningsnr,stationsnr from station HAVING stationsnr=250501 or stationsnr=250502;
-select föreningsnr,stationsnr from station WHERE stationsnr>=250501 HAVING stationsnr<=250502;
-select föreningsnr,count(*) as count,sum(stationsnr) as sum from station group by föreningsnr having count > 40 and sum/count >= 120000 ;
-select föreningsnr from station group by föreningsnr having count(*) > 40 and sum(stationsnr)/count(*) >= 120000 ;
-select station.föreningsnr,föreningsnamn,count(*) from station,forening where station.föreningsnr=forening.föreningsnr group by föreningsnamn having station.föreningsnr >= 40;
-
-#
-# MIN(), MAX() and COUNT() optimizing
-#
-select count(*) from station;
-select count(*) from station where stationsnr < 098024;
-select min(stationsnr) from station where stationsnr>= 098024;
-select max(stationsnr) from station where stationsnr>= 098024;
-select count(*) from station_drvm where stationsnr=098024;
-select count(*) from station_drvm where kundnr=78987 and stationsnr=098024;
-explain select min(stationsnr),max(stationsnr),count(*) from station;
-select min(stationsnr),max(stationsnr),count(*) from station;
-select min(kortnr),max(kortnr) from station_drvm where kundnr=78987 and stationsnr=098024;
-select count(*),min(kortnr),max(kortnr) from station_drvm where kundnr=78987 and stationsnr=098024;
-select kundnr,count(*) from station_drvm where stationsnr=098024 group by kundnr limit 20;
-select max(kundnr) from station_drvm where stationsnr=98024;
-#
-# Test of alias
-#
-select system.period from ok_system = system ;
-select system.period from ok_system as system ;
-select system.period as "Nuvarande period" from ok_system as system;
-select period as ok_period from ok_system;
-select period as ok_period from ok_system group by ok_period;
-select 1+1 as summa from ok_system group by summa;
-select period as "Nuvarande period" from ok_system group by "Nuvarande period";
-
-#
-# Some simple show commands
-#
-show databases;
-show tables;
-show tables from kf96 like "s%";
-show columns from station ;
-show columns from station from ok like 's%' ;
-show keys from station ;
-show variables;
-show variables like "p%";
-show table status from ok like "station%";
-
-
-#############################################################################
-#############################################################################
-##################### END `ok' TESTS ######################################
-#############################################################################
-#############################################################################
-
-
-#
-# numerical functions
-#
-select 1+1,1-1,1+1*2,8/5,8%5,mod(8,5),mod(8,5)|0,-(1+1)*-2,sign(-5) ;
-select floor(5.5),floor(-5.5),ceiling(5.5),ceiling(-5.5),round(5.5),round(-5.5);
-select round(5.64,1),round(5.64,2),round(5.64,-1),round(5.64,-2);
-select truncate(52.64,1),truncate(52.64,2),truncate(52.64,-1),truncate(52.64,-2);
-select abs(-10),log(exp(10)),exp(log(sqrt(10))*2),pow(10,log10(10)),rand(999999),rand(),power(2,4);
-select pi(),sin(pi()/2),cos(pi()/2),tan(pi()),cot(1),asin(1),acos(0),atan(1);
-select 1 | (1+1),5 & 3,bit_count(7) ;
-select 1 << 32,1 << 63, 1 << 64, 4 >> 2, 4 >> 63, 1<< 63 >> 60;
-select 10,10.0,10.,.1e+2,100.0e-1;
-select 6e-05, -6e-05, --6e-05, -6e-05+1.000000;
-select 0,256,00000000000000065536,2147483647,-2147483648,2147483648,+4294967296;
-select 922337203685477580,92233720368547758000;
-select -922337203685477580,-92233720368547758000;
-select 9223372036854775807,-009223372036854775808;
-select +9999999999999999999,-9999999999999999999;
-select degrees(pi()),radians(360);
-
-#
-# test functions
-#
-select 0=0,1>0,1>=1,1<0,1<=0,1!=0,strcmp("abc","abcd"),strcmp("b","a"),strcmp("a","a") ;
-select "a"<"b","a"<="b","b">="a","b">"a","a"="A","a"<>"b";
-select "a "="A", "A "="a", "a " <= "A b";
-select "abc" like "a%", "abc" not like "%d%", "a%" like "a\%","abc%" like "a%\%","abcd" like "a%b_%d", "a" like "%%a","abcde" like "a%_e","abc" like "abc%";
-select "a" like "%%b","a" like "%%ab","ab" like "a\%", "ab" like "_", "ab" like "ab_", "abc" like "%_d", "abc" like "abc%d";
-select '?' like '|%', '?' like '|%' ESCAPE '|', '%' like '|%', '%' like '|%' ESCAPE '|', '%' like '%';
-select 'abc' like '%c','abcabc' like '%c', "ab" like "", "ab" like "a", "ab" like "ab";
-select "Det här är svenska" regexp "h[[:alpha:]]+r", "aba" regexp "^(a|b)*$";
-select "aba" regexp concat("^","a");
-select !0,NOT 0=1,!(0=0),1 AND 1,1 && 0,0 OR 1,1 || NULL, 1=1 or 1=1 and 1=0;
-select IF(0,"ERROR","this"),IF(1,"is","ERROR"),IF(NULL,"ERROR","a"),IF(1,2,3)|0,IF(1,2.0,3.0)+0 ;
-select 2 between 1 and 3, "monty" between "max" and "my",2=2 and "monty" between "max" and "my" and 3=3;
-select 'b' between 'a' and 'c', 'B' between 'a' and 'c';
-select 2 in (3,2,5,9,5,1),"monty" in ("david","monty","allan"), 1.2 in (1.4,1.2,1.0);
-select -1.49 or -1.49,0.6 or 0.6;
-select least(1,2,3) | greatest(16,32,8), least(5,4)*1,greatest(-1.0,1.0)*1,least(3,2,1)*1.0,greatest(1,1.1,1.0),least("10",9),greatest("A","B","0");
-select decode(encode(repeat("a",100000),"monty"),"monty")=repeat("a",100000);
-select decode(encode("abcdef","monty"),"monty")="abcdef";
-
-select CASE "b" when "a" then 1 when "b" then 2 END;
-select CASE "c" when "a" then 1 when "b" then 2 END;
-select CASE "c" when "a" then 1 when "b" then 2 ELSE 3 END;
-select CASE BINARY "b" when "a" then 1 when "B" then 2 WHEN "b" then "ok" END;
-select CASE "b" when "a" then 1 when binary "B" then 2 WHEN "b" then "ok" END;
-select CASE concat("a","b") when concat("ab","") then "a" when "b" then "b" end;
-select CASE when 1=0 then "true" else "false" END;
-select CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END;
-select CASE 2.0 when 1 then "one" WHEN 2.0 then "two" ELSE "more" END;
-select (CASE "two" when "one" then "1" WHEN "two" then "2" END) | 0;
-select (CASE "two" when "one" then 1.00 WHEN "two" then 2.00 END) +0.0;
-select case 1/0 when "a" then "true" else "false" END;
-select case 1/0 when "a" then "true" END;
-select (case 1/0 when "a" then "true" END) | 0;
-select (case 1/0 when "a" then "true" END) + 0.0;
-select case when 1>0 then "TRUE" else "FALSE" END;
-select case when 1<0 then "TRUE" else "FALSE" END;
-
-#
-# string functions
-#
-select 'hello',"'hello'",'""hello""','''h''e''l''l''o''',"hel""lo",'hel\'lo';
-select 'hello' 'monty';
-select length("\n\t\r\b\0\_\%\\");
-select concat("monty"," was here ","again"),length("hello"),char(ascii('h'));
-select locate("he","hello"),locate("he","hello",2),locate("lo","hello",2) ;
-select instr("hello","he");
-select position("ll" in "hello"),position("a" in "hello");
-select left("hello",2),right("hello",2),substring("hello",2,2),mid("hello",1,5) ;
-select concat("",left(right(concat("what ",concat("is ","happening")),9),4),"",substring("monty",5,1)) ;
-select substring_index("www.tcx.se",".",-2),substring_index("www.tcx.se",".",1);
-select substring_index("www.tcx.se","tcx",1),substring_index("www.tcx.se","tcx",-1);
-select substring_index(".tcx.se",".",-2),substring_index(".tcx.se",".tcx",-1);
-
-select concat(":",ltrim(" left "),":",rtrim(" right "),":");
-select concat(":",trim(LEADING FROM " left"),":",trim(TRAILING FROM " right "),":");
-select concat(":",trim(" m "),":",trim(BOTH FROM " y "),":",trim("*" FROM "*s*"),":");
-select concat(":",trim(BOTH "ab" FROM "ababmyabab"),":",trim(BOTH "*" FROM "***sql"),":");
-select concat(":",trim(LEADING ".*" FROM ".*my"),":",trim(TRAILING ".*" FROM "sql.*.*"),":");
-
-select insert("txs",2,1,"hi"),insert("is ",4,0,"a"),insert("txxxxt",2,4,"es");
-select replace("aaaa","a","b"),replace("aaaa","aa","b"),replace("aaaa","a","bb"),replace("aaaa","","b"),replace("bbbb","a","c");
-select replace(concat(lcase(concat("THIS"," ","IS"," ","A"," ")),ucase("false")," ","test"),"FALSE","REAL") ;
-select soundex(""),soundex("he"),soundex("hello all folks");
-select password("test"),length(encrypt("test")),encrypt("test","aa");
-select md5("hello");
-select repeat("monty",5),concat("*",space(5),"*");
-select reverse("abc"),reverse("abcd");
-select rpad("a",4,"1"),rpad("a",4,"12"),rpad("abcd",3,"12");
-select lpad("a",4,"1"),lpad("a",4,"12"),lpad("abcd",3,"12");
-select rpad(741653838,17,'0'),lpad(741653838,17,'0');
-select LEAST(NULL,'HARRY','HARRIOT',NULL,'HAROLD'),GREATEST(NULL,'HARRY','HARRIOT',NULL,'HAROLD');
-
-#
-# varbinary as string and number
-#
-select 0x41,0x41+0,0x41 | 0x7fffffffffffffff | 0,0xffffffffffffffff | 0 ;
-select 0x31+1,concat(0x31)+1,-0xf;
-
-#
-# misc functions
-#
-select interval(55,10,20,30,40,50,60,70,80,90,100),interval(3,1,1+1,1+1+1+1),field("IBM","NCA","ICL","SUN","IBM","DIGITAL"),field("A","B","C"),elt(2,"ONE","TWO","THREE"),interval(0,1,2,3,4),elt(1,1,2,3)|0,elt(1,1.1,1.2,1.3)+0;
-select find_in_set("b","a,b,c"),find_in_set("c","a,b,c"),find_in_set("dd","a,bbb,dd"),find_in_set("bbb","a,bbb,dd");
-select find_in_set("d","a,b,c"),find_in_set("dd","a,bbb,d"),find_in_set("bb","a,bbb,dd");
-select make_set(0,'a','b','c'),make_set(-1,'a','b','c'),make_set(1,'a','b','c'),make_set(2,'a','b','c'),make_set(1+2,concat('a','b'),'c');
-select make_set(NULL,'a','b','c'),make_set(1|4,'a',NULL,'c'),make_set(1+2,'a',NULL,'c');
-select export_set(9,"Y","N","-",5),export_set(9,"Y","N"),export_set(9,"Y","N","");
-
-select format(1.5555,0),format(123.5555,1),format(1234.5555,2),format(12345.5555,3),format(123456.5555,4),format(1234567.5555,5),format("12345.2399",2);
-
-select inet_ntoa(inet_aton("255.255.255.255.255.255.255.255"));
-select inet_aton("255.255.255.255.255"),inet_aton("255.255.1.255"),inet_aton("0.1.255");
-select inet_ntoa(1099511627775),inet_ntoa(4294902271),inet_ntoa(511);
-
-#
-# system functions
-#
-select database(),user();
-
-#
-# Null tests
-#
-select null,\N,isnull(null),isnull(1/0),isnull(1/0 = null),ifnull(null,1),ifnull(null,"TRUE"),ifnull("TRUE","ERROR"),1/0 is null,1 is not null;
-select 1 | NULL,1 & NULL,1+NULL,1-NULL;
-select NULL=NULL,NULL<>NULL,IFNULL(NULL,1.1)+0,IFNULL(NULL,1) | 0;
-select strcmp("a",NULL),(1<NULL)+0.0,NULL regexp "a",null like "a%","a%" like null;
-select concat("a",NULL),replace(NULL,"a","b"),replace("string","i",NULL),replace("string",NULL,"i"),insert("abc",1,1,NULL),left(NULL,1);
-select repeat("a",0),repeat("ab",5+5),repeat("ab",-1),reverse(NULL);
-select field(NULL,"a","b","c");
-select 2 between null and 1,2 between 3 AND NULL,NULL between 1 and 2,2 between NULL and 3, 2 between 1 AND null;
-SELECT NULL AND NULL, 1 AND NULL, NULL AND 1, NULL OR NULL, 0 OR NULL, NULL OR 0;
-SELECT (NULL OR NULL) IS NULL;
-select NULL AND 0, 0 and NULL;
-select inet_ntoa(null),inet_aton(null),inet_aton("122.256"),inet_aton("122.226."),inet_aton("");
-#
-# Wrong or 'funny' use of functions.
-#
-
-select insert("aa",100,1,"b"),insert("aa",1,3,"b"),left("aa",-1),substring("a",1,2);
-select elt(2,1),field(NULL,"a","b","c"),reverse("");
-select find_in_set("","a,b,c"),find_in_set("","a,b,c,"),find_in_set("",",a,b,c");
-select find_in_set("abc","abc"),find_in_set("ab","abc"),find_in_set("abcd","abc");
-select locate("a","b",2),locate("","a",1);
-select ltrim("a"),rtrim("a"),trim(BOTH "" from "a"),trim(BOTH " " from "a");
-select concat("1","2")|0,concat("1",".5")+0.0;
-select substring_index("www.tcx.se","",3);
-select length(repeat("a",100000000)),length(repeat("a",1000*64));
-select position("0" in "baaa" in (1)),position("0" in "1" in (1,2,3)),position("sql" in ("mysql"));
-select position(("1" in (1,2,3)) in "01");
-select 5 between 0 and 10 between 0 and 1,(5 between 0 and 10) between 0 and 1;
-select 1 and 2 between 2 and 10, 2 between 2 and 10 and 1;
-select 1 and 0 or 2, 2 or 1 and 0;
-select length(repeat("a",65500)),length(concat(repeat("a",32000),repeat("a",32000))),length(replace("aaaaa","a",concat(repeat("a",10000)))),length(insert(repeat("a",40000),1,30000,repeat("b",50000)));
-select length(repeat("a",1000000)),length(concat(repeat("a",32000),repeat("a",32000),repeat("a",32000))),length(replace("aaaaa","a",concat(repeat("a",32000)))),length(insert(repeat("a",48000),1,1000,repeat("a",48000)));
-select 1+2/*hello*/+3;
-select 1 /* long
-multi line comment */;
-/* empty query */;
-select 1 /*!32301 +1 */;
-select 1 /*!52301 +1 */;
-
-#
-# time functions
-#
-select from_days(to_days("960101")),to_days(960201)-to_days("19960101"),to_days(date_add(curdate(), interval 1 day))-to_days(curdate()),weekday("1997-11-29");
-select period_add("9602",-12),period_diff(199505,"9404") ;
-select now()-now(),weekday(curdate())-weekday(now()),unix_timestamp()-unix_timestamp(now());
-select from_unixtime(unix_timestamp("1994-03-02 10:11:12")),from_unixtime(unix_timestamp("1994-03-02 10:11:12"),"%Y-%m-%d %h:%i:%s"),from_unixtime(unix_timestamp("1994-03-02 10:11:12"))+0;
-select sec_to_time(9001),sec_to_time(9001)+0,time_to_sec("15:12:22");
-select now()-curdate()*1000000-curtime();
-select strcmp(current_timestamp(),concat(current_date()," ",current_time()));
-select date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w");
-select date_format("1997-01-02", concat("%M %W %D ","%Y %y %m %d %h %i %s %w"));
-select dayofmonth("1997-01-02"),dayofmonth(19970323);
-select month("1997-01-02"),year("98-02-03"),dayofyear("1997-12-31");
-select DAYOFYEAR("1997-03-03"), WEEK("1998-03-03"), QUARTER(980303);
-select HOUR("1997-03-03 23:03:22"), MINUTE("23:03:22"), SECOND(230322);
-select week(19980101),week(19970101),week(19980101,1),week(19970101,1);
-select week(19981231),week(19971231),week(19981231,1),week(19971231,1);
-select week(19950101),week(19950101,1);
-select yearweek('1981-12-31',1),yearweek('1982-01-01',1),yearweek('1982-12-31',1),yearweek('1983-01-01',1);
-select date_format('1998-12-31','%x-%v'),date_format('1999-01-01','%x-%v');
-select date_format('1999-12-31','%x-%v'),date_format('2000-01-01','%x-%v');
-select yearweek('1987-01-01',1),yearweek('1987-01-01');
-
-select dayname("1962-03-03"),dayname("1962-03-03")+0;
-select monthname("1972-03-04"),monthname("1972-03-04")+0;
-select time_format(19980131000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
-select time_format(19980131010203,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
-select time_format(19980131131415,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
-select time_format(19980131010015,'%H|%I|%k|%l|%i|%p|%r|%S|%T');
-select date_format(concat('19980131',131415),'%H|%I|%k|%l|%i|%p|%r|%S|%T| %M|%W|%D|%Y|%y|%a|%b|%j|%m|%d|%h|%s|%w');
-select date_format(19980021000000,'%H|%I|%k|%l|%i|%p|%r|%S|%T| %M|%W|%D|%Y|%y|%a|%b|%j|%m|%d|%h|%s|%w');
-select date_add("1997-12-31 23:59:59",INTERVAL 1 SECOND);
-select date_add("1997-12-31 23:59:59",INTERVAL 1 MINUTE);
-select date_add("1997-12-31 23:59:59",INTERVAL 1 HOUR);
-select date_add("1997-12-31 23:59:59",INTERVAL 1 DAY);
-select date_add("1997-12-31 23:59:59",INTERVAL 1 MONTH);
-select date_add("1997-12-31 23:59:59",INTERVAL 1 YEAR);
-select date_add("1997-12-31 23:59:59",INTERVAL "1:1" MINUTE_SECOND);
-select date_add("1997-12-31 23:59:59",INTERVAL "1:1" HOUR_MINUTE);
-select date_add("1997-12-31 23:59:59",INTERVAL "1:1" DAY_HOUR);
-select date_add("1997-12-31 23:59:59",INTERVAL "1 1" YEAR_MONTH);
-select date_add("1997-12-31 23:59:59",INTERVAL "1:1:1" HOUR_SECOND);
-select date_add("1997-12-31 23:59:59",INTERVAL "1 1:1" DAY_MINUTE);
-select date_add("1997-12-31 23:59:59",INTERVAL "1 1:1:1" DAY_SECOND);
-
-select date_sub("1998-01-01 00:00:00",INTERVAL 1 SECOND);
-select date_sub("1998-01-01 00:00:00",INTERVAL 1 MINUTE);
-select date_sub("1998-01-01 00:00:00",INTERVAL 1 HOUR);
-select date_sub("1998-01-01 00:00:00",INTERVAL 1 DAY);
-select date_sub("1998-01-01 00:00:00",INTERVAL 1 MONTH);
-select date_sub("1998-01-01 00:00:00",INTERVAL 1 YEAR);
-select date_sub("1998-01-01 00:00:00",INTERVAL "1:1" MINUTE_SECOND);
-select date_sub("1998-01-01 00:00:00",INTERVAL "1:1" HOUR_MINUTE);
-select date_sub("1998-01-01 00:00:00",INTERVAL "1:1" DAY_HOUR);
-select date_sub("1998-01-01 00:00:00",INTERVAL "1 1" YEAR_MONTH);
-select date_sub("1998-01-01 00:00:00",INTERVAL "1:1:1" HOUR_SECOND);
-select date_sub("1998-01-01 00:00:00",INTERVAL "1 1:1" DAY_MINUTE);
-select date_sub("1998-01-01 00:00:00",INTERVAL "1 1:1:1" DAY_SECOND);
-
-select date_add("1997-12-31 23:59:59",INTERVAL 100000 SECOND);
-select date_add("1997-12-31 23:59:59",INTERVAL -100000 MINUTE);
-select date_add("1997-12-31 23:59:59",INTERVAL 100000 HOUR);
-select date_add("1997-12-31 23:59:59",INTERVAL -100000 DAY);
-select date_add("1997-12-31 23:59:59",INTERVAL 100000 MONTH);
-select date_add("1997-12-31 23:59:59",INTERVAL -100000 YEAR);
-select date_add("1997-12-31 23:59:59",INTERVAL "10000:1" MINUTE_SECOND);
-select date_add("1997-12-31 23:59:59",INTERVAL "-10000:1" HOUR_MINUTE);
-select date_add("1997-12-31 23:59:59",INTERVAL "10000:1" DAY_HOUR);
-select date_add("1997-12-31 23:59:59",INTERVAL "-100 1" YEAR_MONTH);
-select date_add("1997-12-31 23:59:59",INTERVAL "10000:99:99" HOUR_SECOND);
-select date_add("1997-12-31 23:59:59",INTERVAL " -10000 99:99" DAY_MINUTE);
-select date_add("1997-12-31 23:59:59",INTERVAL "10000 99:99:99" DAY_SECOND);
-select "1997-12-31 23:59:59" + INTERVAL 1 SECOND;
-select INTERVAL 1 DAY + "1997-12-31";
-select "1998-01-01 00:00:00" - INTERVAL 1 SECOND;
-
-select date_sub("1998-01-02",INTERVAL 31 DAY);
-select date_add("1997-12-31",INTERVAL 1 SECOND);
-select date_add("1997-12-31",INTERVAL 1 DAY);
-select date_add(NULL,INTERVAL 100000 SECOND);
-select date_add("1997-12-31 23:59:59",INTERVAL NULL SECOND);
-select date_add("1997-12-31 23:59:59",INTERVAL NULL MINUTE_SECOND);
-select date_add("9999-12-31 23:59:59",INTERVAL 1 SECOND);
-select date_sub("0000-00-00 00:00:00",INTERVAL 1 SECOND);
-select date_add('1998-01-30',Interval 1 month);
-select date_add('1998-01-30',Interval '2:1' year_month);
-select date_add('1996-02-29',Interval '1' year);
-select extract(YEAR FROM "1999-01-02 10:11:12");
-select extract(YEAR_MONTH FROM "1999-01-02");
-select extract(DAY FROM "1999-01-02");
-select extract(DAY_HOUR FROM "1999-01-02 10:11:12");
-select extract(DAY_MINUTE FROM "02 10:11:12");
-select extract(DAY_SECOND FROM "225 10:11:12");
-select extract(HOUR FROM "1999-01-02 10:11:12");
-select extract(HOUR_MINUTE FROM "10:11:12");
-select extract(HOUR_SECOND FROM "10:11:12");
-select extract(MINUTE FROM "10:11:12");
-select extract(MINUTE_SECOND FROM "10:11:12");
-select extract(SECOND FROM "1999-01-02 10:11:12");
-
-#
-# test variables
-#
-set @`test`=1,@TEST=3,@select=2;
-select @test,@`select`,@TEST,@not_used;
-set @test_int=10,@test_double=1e-10,@test_string="abcdeghi",@test_string2="abcdefghij",@select=NULL;
-select @test_int,@test_double,@test_string,@test_string2,@select;
-set @test_int="hello",@test_double="hello",@test_string="hello",@test_string2="hello";
-select @test_int,@test_double,@test_string,@test_string2;
-set @test_int="hellohello",@test_double="hellohello",@test_string="hellohello",@test_string2="hellohello";
-select @test_int,@test_double,@test_string,@test_string2;
-set @test_int=null,@test_double=null,@test_string=null,@test_string2=null;
-select @test_int,@test_double,@test_string,@test_string2;
-select @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3;
-
-#
-# Some functions that has failed sometimes
-#
-select concat(encrypt('haha','R1'),encrypt('haha','R2'));
-
-#
-# Functions and groups
-#
-select concat(station_period.föreningsnr,station_period.stationsnr) as concat,station_period.stationsnr+1,left(ok_namn,4),sum(priv_inköp/100),sum(length(concat("1","2"))) from station_period,station where station.stationsnr = station_period.stationsnr and station_period.föreningsnr = 34 group by concat,2,3 order by 2;
-
-#
-# Some new procedures
-#
-select stationsnr from station_drvm where stationsnr>=98001 and stationsnr <= 98002 group by stationsnr procedure split_sum(5,dm_1_kvant10,1,stationsnr,kundnr,kortnr) ;
-select stationsnr from station_drvm where stationsnr>=98001 and stationsnr <= 98002 group by stationsnr procedure split_count(5,dm_1_kvant10,1,stationsnr,kundnr,kortnr) ;
-
-#
-# explain
-#
-explain select period from ok_system;
-explain select period from ok_system where period=1900;
-explain select ok_namn from station where ok_namn like "L%" and ok_namn = "ok";
-explain select distinct ok_namn from station,station_period where station.stationsnr=station_period.stationsnr order by ok_namn;
-explain select 1;
-explain select count(*) from ok_system;
-
-select forening.föreningsnr,max(ok_namn) from station,forening where forening.föreningsnr=station.föreningsnr group by 1 into outfile "/tmp/select-test.out";
-
-#
-# ODBC compatibility
-#
-
-select {fn length("hello")}, { date "1997-10-20" };
-
-#
-# AVG() crashed for Perra when sorting.
-#
-
-use kf96;
-#set option sql_big_tables=1;
-
-select övergrupp as Övergrupp,AVG(100 * omdöme * antal_läst_mersmak / antal_läst_med_mersmak / antal_intervjuade) as my_index from mersmak_tidnings_info,mersmak_artikel_info where mersmak_tidnings_info.år=mersmak_artikel_info.år and mersmak_tidnings_info.nummer=mersmak_artikel_info.nr and mersmak_tidnings_info.namn=mersmak_artikel_info.artikelnamn and mersmak_tidnings_info.typ='ar' and mersmak_tidnings_info.bildnr=1 group by Övergrupp order by my_index desc ;
-
-select concat("O",substring('000',1,3-length(concat(111))),"K");
-
-#
-# Test in the "test" database
-#
-
-use test;
-#set option sql_big_tables=1;
-
-drop table if exists t1,t2,t3,t4,t5;
-
-CREATE TABLE t1 (
- auto int(5) unsigned DEFAULT 0 NOT NULL auto_increment,
- string char(10) default "hello",
- tiny tinyint(4) DEFAULT '0' NOT NULL ,
- short smallint(6) DEFAULT '1' NOT NULL ,
- medium mediumint(8) DEFAULT '0' NOT NULL,
- long_int int(11) DEFAULT '0' NOT NULL,
- longlong bigint(13) DEFAULT '0' NOT NULL,
- real_float float(13,1) DEFAULT 0.0 NOT NULL,
- real_double double(16,4),
- utiny tinyint(3) unsigned DEFAULT '0' NOT NULL,
- ushort smallint(5) unsigned zerofill DEFAULT '00000' NOT NULL,
- umedium mediumint(8) unsigned DEFAULT '0' NOT NULL,
- ulong int(11) unsigned DEFAULT '0' NOT NULL,
- ulonglong bigint(13) unsigned DEFAULT '0' NOT NULL,
- time_stamp timestamp,
- date_field date,
- time_field time,
- date_time datetime,
- blob_col blob,
- tinyblob_col tinyblob,
- mediumblob_col mediumblob not null,
- longblob_col longblob not null,
- options enum('one','two','tree') not null,
- flags set('one','two','tree') not null,
- PRIMARY KEY (auto),
- KEY (utiny),
- KEY (tiny),
- KEY (short),
- KEY any_name (medium),
- KEY (longlong),
- KEY (real_float),
- KEY (ushort),
- KEY (umedium),
- KEY (ulong),
- KEY (ulonglong,ulong),
- KEY (options,flags)
-);
-
-show fields from t1;
-show keys from t1;
-
-CREATE UNIQUE INDEX test on t1 ( auto ) ;
-CREATE INDEX test2 on t1 ( ulonglong,ulong) ;
-CREATE INDEX test3 on t1 ( medium ) ;
-DROP INDEX test ON t1;
-
-insert into t1 values (10, 1,1,1,1,1,1,1,1,1,1,1,1,1,NULL,0,0,0,1,1,1,1,'one','one');
-insert into t1 values (NULL,2,2,2,2,2,2,2,2,2,2,2,2,2,NULL,NULL,NULL,NULL,NULL,NULL,2,2,'two','two,one');
-insert into t1 values (0,1/3,3,3,3,3,3,3,3,3,3,3,3,3,NULL,'19970303','10:10:10','19970303 101010','','','','3',3,3);
-insert into t1 values (0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,NULL,19970807,080706,19970403090807,-1,-1,-1,'-1',-1,-1);
-insert into t1 values (0,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,NULL,0,0,0,-4294967295,-4294967295,-4294967295,'-4294967295',0,"one,two,tree");
-insert into t1 values (0,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,NULL,0,0,0,4294967295,4294967295,4294967295,'4294967295',0,0);
-insert into t1 (tiny) values (1);
-
-select auto,string,tiny,short,medium,long_int,longlong,real_float,real_double,utiny,ushort,umedium,ulong,ulonglong,mod(floor(time_stamp/1000000),1000000)-mod(curdate(),1000000),date_field,time_field,date_time,blob_col,tinyblob_col,mediumblob_col,longblob_col from t1;
-
-
-ALTER TABLE t1
-add new_field char(10) default "new" not null,
-change blob_col new_blob_col varchar(20),
-change date_field date_field char(10),
-alter column string set default "new default",
-alter short drop default,
-DROP INDEX utiny,
-DROP INDEX ushort,
-DROP PRIMARY KEY,
-DROP FOREIGN KEY any_name,
-ADD INDEX (auto);
-
-LOCK TABLES t1 WRITE;
-ALTER TABLE t1
-RENAME as t2,
-DROP longblob_col;
-UNLOCK TABLES;
-
-ALTER TABLE t2 rename as t3;
-LOCK TABLES t3 WRITE ;
-ALTER TABLE t3 rename as t1;
-UNLOCK TABLES;
-
-select auto,new_field,new_blob_col,date_field from t1 ;
-
-#
-# check with old syntax
-#
-CREATE TABLE t2 (
- auto int(5) unsigned NOT NULL DEFAULT 0 auto_increment,
- string char(20),
- mediumblob_col mediumblob not null,
- new_field char(2),
- PRIMARY KEY (auto)
-);
-
-INSERT INTO t2 (string,mediumblob_col,new_field) SELECT string,mediumblob_col,new_field from t1 where auto > 10;
-
-select * from t2;
-
-# test enums
-select distinct flags from t1;
-select flags from t1 where find_in_set("two",flags)>0;
-select flags from t1 where find_in_set("unknown",flags)>0;
-select options,flags from t1 where options="ONE" and flags="ONE";
-select options,flags from t1 where options="one" and flags="one";
-
-drop table t2;
-
-#
-# Check CREATE ... SELECT
-#
-
-create table t2 select * from t1;
-update t2 set string="changed" where auto=16;
-show columns from t1;
-show columns from t2;
-select * from t1,t2 where t1.auto=t2.auto and ((t1.string<>t2.string and (t1.string is not null or t2.string is not null)) or (t1.tiny<>t2.tiny and (t1.tiny is not null or t2.tiny is not null)) or (t1.short<>t2.short and (t1.short is not null or t2.short is not null)) or (t1.medium<>t2.medium and (t1.medium is not null or t2.medium is not null)) or (t1.long_int<>t2.long_int and (t1.long_int is not null or t2.long_int is not null)) or (t1.longlong<>t2.longlong and (t1.longlong is not null or t2.longlong is not null)) or (t1.real_float<>t2.real_float and (t1.real_float is not null or t2.real_float is not null)) or (t1.real_double<>t2.real_double and (t1.real_double is not null or t2.real_double is not null)) or (t1.utiny<>t2.utiny and (t1.utiny is not null or t2.utiny is not null)) or (t1.ushort<>t2.ushort and (t1.ushort is not null or t2.ushort is not null)) or (t1.umedium<>t2.umedium and (t1.umedium is not null or t2.umedium is not null)) or (t1.ulong<>t2.ulong and (t1.ulong is not null or t2.ulong is not null)) or (t1.ulonglong<>t2.ulonglong and (t1.ulonglong is not null or t2.ulonglong is not null)) or (t1.time_stamp<>t2.time_stamp and (t1.time_stamp is not null or t2.time_stamp is not null)) or (t1.date_field<>t2.date_field and (t1.date_field is not null or t2.date_field is not null)) or (t1.time_field<>t2.time_field and (t1.time_field is not null or t2.time_field is not null)) or (t1.date_time<>t2.date_time and (t1.date_time is not null or t2.date_time is not null)) or (t1.new_blob_col<>t2.new_blob_col and (t1.new_blob_col is not null or t2.new_blob_col is not null)) or (t1.tinyblob_col<>t2.tinyblob_col and (t1.tinyblob_col is not null or t2.tinyblob_col is not null)) or (t1.mediumblob_col<>t2.mediumblob_col and (t1.mediumblob_col is not null or t2.mediumblob_col is not null)) or (t1.options<>t2.options and (t1.options is not null or t2.options is not null)) or (t1.flags<>t2.flags and (t1.flags is not null or t2.flags is not null)) or (t1.new_field<>t2.new_field and (t1.new_field is not null or t2.new_field is not null)));
-select * from t1,t2 where t1.auto=t2.auto and not (t1.string<=>t2.string and t1.tiny<=>t2.tiny and t1.short<=>t2.short and t1.medium<=>t2.medium and t1.long_int<=>t2.long_int and t1.longlong<=>t2.longlong and t1.real_float<=>t2.real_float and t1.real_double<=>t2.real_double and t1.utiny<=>t2.utiny and t1.ushort<=>t2.ushort and t1.umedium<=>t2.umedium and t1.ulong<=>t2.ulong and t1.ulonglong<=>t2.ulonglong and t1.time_stamp<=>t2.time_stamp and t1.date_field<=>t2.date_field and t1.time_field<=>t2.time_field and t1.date_time<=>t2.date_time and t1.new_blob_col<=>t2.new_blob_col and t1.tinyblob_col<=>t2.tinyblob_col and t1.mediumblob_col<=>t2.mediumblob_col and t1.options<=>t2.options and t1.flags<=>t2.flags and t1.new_field<=>t2.new_field);
-
-drop table t2;
-
-create table t2 (primary key (auto)) select auto+1 as auto,1 as t1, "a" as t2, repeat("a",256) as t3, binary repeat("b",256) as t4 from t1;
-show columns from t2;
-select * from t2;
-drop table t1,t2;
-
-create table t1 (c int);
-insert into t1 values(1),(2);
-create table t2 select * from t1;
-create table t3 select * from t1, t2; # Should give an error
-create table t3 select t1.c AS c1, t2.c AS c2,1 as "const" from t1, t2;
-show columns from t3;
-drop table t1,t2,t3;
-
-create table t1 ( myfield INT NOT NULL, UNIQUE INDEX (myfield), unique (myfield), index(myfield));
-drop table t1;
-
-create table t1 ( id integer unsigned not null primary key );
-create table t2 ( id integer unsigned not null primary key );
-insert into t1 values (1), (2);
-insert into t2 values (1);
-select t1.id as id_A, t2.id as id_B from t1 left join t2 using ( id );
-create table t3 (id_A integer unsigned not null, id_B integer unsigned null );
-insert into t3 select t1.id as id_A, t2.id as id_B from t1 left join t2 using ( id );
-select * from t3;
-drop table t3;
-create table t3 select t1.id as id_A, t2.id as id_B from t1 left join t2 using ( id );
-select * from t3;
-drop table t1,t2,t3;
-
-#
-# Check floating point handling
-
-create table t1 (f1 float(24),f2 float(52));
-show columns from t1;
-insert into t1 values(10,10),(1e+5,1e+5),(1234567890,1234567890),(1e+10,1e+10),(1e+15,1e+15),(1e+20,1e+20),(1e+50,1e+50),(1e+150,1e+150);
-insert into t1 values(-10,-10),(1e-5,1e-5),(1e-10,1e-10),(1e-15,1e-15),(1e-20,1e-20),(1e-50,1e-50),(1e-150,1e-150);
-select * from t1;
-drop table t1;
-
-#
-# FLOAT/DOUBLE/DECIMAL handling
-#
-
-create table t1 (f float, f2 float(24), f3 float(6,2), d double, d2 float(53), d3 double(10,3), de decimal, de2 decimal(6), de3 decimal(5,2), n numeric, n2 numeric(8), n3 numeric(5,6));
-show columns from t1;
-drop table t1;
-create table t1 (f float(54)); # Should give an error
-drop table if exists t1;
-
-create table t1 (a decimal(7,3) not null, key (a));
-insert into t1 values ("0"),("-0.00"),("-0.01"),("-0.002"),("1");
-select a from t1 order by a;
-select min(a) from t1;
-drop table t1;
-
-#
-# BIGINT handling
-#
-
-create table t1 (a bigint unsigned);
-insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFF);
-select * from t1;
-drop table t1;
-
-#
-# Check on condition on different length keys.
-
-CREATE TABLE t1 (
- a char(5) NOT NULL,
- b char(4) NOT NULL,
- KEY (a),
- KEY (b)
-);
-
-INSERT INTO t1 VALUES ('A','B'),('b','A'),('C','c'),('D','E'),('a','a');
-
-select * from t1,t1 as t2;
-explain select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B;
-select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B;
-select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B order by t1.a;
-select * from t1 where a='a';
-drop table t1;
-
-#
-# Check null keys
-
-create table t1 (a int, b int not null,unique key (a,b),index(b)) type=myisam;
-insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6);
-explain select * from t1 where a is null;
-explain select * from t1 where a is null and b = 2;
-explain select * from t1 where a is null and b = 7;
-explain select * from t1 where a=2 and b = 2;
-explain select * from t1 where a<=>b limit 2;
-explain select * from t1 where (a is null or a > 0 and a < 3) and b < 5 limit 3;
-explain select * from t1 where (a is null or a = 7) and b=7;
-explain select * from t1 where (a is null and b>a) or a is null and b=7 limit 2;
-explain select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
-explain select * from t1 where a > 1 and a < 3 limit 1;
-explain select * from t1 where a > 8 and a < 9;
-select * from t1 where a is null;
-select * from t1 where a is null and b = 7;
-select * from t1 where a<=>b limit 2;
-select * from t1 where (a is null or a > 0 and a < 3) and b < 5 limit 3;
-select * from t1 where (a is null or a > 0 and a < 3) and b > 7 limit 3;
-select * from t1 where (a is null or a = 7) and b=7;
-select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
-alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10));
-explain select * from t1 where a is null and b = 2;
-explain select * from t1 where a is null and b = 2 and c=0;
-explain select * from t1 where a is null and b = 7 and c=0;
-explain select * from t1 where a=2 and b = 2;
-explain select * from t1 where a<=>b limit 2;
-explain select * from t1 where (a is null or a > 0 and a < 3) and b < 5 and c=0 limit 3;
-explain select * from t1 where (a is null or a = 7) and b=7 and c=0;
-explain select * from t1 where (a is null and b>a) or a is null and b=7 limit 2;
-explain select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
-explain select * from t1 where a > 1 and a < 3 limit 1;
-explain select * from t1 where a is null and b=7 or a > 1 and a < 3 limit 1;
-explain select * from t1 where a > 8 and a < 9;
-explain select * from t1 where b like "6%";
-select * from t1 where a is null;
-select * from t1 where a is null and b = 7 and c=0;
-select * from t1 where a<=>b limit 2;
-select * from t1 where (a is null or a > 0 and a < 3) and b < 5 limit 3;
-select * from t1 where (a is null or a > 0 and a < 3) and b > 7 limit 3;
-select * from t1 where (a is null or a = 7) and b=7 and c=0;
-select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
-select * from t1 where b like "6%";
-drop table t1;
-
-#
-# Check some special create statements.
-#
-
-create table t1 (b char(0));
-insert into t1 values (""),(null);
-select * from t1;
-drop table if exists t1;
-
-create table t1 (b char(0) not null);
-create table if not exists t1 (b char(0) not null);
-insert into t1 values (""),(null);
-select * from t1;
-drop table if exists t1;
-
-#
-# the following should give errors
-#
-
-create table t2 type=heap select * from t1;
-create table t2 select auto+1 from t1;
-drop table if exists t1,t2;
-create table t1 (b char(0) not null, index(b));
-create table t1 (a int not null auto_increment,primary key (a)) type=heap;
-create table t1 (a int not null,b text) type=heap;
-create table t1 (a int ,primary key(a)) type=heap;
-create table t1 (a int,b text, index(a)) type=isam;
-create table t1 (a int,b text, index(b)) type=isam;
-drop table if exists t1;
-
-#
-# Test of some show commands
-#
-create table t1 (a int not null primary key, b int not null,c int not null, key(b,c));
-insert into t1 values (1,2,2),(2,2,3),(3,2,4),(4,2,4);
-create table t2 type=isam select * from t1;
-optimize table t1;
-check table t1,t2;
-repair table t1,t2;
-check table t2,t1;
-lock tables t1 read;
-check table t2,t1;
-show keys from t1;
-drop table t1,t2;
-
-create table t1 (a int not null primary key, b int not null,c int not null, key(b,c));
-insert into t1 values (1,2,2),(2,2,3),(3,2,4),(4,2,4);
-check table t1 type=fast;
-check table t1 type=fast;
-check table t1 type=changed;
-insert into t1 values (5,5,5);
-check table t1 type=changed;
-check table t1 type=extended;
-show keys from t1;
-insert into t1 values (5,5,5);
-optimize table t1;
-optimize table t1;
-drop table t1;
-
-#
-# simple test of all group functions
-#
-
-create table t1 (grp int, a bigint unsigned, c char(10) not null);
-insert into t1 values (1,1,"a");
-insert into t1 values (2,2,"b");
-insert into t1 values (2,3,"c");
-insert into t1 values (3,4,"E");
-insert into t1 values (3,5,"C");
-insert into t1 values (3,6,"D");
-
-# Test of MySQL field extension with and without matching records.
-select a,c,sum(a) from t1 group by a;
-select a,c,sum(a) from t1 where a > 10 group by a;
-select sum(a) from t1 where a > 10;
-select a from t1 order by rand(10);
-select distinct a from t1 order by rand(10);
-select count(distinct a),count(distinct grp) from t1;
-insert into t1 values (null,null,'');
-select count(distinct a),count(distinct grp) from t1;
-
-select sum(a),count(a),avg(a),std(a),bit_or(a),bit_and(a),min(a),max(a),min(c),max(c) from t1;
-select grp, sum(a),count(a),avg(a),std(a),bit_or(a),bit_and(a),min(a),max(a),min(c),max(c) from t1 group by grp;
-select grp, sum(a)+count(a)+avg(a)+std(a)+bit_or(a)+bit_and(a)+min(a)+max(a)+min(c)+max(c) as sum from t1 group by grp;
-
-create table t2 (grp int, a bigint unsigned, c char(10));
-insert into t2 select grp,max(a)+max(grp),max(c) from t1 group by grp;
-replace into t2 select grp, a, c from t1 limit 2,1;
-select * from t2;
-
-drop table t2;
-
-#
-# test of left outer join
-#
-
-create table t2 (id int, a bigint unsigned not null, c char(10), d int, primary key (a));
-insert into t2 values (1,1,"a",1);
-insert into t2 values (3,4,"A",4);
-insert into t2 values (3,5,"B",5);
-insert into t2 values (3,6,"C",6);
-insert into t2 values (4,7,"D",7);
-
-select t1.*,t2.* from t1 JOIN t2 where t1.a=t2.a;
-select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) order by t1.grp,t1.a,t2.c;
-select t1.*,t2.* from { oj t2 left outer join t1 on (t1.a=t2.a) };
-select t1.*,t2.* from t1 as t0,{ oj t2 left outer join t1 on (t1.a=t2.a) } WHERE t0.a=2;
-select t1.*,t2.* from t1 left join t2 using (a);
-select t1.*,t2.* from t1 left join t2 using (a,c);
-select t1.*,t2.* from t1 left join t2 using (c);
-select t1.*,t2.* from t1 natural left outer join t2;
-
-select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) where t2.id=3;
-select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) where t2.id is null;
-
-explain select t1.*,t2.* from t1,t2 where t1.a=t2.a and isnull(t2.a)=1;
-explain select t1.*,t2.* from t1 left join t2 on t1.a=t2.a where isnull(t2.a)=1;
-
-select t1.*,t2.*,t3.a from t1 left join t2 on (t1.a=t2.a) left join t1 as t3 on (t2.a=t3.a);
-
-# The next query should rearange the left joins to get this to work
-explain select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a);
-select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a);
-
-# The next query should give an error in MySQL
-select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t2.a=t3.a);
-
-# Test of inner join
-select t1.*,t2.* from t1 inner join t2 using (a);
-select t1.*,t2.* from t1 inner join t2 on (t1.a=t2.a);
-select t1.*,t2.* from t1 natural join t2;
-
-drop table t1,t2;
-
-#
-# Problem with std()
-#
-CREATE TABLE t1 (id int(11),value1 float(10,2));
-INSERT INTO t1 VALUES (1,0.00),(1,1.00), (1,2.00), (2,10.00), (2,11.00), (2,12.00);
-CREATE TABLE t2 (id int(11),name char(20));
-INSERT INTO t2 VALUES (1,'Set One'),(2,'Set Two');
-select id, avg(value1), std(value1) from t1 group by id;
-select name, avg(value1), std(value1) from t1, t2 where t1.id = t2.id group by t1.id;
-drop table t1,t2;
-
-#
-# Test of bug in left join & avg
-
-create table t1 (id int not null);
-create table t2 (id int not null,rating int null);
-insert into t1 values(1),(2),(3);
-insert into t2 values(1, 3),(2, NULL),(2, NULL),(3, 2),(3, NULL);
-select t1.id, avg(rating) from t1 left join t2 on ( t1.id = t2.id ) group by t1.id;
-drop table t1,t2;
-
-# test of count
-
-create table t1 (a smallint(6) primary key, c char(10), b text);
-INSERT INTO t1 VALUES (1,'1','1');
-INSERT INTO t1 VALUES (2,'2','2');
-INSERT INTO t1 VALUES (4,'4','4');
-
-select count(*) from t1;
-select count(*) from t1 where a = 1;
-select count(*) from t1 where a = 100;
-select count(*) from t1 where a >= 10;
-select count(a) from t1 where a = 1;
-select count(a) from t1 where a = 100;
-select count(a) from t1 where a >= 10;
-select count(b) from t1 where b >= 2;
-select count(b) from t1 where b >= 10;
-select count(c) from t1 where c = 10;
-drop table t1;
-
-#
-# Test of left join bug
-#
-
-CREATE TABLE t1 (
- usr_id INT unsigned NOT NULL,
- uniq_id INT unsigned NOT NULL AUTO_INCREMENT,
- start_num INT unsigned NOT NULL DEFAULT 1,
- increment INT unsigned NOT NULL DEFAULT 1,
- PRIMARY KEY (uniq_id),
- INDEX usr_uniq_idx (usr_id, uniq_id),
- INDEX uniq_usr_idx (uniq_id, usr_id)
-);
-CREATE TABLE t2 (
- id INT unsigned NOT NULL DEFAULT 0,
- usr2_id INT unsigned NOT NULL DEFAULT 0,
- max INT unsigned NOT NULL DEFAULT 0,
- c_amount INT unsigned NOT NULL DEFAULT 0,
- d_max INT unsigned NOT NULL DEFAULT 0,
- d_num INT unsigned NOT NULL DEFAULT 0,
- orig_time INT unsigned NOT NULL DEFAULT 0,
- c_time INT unsigned NOT NULL DEFAULT 0,
- active ENUM ("no","yes") NOT NULL,
- PRIMARY KEY (id,usr2_id),
- INDEX id_idx (id),
- INDEX usr2_idx (usr2_id)
-);
-INSERT INTO t1 VALUES (3,NULL,0,50),(3,NULL,0,200),(3,NULL,0,25),(3,NULL,0,84676),(3,NULL,0,235),(3,NULL,0,10),(3,NULL,0,3098),(3,NULL,0,2947),(3,NULL,0,8987),(3,NULL,0,8347654),(3,NULL,0,20398),(3,NULL,0,8976),(3,NULL,0,500),(3,NULL,0,198);
-
-#1st select shows that one record is returned with null entries for the right
-#table, when selecting on an id that does not exist in the right table t2
-SELECT t1.usr_id,t1.uniq_id,t1.increment,
-t2.usr2_id,t2.c_amount,t2.max
-FROM t1
-LEFT JOIN t2 ON t2.id = t1.uniq_id
-WHERE t1.uniq_id = 4
-ORDER BY t2.c_amount;
-
-# The same with RIGHT JOIN
-SELECT t1.usr_id,t1.uniq_id,t1.increment,
-t2.usr2_id,t2.c_amount,t2.max
-FROM t2
-RIGHT JOIN t1 ON t2.id = t1.uniq_id
-WHERE t1.uniq_id = 4
-ORDER BY t2.c_amount;
-
-INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes');
-INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes');
-INSERT INTO t2 VALUES (7,3,1000,2000,0,0,746294,937484,'yes');
-
-#3rd select should show that one record is returned with null entries for the
-# right table, when selecting on an id that does not exist in the right table
-# t2 but this select returns an empty set!!!!
-SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4 ORDER BY t2.c_amount;
-SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4 GROUP BY t2.c_amount;
-# Removing the ORDER BY works:
-SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4;
-
-drop table t1,t2;
-
-#
-# Test syntax of not supported functions
-#
-
-create table t1 (
- a int not null references t2,
- b int not null references t2 (c),
- primary key (a,b),
- foreign key (a) references t3 match full,
- foreign key (a) references t3 match partial,
- foreign key (a,b) references t3 (c,d) on delete no action
- on update no action,
- foreign key (a,b) references t3 (c,d) on update cascade,
- foreign key (a,b) references t3 (c,d) on delete set default,
- foreign key (a,b) references t3 (c,d) on update set null);
-
-create index a on t1 (a);
-create unique index b on t1 (a,b);
-
-grant all privileges on t1 to monty,david with grant option;
-show grants for monty;
-show grants for david;
-revoke all privileges on t1 from david;
-show grants for david;
-drop table t1;
-
-#
-# test sort,min and max on binary fields
-#
-
-create table t1 (name char(20) not null, primary key (name));
-create table t2 (name char(20) binary not null, primary key (name));
-insert into t1 values ("å");
-insert into t1 values ("ä");
-insert into t1 values ("ö");
-insert into t2 select * from t1;
-
-select * from t1 order by name;
-select concat("*",name,"*") from t1 order by 1;
-select min(name),min(concat("*",name,"*")),max(name),max(concat("*",name,"*")) from t1;
-select * from t2 order by name;
-select concat("*",name,"*") from t2 order by 1;
-select min(name),min(concat("*",name,"*")),max(name),max(concat("*",name,"*")) from t2;
-select name from t1 where name between 'Ä' and 'Ö';
-select name from t2 where name between 'ä' and 'ö';
-select name from t2 where name between 'Ä' and 'Ö';
-
-drop table t1,t2;
-
-#
-# test of full join with blob
-#
-
-create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary key (nr));
-insert into t1 values (null,"a","A");
-insert into t1 values (null,"bbb","BBB");
-insert into t1 values (null,"ccc","CCC");
-select last_insert_id();
-select * from t1,t1 as t2;
-
-drop table t1;
-
-#
-# Test of changing TEXT column
-#
-create table t1 (a text);
-insert into t1 values ('where');
-update t1 set a='Where';
-select * from t1;
-drop table t1;
-
-#
-# Some special cases with empty tables
-#
-
-create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary key (nr));
-select count(*) from t1;
-select * from t1;
-select * from t1 limit 0;
-drop table t1;
-
-#
-# Test keywords as fields
-#
-create table t1 (time time, date date, timestamp timestamp);
-insert into t1 values ("12:22:22","97:02:03","1997-01-02");
-select * from t1;
-select t1.time+0,t1.date+0,t1.timestamp+0,concat(date," ",time) from t1;
-drop table t1;
-
-#
-# test of blob, text, char and char binary
-#
-create table t1 (t text,c char(10),b blob, d char(10) binary);
-insert into t1 values (NULL,NULL,NULL,NULL);
-insert into t1 values ("","","","");
-insert into t1 values ("hello","hello","hello","hello");
-insert into t1 values ("HELLO","HELLO","HELLO","HELLO");
-insert into t1 values ("HELLO MY","HELLO MY","HELLO MY","HELLO MY");
-insert into t1 values ("a","a","a","a");
-insert into t1 values (1,1,1,1);
-insert into t1 values (NULL,NULL,NULL,NULL);
-update t1 set c="",b=null where c="1";
-
-lock tables t1 READ;
-show fields from t1;
-lock tables t1 WRITE;
-show fields from t1;
-unlock tables;
-
-select t from t1 where t like "hello";
-select c from t1 where c like "hello";
-select b from t1 where b like "hello";
-select d from t1 where d like "hello";
-select c from t1 having c like "hello";
-select d from t1 having d like "hello";
-select t from t1 where t like "%HELLO%";
-select c from t1 where c like "%HELLO%";
-select b from t1 where b like "%HELLO%";
-select d from t1 where d like "%HELLO%";
-select c from t1 having c like "%HELLO%";
-select d from t1 having d like "%HELLO%";
-select t from t1 order by t;
-select c from t1 order by c;
-select b from t1 order by b;
-select d from t1 order by d;
-select distinct t from t1;
-select distinct b from t1;
-select distinct t from t1 order by t;
-select distinct b from t1 order by b;
-select t from t1 group by t;
-select b from t1 group by b;
-set option sql_big_tables=1;
-select distinct t from t1;
-select distinct b from t1;
-select distinct t from t1 order by t;
-select distinct b from t1 order by b;
-select distinct c from t1;
-select distinct d from t1;
-select distinct c from t1 order by c;
-select distinct d from t1 order by d;
-select c from t1 group by c;
-select d from t1 group by d;
-set option sql_big_tables=0;
-select distinct * from t1;
-select t,count(*) from t1 group by t;
-select b,count(*) from t1 group by b;
-select c,count(*) from t1 group by c;
-select d,count(*) from t1 group by d;
-drop table t1;
-
-#
-# testing different DATETIME ranges
-#
-create table t1 (t datetime);
-insert into t1 values(101),(691231),(700101),(991231),(10000101),(99991231),(101000000),(691231000000),(700101000000),(991231235959),(10000101000000),(99991231235959);
-select * from t1;
-delete from t1 where t > 0;
-optimize table t1;
-insert into t1 values("000101"),("691231"),("700101"),("991231"),("00000101"),("00010101"),("99991231"),("00101000000"),("691231000000"),("700101000000"),("991231235959"),("10000101000000"),("99991231235959");
-select * from t1;
-drop table t1;
-
-#
-# testing different TIME formats
-#
-create table t1 (t time);
-insert into t1 values("10:22:33"),("12:34:56.78"),(10),(1234),(123456.78),(1234559.99),("1"),("1:23"),("1:23:45"), ("10.22"), ("-10 1:22:33.45"),("20 10:22:33"),("1999-02-03 20:33:34");
-# Test wrong values
-insert into t1 values("10.22.22"),(1234567),(123456789),(123456789.10),("10 22:22"),("12.45a");
-select * from t1;
-drop table t1;
-
-create table t1 (date date);
-insert into t1 values ("2000-08-10"),("2000-08-11");
-select date_add(date,INTERVAL 1 DAY),date_add(date,INTERVAL 1 SECOND) from t1;
-drop table t1;
-
-create table t1 (t time);
-insert into t1 values ('09:00:00'),('13:00:00'),('19:38:34'), ('13:00:00'),('09:00:00'),('09:00:00'),('13:00:00'),('13:00:00'),('13:00:00'),('09:00:00');
-;
-select t, time_to_sec(t),sec_to_time(time_to_sec(t)) from t1;
-select sec_to_time(time_to_sec(t)) from t1;
-drop table t1;
-
-#
-# test of into outfile|dumpfile
-#
-
-create table t1 (`a` blob);
-insert into t1 values("hello world"),("Hello mars"),(NULL);
-select * into outfile "/tmp/select-test.1" from t1;
-select load_file("/tmp/select-test.1");
-select * into dumpfile "/tmp/select-test.2" from t1 limit 1;
-select load_file("/tmp/select-test.2");
-select * into dumpfile "/tmp/select-test.3" from t1 where a is null;
-select load_file("/tmp/select-test.3");
-
-# the following should give errors
-
-select * into outfile "/tmp/select-test.1" from t1;
-select * into dumpfile "/tmp/select-test.1" from t1;
-select * into dumpfile "/tmp/select-test.99" from t1;
-select load_file("/tmp/select-test.not-exist");
-drop table t1;
-
-#
-# This failed for lia Perminov
-#
-
-create table t1 (id int primary key);
-create table t2 (id int);
-insert into t1 values (75);
-insert into t1 values (79);
-insert into t1 values (78);
-insert into t1 values (77);
-replace into t1 values (76);
-replace into t1 values (76);
-insert into t1 values (104);
-insert into t1 values (103);
-insert into t1 values (102);
-insert into t1 values (101);
-insert into t1 values (105);
-insert into t1 values (106);
-insert into t1 values (107);
-
-insert into t2 values (107);
-insert into t2 values (75);
-
-select t1.id, t2.id from t1, t2 where t2.id = t1.id;
-select t1.id, count(t2.id) from t1,t2 where t2.id = t1.id group by t1.id;
-select t1.id, count(t2.id) from t1,t2 where t2.id = t1.id group by t2.id;
-
-drop table t1,t2;
-
-#
-# Bug with distinct and INSERT INTO
-# Bug with group by and not used fields
-#
-
-CREATE TABLE t1 (id int,facility char(20));
-CREATE TABLE t2 (facility char(20));
-INSERT INTO t1 VALUES (NULL,NULL);
-INSERT INTO t1 VALUES (-1,'');
-INSERT INTO t1 VALUES (0,'');
-INSERT INTO t1 VALUES (1,'/L');
-INSERT INTO t1 VALUES (2,'A01');
-INSERT INTO t1 VALUES (3,'ANC');
-INSERT INTO t1 VALUES (4,'F01');
-INSERT INTO t1 VALUES (5,'FBX');
-INSERT INTO t1 VALUES (6,'MT');
-INSERT INTO t1 VALUES (7,'P');
-INSERT INTO t1 VALUES (8,'RV');
-INSERT INTO t1 VALUES (9,'SRV');
-INSERT INTO t1 VALUES (10,'VMT');
-INSERT INTO t2 SELECT DISTINCT FACILITY FROM t1;
-
-select id from t1 group by id;
-select * from t1 order by id;
-select id-5,facility from t1 order by "id-5";
-select max(id),concat(facility) from t1 group by id ;
-select id+0 as a,max(id),concat(facility) as b from t1 group by a order by b desc;
-select id >= 0 and id <= 5 as grp,count(*) from t1 group by grp;
-
-SELECT DISTINCT FACILITY FROM t1;
-SELECT FACILITY FROM t2;
-SELECT count(*) from t1,t2 where t1.facility=t2.facility;
-select count(facility) from t1;
-select count(*) from t1;
-select count(*) from t1 where facility IS NULL;
-select count(*) from t1 where facility = NULL;
-select count(*) from t1 where facility IS NOT NULL;
-select count(*) from t1 where id IS NULL;
-select count(*) from t1 where id IS NOT NULL;
-
-drop table t1,t2;
-
-#
-# Bug with order by
-#
-
-CREATE TABLE t1 (
- id int(6) DEFAULT '0' NOT NULL,
- idservice int(5),
- clee char(20) NOT NULL,
- flag char(1),
- KEY id (id),
- PRIMARY KEY (clee)
-);
-
-
-INSERT INTO t1 VALUES (2,4,'6067169d','Y');
-INSERT INTO t1 VALUES (2,5,'606716d1','Y');
-INSERT INTO t1 VALUES (2,1,'606717c1','Y');
-INSERT INTO t1 VALUES (3,1,'6067178d','Y');
-INSERT INTO t1 VALUES (2,6,'60671515','Y');
-INSERT INTO t1 VALUES (2,7,'60671569','Y');
-INSERT INTO t1 VALUES (2,3,'dd','Y');
-
-CREATE TABLE t2 (
- id int(6) DEFAULT '0' NOT NULL auto_increment,
- description varchar(40) NOT NULL,
- idform varchar(40),
- ordre int(6) unsigned DEFAULT '0' NOT NULL,
- image varchar(60),
- PRIMARY KEY (id),
- KEY id (id,ordre)
-);
-
-#
-# Dumping data for table 't2'
-#
-
-INSERT INTO t2 VALUES (1,'Emettre un appel d''offres','en_construction.html',10,'emettre.gif');
-INSERT INTO t2 VALUES (2,'Emettre des soumissions','en_construction.html',20,'emettre.gif');
-INSERT INTO t2 VALUES (7,'Liste des t2','t2_liste_form.phtml',51060,'link.gif');
-INSERT INTO t2 VALUES (8,'Consulter les soumissions','consulter_soumissions.phtml',200,'link.gif');
-INSERT INTO t2 VALUES (9,'Ajouter un type de materiel','typeMateriel_ajoute_form.phtml',51000,'link.gif');
-INSERT INTO t2 VALUES (10,'Lister/modifier un type de materiel','typeMateriel_liste_form.phtml',51010,'link.gif');
-INSERT INTO t2 VALUES (3,'Créer une fiche de client','clients_ajoute_form.phtml',40000,'link.gif');
-INSERT INTO t2 VALUES (4,'Modifier des clients','en_construction.html',40010,'link.gif');
-INSERT INTO t2 VALUES (5,'Effacer des clients','en_construction.html',40020,'link.gif');
-INSERT INTO t2 VALUES (6,'Ajouter un service','t2_ajoute_form.phtml',51050,'link.gif');
-
-
-select t1.id,t1.idservice,t2.ordre,t2.description from t1, t2 where t1.id = 2 and t1.idservice = t2.id order by t2.ordre;
-
-drop table t1,t2;
-
-create table t1 (first char(10),last char(10));
-insert into t1 values ("Michael","Widenius");
-insert into t1 values ("Allan","Larsson");
-insert into t1 values ("David","Axmark");
-select concat(first," ",last) as name from t1 order by name;
-select concat(last," ",first) as name from t1 order by name;
-drop table t1;
-
-#
-# bug in distinct + order by
-#
-
-create table t1 (i int);
-insert into t1 values(1),(2),(1),(2),(1),(2),(3);
-select distinct i from t1;
-select distinct i from t1 order by rand(5);
-select distinct i from t1 order by i desc;
-select distinct i from t1 order by 1-i;
-select distinct i from t1 order by mod(i,2);
-drop table t1;
-
-#
-# test of dummy table names
-#
-
-create table 1ea10 (1a20 int,1e int);
-insert into 1ea10 values(1,1);
-select 1ea10.1a20,1e+ 1e+10 from 1ea10;
-drop table 1ea10;
-create table t1 (t1.index int);
-drop table t1;
-drop database if exists test$1;
-create database test$1;
-create table test$1.$test1 (a$1 int, $b int, c$ int);
-insert into test$1.$test1 values (1,2,3);
-select a$1, $b, c$ from test$1.$test1;
-create table test$1.test2$ (a int);
-drop table test$1.test2$;
-drop database test$1;
-
-#
-# This failed for Elizabeth Mattijsen
-#
-
-CREATE TABLE t1 (
- ID CHAR(32) NOT NULL,
- name CHAR(32) NOT NULL,
- value CHAR(255),
- INDEX indexIDname (ID(8),name(8))
-) ;
-
-INSERT INTO t1 VALUES
-('keyword','indexdir','/export/home/local/www/database/indexes/keyword');
-INSERT INTO t1 VALUES ('keyword','urlprefix','text/ /text');
-INSERT INTO t1 VALUES ('keyword','urlmap','/text/ /');
-INSERT INTO t1 VALUES ('keyword','attr','personal employee company');
-INSERT INTO t1 VALUES
-('emailgids','indexdir','/export/home/local/www/database/indexes/emailgids');
-INSERT INTO t1 VALUES ('emailgids','urlprefix','text/ /text');
-INSERT INTO t1 VALUES ('emailgids','urlmap','/text/ /');
-INSERT INTO t1 VALUES ('emailgids','attr','personal employee company');
-
-SELECT value FROM t1 WHERE ID='emailgids' AND name='attr';
-
-drop table t1;
-
-#
-# problem with date conversions
-#
-
-CREATE TABLE t1 (name char(6),cdate date);
-INSERT INTO t1 VALUES ('name1','1998-01-01');
-INSERT INTO t1 VALUES ('name2','1998-01-01');
-INSERT INTO t1 VALUES ('name1','1998-01-02');
-INSERT INTO t1 VALUES ('name2','1998-01-02');
-CREATE TABLE t2 (cdate date, note char(6));
-INSERT INTO t2 VALUES ('1998-01-01','note01');
-INSERT INTO t2 VALUES ('1998-01-02','note02');
-select name,t1.cdate,note from t1,t2 where t1.cdate=t2.cdate and t1.cdate='1998-01-01';
-drop table t1,t2;
-
-#
-# Date and BETWEEN
-#
-
-CREATE TABLE t1 ( datum DATE );
-INSERT INTO t1 VALUES ( "2000-1-1" );
-INSERT INTO t1 VALUES ( "2000-1-2" );
-INSERT INTO t1 VALUES ( "2000-1-3" );
-INSERT INTO t1 VALUES ( "2000-1-4" );
-INSERT INTO t1 VALUES ( "2000-1-5" );
-SELECT * FROM t1 WHERE datum BETWEEN "2000-1-2" AND "2000-1-4";
-DROP TABLE t1;
-
-#
-# test of primary key conversions
-#
-
-create table t1 (t1 char(3) primary key);
-insert into t1 values("ABC");
-insert into t1 values("ABA");
-insert into t1 values("AB%");
-select * from t1 where t1="ABC";
-select * from t1 where t1="ABCD";
-select * from t1 where t1 like "a_\%";
-describe select * from t1 where t1="ABC";
-describe select * from t1 where t1="ABCD";
-drop table t1;
-
-#
-# Test of like
-#
-
-create table t1 (a varchar(10), key(a));
-insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
-select * from t1 where a like "abc%";
-select * from t1 where a like "test%";
-select * from t1 where a like "te_t";
-drop table t1;
-
-#
-# test of max(date) and having
-#
-
-CREATE TABLE t1 (
- user_id char(10),
- summa int(11),
- rdate date
-);
-INSERT INTO t1 VALUES ('aaa',100,'1998-01-01');
-INSERT INTO t1 VALUES ('aaa',200,'1998-01-03');
-INSERT INTO t1 VALUES ('bbb',50,'1998-01-02');
-INSERT INTO t1 VALUES ('bbb',200,'1998-01-04');
-select max(rdate) as s from t1 where rdate < '1998-01-03' having s> "1998-01-01";
-select max(rdate) as s from t1 having s="1998-01-04";
-select max(rdate+0) as s from t1 having s="19980104";
-drop table t1;
-
-#
-# Test of group (Failed for Lars Hoss <lh@pbm.de>)
-#
-
-CREATE TABLE t1 (
- spID int(10) unsigned,
- userID int(10) unsigned,
- score smallint(5) unsigned,
- lsg char(40),
- date date
-);
-
-INSERT INTO t1 VALUES (1,1,1,'','0000-00-00');
-INSERT INTO t1 VALUES (2,2,2,'','0000-00-00');
-INSERT INTO t1 VALUES (2,1,1,'','0000-00-00');
-INSERT INTO t1 VALUES (3,3,3,'','0000-00-00');
-
-CREATE TABLE t2 (
- userID int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
- niName char(15),
- passwd char(8),
- mail char(50),
- isAukt enum('N','Y') DEFAULT 'N',
- vName char(30),
- nName char(40),
- adr char(60),
- plz char(5),
- ort char(35),
- land char(20),
- PRIMARY KEY (userID)
-);
-
-INSERT INTO t2 VALUES (1,'name','pass','mail','Y','v','n','adr','1','1','1');
-INSERT INTO t2 VALUES (2,'name','pass','mail','Y','v','n','adr','1','1','1');
-INSERT INTO t2 VALUES (3,'name','pass','mail','Y','v','n','adr','1','1','1');
-
-SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID GROUP BY t2.userid;
-SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid;
-SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid;
-
-drop table test.t1,test.t2;
-
-#
-# Test of LEFT JOIN with const tables (failed for frankie@etsetb.upc.es)
-#
-
-CREATE TABLE t1 (
- cod_asig int(11) DEFAULT '0' NOT NULL,
- desc_larga_cat varchar(80) DEFAULT '' NOT NULL,
- desc_larga_cas varchar(80) DEFAULT '' NOT NULL,
- desc_corta_cat varchar(40) DEFAULT '' NOT NULL,
- desc_corta_cas varchar(40) DEFAULT '' NOT NULL,
- cred_total double(3,1) DEFAULT '0.0' NOT NULL,
- pre_requisit int(11),
- co_requisit int(11),
- preco_requisit int(11),
- PRIMARY KEY (cod_asig)
-);
-
-INSERT INTO t1 VALUES (10360,'asdfggfg','Introduccion a los Ordenadores I','asdfggfg','Introduccio Ordinadors I',6.0,NULL,NULL,NULL);
-INSERT INTO t1 VALUES (10361,'Components i Circuits Electronics I','Componentes y Circuitos Electronicos I','Components i Circuits Electronics I','Comp. i Circ. Electr. I',6.0,NULL,NULL,NULL);
-INSERT INTO t1 VALUES (10362,'Laboratori d`Ordinadors','Laboratorio de Ordenadores','Laboratori d`Ordinadors','Laboratori Ordinadors',4.5,NULL,NULL,NULL);
-INSERT INTO t1 VALUES (10363,'Tecniques de Comunicacio Oral i Escrita','Tecnicas de Comunicacion Oral y Escrita','Tecniques de Comunicacio Oral i Escrita','Tec. Com. Oral i Escrita',4.5,NULL,NULL,NULL);
-INSERT INTO t1 VALUES (11403,'Projecte Fi de Carrera','Proyecto Fin de Carrera','Projecte Fi de Carrera','PFC',9.0,NULL,NULL,NULL);
-INSERT INTO t1 VALUES (11404,'+lgebra lineal','Algebra lineal','+lgebra lineal','+lgebra lineal',15.0,NULL,NULL,NULL);
-INSERT INTO t1 VALUES (11405,'+lgebra lineal','Algebra lineal','+lgebra lineal','+lgebra lineal',18.0,NULL,NULL,NULL);
-INSERT INTO t1 VALUES (11406,'Calcul Infinitesimal','Cßlculo Infinitesimal','Calcul Infinitesimal','Calcul Infinitesimal',15.0,NULL,NULL,NULL);
-
-CREATE TABLE t2 (
- idAssignatura int(11) DEFAULT '0' NOT NULL,
- Grup int(11) DEFAULT '0' NOT NULL,
- Places smallint(6) DEFAULT '0' NOT NULL,
- PlacesOcupades int(11) DEFAULT '0',
- PRIMARY KEY (idAssignatura,Grup)
-);
-
-
-INSERT INTO t2 VALUES (10360,12,333,0);
-INSERT INTO t2 VALUES (10361,30,2,0);
-INSERT INTO t2 VALUES (10361,40,3,0);
-INSERT INTO t2 VALUES (10360,45,10,0);
-INSERT INTO t2 VALUES (10362,10,12,0);
-INSERT INTO t2 VALUES (10360,55,2,0);
-INSERT INTO t2 VALUES (10360,70,0,0);
-INSERT INTO t2 VALUES (10360,565656,0,0);
-INSERT INTO t2 VALUES (10360,32767,7,0);
-INSERT INTO t2 VALUES (10360,33,8,0);
-INSERT INTO t2 VALUES (10360,7887,85,0);
-INSERT INTO t2 VALUES (11405,88,8,0);
-INSERT INTO t2 VALUES (10360,0,55,0);
-INSERT INTO t2 VALUES (10360,99,0,0);
-INSERT INTO t2 VALUES (11411,30,10,0);
-INSERT INTO t2 VALUES (11404,0,0,0);
-INSERT INTO t2 VALUES (10362,11,111,0);
-INSERT INTO t2 VALUES (10363,33,333,0);
-INSERT INTO t2 VALUES (11412,55,0,0);
-INSERT INTO t2 VALUES (50003,66,6,0);
-INSERT INTO t2 VALUES (11403,5,0,0);
-INSERT INTO t2 VALUES (11406,11,11,0);
-INSERT INTO t2 VALUES (11410,11410,131,0);
-INSERT INTO t2 VALUES (11416,11416,32767,0);
-INSERT INTO t2 VALUES (11409,0,0,0);
-
-CREATE TABLE t3 (
- id int(11) DEFAULT '0' NOT NULL auto_increment,
- dni_pasaporte char(16) DEFAULT '' NOT NULL,
- idPla int(11) DEFAULT '0' NOT NULL,
- cod_asig int(11) DEFAULT '0' NOT NULL,
- any smallint(6) DEFAULT '0' NOT NULL,
- quatrimestre smallint(6) DEFAULT '0' NOT NULL,
- estat char(1) DEFAULT 'M' NOT NULL,
- PRIMARY KEY (id),
- UNIQUE dni_pasaporte (dni_pasaporte,idPla),
- UNIQUE dni_pasaporte_2 (dni_pasaporte,idPla,cod_asig,any,quatrimestre)
-);
-
-INSERT INTO t3 VALUES (1,'11111111',1,10362,98,1,'M');
-
-CREATE TABLE t4 (
- id int(11) DEFAULT '0' NOT NULL auto_increment,
- papa int(11) DEFAULT '0' NOT NULL,
- fill int(11) DEFAULT '0' NOT NULL,
- idPla int(11) DEFAULT '0' NOT NULL,
- PRIMARY KEY (id),
- KEY papa (idPla,papa),
- UNIQUE papa_2 (idPla,papa,fill)
-);
-
-INSERT INTO t4 VALUES (1,-1,10360,1);
-INSERT INTO t4 VALUES (2,-1,10361,1);
-INSERT INTO t4 VALUES (3,-1,10362,1);
-
-SELECT DISTINCT fill,desc_larga_cat,cred_total,Grup,Places,PlacesOcupades FROM t4 LEFT JOIN t3 ON t3.cod_asig=fill AND estat='S' AND dni_pasaporte='11111111' AND t3.idPla=1 , t2,t1 WHERE fill=t1.cod_asig AND Places>PlacesOcupades AND fill=idAssignatura AND t4.idPla=1 AND papa=-1;
-
-SELECT DISTINCT fill,t3.idPla FROM t4 LEFT JOIN t3 ON t3.cod_asig=t4.fill AND t3.estat='S' AND t3.dni_pasaporte='1234' AND t3.idPla=1 ;
-
-INSERT INTO t3 VALUES (3,'1234',1,10360,98,1,'S');
-SELECT DISTINCT fill,t3.idPla FROM t4 LEFT JOIN t3 ON t3.cod_asig=t4.fill AND t3.estat='S' AND t3.dni_pasaporte='1234' AND t3.idPla=1 ;
-
-drop table t1,t2,t3,test.t4;
-
-#
-# Bug in GROUP BY, by Nikki Chumakov <nikki@saddam.cityline.ru>
-
-CREATE TABLE t1 (
- PID int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
- payDate date DEFAULT '0000-00-00' NOT NULL,
- recDate datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
- URID int(10) unsigned DEFAULT '0' NOT NULL,
- CRID int(10) unsigned DEFAULT '0' NOT NULL,
- amount int(10) unsigned DEFAULT '0' NOT NULL,
- operator int(10) unsigned,
- method enum('unknown','cash','dealer','check','card','lazy','delayed','test') DEFAULT 'unknown' NOT NULL,
- DIID int(10) unsigned,
- reason char(1) binary DEFAULT '' NOT NULL,
- code_id int(10) unsigned,
- qty mediumint(8) unsigned DEFAULT '0' NOT NULL,
- PRIMARY KEY (PID),
- KEY URID (URID),
- KEY reason (reason),
- KEY method (method),
- KEY payDate (payDate)
-);
-
-INSERT INTO t1 VALUES (1,'1970-01-01','1997-10-17 00:00:00',2529,1,21000,11886,'check',0,'F',16200,6);
-
-SELECT COUNT(P.URID),SUM(P.amount),P.method, MIN(PP.recdate+0) > 19980501000000 AS IsNew FROM t1 AS P JOIN t1 as PP WHERE P.URID = PP.URID GROUP BY method,IsNew;
-
-drop table t1;
-
-# Another SUM() problem with 3.23.2
-
-create table t1 (
- num float(5,2),
- user char(20)
-);
-insert into t1 values (10.3,'nem'),(20.53,'monty'),(30.23,'sinisa');
-insert into t1 values (30.13,'nem'),(20.98,'monty'),(10.45,'sinisa');
-insert into t1 values (5.2,'nem'),(8.64,'monty'),(11.12,'sinisa');
-select sum(num) from t1;
-select sum(num) from t1 group by user;
-drop table t1;
-
-#
-# Problem with GROUP BY + ORDER BY when no match
-# Tested with locking
-#
-
-CREATE TABLE t1 (
- cid mediumint(9) DEFAULT '0' NOT NULL auto_increment,
- firstname varchar(32) DEFAULT '' NOT NULL,
- surname varchar(32) DEFAULT '' NOT NULL,
- PRIMARY KEY (cid)
-);
-INSERT INTO t1 VALUES (1,'That','Guy');
-INSERT INTO t1 VALUES (2,'Another','Gent');
-
-CREATE TABLE t2 (
- call_id mediumint(8) DEFAULT '0' NOT NULL auto_increment,
- contact_id mediumint(8) DEFAULT '0' NOT NULL,
- PRIMARY KEY (call_id),
- KEY contact_id (contact_id)
-);
-
-lock tables t1 read,t2 write;
-
-INSERT INTO t2 VALUES (10,2);
-INSERT INTO t2 VALUES (18,2);
-INSERT INTO t2 VALUES (62,2);
-INSERT INTO t2 VALUES (91,2);
-INSERT INTO t2 VALUES (92,2);
-
-SELECT cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid;
-SELECT HIGH_PRIORITY cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid ORDER BY surname, firstname;
-
-drop table t1,t2;
-unlock tables;
-
-#
-# Test of locking and delete of files
-#
-
-CREATE TABLE t1 (a int);
-CREATE TABLE t2 (a int);
-lock tables t1 write,t1 as b write, t2 write, t2 as c read;
-drop table t1;
-drop table t2;
-
-CREATE TABLE t1 (a int);
-CREATE TABLE t2 (a int);
-lock tables t1 write,t1 as b write, t2 write, t2 as c read;
-drop table t2;
-drop table t1;
-unlock tables;
-
-#
-# Order by on first index part
-#
-
-create table t1 (id int not null,col1 int not null,col2 int not null,index(col1));
-insert into t1 values(1,2,2),(2,2,1),(3,1,2),(4,1,1),(5,1,4),(6,2,3),(7,3,1),(8,2,4);
-select * from t1 order by col1,col2;
-select col1 from t1 order by id;
-select col1 as id from t1 order by t1.id;
-select concat(col1) as id from t1 order by t1.id;
-drop table t1;
-
-#
-# Problem with many key parts and many or
-#
-
-CREATE TABLE t1 (
- price int(5) DEFAULT '0' NOT NULL,
- area varchar(40) DEFAULT '' NOT NULL,
- type varchar(40) DEFAULT '' NOT NULL,
- transityes enum('Y','N') DEFAULT 'Y' NOT NULL,
- shopsyes enum('Y','N') DEFAULT 'Y' NOT NULL,
- schoolsyes enum('Y','N') DEFAULT 'Y' NOT NULL,
- petsyes enum('Y','N') DEFAULT 'Y' NOT NULL,
- KEY price (price,area,type,transityes,shopsyes,schoolsyes,petsyes)
-);
-
-INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','N','N','N','N');
-INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','N','N','N','N');
-INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','','','','');
-INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
-INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
-INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
-INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
-INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
-
- SELECT * FROM t1 WHERE area='Vancouver' and transityes='y' and schoolsyes='y' and ( ((type='1 Bedroom' or type='Studio/Bach') and (price<=500)) or ((type='2 Bedroom') and (price<=550)) or ((type='Shared/Roomate') and (price<=300)) or ((type='Room and Board') and (price<=500)) ) and price <= 400;
-
-drop table t1;
-
-#
-# Problem with distinct without results
-#
-CREATE TABLE t1 (UserId int(11) DEFAULT '0' NOT NULL);
-INSERT INTO t1 VALUES (20);
-INSERT INTO t1 VALUES (27);
-
-SELECT UserId FROM t1 WHERE Userid=22;
-SELECT UserId FROM t1 WHERE UserId=22 group by Userid;
-SELECT DISTINCT UserId FROM t1 WHERE UserId=22 group by Userid;
-SELECT DISTINCT UserId FROM t1 WHERE UserId=22;
-drop table t1;
-
-#
-# Check for problems with delete
-#
-
-CREATE TABLE t1 (a tinyint(3), b tinyint(5));
-INSERT INTO t1 VALUES (1,1);
-INSERT LOW_PRIORITY INTO t1 VALUES (1,2);
-INSERT INTO t1 VALUES (1,3);
-DELETE from t1 where a=1 limit 1;
-DELETE LOW_PRIORITY from t1 where a=1;
-
-INSERT INTO t1 VALUES (1,1);
-DELETE from t1;
-LOCK TABLE t1 write;
-INSERT INTO t1 VALUES (1,2);
-DELETE from t1;
-UNLOCK TABLES;
-INSERT INTO t1 VALUES (1,2);
-SET AUTOCOMMIT=0;
-DELETE from t1;
-SET AUTOCOMMIT=1;
-drop table t1;
-
-create table t1 (s1 char(64),s2 char(64));
-
-insert into t1 values('aaa','aaa');
-insert into t1 values('aaa|qqq','qqq');
-insert into t1 values('gheis','^[^a-dXYZ]+$');
-insert into t1 values('aab','^aa?b');
-insert into t1 values('Baaan','^Ba*n');
-insert into t1 values('aaa','qqq|aaa');
-insert into t1 values('qqq','qqq|aaa');
-
-insert into t1 values('bbb','qqq|aaa');
-insert into t1 values('bbb','qqq');
-insert into t1 values('aaa','aba');
-
-insert into t1 values(null,'abc');
-insert into t1 values('def',null);
-insert into t1 values(null,null);
-insert into t1 values('ghi','ghi[');
-
-select HIGH_PRIORITY s1 regexp s2 from t1;
-
-drop table t1;
-
-#
-# Test retreiving row with last insert_id value.
-#
-
-create table t1 (a int not null auto_increment,b int not null,primary key (a,b));
-insert into t1 SET A=NULL,B=1;
-insert into t1 SET a=null,b=2;
-select * from t1 where a is null and b=2;
-select * from t1 where a is null;
-explain select * from t1 where b is null;
-drop table t1;
-
-#
-# Test of IS NULL on AUTO_INCREMENT with LEFT JOIN
-#
-
-CREATE TABLE t1 (
- id smallint(5) unsigned DEFAULT '0' NOT NULL auto_increment,
- name char(60) DEFAULT '' NOT NULL,
- PRIMARY KEY (id)
-);
-INSERT INTO t1 VALUES (1,'Antonio Paz');
-INSERT INTO t1 VALUES (2,'Lilliana Angelovska');
-INSERT INTO t1 VALUES (3,'Thimble Smith');
-
-CREATE TABLE t2 (
- id smallint(5) unsigned DEFAULT '0' NOT NULL auto_increment,
- owner smallint(5) unsigned DEFAULT '0' NOT NULL,
- name char(60),
- PRIMARY KEY (id)
-);
-INSERT INTO t2 VALUES (1,1,'El Gato');
-INSERT INTO t2 VALUES (2,1,'Perrito');
-INSERT INTO t2 VALUES (3,3,'Happy');
-
-select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner);
-select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.id is null;
-explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.id is null;
-explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.name is null;
-select count(*) from t1 left join t2 on (t1.id = t2.owner);
-
-select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner);
-select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.id is null;
-explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.id is null;
-explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.name is null;
-select count(*) from t2 right join t1 on (t1.id = t2.owner);
-
-select t1.name, t2.name, t2.id,t3.id from t2 right join t1 on (t1.id = t2.owner) left join t1 as t3 on t3.id=t2.owner;
-select t1.name, t2.name, t2.id,t3.id from t1 right join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner;
-select t1.name, t2.name, t2.id, t2.owner, t3.id from t1 left join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner;
-
-drop table t1,t2;
-
-create table t1 (id int not null, str char(10), index(str));
-insert into t1 values (1, null), (2, null), (3, "foo"), (4, "bar");
-select * from t1 where str is not null;
-select * from t1 where str is null;
-drop table t1;
-
-#
-# Test wrong LEFT JOIN query
-#
-
-CREATE TABLE t1 (
- t1_id bigint(21) DEFAULT '0' NOT NULL auto_increment,
- PRIMARY KEY (t1_id)
-);
-CREATE TABLE t2 (
- t2_id bigint(21) DEFAULT '0' NOT NULL auto_increment,
- PRIMARY KEY (t2_id)
-);
-CREATE TABLE t3 (
- t3_id bigint(21) DEFAULT '0' NOT NULL auto_increment,
- PRIMARY KEY (t3_id)
-);
-CREATE TABLE t4 (
- seq_0_id bigint(21) DEFAULT '0' NOT NULL,
- seq_1_id bigint(21) DEFAULT '0' NOT NULL,
- KEY seq_0_id (seq_0_id),
- KEY seq_1_id (seq_1_id)
-);
-CREATE TABLE t5 (
- seq_0_id bigint(21) DEFAULT '0' NOT NULL,
- seq_1_id bigint(21) DEFAULT '0' NOT NULL,
- KEY seq_1_id (seq_1_id),
- KEY seq_0_id (seq_0_id)
-);
-
-insert into t1 values (1);
-insert into t2 values (1);
-insert into t3 values (1);
-insert into t4 values (1,1);
-insert into t5 values (1,1);
-
-explain select * from t3 left join t4 on t4.seq_1_id = t2.t2_id left join t1 on t1.t1_id = t4.seq_0_id left join t5 on t5.seq_0_id = t1.t1_id left join t2 on t2.t2_id = t5.seq_1_id where t3.t3_id = 23;
-
-drop table t1,t2,t3,t4,t5;
-
-# Test bug with NATURAL join:
-
-CREATE TABLE t1 (id1 INT NOT NULL PRIMARY KEY, dat1 CHAR(1), id2 INT);
-INSERT INTO t1 VALUES (1,'a',1);
-INSERT INTO t1 VALUES (2,'b',1);
-INSERT INTO t1 VALUES (3,'c',2);
-
-CREATE TABLE t2 (id2 INT NOT NULL PRIMARY KEY, dat2 CHAR(1));
-INSERT INTO t2 VALUES (1,'x');
-INSERT INTO t2 VALUES (2,'y');
-INSERT INTO t2 VALUES (3,'z');
-
-SELECT t2.id2 FROM t2 LEFT OUTER JOIN t1 ON t1.id2 = t2.id2 WHERE id1 IS NULL;
-SELECT t2.id2 FROM t2 NATURAL LEFT OUTER JOIN t1 WHERE id1 IS NULL;
-
-drop table t1,t2;
-
-#
-# Test of order by on field()
-#
-
-CREATE TABLE t1 (id int auto_increment primary key,aika varchar(40),aikakentta timestamp);
-insert into t1 (aika) values ('Keskiviikko');
-insert into t1 (aika) values ('Tiistai');
-insert into t1 (aika) values ('Maanantai');
-insert into t1 (aika) values ('Sunnuntai');
-
-SELECT FIELD(SUBSTRING(t1.aika,1,2),'Ma','Ti','Ke','To','Pe','La','Su') AS test FROM t1 ORDER by test;
-drop table t1;
-
-#
-# Test of ORDER BY on IF
-#
-
-CREATE TABLE t1
-(
- a int unsigned NOT NULL,
- b int unsigned NOT NULL,
- c int unsigned NOT NULL,
- UNIQUE(a),
- INDEX(b),
- INDEX(c)
-);
-
-CREATE TABLE t2
-(
- c int unsigned NOT NULL,
- i int unsigned NOT NULL,
- INDEX(c)
-);
-
-CREATE TABLE t3
-(
- c int unsigned NOT NULL,
- v varchar(64),
- INDEX(c)
-);
-
-INSERT INTO t1 VALUES (1,1,1);
-INSERT INTO t1 VALUES (2,1,2);
-INSERT INTO t1 VALUES (3,2,1);
-INSERT INTO t1 VALUES (4,2,2);
-INSERT INTO t2 VALUES (1,50);
-INSERT INTO t2 VALUES (2,25);
-INSERT INTO t3 VALUES (1,'123 Park Place');
-INSERT INTO t3 VALUES (2,'453 Boardwalk');
-
-SELECT a,b,if(b = 1,i,if(b = 2,v,''))
-FROM t1
-LEFT JOIN t2 USING(c)
-LEFT JOIN t3 ON t3.c = t1.c;
-
-SELECT a,b,if(b = 1,i,if(b = 2,v,''))
-FROM t1
-LEFT JOIN t2 USING(c)
-LEFT JOIN t3 ON t3.c = t1.c
-ORDER BY a;
-
-drop table t1,t2,t3;
-
-#
-# test of IN (NULL)
-#
-
-CREATE TABLE t1 (field char(1));
-INSERT INTO t1 VALUES ('A'),(NULL);
-SELECT * from t1 WHERE field IN (NULL);
-SELECT * from t1 WHERE field NOT IN (NULL);
-SELECT * from t1 where field = field;
-SELECT * from t1 where field <=> field;
-DELETE FROM t1 WHERE field NOT IN (NULL);
-SELECT * FROM t1;
-drop table t1;
-
-#
-# Test insert of now() and curtime()
-#
-
-CREATE TABLE t1 (a timestamp, b date, c time, d datetime);
-insert into t1 (b,c,d) values(now(),curtime(),now());
-select date_format(a,"%Y-%m-%d")=b,right(a,6)=c+0,a=d+0 from t1;
-drop table t1;
-
-#
-# Test of binary and normal strings
-#
-
-create table t1 (a char(10) not null, b char(10) binary not null,index (a));
-insert into t1 values ("hello ","hello "),("hello2 ","hello2 ");
-select * from t1 where a="hello ";
-select * from t1 where b="hello ";
-select * from t1 where b="hello";
-drop table t1;
-
-#
-# Test some warnings
-#
-
-create table t1 (a int);
-insert into t1 values (1);
-insert into t1 values ("hej");
-insert into t1 values ("hej"),("då");
-set SQL_WARNINGS=1;
-insert into t1 values ("hej");
-insert into t1 values ("hej"),("då");
-drop table t1;
-set SQL_WARNINGS=0;
-
-#
-# Test of join with blobs and min
-#
-
-CREATE TABLE t1 (
- t1_id bigint(21) DEFAULT '0' NOT NULL auto_increment,
- _field_72 varchar(128) DEFAULT '' NOT NULL,
- _field_95 varchar(32),
- _field_115 tinyint(4) DEFAULT '0' NOT NULL,
- _field_122 tinyint(4) DEFAULT '0' NOT NULL,
- _field_126 tinyint(4),
- _field_134 tinyint(4),
- PRIMARY KEY (t1_id),
- UNIQUE _field_72 (_field_72),
- KEY _field_115 (_field_115),
- KEY _field_122 (_field_122)
-);
-
-
-INSERT INTO t1 VALUES (1,'admin','21232f297a57a5a743894a0e4a801fc3',0,1,NULL,NULL);
-INSERT INTO t1 VALUES (2,'hroberts','7415275a8c95952901e42b13a6b78566',0,1,NULL,NULL);
-INSERT INTO t1 VALUES (3,'guest','d41d8cd98f00b204e9800998ecf8427e',1,0,NULL,NULL);
-
-
-CREATE TABLE t2 (
- seq_0_id bigint(21) DEFAULT '0' NOT NULL,
- seq_1_id bigint(21) DEFAULT '0' NOT NULL,
- PRIMARY KEY (seq_0_id,seq_1_id)
-);
-
-
-INSERT INTO t2 VALUES (1,1);
-INSERT INTO t2 VALUES (2,1);
-INSERT INTO t2 VALUES (2,2);
-
-CREATE TABLE t3 (
- t3_id bigint(21) DEFAULT '0' NOT NULL auto_increment,
- _field_131 varchar(128),
- _field_133 tinyint(4) DEFAULT '0' NOT NULL,
- _field_135 datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
- _field_137 tinyint(4),
- _field_139 datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
- _field_140 blob,
- _field_142 tinyint(4) DEFAULT '0' NOT NULL,
- _field_145 tinyint(4) DEFAULT '0' NOT NULL,
- _field_148 tinyint(4) DEFAULT '0' NOT NULL,
- PRIMARY KEY (t3_id),
- KEY _field_133 (_field_133),
- KEY _field_135 (_field_135),
- KEY _field_139 (_field_139),
- KEY _field_142 (_field_142),
- KEY _field_145 (_field_145),
- KEY _field_148 (_field_148)
-);
-
-
-INSERT INTO t3 VALUES (1,'test job 1',0,'0000-00-00 00:00:00',0,'1999-02-25 22:43:32','test\r\njob\r\n1',0,0,0);
-INSERT INTO t3 VALUES (2,'test job 2',0,'0000-00-00 00:00:00',0,'1999-02-26 21:08:04','',0,0,0);
-
-
-CREATE TABLE t4 (
- seq_0_id bigint(21) DEFAULT '0' NOT NULL,
- seq_1_id bigint(21) DEFAULT '0' NOT NULL,
- PRIMARY KEY (seq_0_id,seq_1_id)
-);
-
-
-INSERT INTO t4 VALUES (1,1);
-INSERT INTO t4 VALUES (2,1);
-
-CREATE TABLE t5 (
- t5_id bigint(21) DEFAULT '0' NOT NULL auto_increment,
- _field_149 tinyint(4),
- _field_156 varchar(128) DEFAULT '' NOT NULL,
- _field_157 varchar(128) DEFAULT '' NOT NULL,
- _field_158 varchar(128) DEFAULT '' NOT NULL,
- _field_159 varchar(128) DEFAULT '' NOT NULL,
- _field_160 varchar(128) DEFAULT '' NOT NULL,
- _field_161 varchar(128) DEFAULT '' NOT NULL,
- PRIMARY KEY (t5_id),
- KEY _field_156 (_field_156),
- KEY _field_157 (_field_157),
- KEY _field_158 (_field_158),
- KEY _field_159 (_field_159),
- KEY _field_160 (_field_160),
- KEY _field_161 (_field_161)
-);
-
-
-INSERT INTO t5 VALUES (1,0,'tomato','','','','','');
-INSERT INTO t5 VALUES (2,0,'cilantro','','','','','');
-
-CREATE TABLE t6 (
- seq_0_id bigint(21) DEFAULT '0' NOT NULL,
- seq_1_id bigint(21) DEFAULT '0' NOT NULL,
- PRIMARY KEY (seq_0_id,seq_1_id)
-);
-
-INSERT INTO t6 VALUES (1,1);
-INSERT INTO t6 VALUES (1,2);
-INSERT INTO t6 VALUES (2,2);
-
-CREATE TABLE t7 (
- t7_id bigint(21) DEFAULT '0' NOT NULL auto_increment,
- _field_143 tinyint(4),
- _field_165 varchar(32),
- _field_166 smallint(6) DEFAULT '0' NOT NULL,
- PRIMARY KEY (t7_id),
- KEY _field_166 (_field_166)
-);
-
-
-INSERT INTO t7 VALUES (1,0,'High',1);
-INSERT INTO t7 VALUES (2,0,'Medium',2);
-INSERT INTO t7 VALUES (3,0,'Low',3);
-
-select t3._field_140,min(t3._field_131), min(t3._field_135), min(t3._field_139), min(t3._field_137), min(link_alias_142._field_165), min(link_alias_133._field_72), min(t3._field_145), min(link_alias_148._field_156), min(t3._field_140), t3.t3_id from t3 left join t4 on t4.seq_0_id = t3.t3_id left join t7 link_alias_142 on t4.seq_1_id = link_alias_142.t7_id left join t6 on t6.seq_0_id = t3.t3_id left join t1 link_alias_133 on t6.seq_1_id = link_alias_133.t1_id left join t2 on t2.seq_0_id = t3.t3_id left join t5 link_alias_148 on t2.seq_1_id = link_alias_148.t5_id where t3.t3_id in (1) group by t3.t3_id order by link_alias_142._field_166, _field_139, link_alias_133._field_72, _field_135, link_alias_148._field_156;
-
-drop table t1,t2,t3,t4,t5,t6,t7;
-
-#
-# Test of timestamp and blobs
-
-CREATE TABLE t1 (value TEXT NOT NULL, id VARCHAR(32) NOT NULL, stamp timestamp, PRIMARY KEY (id));
-INSERT INTO t1 VALUES ("my value", "myKey","1999-04-02 00:00:00");
-SELECT stamp FROM t1 WHERE id="myKey";
-UPDATE t1 SET value="my value" WHERE id="myKey";
-SELECT stamp FROM t1 WHERE id="myKey";
-drop table t1;
-
-create table t1 (a timestamp);
-insert into t1 values (now());
-select date_format(a,"%Y %y"),year(a),year(now()) from t1;
-drop table t1;
-
-create table t1 (ix timestamp);
-insert into t1 values (19991101000000),(19990102030405),(19990630232922),(19990601000000),(19990930232922),(19990531232922),(19990501000000),(19991101000000),(19990501000000);
-select * from t1;
-drop table t1;
-
-CREATE TABLE t1 (date date, date_time datetime, time_stamp timestamp);
-INSERT INTO t1 VALUES ("1998-12-31","1998-12-31 23:59:59",19981231235959);
-INSERT INTO t1 VALUES ("1999-01-01","1999-01-01 00:00:00",19990101000000);
-INSERT INTO t1 VALUES ("1999-09-09","1999-09-09 23:59:59",19990909235959);
-INSERT INTO t1 VALUES ("2000-01-01","2000-01-01 00:00:00",20000101000000);
-INSERT INTO t1 VALUES ("2000-02-28","2000-02-28 00:00:00",20000228000000);
-INSERT INTO t1 VALUES ("2000-02-29","2000-02-29 00:00:00",20000229000000);
-INSERT INTO t1 VALUES ("2000-03-01","2000-03-01 00:00:00",20000301000000);
-INSERT INTO t1 VALUES ("2000-12-31","2000-12-31 23:59:59",20001231235959);
-INSERT INTO t1 VALUES ("2001-01-01","2001-01-01 00:00:00",20010101000000);
-INSERT INTO t1 VALUES ("2004-12-31","2004-12-31 23:59:59",20041231235959);
-INSERT INTO t1 VALUES ("2005-01-01","2005-01-01 00:00:00",20050101000000);
-INSERT INTO t1 VALUES ("2030-01-01","2030-01-01 00:00:00",20300101000000);
-INSERT INTO t1 VALUES ("2050-01-01","2050-01-01 00:00:00",20500101000000);
-SELECT * FROM t1;
-drop table t1;
-
-#
-# test of DELAYED insert and timestamps
-# (Can't be tested with purify :( )
-#
-
-#create table t1 (a char(10), tmsp timestamp);
-#insert into t1 set a = 1;
-#insert delayed into t1 set a = 2;
-#insert into t1 set a = 3, tmsp=NULL;
-#insert delayed into t1 set a = 4;
-#insert delayed into t1 set a = 5, tmsp = 19711006010203;
-#insert delayed into t1 (a, tmsp) values (6, 19711006010203);
-#insert delayed into t1 (a, tmsp) values (7, NULL);
-#insert into t1 set a = 8,tmsp=19711006010203;
-#select * from t1 where tmsp=0;
-#select * from t1 where tmsp=19711006010203;
-#drop table t1;
-
-#
-# Test of date and not null
-#
-
-CREATE TABLE t1 (a datetime not null);
-insert into t1 values (0);
-select * from t1 where a is null;
-drop table t1;
-
-create table t1 (id int not null, str char(10), unique(str));
-insert into t1 values (1, null),(2, null),(3, "foo"),(4, "bar");
-select * from t1 where str is null;
-select * from t1 where str="foo";
-explain select * from t1 where str is null;
-explain select * from t1 where str="foo";
-explain select * from t1 ignore key (str) where str="foo";
-explain select * from t1 use key (str,str) where str="foo";
-
-#The following should give errors
-explain select * from t1 use key (str,str,foo) where str="foo";
-explain select * from t1 ignore key (str,str,foo) where str="foo";
-drop table t1;
-
-#
-# Test of bug in COUNT(i)*(i+0)
-#
-
-CREATE TABLE t1 (d DATETIME, i INT);
-INSERT INTO t1 VALUES (NOW(), 1);
-SELECT COUNT(i), i, COUNT(i)*i FROM t1 GROUP BY i;
-SELECT COUNT(i), (i+0), COUNT(i)*(i+0) FROM t1 GROUP BY i;
-DROP TABLE t1;
-
-#
-# Test if time type
-#
-create table t1 (t time);
-insert t1 values (30),(1230),("1230"),("12:30"),("12:30:35"),("1 12:30:31.32");
-select * from t1;
-drop table t1;
-
-#
-# Problem med concat
-#
-
-create table t1 (Zeit time, Tag tinyint not null, Monat tinyint not null, Jahr smallint not null, index(Tag), index(Monat), index(Jahr) );
-insert into t1 values ("09:26:00",16,9,1998);
-insert into t1 values ("09:26:00",16,9,1998);
-SELECT CONCAT(Jahr,'-',Monat,'-',Tag,' ',Zeit) AS Date,
- UNIX_TIMESTAMP(CONCAT(Jahr,'-',Monat,'-',Tag,' ',Zeit)) AS Unix
-FROM t1;
-drop table t1;
-
-create table t1 ( domain char(50) );
-insert into t1 VALUES ("hello.de" ), ("test.de" );
-select domain from t1 where concat('@', trim(leading '.' from concat('.', domain))) = '@hello.de';
-select domain from t1 where concat('@', trim(leading '.' from concat('.', domain))) = '@test.de';
-drop table t1;
-
-#
-# Problem med range optimizer
-#
-
-CREATE TABLE t1 (
- event_date date DEFAULT '0000-00-00' NOT NULL,
- type int(11) DEFAULT '0' NOT NULL,
- event_id int(11) DEFAULT '0' NOT NULL,
- PRIMARY KEY (event_date,type,event_id)
-);
-
-INSERT INTO t1 VALUES ('1999-07-10',100100,24),('1999-07-11',100100,25),('1999-07-13',100600,0),('1999-07-13',100600,4),('1999-07-13',100600,26),('1999-07-14',100600,10),('1999-07-15',100600,16),('1999-07-15',100800,45),('1999-07-15',101000,47),('1999-07-16',100800,46),('1999-07-20',100600,5),('1999-07-20',100600,27),('1999-07-21',100600,11),('1999-07-22',100600,17),('1999-07-23',100100,39),('1999-07-24',100100,39),('1999-07-24',100500,40),('1999-07-25',100100,39),('1999-07-27',100600,1),('1999-07-27',100600,6),('1999-07-27',100600,28),('1999-07-28',100600,12),('1999-07-29',100500,41),('1999-07-29',100600,18),('1999-07-30',100500,41),('1999-07-31',100500,41),('1999-08-01',100700,34),('1999-08-03',100600,7),('1999-08-03',100600,29),('1999-08-04',100600,13),('1999-08-05',100500,42),('1999-08-05',100600,19),('1999-08-06',100500,42),('1999-08-07',100500,42),('1999-08-08',100500,42),('1999-08-10',100600,2),('1999-08-10',100600,9),('1999-08-10',100600,30),('1999-08-11',100600,14),('1999-08-12',100600,20),('1999-08-17',100500,8),('1999-08-17',100600,31),('1999-08-18',100600,15),('1999-08-19',100600,22),('1999-08-24',100600,3),('1999-08-24',100600,32),('1999-08-27',100500,43),('1999-08-31',100600,33),('1999-09-17',100100,37),('1999-09-18',100100,37),('1999-09-19',100100,37),('2000-12-18',100700,38);
-
-select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date;
-explain select event_date,type,event_id from t1 WHERE type = 100601 and event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date;
-select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND (type=100600 OR type=100100) or event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND type=100099;
-drop table t1;
-
-CREATE TABLE t1 (
- PAPER_ID smallint(6) DEFAULT '0' NOT NULL,
- YEAR smallint(6) DEFAULT '0' NOT NULL,
- ISSUE smallint(6) DEFAULT '0' NOT NULL,
- CLOSED tinyint(4) DEFAULT '0' NOT NULL,
- ISS_DATE date DEFAULT '0000-00-00' NOT NULL,
- PRIMARY KEY (PAPER_ID,YEAR,ISSUE)
-);
-INSERT INTO t1 VALUES (3,1999,34,0,'1999-07-12');
-INSERT INTO t1 VALUES (1,1999,111,0,'1999-03-23');
-INSERT INTO t1 VALUES (1,1999,222,0,'1999-03-23');
-INSERT INTO t1 VALUES (3,1999,33,0,'1999-07-12');
-INSERT INTO t1 VALUES (3,1999,32,0,'1999-07-12');
-INSERT INTO t1 VALUES (3,1999,31,0,'1999-07-12');
-INSERT INTO t1 VALUES (3,1999,30,0,'1999-07-12');
-INSERT INTO t1 VALUES (3,1999,29,0,'1999-07-12');
-INSERT INTO t1 VALUES (3,1999,28,0,'1999-07-12');
-INSERT INTO t1 VALUES (1,1999,40,1,'1999-05-01');
-INSERT INTO t1 VALUES (1,1999,41,1,'1999-05-01');
-INSERT INTO t1 VALUES (1,1999,42,1,'1999-05-01');
-INSERT INTO t1 VALUES (1,1999,46,1,'1999-05-01');
-INSERT INTO t1 VALUES (1,1999,47,1,'1999-05-01');
-INSERT INTO t1 VALUES (1,1999,48,1,'1999-05-01');
-INSERT INTO t1 VALUES (1,1999,49,1,'1999-05-01');
-INSERT INTO t1 VALUES (1,1999,50,0,'1999-05-01');
-INSERT INTO t1 VALUES (1,1999,51,0,'1999-05-01');
-INSERT INTO t1 VALUES (1,1999,200,0,'1999-06-28');
-INSERT INTO t1 VALUES (1,1999,52,0,'1999-06-28');
-INSERT INTO t1 VALUES (1,1999,53,0,'1999-06-28');
-INSERT INTO t1 VALUES (1,1999,54,0,'1999-06-28');
-INSERT INTO t1 VALUES (1,1999,55,0,'1999-06-28');
-INSERT INTO t1 VALUES (1,1999,56,0,'1999-07-01');
-INSERT INTO t1 VALUES (1,1999,57,0,'1999-07-01');
-INSERT INTO t1 VALUES (1,1999,58,0,'1999-07-01');
-INSERT INTO t1 VALUES (1,1999,59,0,'1999-07-01');
-INSERT INTO t1 VALUES (1,1999,60,0,'1999-07-01');
-INSERT INTO t1 VALUES (3,1999,35,0,'1999-07-12');
-select YEAR,ISSUE from t1 where PAPER_ID=3 and (YEAR>1999 or (YEAR=1999 and ISSUE>28)) order by YEAR,ISSUE;
-check table t1;
-repair table t1;
-drop table t1;
-
-CREATE TABLE t1 (
- id int(11) NOT NULL auto_increment,
- parent_id int(11) DEFAULT '0' NOT NULL,
- level tinyint(4) DEFAULT '0' NOT NULL,
- PRIMARY KEY (id),
- KEY parent_id (parent_id),
- KEY level (level)
-);
-INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1),(179,5,2);
-SELECT * FROM t1 WHERE level = 1 AND parent_id = 1;
-# The following select returned 0 rows in 3.23.8
-SELECT * FROM t1 WHERE level = 1 AND parent_id = 1 order by id;
-drop table t1;
-
-#
-# Testing of bug in range optimizer with many key parts and > and <
-#
-
-create table t1(
- Satellite varchar(25) not null,
- SensorMode varchar(25) not null,
- FullImageCornersUpperLeftLongitude double not null,
- FullImageCornersUpperRightLongitude double not null,
- FullImageCornersUpperRightLatitude double not null,
- FullImageCornersLowerRightLatitude double not null,
- index two (Satellite, SensorMode, FullImageCornersUpperLeftLongitude, FullImageCornersUpperRightLongitude, FullImageCornersUpperRightLatitude, FullImageCornersLowerRightLatitude));
-
-insert into t1 values("OV-3","PAN1",91,-92,40,50);
-insert into t1 values("OV-4","PAN1",91,-92,40,50);
-
-select * from t1 where t1.Satellite = "OV-3" and t1.SensorMode = "PAN1" and t1.FullImageCornersUpperLeftLongitude > -90.000000 and t1.FullImageCornersUpperRightLongitude < -82.000000;
-drop table t1;
-
-create table t1 ( aString char(100) not null default "", key aString (aString(10)) );
-insert t1 (aString) values ( "believe in myself" ), ( "believe" ), ("baaa" ), ( "believe in love");
-select * from t1 where aString < "believe in myself" order by aString;
-select * from t1 where aString > "believe in love" order by aString;
-alter table t1 drop key aString;
-select * from t1 where aString < "believe in myself" order by aString;
-select * from t1 where aString > "believe in love" order by aString;
-drop table t1;
-
-#
-# problem med primary key
-#
-
-CREATE TABLE t1 (program enum('signup','unique','sliding') not null, type enum('basic','sliding','signup'), sites set('mt'), PRIMARY KEY (program));
-# The following should give an error for wrong primary key
-ALTER TABLE t1 modify program enum('signup','unique','sliding');
-drop table t1;
-
-#
-# Test year
-#
-
-create table t1 (y year,y2 year(2));
-insert into t1 values (0,0),(1999,1999),(2000,2000),(2001,2001),(70,70),(69,69);
-select * from t1;
-select * from t1 order by y;
-select * from t1 order by y2;
-drop table t1;
-
-#
-# Test of distinct
-#
-
-CREATE TABLE t1 (a int(10) unsigned not null primary key,b int(10) unsigned);
-INSERT INTO t1 VALUES (1,1),(2,1);
-CREATE TABLE t2 (a int(10) unsigned not null, key (A));
-INSERT INTO t2 VALUES (1),(2);
-CREATE TABLE t3 (a int(10) unsigned, key(A), b text);
-INSERT INTO t3 VALUES (1,'1'),(2,'2');
-SELECT DISTINCT t3.b FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
-INSERT INTO t2 values (1),(2),(3);
-INSERT INTO t3 VALUES (1,'1'),(2,'2'),(1,'1'),(2,'2');
-explain SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
-SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
-
-# Create a lot of data into t3;
-create temporary table t4 select * from t3;
-insert into t3 select * from t4;
-insert into t4 select * from t3;
-insert into t3 select * from t4;
-insert into t4 select * from t3;
-insert into t3 select * from t4;
-insert into t4 select * from t3;
-insert into t3 select * from t4;
-
-explain select distinct t1.a from t1,t3 where t1.a=t3.a;
-flush status;
-select distinct t1.a from t1,t3 where t1.a=t3.a;
-show status like 'Handler%';
-flush status;
-select distinct 1 from t1,t3 where t1.a=t3.a;
-show status like 'Handler%';
-drop table t1,t2,t3,t4;
-
-#
-# test of unsigned int
-#
-
-create table t1 (this int unsigned);
-insert into t1 values (1);
-select * from t1;
-drop table t1;
-
-#
-# Test of reverse with empty blob
-#
-
-create table t1 (a blob);
-insert into t1 values ("empty"),("");
-select a,reverse(a) from t1;
-drop table t1;
-
-#
-# Test of heap tables.
-#
-
-create table t1 (a int not null,b int not null, primary key (a)) type=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100;
-insert into t1 values(1,1),(2,2),(3,3),(4,4);
-delete from t1 where a=1 or a=0;
-show table status like "t1";
-show keys from t1;
-select * from t1;
-select * from t1 where a=4;
-update t1 set b=5 where a=4;
-update t1 set b=b+1 where a>=3;
-replace t1 values (3,3);
-select * from t1;
-alter table t1 add c int not null, add key (c,a);
-drop table t1;
-
-create table t1 (a int not null,b int not null, primary key (a)) type=heap comment="testing heaps";
-insert into t1 values(1,1),(2,2),(3,3),(4,4);
-alter table t1 modify a int not null auto_increment, type=myisam, comment="new myisam table";
-show table status like "t1";
-select * from t1;
-drop table t1;
-
-create table t1 (a int not null) type=heap;
-insert into t1 values (869751),(736494),(226312),(802616);
-select * from t1 where a > 736494;
-alter table t1 add unique uniq_id(a);
-select * from t1 where a > 736494;
-select * from t1 where a = 736494;
-select * from t1 where a=869751 or a=736494;
-select * from t1 where a in (869751,736494,226312,802616);
-alter table t1 type=myisam;
-explain select * from t1 where a in (869751,736494,226312,802616);
-drop table t1;
-
-create table t1 (x int not null, y int not null, key x(x), unique y(y))
-type=heap;
-insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
-select * from t1 where x=1;
-select * from t1,t1 as t2 where t1.x=t2.y;
-explain select * from t1,t1 as t2 where t1.x=t2.y;
-drop table t1;
-
-create table t1 (a int) type=heap;
-insert into t1 values(1);
-select max(a) from t1;
-drop table t1;
-
-CREATE TABLE t1 ( a int not null default 0, b int not null default 0, key(a), key(b) ) TYPE=HEAP;
-insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
-select * from t1 where a=1;
-insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
-select * from t1 where a=1;
-drop table t1;
-
-create table t1 (id int unsigned not null, primary key (id)) type=HEAP;
-insert into t1 values(1);
-select max(id) from t1;
-insert into t1 values(2);
-select max(id) from t1;
-replace into t1 values(1);
-drop table t1;
-
-create table t1 (n int) type=heap;
-drop table t1;
-
-create table t1 (n int) type=heap;
-drop table if exists t1;
-
-# Test of non unique index
-
-CREATE table t1(f1 int not null,f2 char(20) not
-null,index(f2)) type=heap;
-INSERT into t1 set f1=12,f2="bill";
-INSERT into t1 set f1=13,f2="bill";
-INSERT into t1 set f1=14,f2="bill";
-INSERT into t1 set f1=15,f2="bill";
-INSERT into t1 set f1=16,f2="ted";
-INSERT into t1 set f1=12,f2="ted";
-INSERT into t1 set f1=12,f2="ted";
-INSERT into t1 set f1=12,f2="ted";
-INSERT into t1 set f1=12,f2="ted";
-delete from t1 where f2="bill";
-select * from t1;
-drop table t1;
-#
-# Test of auto_increment.
-#
-
-create table t1 (a int not null auto_increment,b int, primary key (a)) type=myisam auto_increment=3;
-insert into t1 values (1,1),(NULL,3),(NULL,4);
-delete from t1 where a=4;
-insert into t1 values (NULL,5),(NULL,6);
-select * from t1;
-delete from t1 where a=6;
-show table status like "t1";
-replace t1 values (3,1);
-ALTER TABLE t1 add c int;
-replace t1 values (3,3,3);
-insert into t1 values (NULL,7,7);
-update t1 set a=8,b=b+1,c=c+1 where a=7;
-insert into t1 values (NULL,9,9);
-select * from t1;
-drop table t1;
-
-create table t1 (a int not null auto_increment,b int, primary key (a)) type=isam;
-insert into t1 values (1,1),(NULL,2),(3,3),(NULL,4);
-delete from t1 where a=4 or a=2;
-insert into t1 values (NULL,4),(NULL,5),(6,6);
-select * from t1;
-delete from t1 where a=6;
-show table status like "t1";
-replace t1 values (3,1);
-replace t1 values (3,3);
-ALTER TABLE t1 add c int;
-insert into t1 values (NULL,6,6);
-select * from t1;
-drop table t1;
-
-create table t1 (
- skey tinyint unsigned NOT NULL auto_increment PRIMARY KEY,
- sval char(20)
-);
-insert into t1 values (NULL, "hello");
-insert into t1 values (NULL, "hey");
-select * from t1;
-select _rowid,t1._rowid,skey,sval from t1;
-drop table t1;
-
-#
-# Test auto_increment on sub key
-#
-create table t1 (a char(10) not null, b int not null auto_increment, primary key(a,b));
-insert into t1 values ("a",1),("b",2),("a",2),("c",1);
-insert into t1 values ("a",NULL),("b",NULL),("c",NULL),("d",NULL);
-insert into t1 (a) values ("a"),("b"),("c"),("d");
-insert into t1 (a) values ("a");
-insert into t1 values ("d",last_insert_id());
-select * from t1;
-drop table t1;
-
-create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ordid), index(ord,ordid));
-insert into t1 (ordid,ord) values (NULL,'sdj'),(NULL,'sdj');
-select * from t1;
-drop table t1;
-
-create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid));
-insert into t1 values (NULL,'sdj'),(NULL,'sdj'),(NULL,"abc"),(NULL,'abc'),(NULL,'zzz'),(NULL,'sdj'),(NULL,'abc');
-select * from t1;
-drop table t1;
-
-#
-# Test of some CREATE TABLE'S that should fail
-#
-
-create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) type=isam;
-create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) type=heap;
-create table t1 (ordid int(8), primary key (ordid));
-create table t1 (ordid int(8), unique (ordid)) type=isam;
-
-#
-# Test of temporary tables
-#
-CREATE TABLE t1 (c int not null, d char (10) not null);
-insert into t1 values(1,""),(2,"a"),(3,"b");
-CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null);
-insert into t1 values(4,"e"),(5,"f"),(6,"g");
-alter table t1 rename t2;
-select * from t1;
-select * from t2;
-CREATE TABLE t2 (x int not null, y int not null);
-alter table t2 rename t1;
-select * from t1;
-create TEMPORARY TABLE t2 type=heap select * from t1;
-
-# This should give errors
-CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null);
-ALTER TABLE t1 RENAME t2;
-
-select * from t2;
-alter table t2 add primary key (a,b);
-drop table t1,t2;
-select * from t1;
-drop table t2;
-create temporary table t1 select *,2 as "e" from t1;
-select * from t1;
-drop table t1;
-drop table t1;
-
-#
-# test of updating of keys
-#
-
-create table t1 (a int auto_increment , primary key (a));
-insert into t1 values (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
-update t1 set a=a+10 where a > 34;
-update t1 set a=a+100 where a > 0;
-drop table t1;
-
-CREATE TABLE t1
- (
- place_id int (10) unsigned NOT NULL,
- shows int(10) unsigned DEFAULT '0' NOT NULL,
- ishows int(10) unsigned DEFAULT '0' NOT NULL,
- ushows int(10) unsigned DEFAULT '0' NOT NULL,
- clicks int(10) unsigned DEFAULT '0' NOT NULL,
- iclicks int(10) unsigned DEFAULT '0' NOT NULL,
- uclicks int(10) unsigned DEFAULT '0' NOT NULL,
- ts timestamp(14),
- PRIMARY KEY (place_id,ts)
- );
-
-INSERT INTO t1 (place_id,shows,ishows,ushows,clicks,iclicks,uclicks,ts)
-VALUES (1,0,0,0,0,0,0,20000928174434);
-UPDATE t1 SET shows=shows+1,ishows=ishows+1,ushows=ushows+1,clicks=clicks+1,iclicks=iclicks+1,uclicks=uclicks+1 WHERE place_id=1 AND ts>="2000-09-28 00:00:00";
-select place_id,shows from t1;
-drop table t1;
-
-#
-# Test of refering to old values
-#
-create table t1 (a int not null);
-insert into t1 values (1);
-insert into t1 values (a+2);
-insert into t1 values (a+3);
-insert into t1 values (4),(a+5);
-select * from t1;
-drop table t1;
-
-#
-# Test of LEFT JOIN + GROUP FUNCTIONS within functions:
-#
-
-CREATE TABLE t1 (
- pcode varchar(8) DEFAULT '' NOT NULL
-);
-INSERT INTO t1 VALUES ('kvw2000'),('kvw2001'),('kvw3000'),('kvw3001'),('kvw3002'),('kvw3500'),('kvw3501'),('kvw3502'),('kvw3800'),('kvw3801'),('kvw3802'),('kvw3900'),('kvw3901'),('kvw3902'),('kvw4000'),('kvw4001'),('kvw4002'),('kvw4200'),('kvw4500'),('kvw5000'),('kvw5001'),('kvw5500'),('kvw5510'),('kvw5600'),('kvw5601'),('kvw6000'),('klw1000'),('klw1020'),('klw1500'),('klw2000'),('klw2001'),('klw2002'),('kld2000'),('klw2500'),('kmw1000'),('kmw1500'),('kmw2000'),('kmw2001'),('kmw2100'),('kmw3000'),('kmw3200');
-CREATE TABLE t2 (
- pcode varchar(8) DEFAULT '' NOT NULL,
- KEY pcode (pcode)
-);
-INSERT INTO t2 VALUES ('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw2000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3000'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw3500'),('kvw6000'),('kvw6000'),('kld2000');
-
-SELECT t1.pcode, IF(ISNULL(t2.pcode), 0, COUNT(*)) AS count FROM t1
-LEFT JOIN t2 ON t1.pcode = t2.pcode GROUP BY t1.pcode;
-SELECT SQL_BIG_RESULT t1.pcode, IF(ISNULL(t2.pcode), 0, COUNT(*)) AS count FROM t1 LEFT JOIN t2 ON t1.pcode = t2.pcode GROUP BY t1.pcode;
-drop table t1,t2;
-
-#
-# Another left join problem
-#
-
-CREATE TABLE t1 (
- id int(11),
- pid int(11),
- rep_del tinyint(4),
- KEY id (id),
- KEY pid (pid)
-);
-INSERT INTO t1 VALUES (1,NULL,NULL);
-INSERT INTO t1 VALUES (2,1,NULL);
-select * from t1 LEFT JOIN t1 t2 ON (t1.id=t2.pid) AND t2.rep_del IS NULL;
-create index rep_del ON t1(rep_del);
-select * from t1 LEFT JOIN t1 t2 ON (t1.id=t2.pid) AND t2.rep_del IS NULL;
-drop table t1;
-
-CREATE TABLE t1 (
- id int(11) DEFAULT '0' NOT NULL,
- name tinytext DEFAULT '' NOT NULL,
- UNIQUE id (id)
-);
-INSERT INTO t1 VALUES (1,'yes'),(2,'no');
-CREATE TABLE t2 (
- id int(11) DEFAULT '0' NOT NULL,
- idx int(11) DEFAULT '0' NOT NULL,
- UNIQUE id (id,idx)
-);
-INSERT INTO t2 VALUES (1,1);
-explain SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL;
-SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL;
-drop table t1,t2;
-
-#
-# Test of update and delete with limit
-#
-create table t1 (a int primary key, b int not null);
-insert into t1 () values (); -- Testing default values
-insert into t1 values (1,1),(2,1),(3,1);
-update t1 set a=4 where b=1 limit 1;
-select * from t1;
-update t1 set b=2 where b=1 limit 2;
-select * from t1;
-update t1 set b=4 where b=1;
-select * from t1;
-delete from t1 where b=2 limit 1;
-select * from t1;
-delete from t1 limit 1;
-select * from t1;
-drop table t1;
-
-#
-# Test of BLOB:s with NULL keys.
-#
-
-create table t1 (a blob, key (a(10)));
-insert into t1 values ("bye"),("hello"),("hello"),("hello word");
-select * from t1 where a like "hello%";
-drop table t1;
-
-#
-# Test of alter table
-#
-
-create table t1 (
-col1 int not null auto_increment primary key,
-col2 varchar(30) not null,
-col3 varchar (20) not null,
-col4 varchar(4) not null,
-col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null,
-col6 int not null);
-alter table t1
-add column col4_5 varchar(20) not null after col4,
-add column col7 varchar(30) not null after col6,
-add column col8 datetime not null;
-drop table t1;
-
-# Check that pack_keys and dynamic length rows are not forced.
-
-CREATE TABLE t1 (
-GROUP_ID int(10) unsigned DEFAULT '0' NOT NULL,
-LANG_ID smallint(5) unsigned DEFAULT '0' NOT NULL,
-NAME varchar(80) DEFAULT '' NOT NULL,
-PRIMARY KEY (GROUP_ID,LANG_ID),
-KEY NAME (NAME));
-show table status like "t1";
-ALTER TABLE t1 CHANGE NAME NAME CHAR(80) not null;
-SHOW COLUMNS FROM t1;
-DROP TABLE t1;
-
-#
-# Problem with INSERT ... SELECT
-#
-
-create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL);
-insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12);
-create table t2 (payoutID SMALLINT UNSIGNED NOT NULL PRIMARY KEY);
-insert into t2 (payoutID) SELECT DISTINCT payoutID FROM t1;
-insert into t2 (payoutID) SELECT payoutID+10 FROM t1;
-select * from t2;
-drop table t1,t2;
-
-#
-# problem with join
-#
-
-CREATE TABLE t1 (
- id int(11) NOT NULL auto_increment,
- token varchar(100) DEFAULT '' NOT NULL,
- count int(11) DEFAULT '0' NOT NULL,
- qty int(11),
- phone char(1) DEFAULT '' NOT NULL,
- timestamp datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
- PRIMARY KEY (id),
- KEY token (token(15)),
- KEY timestamp (timestamp),
- UNIQUE token_2 (token(75),count,phone)
-);
-
-INSERT INTO t1 VALUES (21,'e45703b64de71482360de8fec94c3ade',3,7800,'n','1999-12-23 17:22:21');
-INSERT INTO t1 VALUES (22,'e45703b64de71482360de8fec94c3ade',4,5000,'y','1999-12-23 17:22:21');
-INSERT INTO t1 VALUES (18,'346d1cb63c89285b2351f0ca4de40eda',3,13200,'b','1999-12-23 11:58:04');
-INSERT INTO t1 VALUES (17,'ca6ddeb689e1b48a04146b1b5b6f936a',4,15000,'b','1999-12-23 11:36:53');
-INSERT INTO t1 VALUES (16,'ca6ddeb689e1b48a04146b1b5b6f936a',3,13200,'b','1999-12-23 11:36:53');
-INSERT INTO t1 VALUES (26,'a71250b7ed780f6ef3185bfffe027983',5,1500,'b','1999-12-27 09:44:24');
-INSERT INTO t1 VALUES (24,'4d75906f3c37ecff478a1eb56637aa09',3,5400,'y','1999-12-23 17:29:12');
-INSERT INTO t1 VALUES (25,'4d75906f3c37ecff478a1eb56637aa09',4,6500,'y','1999-12-23 17:29:12');
-INSERT INTO t1 VALUES (27,'a71250b7ed780f6ef3185bfffe027983',3,6200,'b','1999-12-27 09:44:24');
-INSERT INTO t1 VALUES (28,'a71250b7ed780f6ef3185bfffe027983',3,5400,'y','1999-12-27 09:44:36');
-INSERT INTO t1 VALUES (29,'a71250b7ed780f6ef3185bfffe027983',4,17700,'b','1999-12-27 09:45:05');
-
-CREATE TABLE t2 (
- id int(11) NOT NULL auto_increment,
- category int(11) DEFAULT '0' NOT NULL,
- county int(11) DEFAULT '0' NOT NULL,
- state int(11) DEFAULT '0' NOT NULL,
- phones int(11) DEFAULT '0' NOT NULL,
- nophones int(11) DEFAULT '0' NOT NULL,
- PRIMARY KEY (id),
- KEY category (category,county,state)
-);
-INSERT INTO t2 VALUES (3,2,11,12,5400,7800);
-INSERT INTO t2 VALUES (4,2,25,12,6500,11200);
-INSERT INTO t2 VALUES (5,1,37,6,10000,12000);
-
-select a.id, b.category as catid, b.state as stateid, b.county as
-countyid from t1 a, t2 b where (a.token =
-'a71250b7ed780f6ef3185bfffe027983') and (a.count = b.id);
-select a.id, b.category as catid, b.state as stateid, b.county as
-countyid from t1 a, t2 b where (a.token =
-'a71250b7ed780f6ef3185bfffe027983') and (a.count = b.id) order by a.id;
-
-drop table t1, t2;
-
-#
-# Test of join of many tables.
-
-create table t1 (a int primary key);
-insert into t1 values(1),(2);
-select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a) left join t1 as t32 using (a) left join t1 as t33 using (a) left join t1 as t34 using (a) left join t1 as t35 using (a) left join t1 as t36 using (a) left join t1 as t37 using (a) left join t1 as t38 using (a) left join t1 as t39 using (a) left join t1 as t40 using (a) left join t1 as t41 using (a) left join t1 as t42 using (a) left join t1 as t43 using (a) left join t1 as t44 using (a) left join t1 as t45 using (a) left join t1 as t46 using (a) left join t1 as t47 using (a) left join t1 as t48 using (a) left join t1 as t49 using (a) left join t1 as t50 using (a) left join t1 as t51 using (a) left join t1 as t52 using (a) left join t1 as t53 using (a) left join t1 as t54 using (a) left join t1 as t55 using (a) left join t1 as t56 using (a) left join t1 as t57 using (a) left join t1 as t58 using (a) left join t1 as t59 using (a) left join t1 as t60 using (a);
-drop table t1;
-
-#
-# test of safe selects
-#
-SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=4, SQL_MAX_JOIN_SIZE=9;
-create table t1 (a int primary key, b char(20));
-insert into t1 values(1,"test");
-SELECT SQL_BUFFER_RESULT * from t1;
-update t1 set b="a" where a=1;
-delete from t1 where a=1;
-insert into t1 values(1,"test"),(2,"test2");
-SELECT SQL_BUFFER_RESULT * from t1;
-update t1 set b="a" where a=1;
-select 1 from t1,t1 as t2,t1 as t3,t1 as t4;
-
-# The following should give errors:
-update t1 set b="a";
-update t1 set b="a" where b="test";
-delete from t1;
-delete from t1 where b="test";
-delete from t1 where a+0=1;
-select 1 from t1,t1 as t2,t1 as t3,t1 as t4,t1 as t5;
-
-# The following should be ok:
-update t1 set b="a" limit 1;
-update t1 set b="a" where b="b" limit 2;
-delete from t1 where b="test" limit 1;
-delete from t1 where a+0=1 limit 2;
-drop table t1;
-
-SET SQL_SAFE_UPDATES=0,SQL_SELECT_LIMIT=DEFAULT, SQL_MAX_JOIN_SIZE=DEFAULT;
-
-# Test of raided tables
-
-DROP TABLE IF EXISTS raidtest;
-DROP TABLE IF EXISTS raidnew;
-CREATE TABLE raidtest (
-id int unsigned not null auto_increment primary key,
-c char(255) not null
-) RAID_TYPE=STRIPED RAID_CHUNKS=2 RAID_CHUNKSIZE=123;
-INSERT INTO raidtest VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO raidtest VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO raidtest VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO raidtest VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO raidtest VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-select count(*) from raidtest;
-ALTER TABLE raidtest ADD COLUMN x INT UNSIGNED NOT NULL;
-ALTER TABLE raidtest ADD KEY c (c);
-ALTER TABLE raidtest DROP KEY c;
-ALTER TABLE raidtest DROP COLUMN x;
-ALTER TABLE raidtest RENAME raidnew;
-select count(*) from raidnew;
-DROP TABLE raidnew;
-/* variable rows */
-DROP TABLE IF EXISTS raidnew;
-CREATE TABLE raidtest (
-id int unsigned not null auto_increment primary key,
-c varchar(255) not null
-) RAID_TYPE=STRIPED RAID_CHUNKS=5 RAID_CHUNKSIZE=121;
-INSERT INTO raidtest VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO raidtest VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO raidtest VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO raidtest VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-INSERT INTO raidtest VALUES
-(NULL,'1'),(NULL,'a'),(NULL,'a'),(NULL,'a'),(NULL,'p'),(NULL,'a'),
-(NULL,'2'),(NULL,'b'),(NULL,'a'),(NULL,'a'),(NULL,'q'),(NULL,'a'),
-(NULL,'3'),(NULL,'c'),(NULL,'a'),(NULL,'a'),(NULL,'r'),(NULL,'a'),
-(NULL,'4'),(NULL,'d'),(NULL,'a'),(NULL,'a'),(NULL,'s'),(NULL,'a'),
-(NULL,'5'),(NULL,'e'),(NULL,'a'),(NULL,'a'),(NULL,'t'),(NULL,'a'),
-(NULL,'6'),(NULL,'f'),(NULL,'a'),(NULL,'a'),(NULL,'u'),(NULL,'a'),
-(NULL,'7'),(NULL,'g'),(NULL,'a'),(NULL,'a'),(NULL,'v'),(NULL,'a'),
-(NULL,'8'),(NULL,'h'),(NULL,'a'),(NULL,'a'),(NULL,'w'),(NULL,'a'),
-(NULL,'9'),(NULL,'i'),(NULL,'a'),(NULL,'a'),(NULL,'x'),(NULL,'a'),
-(NULL,'0'),(NULL,'j'),(NULL,'a'),(NULL,'a'),(NULL,'y'),(NULL,'a'),
-(NULL,'1'),(NULL,'k'),(NULL,'a'),(NULL,'a'),(NULL,'z'),(NULL,'a'),
-(NULL,'2'),(NULL,'l'),(NULL,'a'),(NULL,'a'),(NULL,'/'),(NULL,'a'),
-(NULL,'3'),(NULL,'m'),(NULL,'a'),(NULL,'a'),(NULL,'*'),(NULL,'a'),
-(NULL,'4'),(NULL,'n'),(NULL,'a'),(NULL,'a'),(NULL,'+'),(NULL,'a'),
-(NULL,'5'),(NULL,'o'),(NULL,'a'),(NULL,'a'),(NULL,'?'),(NULL,'a');
-select count(*) from raidtest;
-ALTER TABLE raidtest ADD COLUMN x INT UNSIGNED NOT NULL;
-ALTER TABLE raidtest ADD KEY c (c);
-ALTER TABLE raidtest DROP KEY c;
-ALTER TABLE raidtest DROP COLUMN x;
-ALTER TABLE raidtest RENAME raidnew;
-ALTER TABLE raidnew CHANGE COLUMN c c VARCHAR(251) NOT NULL;
-select count(*) from raidnew;
-DROP TABLE raidnew;
-
-#
-# Problem with count(distinct)
-#
-
-create table t1 (libname varchar(21) not null, city text, primary key (libname));
-create table t2 (isbn varchar(21) not null, author text, title text, primary key (isbn));
-create table t3 (isbn varchar(21) not null, libname varchar(21) not null, quantity int ,primary key (isbn,libname));
-insert into t2 values ('001','Daffy','A duck''s life');
-insert into t2 values ('002','Bugs','A rabbit\'s life');
-insert into t2 values ('003','Cowboy','Life on the range');
-insert into t2 values ('000','Anonymous','Wanna buy this book?');
-insert into t2 values ('004','Best Seller','One Heckuva book');
-insert into t2 values ('005','EveryoneBuys','This very book');
-insert into t2 values ('006','San Fran','It is a san fran lifestyle');
-insert into t2 values ('007','BerkAuthor','Cool.Berkley.the.book');
-insert into t3 values('000','New York Public Libra','1');
-insert into t3 values('001','New York Public Libra','2');
-insert into t3 values('002','New York Public Libra','3');
-insert into t3 values('003','New York Public Libra','4');
-insert into t3 values('004','New York Public Libra','5');
-insert into t3 values('005','New York Public Libra','6');
-insert into t3 values('006','San Fransisco Public','5');
-insert into t3 values('007','Berkeley Public1','3');
-insert into t3 values('007','Berkeley Public2','3');
-insert into t3 values('001','NYC Lib','8');
-insert into t1 values ('New York Public Libra','New York');
-insert into t1 values ('San Fransisco Public','San Fran');
-insert into t1 values ('Berkeley Public1','Berkeley');
-insert into t1 values ('Berkeley Public2','Berkeley');
-insert into t1 values ('NYC Lib','New York');
-select t2.isbn,city,t1.libname,count(t1.libname) as a from t3 left join t1 on t3.libname=t1.libname left join t2 on t3.isbn=t2.isbn group by city,t1.libname;
-select t2.isbn,city,t1.libname,count(distinct t1.libname) as a from t3 left join t1 on t3.libname=t1.libname left join t2 on t3.isbn=t2.isbn group by city having count(distinct t1.libname) > 1;
-drop table t1, t2, t3;
-
-#
-# Problem with table dependencies
-#
-
-create table t1 (
- id int not null,
- name tinytext not null,
- unique (id)
-);
-create table t2 (
- id int not null,
- idx int not null,
- unique (id, idx)
-);
-create table t3 (
- id int not null,
- idx int not null,
- unique (id, idx)
-);
-insert into t1 values (1,'yes'), (2,'no');
-insert into t2 values (1,1);
-insert into t3 values (1,1);
-EXPLAIN
-SELECT DISTINCT
- t1.id
-from
- t1
- straight_join
- t2
- straight_join
- t3
- straight_join
- t1 as j_lj_t2 left join t2 as t2_lj
- on j_lj_t2.id=t2_lj.id
- straight_join
- t1 as j_lj_t3 left join t3 as t3_lj
- on j_lj_t3.id=t3_lj.id
-WHERE
- ((t1.id=j_lj_t2.id AND t2_lj.id IS NULL) OR (t1.id=t2.id AND t2.idx=2))
- AND ((t1.id=j_lj_t3.id AND t3_lj.id IS NULL) OR (t1.id=t3.id AND t3.idx=2));
-SELECT DISTINCT
- t1.id
-from
- t1
- straight_join
- t2
- straight_join
- t3
- straight_join
- t1 as j_lj_t2 left join t2 as t2_lj
- on j_lj_t2.id=t2_lj.id
- straight_join
- t1 as j_lj_t3 left join t3 as t3_lj
- on j_lj_t3.id=t3_lj.id
-WHERE
- ((t1.id=j_lj_t2.id AND t2_lj.id IS NULL) OR (t1.id=t2.id AND t2.idx=2))
- AND ((t1.id=j_lj_t3.id AND t3_lj.id IS NULL) OR (t1.id=t3.id AND t3.idx=2));
-drop table t1,t2,t3;
-
-#
-# Test of hex constants in WHERE:
-#
-
-create table t1 (ID int(8) unsigned zerofill not null auto_increment,UNIQ bigint(21) unsigned zerofill not null,primary key (ID),unique (UNIQ) );
-insert into t1 set UNIQ=0x38afba1d73e6a18a;
-insert into t1 set UNIQ=123;
-explain select * from t1 where UNIQ=0x38afba1d73e6a18a;
-drop table t1;
-
-#
-# Test of compressed decimal index.
-#
-
-CREATE TABLE t1 (
- name varchar(50) DEFAULT '' NOT NULL,
- author varchar(50) DEFAULT '' NOT NULL,
- category decimal(10,0) DEFAULT '0' NOT NULL,
- email varchar(50),
- password varchar(50),
- proxy varchar(50),
- bitmap varchar(20),
- msg varchar(255),
- urlscol varchar(127),
- urlhttp varchar(127),
- timeout decimal(10,0),
- nbcnx decimal(10,0),
- creation decimal(10,0),
- livinguntil decimal(10,0),
- lang decimal(10,0),
- type decimal(10,0),
- subcat decimal(10,0),
- subtype decimal(10,0),
- reg char(1),
- scs varchar(255),
- capacity decimal(10,0),
- userISP varchar(50),
- CCident varchar(50) DEFAULT '' NOT NULL,
- PRIMARY KEY (name,author,category)
-);
-INSERT INTO t1 VALUES
-('patnom','patauteur',0,'p.favre@cryo-networks.fr',NULL,NULL,'#p2sndnq6ae5g1u6t','essai\nsalut','scol://195.242.78.119:patauteur.patnom',NULL,NULL,NULL,950036174,-882087474,NULL,3,0,3,'1','Pub/patnom/futur_divers.scs',NULL,'pat','CC1');
-INSERT INTO t1 VALUES
-('LeNomDeMonSite','Marc',0,'m.barilley@cryo-networks.fr',NULL,NULL,NULL,NULL,'scol://195.242.78.119:Marc.LeNomDeMonSite',NULL,NULL,NULL,950560434,-881563214,NULL,3,0,3,'1','Pub/LeNomDeMonSite/domus_hibere.scs',NULL,'Marq','CC1');
-select * from t1 where name='patnom' and author='patauteur' and category=0;
-drop table t1;
-
-#
-# Test of group by bug in bugzilla
-#
-
-CREATE TABLE t1 (
- bug_id mediumint(9) DEFAULT '0' NOT NULL auto_increment,
- groupset bigint(20) DEFAULT '0' NOT NULL,
- assigned_to mediumint(9) DEFAULT '0' NOT NULL,
- bug_file_loc text,
- bug_severity enum('blocker','critical','major','normal','minor','trivial','enhancement') DEFAULT 'blocker' NOT NULL,
- bug_status enum('NEW','ASSIGNED','REOPENED','RESOLVED','VERIFIED','CLOSED') DEFAULT 'NEW' NOT NULL,
- creation_ts datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
- delta_ts timestamp(14),
- short_desc mediumtext,
- long_desc mediumtext,
- op_sys enum('All','Windows 3.1','Windows 95','Windows 98','Windows NT','Windows 2000','Linux','other') DEFAULT 'All' NOT NULL,
- priority enum('P1','P2','P3','P4','P5') DEFAULT 'P1' NOT NULL,
- product varchar(64) DEFAULT '' NOT NULL,
- rep_platform enum('All','PC','VTD-8','Other'),
- reporter mediumint(9) DEFAULT '0' NOT NULL,
- version varchar(16) DEFAULT '' NOT NULL,
- component varchar(50) DEFAULT '' NOT NULL,
- resolution enum('','FIXED','INVALID','WONTFIX','LATER','REMIND','DUPLICATE','WORKSFORME') DEFAULT '' NOT NULL,
- target_milestone varchar(20) DEFAULT '' NOT NULL,
- qa_contact mediumint(9) DEFAULT '0' NOT NULL,
- status_whiteboard mediumtext NOT NULL,
- votes mediumint(9) DEFAULT '0' NOT NULL,
- PRIMARY KEY (bug_id),
- KEY assigned_to (assigned_to),
- KEY creation_ts (creation_ts),
- KEY delta_ts (delta_ts),
- KEY bug_severity (bug_severity),
- KEY bug_status (bug_status),
- KEY op_sys (op_sys),
- KEY priority (priority),
- KEY product (product),
- KEY reporter (reporter),
- KEY version (version),
- KEY component (component),
- KEY resolution (resolution),
- KEY target_milestone (target_milestone),
- KEY qa_contact (qa_contact),
- KEY votes (votes)
-);
-
-INSERT INTO t1 VALUES (1,0,0,'','normal','','2000-02-10 09:25:12',20000321114747,'','','Linux','P1','TestProduct','PC',3,'other','TestComponent','','M1',0,'',0);
-INSERT INTO t1 VALUES (9,0,0,'','enhancement','','2000-03-10 11:49:36',20000321114747,'','','All','P5','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - conversion','','',0,'',0);
-INSERT INTO t1 VALUES (10,0,0,'','enhancement','','2000-03-10 18:10:16',20000321114747,'','','All','P4','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - conversion','','',0,'',0);
-INSERT INTO t1 VALUES (7,0,0,'','critical','','2000-03-09 10:50:21',20000321114747,'','','All','P1','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - generic','','',0,'',0);
-INSERT INTO t1 VALUES (6,0,0,'','normal','','2000-03-09 10:42:44',20000321114747,'','','All','P2','AAAAA','PC',3,'2.00 CD - Pre','kkkkkkkkkkk lllllllllll','','',0,'',0);
-INSERT INTO t1 VALUES (8,0,0,'','major','','2000-03-09 11:32:14',20000321114747,'','','All','P3','AAAAA','PC',3,'2.00 CD - Pre','kkkkkkkkkkk lllllllllll','','',0,'',0);
-INSERT INTO t1 VALUES (5,0,0,'','enhancement','','2000-03-09 10:38:59',20000321114747,'','','All','P5','CCC/CCCCCC','PC',5,'7.00','Administration','','',0,'',0);
-INSERT INTO t1 VALUES (4,0,0,'','normal','','2000-03-08 18:32:14',20000321114747,'','','other','P2','TestProduct','Other',3,'other','TestComponent2','','',0,'',0);
-INSERT INTO t1 VALUES (3,0,0,'','normal','','2000-03-08 18:30:52',20000321114747,'','','other','P2','TestProduct','Other',3,'other','TestComponent','','',0,'',0);
-INSERT INTO t1 VALUES (2,0,0,'','enhancement','','2000-03-08 18:24:51',20000321114747,'','','All','P2','TestProduct','Other',4,'other','TestComponent2','','',0,'',0);
-INSERT INTO t1 VALUES (11,0,0,'','blocker','','2000-03-13 09:43:41',20000321114747,'','','All','P2','CCC/CCCCCC','PC',5,'7.00','DDDDDDDDD','','',0,'',0);
-INSERT INTO t1 VALUES (12,0,0,'','normal','','2000-03-13 16:14:31',20000321114747,'','','All','P2','AAAAA','PC',3,'2.00 CD - Pre','kkkkkkkkkkk lllllllllll','','',0,'',0);
-INSERT INTO t1 VALUES (13,0,0,'','normal','','2000-03-15 16:20:44',20000321114747,'','','other','P2','TestProduct','Other',3,'other','TestComponent','','',0,'',0);
-INSERT INTO t1 VALUES (14,0,0,'','blocker','','2000-03-15 18:13:47',20000321114747,'','','All','P1','AAAAA','PC',3,'2.00 CD - Pre','BBBBBBBBBBBBB - generic','','',0,'',0);
-INSERT INTO t1 VALUES (15,0,0,'','minor','','2000-03-16 18:03:28',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','DDDDDDDDD','','',0,'',0);
-INSERT INTO t1 VALUES (16,0,0,'','normal','','2000-03-16 18:33:41',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
-INSERT INTO t1 VALUES (17,0,0,'','normal','','2000-03-16 18:34:18',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
-INSERT INTO t1 VALUES (18,0,0,'','normal','','2000-03-16 18:34:56',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
-INSERT INTO t1 VALUES (19,0,0,'','enhancement','','2000-03-16 18:35:34',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
-INSERT INTO t1 VALUES (20,0,0,'','enhancement','','2000-03-16 18:36:23',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
-INSERT INTO t1 VALUES (21,0,0,'','enhancement','','2000-03-16 18:37:23',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
-INSERT INTO t1 VALUES (22,0,0,'','enhancement','','2000-03-16 18:38:16',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','Administration','','',0,'',0);
-INSERT INTO t1 VALUES (23,0,0,'','normal','','2000-03-16 18:58:12',20000321114747,'','','All','P2','CCC/CCCCCC','Other',5,'7.00','DDDDDDDDD','','',0,'',0);
-INSERT INTO t1 VALUES (24,0,0,'','normal','','2000-03-17 11:08:10',20000321114747,'','','All','P2','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0);
-INSERT INTO t1 VALUES (25,0,0,'','normal','','2000-03-17 11:10:45',20000321114747,'','','All','P2','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0);
-INSERT INTO t1 VALUES (26,0,0,'','normal','','2000-03-17 11:15:47',20000321114747,'','','All','P2','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0);
-INSERT INTO t1 VALUES (27,0,0,'','normal','','2000-03-17 17:45:41',20000321114747,'','','All','P2','CCC/CCCCCC','PC',5,'7.00','DDDDDDDDD','','',0,'',0);
-INSERT INTO t1 VALUES (28,0,0,'','normal','','2000-03-20 09:51:45',20000321114747,'','','Windows NT','P2','TestProduct','PC',8,'other','TestComponent','','',0,'',0);
-INSERT INTO t1 VALUES (29,0,0,'','normal','','2000-03-20 11:15:09',20000321114747,'','','All','P5','AAAAAAAA-AAA','PC',3,'2.8','Web Interface','','',0,'',0);
-CREATE TABLE t2 (
- value tinytext,
- program varchar(64),
- initialowner tinytext NOT NULL,
- initialqacontact tinytext NOT NULL,
- description mediumtext NOT NULL
-);
-
-INSERT INTO t2 VALUES ('TestComponent','TestProduct','id0001','','');
-INSERT INTO t2 VALUES ('BBBBBBBBBBBBB - conversion','AAAAA','id0001','','');
-INSERT INTO t2 VALUES ('BBBBBBBBBBBBB - generic','AAAAA','id0001','','');
-INSERT INTO t2 VALUES ('TestComponent2','TestProduct','id0001','','');
-INSERT INTO t2 VALUES ('BBBBBBBBBBBBB - eeeeeeeee','AAAAA','id0001','','');
-INSERT INTO t2 VALUES ('kkkkkkkkkkk lllllllllll','AAAAA','id0001','','');
-INSERT INTO t2 VALUES ('Test Procedures','AAAAA','id0001','','');
-INSERT INTO t2 VALUES ('Documentation','AAAAA','id0003','','');
-INSERT INTO t2 VALUES ('DDDDDDDDD','CCC/CCCCCC','id0002','','');
-INSERT INTO t2 VALUES ('Eeeeeeee Lite','CCC/CCCCCC','id0002','','');
-INSERT INTO t2 VALUES ('Eeeeeeee Full','CCC/CCCCCC','id0002','','');
-INSERT INTO t2 VALUES ('Administration','CCC/CCCCCC','id0002','','');
-INSERT INTO t2 VALUES ('Distribution','CCC/CCCCCC','id0002','','');
-INSERT INTO t2 VALUES ('Setup','CCC/CCCCCC','id0002','','');
-INSERT INTO t2 VALUES ('Unspecified','CCC/CCCCCC','id0002','','');
-INSERT INTO t2 VALUES ('Web Interface','AAAAAAAA-AAA','id0001','','');
-INSERT INTO t2 VALUES ('Host communication','AAAAA','id0001','','');
-select value,description,bug_id from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA";
-select value,description,COUNT(bug_id) from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA" group by value;
-
-drop table t1,t2;
-
-#
-# Problem with search on partial index
-#
-
-create table t1
-(
- name_id int not null auto_increment,
- name blob,
- INDEX name_idx (name(5)),
- primary key (name_id)
-);
-
-INSERT t1 VALUES(NULL,'/');
-INSERT t1 VALUES(NULL,'[T,U]_axpby');
-SELECT * FROM t1 WHERE name='[T,U]_axpy';
-SELECT * FROM t1 WHERE name='[T,U]_axpby';
-create table t2
-(
- name_id int not null auto_increment,
- name char(255) binary,
- INDEX name_idx (name(5)),
- primary key (name_id)
-);
-INSERT t2 select * from t1;
-SELECT * FROM t2 WHERE name='[T,U]_axpy';
-SELECT * FROM t2 WHERE name='[T,U]_axpby';
-drop table t1,t2;
-
-#
-# Problem with many enums
-#
-
-CREATE TABLE t1 (
- field enum('001001','001004','001010','001018','001019','001020','001021','001027','001028','001029','001030','001031','001100','002003','002004','002005','002007','002008','002009','002012','002013','002014','003002','003003','003004','003005','003006','003007','003008','003009','003010','003011','003012','003013','003014','003015','003016','003017','003018','003019','004002','004003','004005','004006','004007','004008','004010','004012','004014','004016','004017','004020','004021','004022','004023','004024','004025','004026','006002','006004','006006','006010','006011','006012','006013','006014','007001','007002','007003','007004','007005','007006','007007','007008','007009','007010','007011','007012','007013','007014','007015','007016','007017','007018','007019','007020','007021','007022','007023','007024','007025','007026','007027','007028','007029','007030','007031','007032','007033','007034','007035','007036','007037','007038','007039','007040','007043','007044','009001','009002','009004','009005','009006','009007','009008','009009','009010','009011','009012','009013','010002','010003','010004','010005','010006','010007','010008','010009','010010','010011','010012','010013','010015','010016','010017','010018','010019','010020','010021','010022','010023','010024','010025','010026','010027','010028','011001','011002','011003','011004','011006','011012','011013','011014','011015','011016','012017','012018','012019','012023','012027','012028','012029','012030','012031','012032','012033','012034','012035','012036','012037','012038','012039','014001','016002','016003','016004','016007','016010','016011','016016','016019','016020','016021','016022','016023','016024','016026','016027','016028','016029','016030','016031','016032','016033','016034','017002','018001','019002','019004','020001','020003','020004','020005','020006','020007','020008','020009','022001','022002','022003','023001','023002','023003','023004','023005','023006','023007','023008','023010','023011','023012','023017','023019','023020','023021','023025','023026','023027','023028','023029','023030','023031','023032','023033','023034','023035','025001','025003','025004','025005','025006','025007','025008','025009','025010','025011','025012','025013','025014','025015','025016','025017','025018','025019','025020','025021','025022','025023','025024','025025','025026','025027','025028','025029','025030','025031','025032','025033','025034','025035','025036','025037','025038','025039','025040','025041','025042','025043','025044','025045','025046','025047','025048','025049','025050','025051','025052','025053','025054','025055','025056','025057','025058','025059','025060','025061','025062','025063','027001','027002','027011','035008','035012','036001','037001','037003','037004','037005','037006','037007','037008','037009','038004','038005','038006','038007','038009','039001','039002','039003','039004','039005','039006','046001','046002','046003','046004','046005','046007','046008','046009','046010','046011','046012','046013','046014','047001','047002','048001','051001','051002','051003','051004','052001','052002','052005','053015','053016','053019','053020','053023','053024','053026','053028','053029','053033','053034','053036','053037','053038','053039','053041','053042','053043','053045','053046','053047','053048','053051','053052','053054','053055','053056','053057','053068','053069','053070','053073','053074','053075','053086','053094','053095','053096','053097','053098','053099','053100','053101','053102','053103','053104','053105','053107','053122','053123','053124','053125','053127','053128','054001','054002','054003','054004','054005','054006','054007','054009','054010','056001','056002','056003','056004','056005','056006','056009','056010','056011','056016','056017','056018','056019','056020','056021','056022','057001','057002','057003','057004','058002','058003','058004','058005','060001','060003','060004','060005','060006','060007','061002','061003','061004','061005','061006','069006','069007','069010','069011','069012','069013','069014','069015','069016','069017','069018','069020','069021','069022','069023','069024','071002','071003','071004','071005','071006','071008','071011','071013','071020','071021','071022','072001','073001','073002','073003','073004','074001','074002','074003','074004','074005','074006','074007','074008','074009','074010','074011','074012','075001','075007','076101','076102','076103','077001','077002','077003','077004','077006','077007','077008','077009','078005','079002','079003','079004','079005','079006','079007','081001','082006','082007','082011','082013','082014','082015','082016','082017','082021','082022','082023','082024','082025','082026','082027','082028','082029','082030','082031','082032','082033','082034','082035','082036','082037','082038','082039','082040','082041','082042','082043','082044','084001','084002','084003','084004','084005','084007','084008','084009','084011','084013','084014','084016','084017','084027','084031','084032','084033','084035','084036','084037','084038','084039','084040','084041','084042','084043','084044','084045','084046','084047','084048','084049','084050','084051','085001','085002','085003','085004','085005','085006','085007','085009','085011','085012','085013','085014','085015','085016','085017','085018','085019','085020','085021','085022','085023','085028','085029','085030','085031','085033','085034','085035','085036','085037','085038','085040','085041','085042','085043','085044','085045','085046','085047','085048','085063','085064','085065','085068','085070','085071','085073','085082','085083','085086','085088','085089','085090','085091','085092','085093','085094','085095','085096','085097','085098','085099','085100','085101','085102','085103','085104','085105','085106','085107','085108','085109','085110','085111','085112','085113','085115','085119','085120','085121','085122','085123','085124','085125','085126','085127','085128','085129','085130','085132','085133','085134','085135','085136','085137','086001','086002','086003','086004','086005','088001','088003','088005','088006','088007','088008','088009','089001','090001','090002','090003','090004','090005','090006','090007','090008','090009','090010','090013','090015','090016','090017','090018','090019','090022','090027','090028','091001','091002','091005','091008','091009','091010','091011','091012','091013','091014','091015','091016','091017','091018','093001','093003','093098','093100','093102','093104','093141','093142','093146','093151','093153','093167','093168','093176','094001','094002','094004','094005','095004','099001','099002','100001','101001','102002','102003','105001','105002','106001','113001','113002','113003','113004','113005','113006','113007','113008','113009','113010','113011','113012','113013','113014','113015','113016','113017','113018','113019','113020','113021','113022','113023','113024','113025','113026','113027','113028','114001','115001','115002','115003','115004','115005','115006','115007','115008','115009','115010','115011','115012','115013','115014','115015','115016','115017','115018','115020','115021','115022','115023','115025','115026','115027','115028','115029','115030','115031','115032','115033','115034','115035','115036','115039','115040','115041','115042','115043','115044','115045','115046','115047','115048','115049','115050','115051','115052','115053','115054','115055','115056','115057','115059','115060','115061','115062','115063','115064','115065','115066','115067','115068','115069','115070','115071','115072','115073','115075','115076','115081','115082','115085','115086','115087','115088','115095','115096','115097','115098','115099','115101','115102','115103','115104','115105','115106','115108','115109','115110','115111','115112','115113','115114','115115','115116','115117','115118','115119','115120','115121','115122','116001','116002','116003','116004','116005','116006','116007','116008','116009','116010','116011','116012','117001','117002','117003','123001','124010','124014','124015','124019','124024','124025','124026','124027','124028','124029','124030','124031','124032','124033','124035','124036','124037','124038','124039','124040','124041','124042','124043','124044','124045','124046','124047','124048','124049','124050','124051','124052','124053','124054','124055','124056','124057','124058','124059','124060','124061','124062','124063','124064','124065','126001','126002','126003','126004','126005','126006','126007','126008','126009','126010','126011','126012','130001','132001','132002','132003','133001','133008','133009','133010','133011','133012','133013','133014','133015','133016','133017','133018','133019','133020','133021','133022','133023','133024','133025','133027','133028','133029','133030','133031','134001','135001','135002','135003','135004','135005','135006','135007','135008','135009','135010','136001','137009','137010','137011','137012','137013','137014','137015','137016','137017','137018','137019','138001','138002','138003','138004','139001','139003','140001','141001','141002','141003','141006','141007','141008','141009','141011','141012','141014','141015','141016','141017','141018','141019','141020','141021','141022','141023','141024','141025','141026','141027','141028','142001','142002','142003','142004','142005','142006','142007','142008','142010','142011','142012','144001','145001','145002','145003','145004','145005','145006','145007','145008','145009','145010','145011','145012','145013','145014','145015','145016','147001','150003','150005','150009','150013','150014','150015','150016','150017','150020','150021','152001','152002','152003','152004','152005','152006','152007','154001','154002','154003','155001','155002','155003','155004','155005','155006','159001','159002','159003','159004','160001','160002','160003','161001','162001','162002','162003','162004','162007','162010','162011','162012','163001','163002','163003','163005','163010','163011','163014','163015','163016','165001','165002','165003','165004','165005','165006','165007','165008','165009','165010','165011','165012','165013','165014','165015','165016','165017','165018','165019','165020','165021','165022','165023','165024','165025','165026','165027','165028','165029','165030','165031','165032','165033','165034','165035','165036','167001','168001','168002','168003','168004','168005','168007','168008','168009','168010','168011','168012','168013','168014','169001','169002','169003','169007','169008','169009','169010','170001','171001','171002','171003','171004','171005','171006','171007','171008','171009','172001','174001','174002','174003','176001','176002','176003','177001','177002','179001','179002','179003','179004','179005','179006','179007','179008','179009','179010','179011','179012','179013','179014','179015','179016','179017','179018','179019','179020','179021','179022','179023','179024','179025','179026','179027','179028','179029','179030','179031','179032','179033','179034','179035','179036','179037','179038','179039','179040','179041','179042','179043','179044','179045','179046','179047','180001','180010','180012','180013','180014','180015','180016','180017','180018','180019','180020','180021','180022','180023','180024','180025','180026','180027','180028','180030','180031','180032','180033','180034','180035','180036','180037','180038','180039','180041','180042','180043','180044','180045','180046','180047','180048','180049','180050','180051','180052','180053','180054','180055','180056','180057','180058','180059','180060','180061','180062','180063','180064','180065','180066','180067','180068','180069','180070','180071','182001','184001','184002','184005','184006','184007','184008','184009','184010','184011','185001','185003','187001','188001','188002','188003','188004','188005','188006','188007','188008','188009','188010','188011','191001','191002','192002','194001','194002','194003','194004','194005','194006','194007','195001','195002','195003','195004','195005','195006','195007','196001','196002','197001','197002','197003','197004','197005','197006','198001','198003','198004','198005','198006','198007','198008','198009','198010','198011','198012','198013','198014','198015','198016','198017','201001','201002','201005','202001','203001','203002','203003','203017','203018','203019','204001','204002','204003','205001','208001','208002','208003','208004','208005','209001','209002','209003','210001','210002','210003','210004','210005','210006','210007','210008','210009','210010','210011','210012','210013','211017','212001','212002','212003','212004','212005','212006','212007','212008','212009','212010','212011','212012','212013','218001','218003','218004','218006','218007','218008','218009','218011','218015','218016','218017','218018','218019','218020','218021','218022','218023','218024','218025','218026','218027','218028','218029','218030','218031','218032','218033','218034','218035','218036','221001','221002','221003','221004','221005','221006','221007','221008','221009','221010','221011','221012','221013','223001','223002','223003','224001','224002','224003','224006','224007','224008','225001','225002','225003','225004','225005','225006','225007','225008','225009','225010','225011','225012','225013','226001','226002','226003','226004','226005','226006','226007','226008','226009','227001','227002','227003','227004','227005','227006','227007','227008','227009','227010','227011','227012','227013','227014','227015','227016','227017','227018','227019','227020','227021','227022','227023','227024','227025','227026','227027','227028','227029','227030','227031','227032','227033','227034','227035','227036','227037','227038','227039','227040','227041','227042','227043','227044','227045','227046','227047','227048','227049','227050','227051','227052','227053','227054','227055','227056','227057','227058','227059','227060','227061','227062','227063','227064','227065','227066','227067','227068','227069','227070','227071','227072','227073','227074','227075','227076','227077','227078','227079','227080','227081','227082','227083','227084','227085','227086','227087','227088','227089','227090','227091','227092','227093','227094','227095','227096','227097','227098','227099','227100','227101','227102','227103','227104','227105','227106','227107','227108','227109','227110','227111','227112','227113','227114','227115','227116','227117','227118','227119','227120','227122','227123','227124','227125','227126','227127','227128','227129','227130','227131','227132','227133','227134','227135','227136','227137','227138','227139','227140','227141','227142','227143','227144','227145','227146','227147','227148','227149','227150','227151','227152','228001','229001','229002','229003','229004','229005','230001','230002','232001','233001','233002','233003','233004','233005','233006','233007','233008','234001','234002','234003','234004','234005','234006','234007','234008','234009','234010','234011','234012','234013','234014','234015','234016','234017','234018','234019','234020','234021','234022','234023','234024','234025','234026','234027','234028','234029','234030','235001','235002','235003','235004','235005','236001','236002','236003','237001','238002','238003','238004','238005','238006','238007','238008','333013','333014','333015','333016','333017','333018','333019','333020','333021','333022','333023','333024','333025','333030','333031','333032','333033','333034','333035','334001','334002','334003','334004','334005','334006','334007','336004','337001','337002','337003','337004','339001','339002','343001','344001','344002','344003','344004','344005','345001','345002','345003','347001','347002','348001','348002','348003','348004','348005','349001','349002','349003','350001','353001','353002','353003','353004','355001','355002','355003','355004','355005','355006','356001','358001','359001','359002','360001','360002','360003','360004','360005','366001','366002','366003','366004','369001','373001','373002','373003','373004','373005','373006','373007','373008','373009','373010','373011','373012','373013','373014','373015','373016','373017','373018','373019','373020','373021','374001','374002','374003','374004','374005','374006','374007','374008','374009','374010','374011','374012','374013','374014','374015','374016','376001','376002','376003','376004','376005','376006','376007','376008','376009','376010','376011','376012','376013','376016','376017','376018','376019','376020','376021','379003','382001','382002','383001','384001','384002','385001','385002','386001','386002','386003','386004','386005','386006','386007','386008','386009','386010','386011','386012','386013','386014','387001','389001','389002','389003','389004','392001','393001','393002','393003','393004','395001','396001','397001','397002','399001','399002','399003','400001','400002','401001','401002','401003','402001','402002','402003','402004','402005','403001','403002','403003','504001','504002','504004','504005','504006','504007','504008','504009','504010','504011','504012','504013','504014','504017','504018','504019','504021','504022','504023','504024','504025','506001','506002','508001','508002','511001','511002','511003','511004','511005','511006','511007','511008','511009','511010','511011','511012','511013','511014','511017','511018','511020','511021','511022','511024','511028','511029','513001','513002','513003','513004','514001','515001','515002','515003','515007','515008','515009','515010','515011','515012','515013','515014','515015','518001','518002','518003','520001','520002','521001','521002','521003','521004','521005','521006','521007','521008','521009','521010','521011','521012','521013','521014','521015','521016','523001','523002','523003','523004','523005','523006','523007','524001','700001','701001','701002','701003','702001','702002','702003','702004','702005','702006','702007','702008','703001','703002','703003','704001','704002','704003','704004','705001','706001','706002','707001','707002','707003','708001','709001','709002','710001','710002','711001','711002','712001','713001','713002','714001','714002','715001','716001','718001','718002','719001','719002','991001','991002','991003','991004','991005','991006','991007','991008','992001','995001','996001','996002','996003','998001','998002','998003','998004','998005','998006','998007','999001','999002','011017','011018','034001','034002','071010','208006','239001','519001','519003','126013','184012','053071','374017','374018','374019','374020','374021','404001','405002','405001','405003','405007','405006','405005','405004','240011','240010','240009','240008','240007','240006','240005','240004','240003','240002','240001','240012','240013','240014','240015','240016','240017','357001','235006','235007','712002','355008','355007','056023','999999','046015','019005','126014','241003','241002','241001','240018','240020','240019','242001','242002','242003','242004','242005','242006','089002','406001','406002','406003','406004','406005','406006','243001','243002','243003','243004','243005','243006','243007','243008','010030','010029','407001','407006','407005','407004','407003','407002','408001','366005','133032','016035','077010','996004','025064','011019','407007','407008','407009','409001','115123','504026','039007','039009','039008','039010','039011','039012','180072','240021','240023','408002','405008','235008','525001','525002','525003','525004','410001','410002','410003','410004','410005','410006','410007','410008','410009','410010','410011','410012','410013','410014','410015','410016','344006','240031','240030','240029','240028','240027','240026','240025','240024','240034','240033','240032','410017','410018','411001','411002','411003','411004','411005','411006','411007','411008','203020','203021','203022','412001','412002','412003','412004','069025','244001','244002','244009','244008','244007','244006','244005','244004','244003','244015','244014','244013','244012','244011','244010','244016','244017','240042','240041','240040','240039','240038','240037','240036','240035','405009','405010','240043','504034','504033','504032','504031','504030','504029','504028','504027','504042','504041','504040','504039','504038','504037','504036','504035','800001','410019','410020','410021','244018','244019','244020','399004','413001','504043','198018','198019','344007','082045','010031','010032','010033','010034','010035','504044','515016','801002','801003','801004','801005','802001','801001','414001','414002','414003','141029','141030','803001','803002','803003','803004','803005','803006','803007','803008','803009','803010','803011','803012','803013','803014','803015','803016','803017','410022','410023','803018','803019','803020','415002','415001','244021','011020','011023','011022','011021','025065','165037','165038','165039','416001','416002','416003','417001','418001','504045','803022','803021','240022','419001','420001','804010','804009','804008','804007','804006','804005','804004','804003','804002','804001','804020','804019','804018','804017','804016','804015','804014','804013','804012','804011','804024','804021','804023','804022','511019','511016','511015','511032','511031','511030','511027','511026','511025','511033','511023','133034','133033','169011','344008','344009','244022','244026','244025','244030','244023','244024','244027','244028','244029','244031','082046','082047','082048','126015','126016','416004','416005','421001','421002','016037','016036','115124','115125','115126','240049','240048','240047','240046','240045','240044','244032','244033','422001','422002','422003','422004','422005','184013','239002','805001','805002','805003','805004','805005','056024','423001','344010','235009','212014','056025','056026','802002','244034','244035','244036','244037','244038','244039','515017','504046','203015','245002','245001','071023','056027','056028','056029','056030','056031','056032','424001','056034','056033','805006','805007','805008','805009','805010','422008','422007','422006','422010','422009','422011','209004','150022','150023','100002','056035','023036','185004','185005','246001','247001','247002','425001','416006','165042','165041','165040','165043','010040','010039','010038','010037','010036','422012','422013','422014','422015','426000','248001','248002','248003','248004','248005','249001','249002','249003','249004','249005','249006','250007','250001','250002','250003','250004','250005','250006','250008','250009','250010','250011','250012','250013','251001','251002','422016','422017','422018','806001','806002','116013','235010','235011','091026','091027','091028','091029','091019','091020','091021','091022','091023','091024','091025','252001','243009','249007','249008','249009','011024','011025','427001','428002','428001','169012','429001','429002','429003') DEFAULT '001001' NOT NULL,
- KEY field (field)
-);
-INSERT INTO t1 VALUES ('001001'),('001001'),('001001'),('001001'),('001001'),('001001'),('001001'),('001001'),('001001'),('001010'),('001010'),('001010'),('001010'),('001010'),('001018'),('001018'),('001018'),('001018'),('001018'),('001018'),('001020'),('001020'),('001020'),('001020'),('001020'),('001020'),('001020'),('001020'),('001021'),('001021'),('001021'),('001021'),('001021'),('001021'),('001027'),('001027'),('001028'),('001030'),('001030'),('001030'),('001030'),('001031'),('001031'),('001031'),('001031'),('001031'),('001100'),('001100'),('002003'),('002003'),('002003'),('002003'),('002003'),('002003'),('002003'),('002003'),('002003'),('002004'),('002004'),('002004'),('002004'),('002004'),('002004'),('002004'),('002004'),('002004'),('002005'),('002005'),('002005'),('002005'),('002005'),('002005'),('002005'),('002005'),('002007'),('002007'),('002007'),('002007'),('002007'),('002007'),('002007'),('002008'),('002008'),('002008'),('002008'),('002008'),('002008'),('002008'),('002008'),('002009'),('002009'),('002009'),('002009'),('002009'),('002009'),('002009'),('002009'),('002012'),('002012'),('002012'),('002012'),('002012'),('002012'),('002012'),('002013'),('002013'),('002013'),('002013'),('002013'),('002013'),('002013'),('002013'),('002013'),('002014'),('002014'),('002014'),('002014'),('002014'),('002014'),('002014'),('002014'),('003002'),('003002'),('003002'),('003002'),('003002'),('003002'),('003003'),('003003'),('003003'),('003003'),('003003'),('003003'),('003004'),('003004'),('003004'),('003004'),('003004'),('003004'),('003005'),('003005'),('003005'),('003005'),('003005'),('003005'),('003005'),('003005'),('003005'),('003006'),('003006'),('003006'),('003006'),('003006'),('003006'),('003006'),('003006'),('003007'),('003007'),('003007'),('003007'),('003007'),('003008'),('003008'),('003008'),('003008'),('003008'),('003008'),('003009'),('003009'),('003009'),('003009'),('003009'),('003009'),('003009'),('003009'),('003009'),('003010'),('003010'),('003010'),('003010'),('003010'),('003010'),('003010'),('003010'),('003010'),('003011'),('003011'),('003011'),('003011'),('003011'),('003011'),('003011'),('003011'),('003012'),('003012'),('003012'),('003012'),('003012'),('003012'),('003012'),('003012'),('003013'),('003013'),('003013'),('003013'),('003013'),('003013'),('003013'),('003013'),('003014'),('003014'),('003014'),('003014'),('003014'),('003014'),('003014'),('003014'),('003015'),('003015'),('003015'),('003015'),('003015'),('003015'),('003016'),('003016'),('003016'),('003016'),('003016'),('003016'),('003017'),('003017'),('003017'),('003017'),('003017'),('003018'),('003018'),('003018'),('003018'),('003018'),('003019'),('003019'),('004003'),('004005'),('004005'),('004005'),('004005'),('004005'),('004005'),('004006'),('004008'),('004010'),('004012'),('004012'),('004014'),('004014'),('004014'),('004014'),('004014'),('004016'),('004017'),('004017'),('004017'),('004017'),('004017'),('004017'),('004017'),('004017'),('004020'),('004020'),('004020'),('004020'),('004020'),('004020'),('004021'),('004021'),('004021'),('004021'),('004021'),('004021'),('004021'),('004022'),('004023'),('004023'),('004023'),('004023'),('004023'),('004023'),('004023'),('004025'),('004026'),('004026'),('004026'),('004026'),('004026'),('006004'),('006006'),('006010'),('006010'),('006010'),('006010'),('006010'),('006010'),('006010'),('006011'),('006011'),('006011'),('006011'),('006011'),('006011'),('006012'),('006012'),('006012'),('006012'),('006012'),('006012'),('006014'),('006014'),('006014'),('007001'),('007001'),('007002'),('007003'),('007005'),('007007'),('007008'),('007009'),('007011'),('007012'),('007013'),('007015'),('007016'),('007017'),('007018'),('007019'),('007019'),('007020'),('007021'),('007021'),('007022'),('007023'),('007023'),('007025'),('007025'),('007025'),('007027'),('007029'),('007031'),('007031'),('007032'),('007034'),('007034'),('007036'),('007036'),('007036'),('007037'),('007037'),('007038'),('007040'),('007040'),('007040'),('007043'),('009001'),('009001'),('009001'),('009001'),('009001'),('009001'),('009001'),('009002'),('009002'),('009002'),('009002'),('009002'),('009004'),('009004'),('009004'),('009004'),('009005'),('009005'),('009005'),('009005'),('009005'),('009005'),('009005'),('009005'),('009006'),('009006'),('009006'),('009006'),('009007'),('009007'),('009007'),('009007'),('009007'),('009007'),('009008'),('009010'),('009010'),('009010'),('009010'),('009010'),('009010'),('009011'),('009011'),('009011'),('009011'),('009011'),('009012'),('009013'),('009013'),('009013'),('010002'),('010002'),('010002'),('010002'),('010002'),('010002'),('010002'),('010002'),('010003'),('010003'),('010003'),('010003'),('010003'),('010003'),('010003'),('010003'),('010003'),('010004'),('010004'),('010004'),('010004'),('010004'),('010004'),('010004'),('010004'),('010004'),('010005'),('010005'),('010005'),('010005'),('010006'),('010006'),('010006'),('010006'),('010006'),('010006'),('010006'),('010006'),('010006'),('010007'),('010007'),('010007'),('010007'),('010007'),('010007'),('010008'),('010008'),('010008'),('010008'),('010008'),('010008'),('010008'),('010009'),('010009'),('010009'),('010009'),('010009'),('010009'),('010010'),('010010'),('010010'),('010010'),('010010'),('010010'),('010010'),('010011'),('010011'),('010011'),('010011'),('010011'),('010011'),('010011'),('010011'),('010012'),('010012'),('010012'),('010012'),('010012'),('010012'),('010012'),('010013'),('010013'),('010013'),('010013'),('010013'),('010013'),('010015'),('010016'),('010016'),('010016'),('010016'),('010016'),('010016'),('010016'),('010016'),('010017'),('010017'),('010017'),('010017'),('010017'),('010017'),('010018'),('010018'),('010018'),('010018'),('010018'),('010018'),('010018'),('010018'),('010018'),('010019'),('010019'),('010019'),('010019'),('010019'),('010019'),('010020'),('010020'),('010020'),('010021'),('010021'),('010021'),('010021'),('010021'),('010021'),('010022'),('010022'),('010022'),('010022'),('010022'),('010022'),('010022'),('010022'),('010023'),('010023'),('010023'),('010023'),('010023'),('010023'),('010023'),('010023'),('010026'),('010027'),('010028'),('010028'),('011001'),('011001'),('011001'),('011001'),('011001'),('011001'),('011001'),('011002'),('011002'),('011002'),('011002'),('011002'),('011002'),('011002'),('011003'),('011003'),('011003'),('011003'),('011003'),('011003'),('011003'),('011003'),('011004'),('011004'),('011004'),('011004'),('011004'),('011004'),('011004'),('011006'),('011006'),('011006'),('011006'),('011006'),('011006'),('011006'),('011012'),('011012'),('011012'),('011013'),('011013'),('011013'),('011013'),('011013'),('011013'),('011014'),('011014'),('011014'),('011014'),('011015'),('011015'),('011015'),('011015'),('011015'),('011016'),('011016'),('011016'),('011016'),('011016'),('012017'),('012017'),('012027'),('012027'),('012032'),('012034'),('012036'),('012036'),('012037'),('012037'),('012038'),('012039'),('014001'),('014001'),('016016'),('016016'),('016016'),('016019'),('016020'),('016020'),('016020'),('016020'),('016020'),('016020'),('016020'),('016020'),('016021'),('016021'),('016021'),('016021'),('016021'),('016021'),('016021'),('016022'),('016022'),('016022'),('016023'),('016023'),('016023'),('016024'),('016024'),('016024'),('016024'),('016024'),('016024'),('016024'),('016026'),('016026'),('016026'),('016026'),('016026'),('016026'),('016028'),('016028'),('016028'),('016028'),('016028'),('016028'),('016028'),('016029'),('016029'),('016030'),('016031'),('016032'),('016032'),('016032'),('016032'),('016032'),('016032'),('016032'),('016033'),('016033'),('016033'),('016033'),('016033'),('016034'),('016034'),('016034'),('016034'),('016034'),('017002'),('017002'),('017002'),('017002'),('017002'),('018001'),('018001'),('018001'),('018001'),('018001'),('018001'),('018001'),('018001'),('019002'),('019002'),('019002'),('019002'),('019002'),('019002'),('019004'),('019004'),('019004'),('019004'),('019004'),('019004'),('020001'),('020001'),('020001'),('020001'),('020004'),('020006'),('020006'),('020006'),('020006'),('020006'),('020006'),('020008'),('020009'),('020009'),('020009'),('020009'),('020009'),('022001'),('022001'),('022001'),('022001'),('022002'),('022002'),('022002'),('022002'),('022003'),('022003'),('022003'),('022003'),('023001'),('023002'),('023002'),('023002'),('023002'),('023002'),('023002'),('023003'),('023003'),('023003'),('023003'),('023004'),('023004'),('023005'),('023005'),('023006'),('023006'),('023006'),('023006'),('023006'),('023006'),('023007'),('023007'),('023010'),('023010'),('023011'),('023011'),('023017'),('023019'),('023019'),('023019'),('023020'),('023020'),('023025'),('023025'),('023025'),('023026'),('023026'),('023026'),('023027'),('023027'),('023027'),('023028'),('023028'),('023029'),('023029'),('023030'),('023030'),('023032'),('023033'),('023033'),('023033'),('023033'),('023033'),('023033'),('023034'),('023035'),('023035'),('025001'),('025001'),('025001'),('025001'),('025001'),('025001'),('025001'),('025003'),('025003'),('025004'),('025004'),('025005'),('025005'),('025007'),('025007'),('025008'),('025008'),('025009'),('025010'),('025010'),('025010'),('025011'),('025011'),('025012'),('025012'),('025013'),('025013'),('025013'),('025014'),('025015'),('025016'),('025018'),('025018'),('025019'),('025019'),('025020'),('025020'),('025021'),('025022'),('025022'),('025023'),('025023'),('025024'),('025025'),('025025'),('025026'),('025026'),('025027'),('025027'),('025027'),('025028'),('025030'),('025031'),('025033'),('025034'),('025035'),('025037'),('025041'),('025042'),('025043'),('025046'),('025048'),('025048'),('025048'),('025049'),('025049'),('025049'),('025050'),('025050'),('025050'),('025051'),('025051'),('025052'),('025052'),('025052'),('025053'),('025053'),('025054'),('025054'),('025054'),('025054'),('025055'),('025056'),('025056'),('025056'),('025056'),('025056'),('025056'),('025056'),('025056'),('025056'),('025057'),('025057'),('025058'),('025058'),('025060'),('025060'),('025061'),('025062'),('025063'),('027001'),('027002'),('027011'),('036001'),('036001'),('036001'),('036001'),('036001'),('037003'),('037006'),('037007'),('037008'),('037008'),('038009'),('039001'),('039001'),('039001'),('039001'),('039001'),('039001'),('039002'),('039002'),('039002'),('039002'),('039002'),('039003'),('039003'),('039003'),('039003'),('039003'),('039003'),('039004'),('039004'),('039004'),('039004'),('039004'),('039005'),('039005'),('039005'),('039005'),('039005'),('039006'),('039006'),('039006'),('039006'),('046001'),('046001'),('046001'),('046001'),('046001'),('046001'),('046001'),('046001'),('046002'),('046002'),('046002'),('046002'),('046002'),('046002'),('046002'),('046002'),('046003'),('046003'),('046003'),('046003'),('046003'),('046003'),('046003'),('046005'),('046005'),('046005'),('046005'),('046005'),('046005'),('046005'),('046007'),('046007'),('046007'),('046007'),('046007'),('046007'),('046008'),('046008'),('046008'),('046008'),('046008'),('046009'),('046009'),('046009'),('046010'),('046012'),('046012'),('046012'),('046013'),('046014'),('046014'),('046014'),('047001'),('047001'),('047001'),('047001'),('047001'),('047001'),('047001'),('047001'),('047002'),('047002'),('047002'),('047002'),('047002'),('047002'),('047002'),('047002'),('048001'),('048001'),('048001'),('048001'),('048001'),('048001'),('048001'),('048001'),('051003'),('051003'),('051003'),('051003'),('051003'),('051004'),('051004'),('051004'),('051004'),('052001'),('052001'),('052001'),('052001'),('052001'),('052001'),('052001'),('052001'),('052002'),('052002'),('052005'),('052005'),('052005'),('052005'),('052005'),('052005'),('053016'),('053019'),('053019'),('053023'),('053023'),('053023'),('053023'),('053024'),('053024'),('053024'),('053026'),('053026'),('053026'),('053026'),('053028'),('053028'),('053029'),('053029'),('053029'),('053029'),('053033'),('053033'),('053033'),('053045'),('053046'),('053051'),('053051'),('053051'),('053054'),('053054'),('053054'),('053054'),('053057'),('053069'),('053069'),('053097'),('053107'),('053125'),('053125'),('053127'),('054001'),('054001'),('054001'),('054001'),('054001'),('054001'),('054001'),('054002'),('054002'),('054002'),('054002'),('054002'),('054002'),('054003'),('054003'),('054003'),('054003'),('054003'),('054003'),('054003'),('054004'),('054004'),('054004'),('054004'),('054004'),('054004'),('054004'),('054006'),('054006'),('054006'),('054007'),('054007'),('054007'),('054007'),('054007'),('054009'),('054009'),('054009'),('054009'),('054010'),('054010'),('054010'),('054010'),('054010'),('054010'),('054010'),('056001'),('056001'),('056001'),('056001'),('056001'),('056001'),('056001'),('056001'),('056001'),('056002'),('056002'),('056002'),('056002'),('056002'),('056002'),('056002'),('056002'),('056003'),('056003'),('056003'),('056003'),('056003'),('056003'),('056004'),('056004'),('056004'),('056004'),('056004'),('056004'),('056004'),('056005'),('056005'),('056005'),('056005'),('056005'),('056005'),('056005'),('056005'),('056005'),('056006'),('056006'),('056006'),('056006'),('056006'),('056006'),('056006'),('056006'),('056006'),('056009'),('056009'),('056009'),('056011'),('056016'),('056016'),('056016'),('056016'),('056016'),('056016'),('056016'),('056017'),('056017'),('056017'),('056017'),('056017'),('056017'),('056017'),('056017'),('056017'),('056018'),('056018'),('056018'),('056018'),('056018'),('056018'),('056019'),('056019'),('056019'),('056019'),('056019'),('056019'),('056019'),('056019'),('056020'),('056020'),('056020'),('056020'),('056022'),('056022'),('056022'),('056022'),('056022'),('057003'),('057003'),('057004'),('058002'),('058002'),('058002'),('058002'),('058003'),('058003'),('058003'),('058003'),('058004'),('058004'),('058004'),('058005'),('058005'),('058005'),('060001'),('060001'),('060001'),('060001'),('060001'),('060004'),('060004'),('060004'),('060004'),('060004'),('060004'),('060005'),('060005'),('060005'),('060005'),('060005'),('060005'),('060007'),('060007'),('060007'),('060007'),('060007'),('060007'),('060007'),('061004'),('061004'),('061004'),('061004'),('061004'),('061004'),('061006'),('061006'),('061006'),('061006'),('061006'),('061006'),('069006'),('069006'),('069006'),('069006'),('069006'),('069006'),('069006'),('069006'),('069006'),('069007'),('069007'),('069007'),('069007'),('069007'),('069007'),('069007'),('069007'),('069010'),('069010'),('069010'),('069010'),('069010'),('069010'),('069011'),('069012'),('069012'),('069012'),('069012'),('069012'),('069012'),('069012'),('069012'),('069012'),('069012'),('069013'),('069013'),('069013'),('069013'),('069013'),('069013'),('069013'),('069013'),('069013'),('069014'),('069014'),('069014'),('069014'),('069014'),('069014'),('069014'),('069014'),('069014'),('069015'),('069015'),('069015'),('069015'),('069015'),('069015'),('069015'),('069015'),('069015'),('069015'),('069016'),('069016'),('069016'),('069016'),('069016'),('069018'),('069018'),('069018'),('069018'),('069018'),('069018'),('069018'),('069018'),('069018'),('069020'),('069020'),('069020'),('069020'),('069021'),('069023'),('071002'),('071002'),('071002'),('071002'),('071002'),('071003'),('071003'),('071003'),('071003'),('071003'),('071004'),('071004'),('071004'),('071004'),('071004'),('071005'),('071005'),('071005'),('071005'),('071005'),('071005'),('071006'),('071006'),('071006'),('071006'),('071008'),('071008'),('071008'),('071008'),('071008'),('071008'),('071011'),('071011'),('071011'),('071011'),('071011'),('071020'),('071020'),('071020'),('071020'),('071020'),('071021'),('071022'),('071022'),('071022'),('072001'),('072001'),('074001'),('074002'),('074002'),('074002'),('074002'),('074002'),('074002'),('074002'),('074002'),('074003'),('074003'),('074003'),('074003'),('074003'),('074003'),('074003'),('074003'),('074004'),('074004'),('074004'),('074004'),('074004'),('074004'),('074004'),('074004'),('074005'),('074005'),('074005'),('074005'),('074005'),('074005'),('074005'),('074005'),('074006'),('074006'),('074006'),('074006'),('074006'),('074006'),('074006'),('074006'),('074007'),('074007'),('074007'),('074007'),('074007'),('074007'),('074007'),('074007'),('074008'),('074008'),('074008'),('074008'),('074008'),('074008'),('074008'),('074008'),('074009'),('074009'),('074009'),('074009'),('074009'),('074009'),('074009'),('074009'),('074010'),('074010'),('074010'),('074010'),('074010'),('074010'),('074010'),('074010'),('074011'),('074011'),('074011'),('074011'),('074011'),('074011'),('074011'),('074011'),('074012'),('074012'),('074012'),('074012'),('074012'),('074012'),('074012'),('075001'),('075001'),('075001'),('075007'),('075007'),('075007'),('075007'),('076101'),('076101'),('076101'),('076101'),('076102'),('076102'),('076102'),('076103'),('076103'),('076103'),('076103'),('076103'),('077001'),('077001'),('077001'),('077002'),('077002'),('077002'),('077002'),('077002'),('077002'),('077002'),('077003'),('077003'),('077003'),('077003'),('077003'),('077003'),('077003'),('077004'),('077004'),('077004'),('077004'),('077004'),('077004'),('077006'),('077006'),('077008'),('077008'),('077008'),('077008'),('077008'),('077008'),('077008'),('077009'),('077009'),('077009'),('077009'),('077009'),('077009'),('077009'),('078005'),('078005'),('078005'),('079002'),('079002'),('079002'),('079002'),('079002'),('079002'),('079002'),('079003'),('079003'),('079004'),('079004'),('079005'),('079005'),('079005'),('079005'),('079005'),('079005'),('079006'),('079006'),('079006'),('079006'),('079007'),('079007'),('079007'),('079007'),('079007'),('081001'),('081001'),('081001'),('081001'),('081001'),('082011'),('082011'),('082011'),('082011'),('082011'),('082013'),('082013'),('082013'),('082013'),('082013'),('082013'),('082014'),('082014'),('082014'),('082014'),('082014'),('082014'),('082014'),('082015'),('082015'),('082015'),('082015'),('082015'),('082016'),('082016'),('082016'),('082016'),('082016'),('082016'),('082017'),('082017'),('082017'),('082017'),('082017'),('082017'),('082017'),('082021'),('082021'),('082022'),('082022'),('082022'),('082022'),('082022'),('082023'),('082023'),('082023'),('082023'),('082023'),('082024'),('082024'),('082024'),('082024'),('082024'),('082025'),('082025'),('082025'),('082025'),('082025'),('082026'),('082026'),('082026'),('082026'),('082026'),('082027'),('082027'),('082027'),('082027'),('082027'),('082028'),('082028'),('082028'),('082028'),('082029'),('082029'),('082029'),('082029'),('082029'),('082030'),('082030'),('082030'),('082030'),('082031'),('082031'),('082031'),('082031'),('082031'),('082032'),('082032'),('082032'),('082033'),('082033'),('082034'),('082034'),('082034'),('082034'),('082034'),('082034'),('082034'),('082035'),('082035'),('082035'),('082036'),('082036'),('082036'),('082036'),('082037'),('082037'),('082037'),('082038'),('082038'),('082038'),('082038'),('082039'),('082039'),('082039'),('082039'),('082040'),('082040'),('082040'),('082040'),('082040'),('082041'),('082041'),('082041'),('082041'),('082042'),('082042'),('082043'),('082043'),('082043'),('082043'),('082043'),('082044'),('082044'),('082044'),('082044'),('084001'),('084002'),('084002'),('084002'),('084002'),('084003'),('084003'),('084003'),('084003'),('084003'),('084003'),('084003'),('084003'),('084004'),('084004'),('084004'),('084004'),('084004'),('084005'),('084005'),('084005'),('084005'),('084005'),('084007'),('084007'),('084007'),('084007'),('084007'),('084007'),('084008'),('084008'),('084008'),('084008'),('084008'),('084008'),('084009'),('084009'),('084009'),('084009'),('084009'),('084009'),('084011'),('084013'),('084013'),('084013'),('084013'),('084013'),('084014'),('084014'),('084014'),('084016'),('084016'),('084016'),('084016'),('084016'),('084016'),('084016'),('084016'),('084017'),('084017'),('084017'),('084017'),('084017'),('084017'),('084017'),('084017'),('084017'),('084027'),('084027'),('084027'),('084027'),('084027'),('084027'),('084032'),('084032'),('084033'),('084033'),('084033'),('084035'),('084035'),('084035'),('084036'),('084036'),('084036'),('084036'),('084036'),('084036'),('084037'),('084037'),('084038'),('084038'),('084038'),('084038'),('084038'),('084038'),('084039'),('084039'),('084039'),('084039'),('084040'),('084040'),('084040'),('084040'),('084040'),('084041'),('084041'),('084041'),('084041'),('084042'),('084042'),('084043'),('084043'),('084043'),('084043'),('084044'),('084044'),('084044'),('084044'),('084044'),('084045'),('084046'),('084046'),('084046'),('084047'),('084048'),('084048'),('084049'),('084049'),('084050'),('084051'),('084051'),('085001'),('085001'),('085001'),('085001'),('085001'),('085001'),('085002'),('085002'),('085002'),('085002'),('085003'),('085003'),('085003'),('085003'),('085003'),('085003'),('085003'),('085004'),('085004'),('085004'),('085004'),('085004'),('085004'),('085004'),('085005'),('085005'),('085005'),('085005'),('085005'),('085005'),('085006'),('085006'),('085006'),('085006'),('085006'),('085006'),('085006'),('085006'),('085007'),('085007'),('085007'),('085007'),('085007'),('085007'),('085007'),('085009'),('085009'),('085009'),('085009'),('085009'),('085009'),('085011'),('085011'),('085011'),('085011'),('085011'),('085011'),('085011'),('085011'),('085012'),('085012'),('085012'),('085012'),('085012'),('085012'),('085012'),('085014'),('085014'),('085014'),('085014'),('085014'),('085014'),('085014'),('085014'),('085014'),('085015'),('085015'),('085015'),('085015'),('085015'),('085015'),('085015'),('085015'),('085016'),('085016'),('085016'),('085016'),('085016'),('085016'),('085016'),('085016'),('085017'),('085017'),('085017'),('085017'),('085017'),('085018'),('085018'),('085018'),('085018'),('085018'),('085019'),('085019'),('085019'),('085019'),('085019'),('085019'),('085019'),('085019'),('085019'),('085020'),('085020'),('085020'),('085020'),('085020'),('085020'),('085022'),('085022'),('085022'),('085022'),('085022'),('085022'),('085023'),('085023'),('085023'),('085023'),('085023'),('085028'),('085028'),('085028'),('085028'),('085028'),('085028'),('085028'),('085029'),('085029'),('085029'),('085029'),('085029'),('085029'),('085029'),('085030'),('085030'),('085030'),('085030'),('085030'),('085030'),('085030'),('085031'),('085031'),('085031'),('085031'),('085031'),('085031'),('085031'),('085033'),('085034'),('085034'),('085034'),('085034'),('085034'),('085034'),('085034'),('085035'),('085035'),('085035'),('085035'),('085035'),('085035'),('085036'),('085036'),('085036'),('085036'),('085036'),('085036'),('085037'),('085037'),('085037'),('085037'),('085037'),('085037'),('085038'),('085038'),('085038'),('085038'),('085038'),('085038'),('085038'),('085040'),('085040'),('085040'),('085040'),('085040'),('085040'),('085040'),('085040'),('085041'),('085041'),('085041'),('085041'),('085041'),('085041'),('085041'),('085041'),('085042'),('085042'),('085042'),('085042'),('085042'),('085042'),('085042'),('085043'),('085043'),('085043'),('085043'),('085043'),('085043'),('085044'),('085044'),('085044'),('085044'),('085044'),('085044'),('085044'),('085045'),('085045'),('085045'),('085045'),('085045'),('085046'),('085046'),('085046'),('085046'),('085046'),('085046'),('085046'),('085046'),('085047'),('085047'),('085047'),('085047'),('085047'),('085047'),('085047'),('085047'),('085048'),('085048'),('085048'),('085048'),('085048'),('085048'),('085048'),('085063'),('085063'),('085063'),('085063'),('085063'),('085064'),('085064'),('085064'),('085064'),('085064'),('085065'),('085065'),('085068'),('085068'),('085068'),('085068'),('085068'),('085068'),('085071'),('085071'),('085071'),('085071'),('085071'),('085071'),('085073'),('085073'),('085082'),('085082'),('085082'),('085082'),('085082'),('085086'),('085086'),('085086'),('085088'),('085088'),('085088'),('085088'),('085088'),('085088'),('085088'),('085089'),('085089'),('085090'),('085090'),('085090'),('085090'),('085090'),('085090'),('085090'),('085090'),('085091'),('085091'),('085091'),('085091'),('085091'),('085092'),('085092'),('085092'),('085093'),('085093'),('085095'),('085095'),('085095'),('085095'),('085095'),('085096'),('085096'),('085096'),('085096'),('085096'),('085096'),('085097'),('085097'),('085097'),('085097'),('085097'),('085098'),('085098'),('085098'),('085098'),('085098'),('085098'),('085098'),('085099'),('085099'),('085099'),('085099'),('085099'),('085099'),('085099'),('085100'),('085100'),('085100'),('085100'),('085100'),('085100'),('085100'),('085100'),('085100'),('085100'),('085101'),('085101'),('085101'),('085101'),('085101'),('085101'),('085101'),('085101'),('085102'),('085102'),('085103'),('085103'),('085103'),('085104'),('085104'),('085104'),('085104'),('085104'),('085105'),('085105'),('085106'),('085106'),('085106'),('085106'),('085106'),('085106'),('085108'),('085108'),('085109'),('085109'),('085109'),('085109'),('085109'),('085109'),('085109'),('085109'),('085110'),('085110'),('085110'),('085110'),('085110'),('085111'),('085111'),('085111'),('085112'),('085112'),('085112'),('085112'),('085113'),('085113'),('085113'),('085113'),('085113'),('085115'),('085120'),('085121'),('085121'),('085121'),('085121'),('085122'),('085122'),('085122'),('085122'),('085122'),('085122'),('085122'),('085122'),('085123'),('085123'),('085123'),('085123'),('085123'),('085123'),('085123'),('085123'),('085125'),('085125'),('085125'),('085125'),('085125'),('085126'),('085126'),('085126'),('085126'),('085126'),('085127'),('085127'),('085127'),('085127'),('085127'),('085127'),('085127'),('085127'),('085128'),('085128'),('085128'),('085128'),('085128'),('085129'),('085129'),('085129'),('085129'),('085129'),('085130'),('085130'),('085130'),('085130'),('085130'),('085132'),('085132'),('085132'),('085132'),('085132'),('085132'),('085133'),('085133'),('085133'),('085133'),('085133'),('085134'),('085134'),('085134'),('085135'),('085135'),('085135'),('085136'),('085136'),('085136'),('085136'),('085137'),('085137'),('085137'),('085137'),('085137'),('085137'),('085137'),('086002'),('086002'),('086002'),('086002'),('086003'),('086003'),('086003'),('086003'),('086005'),('088001'),('088001'),('088001'),('088001'),('088001'),('088003'),('088003'),('088003'),('088003'),('088003'),('088003'),('088005'),('088005'),('088005'),('088005'),('088005'),('088006'),('088006'),('088006'),('088006'),('088006'),('088007'),('088007'),('088007'),('088008'),('088008'),('088008'),('088008'),('088009'),('088009'),('088009'),('088009'),('088009'),('089001'),('089001'),('089001'),('089001'),('089001'),('089001'),('089001'),('090001'),('090001'),('090001'),('090001'),('090001'),('090001'),('090001'),('090002'),('090002'),('090002'),('090002'),('090002'),('090002'),('090003'),('090003'),('090003'),('090003'),('090003'),('090003'),('090003'),('090004'),('090004'),('090004'),('090004'),('090004'),('090004'),('090004'),('090006'),('090006'),('090006'),('090006'),('090006'),('090006'),('090006'),('090008'),('090008'),('090008'),('090008'),('090008'),('090009'),('090009'),('090009'),('090009'),('090009'),('090010'),('090010'),('090013'),('090013'),('090013'),('090016'),('090016'),('090017'),('090018'),('090022'),('090027'),('091001'),('091001'),('091001'),('091001'),('091001'),('091001'),('091002'),('091002'),('091002'),('091002'),('091002'),('091002'),('091009'),('091009'),('091009'),('091009'),('091009'),('091011'),('091011'),('091011'),('091011'),('091011'),('091011'),('091011'),('091012'),('091012'),('091013'),('091013'),('091013'),('091013'),('091013'),('091013'),('091015'),('091015'),('091015'),('091015'),('091015'),('091015'),('091016'),('091016'),('091016'),('091016'),('091016'),('091017'),('091017'),('091018'),('091018'),('091018'),('091018'),('093003'),('093003'),('093003'),('093003'),('093003'),('093003'),('099001'),('099001'),('099001'),('099001'),('099001'),('099001'),('099001'),('100001'),('100001'),('100001'),('100001'),('106001'),('113005'),('113005'),('113005'),('113006'),('113006'),('113018'),('113019'),('113020'),('115001'),('115001'),('115001'),('115002'),('115002'),('115003'),('115004'),('115004'),('115004'),('115004'),('115005'),('115005'),('115005'),('115006'),('115006'),('115006'),('115007'),('115007'),('115007'),('115007'),('115007'),('115008'),('115008'),('115008'),('115009'),('115010'),('115010'),('115010'),('115010'),('115010'),('115011'),('115011'),('115011'),('115011'),('115012'),('115012'),('115013'),('115013'),('115013'),('115014'),('115014'),('115014'),('115014'),('115015'),('115015'),('115015'),('115016'),('115016'),('115016'),('115016'),('115017'),('115017'),('115017'),('115017'),('115017'),('115018'),('115018'),('115020'),('115020'),('115021'),('115021'),('115022'),('115022'),('115022'),('115023'),('115023'),('115023'),('115023'),('115023'),('115025'),('115025'),('115025'),('115026'),('115026'),('115027'),('115027'),('115027'),('115028'),('115028'),('115028'),('115028'),('115029'),('115029'),('115029'),('115030'),('115030'),('115030'),('115031'),('115031'),('115032'),('115032'),('115032'),('115033'),('115033'),('115033'),('115033'),('115034'),('115034'),('115034'),('115035'),('115035'),('115036'),('115036'),('115036'),('115036'),('115036'),('115039'),('115040'),('115040'),('115040'),('115041'),('115041'),('115041'),('115041'),('115041'),('115042'),('115042'),('115042'),('115042'),('115042'),('115043'),('115043'),('115043'),('115044'),('115044'),('115044'),('115044'),('115046'),('115046'),('115046'),('115047'),('115048'),('115050'),('115050'),('115050'),('115050'),('115050'),('115051'),('115051'),('115051'),('115052'),('115053'),('115053'),('115054'),('115054'),('115054'),('115055'),('115055'),('115055'),('115057'),('115059'),('115059'),('115059'),('115059'),('115060'),('115060'),('115060'),('115060'),('115060'),('115060'),('115061'),('115061'),('115061'),('115062'),('115062'),('115062'),('115062'),('115064'),('115064'),('115064'),('115065'),('115065'),('115065'),('115065'),('115066'),('115066'),('115066'),('115067'),('115067'),('115067'),('115068'),('115068'),('115068'),('115069'),('115069'),('115069'),('115069'),('115069'),('115070'),('115070'),('115070'),('115071'),('115071'),('115071'),('115072'),('115072'),('115072'),('115073'),('115073'),('115075'),('115075'),('115075'),('115076'),('115076'),('115076'),('115076'),('115076'),('115076'),('115081'),('115081'),('115081'),('115082'),('115082'),('115082'),('115085'),('115085'),('115085'),('115085'),('115085'),('115086'),('115086'),('115086'),('115087'),('115087'),('115088'),('115088'),('115088'),('115088'),('115088'),('115095'),('115095'),('115095'),('115096'),('115096'),('115097'),('115097'),('115098'),('115098'),('115099'),('115101'),('115102'),('115102'),('115102'),('115103'),('115103'),('115104'),('115104'),('115104'),('115104'),('115105'),('115105'),('115106'),('115106'),('115106'),('115106'),('115106'),('115108'),('115109'),('115111'),('115111'),('115111'),('115111'),('115112'),('115112'),('115112'),('115112'),('115112'),('115113'),('115113'),('115113'),('115114'),('115114'),('115114'),('115114'),('115114'),('115115'),('115115'),('115115'),('115115'),('115116'),('115117'),('115117'),('115117'),('115118'),('115118'),('115119'),('115119'),('115119'),('115119'),('115120'),('115121'),('115121'),('115122'),('115122'),('116001'),('116003'),('116003'),('116003'),('116003'),('116004'),('116004'),('116005'),('116005'),('116006'),('116006'),('116006'),('116007'),('116007'),('116008'),('116008'),('116009'),('116009'),('116009'),('116010'),('116010'),('116010'),('116010'),('116011'),('116011'),('116011'),('116011'),('116012'),('116012'),('123001'),('123001'),('123001'),('123001'),('123001'),('124065'),('126001'),('126001'),('126001'),('126001'),('126001'),('126001'),('126001'),('126001'),('126002'),('126002'),('126002'),('126002'),('126002'),('126002'),('126002'),('126002'),('126003'),('126003'),('126003'),('126003'),('126003'),('126003'),('126003'),('126003'),('126003'),('126004'),('126004'),('126004'),('126004'),('126004'),('126004'),('126004'),('126004'),('126004'),('126004'),('126005'),('126005'),('126005'),('126005'),('126005'),('126005'),('126005'),('126005'),('126005'),('126006'),('126006'),('126006'),('126006'),('126006'),('126006'),('126006'),('126006'),('126006'),('126007'),('126007'),('126007'),('126007'),('126007'),('126007'),('126007'),('126008'),('126008'),('126008'),('126008'),('126008'),('126008'),('126008'),('126008'),('126009'),('126009'),('126009'),('126009'),('126009'),('126009'),('126009'),('126009'),('126010'),('126010'),('126010'),('126010'),('126010'),('126010'),('126010'),('126010'),('126010'),('126011'),('126011'),('126011'),('126011'),('126011'),('126011'),('126011'),('126012'),('126012'),('126012'),('126012'),('130001'),('130001'),('130001'),('130001'),('132001'),('132001'),('132001'),('132001'),('132001'),('132002'),('132002'),('132002'),('132002'),('132002'),('132002'),('132002'),('133001'),('133001'),('133008'),('133009'),('133010'),('133011'),('133011'),('133011'),('133011'),('133011'),('133011'),('133012'),('133015'),('133015'),('133015'),('133015'),('133016'),('133018'),('133018'),('133018'),('133018'),('133018'),('133019'),('133021'),('133021'),('133022'),('133022'),('133023'),('133023'),('133024'),('133024'),('133024'),('133024'),('133024'),('133024'),('133025'),('133027'),('133027'),('133027'),('133027'),('133027'),('133028'),('133028'),('133028'),('133029'),('133029'),('133029'),('133029'),('133029'),('133029'),('133030'),('133030'),('133031'),('133031'),('133031'),('134001'),('134001'),('134001'),('135001'),('135001'),('135001'),('135001'),('135001'),('135002'),('135002'),('135002'),('135004'),('135010'),('135010'),('135010'),('135010'),('135010'),('135010'),('137010'),('137011'),('137012'),('137014'),('137015'),('137015'),('137016'),('137019'),('139001'),('140001'),('140001'),('140001'),('140001'),('140001'),('140001'),('141001'),('141001'),('141001'),('141001'),('141001'),('141002'),('141002'),('141002'),('141002'),('141002'),('141003'),('141003'),('141003'),('141003'),('141003'),('141003'),('141003'),('141003'),('141006'),('141006'),('141006'),('141006'),('141006'),('141006'),('141006'),('141006'),('141007'),('141007'),('141007'),('141007'),('141007'),('141009'),('141009'),('141009'),('141009'),('141009'),('141011'),('141011'),('141011'),('141011'),('141011'),('141011'),('141012'),('141014'),('141014'),('141014'),('141014'),('141014'),('141014'),('141014'),('141014'),('141015'),('141015'),('141015'),('141015'),('141015'),('141016'),('141016'),('141016'),('141016'),('141016'),('141016'),('141017'),('141017'),('141017'),('141017'),('141017'),('141017'),('141018'),('141018'),('141018'),('141018'),('141019'),('141019'),('141019'),('141019'),('141020'),('141020'),('141020'),('141020'),('141020'),('141020'),('141020'),('141021'),('141021'),('141021'),('141021'),('141021'),('141021'),('141022'),('141022'),('141022'),('141022'),('141022'),('141022'),('141023'),('141023'),('141023'),('141023'),('141023'),('141023'),('141023'),('141024'),('141025'),('141025'),('141025'),('141026'),('141026'),('141026'),('141026'),('141026'),('141026'),('141027'),('141027'),('141027'),('141027'),('141027'),('141028'),('141028'),('145001'),('145001'),('145001'),('145001'),('145001'),('145001'),('145001'),('145001'),('145001'),('145002'),('145002'),('145002'),('145002'),('145002'),('145002'),('145002'),('145002'),('145002'),('145003'),('145003'),('145003'),('145003'),('145003'),('145003'),('145003'),('145003'),('145003'),('145003'),('145004'),('145004'),('145004'),('145004'),('145004'),('145004'),('145004'),('145004'),('145004'),('145005'),('145005'),('145005'),('145005'),('145005'),('145005'),('145005'),('145005'),('145005'),('145006'),('145006'),('145006'),('145006'),('145006'),('145006'),('145006'),('145006'),('145006'),('145008'),('145008'),('145008'),('145008'),('145008'),('145008'),('145008'),('145008'),('145009'),('145009'),('145009'),('145009'),('145009'),('145009'),('145009'),('145011'),('145011'),('145011'),('145011'),('145011'),('145011'),('145011'),('145011'),('145012'),('145012'),('145012'),('145012'),('145012'),('145012'),('145012'),('145012'),('145013'),('145013'),('145013'),('145013'),('145013'),('145013'),('145013'),('150009'),('150013'),('150014'),('150015'),('150015'),('150015'),('150016'),('150016'),('150017'),('150017'),('150017'),('150017'),('150020'),('152001'),('152001'),('152001'),('152002'),('152003'),('152003'),('152003'),('152003'),('152004'),('152005'),('152006'),('152006'),('152006'),('152006'),('152007'),('154001'),('154002'),('154002'),('155001'),('155001'),('155002'),('155003'),('155004'),('155004'),('155006'),('159001'),('159003'),('160001'),('160001'),('160001'),('160001'),('160002'),('160002'),('161001'),('162002'),('162002'),('162003'),('162003'),('162003'),('162003'),('162003'),('162007'),('162012'),('162012'),('162012'),('163001'),('163001'),('163001'),('163011'),('163015'),('163016'),('163016'),('165001'),('165001'),('165001'),('165001'),('165002'),('165002'),('165002'),('165002'),('165003'),('165003'),('165003'),('165004'),('165004'),('165004'),('165005'),('165005'),('165005'),('165006'),('165006'),('165006'),('165006'),('165007'),('165007'),('165007'),('165007'),('165008'),('165008'),('165008'),('165008'),('165009'),('165009'),('165009'),('165009'),('165010'),('165010'),('165010'),('165011'),('165011'),('165012'),('165012'),('165012'),('165013'),('165013'),('165013'),('165014'),('165014'),('165014'),('165015'),('165015'),('165015'),('165015'),('165016'),('165016'),('165016'),('165017'),('165017'),('165017'),('165017'),('165018'),('165018'),('165018'),('165018'),('165019'),('165019'),('165019'),('165019'),('165020'),('165020'),('165020'),('165020'),('165021'),('165021'),('165021'),('165021'),('165022'),('165022'),('165022'),('165023'),('165024'),('165024'),('165024'),('165025'),('165025'),('165025'),('165026'),('165026'),('165026'),('165028'),('165029'),('165030'),('165030'),('165030'),('165031'),('165031'),('165033'),('165033'),('165034'),('165034'),('165034'),('165035'),('165035'),('165035'),('165036'),('165036'),('165036'),('168003'),('168003'),('168004'),('168005'),('168014'),('169001'),('169001'),('169001'),('169001'),('169001'),('169001'),('169001'),('169001'),('169001'),('169001'),('169002'),('169002'),('169002'),('169002'),('169002'),('169002'),('169002'),('169002'),('169002'),('169002'),('169003'),('169003'),('169003'),('169003'),('169007'),('169007'),('169007'),('169007'),('169007'),('169007'),('169007'),('169007'),('169007'),('169007'),('169008'),('169008'),('169008'),('169008'),('169008'),('169008'),('169008'),('169009'),('169009'),('169009'),('169009'),('169010'),('171006'),('171006'),('171007'),('171007'),('171008'),('171008'),('171008'),('171009'),('171009'),('171009'),('172001'),('176001'),('176001'),('176001'),('176001'),('176001'),('176001'),('176001'),('176002'),('176002'),('176002'),('176002'),('176002'),('176003'),('176003'),('176003'),('176003'),('176003'),('176003'),('177001'),('177001'),('177001'),('177001'),('177001'),('177001'),('179007'),('179007'),('179012'),('179012'),('179012'),('179012'),('179012'),('179012'),('179013'),('179013'),('179013'),('179013'),('179013'),('179013'),('179042'),('179044'),('179045'),('180001'),('180013'),('180014'),('180014'),('180015'),('180017'),('180018'),('180020'),('180020'),('180021'),('180021'),('180027'),('180030'),('180033'),('180035'),('180036'),('180037'),('180038'),('180041'),('180042'),('180045'),('180045'),('180047'),('180048'),('180049'),('180050'),('180054'),('180060'),('180066'),('180067'),('180068'),('180070'),('182001'),('184001'),('184002'),('184005'),('184005'),('184005'),('184005'),('184006'),('184006'),('184006'),('184006'),('184008'),('184008'),('184008'),('184008'),('184009'),('184009'),('184009'),('184009'),('184010'),('184010'),('184010'),('184010'),('184011'),('184011'),('184011'),('184011'),('185001'),('185001'),('185001'),('185001'),('185001'),('185001'),('185001'),('185003'),('185003'),('185003'),('185003'),('185003'),('185003'),('185003'),('187001'),('191002'),('191002'),('192002'),('194003'),('197001'),('197001'),('197001'),('197001'),('197001'),('197001'),('197001'),('197002'),('197002'),('197002'),('197002'),('197002'),('197002'),('197002'),('197003'),('197003'),('197003'),('197003'),('197003'),('197003'),('197003'),('197004'),('197004'),('197004'),('197004'),('197004'),('197004'),('197004'),('197005'),('197005'),('197005'),('197005'),('197005'),('197005'),('197006'),('197006'),('197006'),('197006'),('197006'),('198001'),('198001'),('198001'),('198001'),('198001'),('198001'),('198003'),('198003'),('198003'),('198004'),('198004'),('198004'),('198004'),('198004'),('198004'),('198005'),('198005'),('198005'),('198005'),('198005'),('198005'),('198005'),('198006'),('198006'),('198006'),('198006'),('198006'),('198006'),('198007'),('198007'),('198007'),('198007'),('198007'),('198007'),('198007'),('198008'),('198008'),('198008'),('198008'),('198008'),('198008'),('198009'),('198009'),('198009'),('198009'),('198009'),('198009'),('198009'),('198010'),('198010'),('198010'),('198010'),('198010'),('198010'),('198011'),('198012'),('198012'),('198012'),('198012'),('198015'),('198015'),('198016'),('198016'),('198016'),('198016'),('198016'),('198016'),('198017'),('198017'),('198017'),('198017'),('198017'),('198017'),('201001'),('201001'),('201001'),('201001'),('201001'),('201002'),('202001'),('202001'),('203001'),('203001'),('203001'),('203001'),('203001'),('203001'),('203001'),('203002'),('203002'),('203002'),('203002'),('203003'),('203003'),('203003'),('203003'),('203003'),('203017'),('203017'),('203017'),('203017'),('203017'),('203017'),('203017'),('203017'),('203017'),('203018'),('203018'),('203018'),('203018'),('203018'),('203019'),('203019'),('203019'),('203019'),('203019'),('204001'),('204002'),('205001'),('205001'),('205001'),('205001'),('205001'),('205001'),('205001'),('208001'),('208001'),('208002'),('208002'),('208002'),('208003'),('208003'),('208003'),('208004'),('208004'),('208004'),('208004'),('208004'),('208004'),('208004'),('208005'),('208005'),('208005'),('208005'),('208005'),('209001'),('209001'),('209001'),('209001'),('209001'),('209002'),('209002'),('209002'),('209002'),('209002'),('209003'),('209003'),('209003'),('209003'),('209003'),('210001'),('210001'),('210001'),('210001'),('210001'),('210004'),('210004'),('210004'),('210004'),('210004'),('210004'),('210009'),('210010'),('212001'),('212001'),('212002'),('212002'),('212002'),('212002'),('212003'),('212003'),('212003'),('212004'),('212004'),('212004'),('212005'),('212005'),('212005'),('212005'),('212005'),('212006'),('212006'),('212006'),('212007'),('212007'),('212008'),('212008'),('212008'),('212008'),('212009'),('212009'),('212009'),('212009'),('212010'),('212010'),('212010'),('212010'),('212011'),('212011'),('212012'),('212012'),('212013'),('212013'),('212013'),('218001'),('218004'),('218009'),('218011'),('218011'),('218015'),('218020'),('218021'),('218021'),('218022'),('218022'),('218022'),('218023'),('218024'),('218025'),('218026'),('218026'),('218027'),('218028'),('218029'),('218029'),('218029'),('218030'),('218031'),('221001'),('221001'),('221001'),('221001'),('221001'),('221001'),('221002'),('221002'),('221002'),('221002'),('221002'),('221002'),('221003'),('221003'),('221003'),('221003'),('221003'),('221003'),('221004'),('221004'),('221004'),('221004'),('221004'),('221004'),('221005'),('221005'),('221005'),('221005'),('221005'),('221006'),('221006'),('221006'),('221006'),('221006'),('221007'),('221007'),('221007'),('221007'),('221007'),('221007'),('221008'),('221008'),('221008'),('221008'),('221008'),('221008'),('221009'),('221009'),('221009'),('221009'),('221009'),('221009'),('221010'),('221010'),('221010'),('221010'),('221011'),('221011'),('221011'),('221011'),('221012'),('221012'),('221012'),('221012'),('221012'),('221012'),('221013'),('221013'),('221013'),('221013'),('221013'),('221013'),('223003'),('223003'),('224001'),('224001'),('224002'),('224002'),('224003'),('224007'),('224008'),('225001'),('225002'),('225002'),('225002'),('225003'),('225003'),('225003'),('225003'),('225004'),('225004'),('225004'),('225005'),('225005'),('225005'),('225005'),('225005'),('225005'),('225006'),('225006'),('225006'),('225007'),('225007'),('225007'),('225008'),('225008'),('225008'),('225008'),('225008'),('225009'),('225009'),('225009'),('225010'),('225010'),('225010'),('225011'),('225011'),('225011'),('225011'),('225011'),('225012'),('225012'),('225012'),('225012'),('225012'),('225012'),('225013'),('225013'),('226001'),('226002'),('226003'),('226003'),('226005'),('226005'),('226006'),('226007'),('226007'),('226007'),('226007'),('227011'),('227015'),('227015'),('227041'),('227045'),('227052'),('227056'),('227063'),('227064'),('227066'),('227067'),('227069'),('227071'),('227073'),('227085'),('227116'),('227119'),('227131'),('227133'),('227147'),('229005'),('229005'),('229005'),('233003'),('233004'),('235001'),('235001'),('235002'),('235003'),('235003'),('235003'),('235004'),('235005'),('235005'),('235005'),('235005'),('235005'),('235005'),('235005'),('236001'),('236001'),('236001'),('236001'),('236002'),('236003'),('236003'),('236003'),('236003'),('236003'),('236003'),('238002'),('238002'),('238002'),('238002'),('238002'),('238002'),('238003'),('238003'),('238003'),('238003'),('238003'),('238003'),('238004'),('238004'),('238004'),('238004'),('238004'),('238005'),('238005'),('238005'),('238007'),('238007'),('238007'),('238007'),('238007'),('238007'),('238007'),('238008'),('238008'),('238008'),('238008'),('238008'),('238008'),('238008'),('334005'),('334006'),('337001'),('337001'),('337001'),('337002'),('337002'),('337003'),('337003'),('337003'),('337004'),('343001'),('343001'),('344001'),('344002'),('344003'),('344004'),('344005'),('344005'),('345001'),('345001'),('348001'),('348004'),('348005'),('348005'),('349001'),('349001'),('349002'),('349002'),('349002'),('350001'),('353002'),('353002'),('353002'),('353003'),('355001'),('355002'),('355005'),('355006'),('355006'),('356001'),('358001'),('358001'),('358001'),('359001'),('359001'),('359002'),('359002'),('359002'),('359002'),('360001'),('360001'),('360002'),('360002'),('360003'),('360003'),('360004'),('360004'),('360005'),('360005'),('360005'),('366001'),('366002'),('366002'),('366003'),('366004'),('369001'),('369001'),('373001'),('373002'),('373002'),('373003'),('373003'),('373005'),('373007'),('373008'),('373009'),('373009'),('373010'),('373010'),('373010'),('373011'),('373011'),('373011'),('373011'),('373012'),('373012'),('373012'),('373013'),('373013'),('373014'),('373014'),('373015'),('373015'),('373015'),('373015'),('373017'),('373017'),('373017'),('373017'),('373018'),('373021'),('374002'),('374004'),('374006'),('374007'),('374008'),('374009'),('374010'),('374011'),('374012'),('374015'),('374016'),('382001'),('382002'),('382002'),('384001'),('386001'),('386001'),('386001'),('386001'),('386001'),('386001'),('386001'),('386002'),('386002'),('386002'),('386002'),('386002'),('386002'),('386002'),('386003'),('386003'),('386003'),('386003'),('386003'),('386003'),('386003'),('386003'),('386003'),('386004'),('386004'),('386004'),('386004'),('386004'),('386004'),('386004'),('386004'),('386005'),('386005'),('386005'),('386005'),('386005'),('386005'),('386005'),('386006'),('386006'),('386006'),('386006'),('386006'),('386006'),('386007'),('386007'),('386007'),('386007'),('386007'),('386007'),('386007'),('386007'),('386007'),('386008'),('386008'),('386008'),('386008'),('386008'),('386008'),('386008'),('386008'),('386009'),('386009'),('386009'),('386010'),('386010'),('386010'),('386010'),('386010'),('386010'),('386010'),('386010'),('386011'),('386011'),('386011'),('386011'),('386011'),('386011'),('386011'),('386011'),('386011'),('386012'),('386012'),('386012'),('386012'),('386012'),('386012'),('386012'),('386012'),('386012'),('386013'),('386013'),('386013'),('386013'),('386013'),('386013'),('386013'),('386014'),('386014'),('386014'),('386014'),('389001'),('389002'),('389002'),('389003'),('389003'),('389003'),('389003'),('389004'),('389004'),('389004'),('389004'),('392001'),('393001'),('393002'),('393002'),('393003'),('393004'),('395001'),('395001'),('397001'),('397001'),('397001'),('397002'),('399001'),('399001'),('399001'),('399001'),('399001'),('399001'),('399001'),('399002'),('399002'),('399002'),('399002'),('399002'),('399002'),('399002'),('399003'),('400001'),('400001'),('400001'),('400001'),('400002'),('403002'),('504001'),('504001'),('504002'),('504002'),('504002'),('504004'),('504004'),('504005'),('504006'),('504007'),('504007'),('504007'),('504008'),('504008'),('504009'),('504009'),('504009'),('504009'),('504009'),('504010'),('504011'),('504011'),('504012'),('504012'),('504014'),('504014'),('504014'),('504014'),('504014'),('504014'),('504014'),('504014'),('504017'),('504017'),('504021'),('504021'),('504021'),('504021'),('504021'),('504021'),('504021'),('504022'),('504023'),('504023'),('504024'),('504024'),('504025'),('504025'),('506001'),('506001'),('506001'),('506001'),('506001'),('506001'),('506002'),('506002'),('506002'),('506002'),('506002'),('511001'),('511001'),('511001'),('511001'),('511001'),('511001'),('511001'),('511002'),('511002'),('511002'),('511002'),('511002'),('511002'),('511002'),('511003'),('511003'),('511003'),('511003'),('511003'),('511003'),('511004'),('511004'),('511004'),('511004'),('511004'),('511004'),('511004'),('511005'),('511005'),('511005'),('511005'),('511005'),('511005'),('511005'),('511006'),('511006'),('511006'),('511006'),('511006'),('511006'),('511006'),('511007'),('511007'),('511007'),('511007'),('511007'),('511008'),('511008'),('511008'),('511008'),('511008'),('511008'),('511009'),('511009'),('511009'),('511009'),('511009'),('511009'),('511010'),('511010'),('511010'),('511010'),('511010'),('511010'),('511011'),('511011'),('511011'),('511011'),('511011'),('511011'),('511012'),('511012'),('511012'),('511012'),('511012'),('511012'),('511012'),('511013'),('511013'),('511013'),('511013'),('511013'),('511013'),('511013'),('511014'),('511014'),('511014'),('511014'),('511014'),('511017'),('511018'),('511020'),('511021'),('511022'),('511024'),('511028'),('511029'),('511029'),('511029'),('511029'),('511029'),('511029'),('513001'),('513001'),('513001'),('513001'),('513001'),('513001'),('513001'),('513001'),('513002'),('513002'),('513002'),('513002'),('513002'),('513002'),('513003'),('513003'),('513003'),('513003'),('513003'),('513003'),('513003'),('513003'),('513004'),('513004'),('513004'),('515001'),('515001'),('515001'),('515001'),('515001'),('515002'),('515002'),('515003'),('515003'),('515007'),('515007'),('515008'),('515011'),('515011'),('515011'),('515011'),('515011'),('515011'),('515012'),('515012'),('515012'),('515012'),('515013'),('515013'),('515013'),('515013'),('515013'),('515014'),('515014'),('515014'),('515014'),('515014'),('515015'),('515015'),('515015'),('515015'),('515015'),('518001'),('518002'),('521001'),('521002'),('521002'),('521002'),('521003'),('521003'),('521003'),('521003'),('521004'),('521004'),('521004'),('521004'),('521005'),('521005'),('521005'),('521005'),('521006'),('521006'),('521006'),('521009'),('521010'),('521010'),('521010'),('521010'),('521011'),('521011'),('521011'),('521011'),('521012'),('521013'),('521013'),('521015'),('521016'),('521016'),('523001'),('523001'),('523001'),('523001'),('523001'),('523001'),('523001'),('523002'),('523002'),('523002'),('523002'),('523002'),('523002'),('523003'),('523003'),('523003'),('523003'),('523003'),('523003'),('523003'),('523004'),('523004'),('523004'),('523004'),('523004'),('523004'),('523005'),('523005'),('523005'),('523005'),('523005'),('523005'),('523005'),('523005'),('523006'),('523006'),('523006'),('523006'),('523006'),('523006'),('523006'),('523007'),('523007'),('523007'),('523007'),('523007'),('523007'),('523007'),('524001'),('700001'),('701001'),('701002'),('701003'),('702001'),('702002'),('702004'),('702005'),('704001'),('704004'),('705001'),('706001'),('706002'),('707001'),('707002'),('707003'),('708001'),('710001'),('710002'),('711001'),('711002'),('712001'),('714001'),('714002'),('715001'),('719001'),('719002'),('991002'),('991002'),('991002'),('991003'),('991003'),('991003'),('991003'),('991003'),('991003'),('991003'),('991004'),('991004'),('991004'),('991005'),('991005'),('991005'),('991006'),('991007'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('995001'),('996001'),('996001'),('996001'),('996001'),('996001'),('996001'),('996001'),('996001'),('996002'),('996002'),('996003'),('996003'),('996003'),('996003'),('996003'),('998001'),('998001'),('998001'),('998001'),('998001'),('998001'),('998001'),('998001'),('998001'),('998001'),('998002'),('998002'),('998002'),('998002'),('998002'),('998002'),('998002'),('998002'),('998002'),('998002'),('998003'),('998003'),('998003'),('998003'),('998003'),('998003'),('998003'),('998003'),('998004'),('998004'),('998005'),('998005'),('998006'),('998007'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999001'),('999002'),('999002'),('011017'),('011017'),('011017'),('011017'),('011017'),('011017'),('011017'),('011018'),('011018'),('011018'),('011018'),('034001'),('034001'),('034002'),('034002'),('071010'),('071010'),('071010'),('519001'),('126013'),('126013'),('126013'),('126013'),('126013'),('184012'),('184012'),('184012'),('404001'),('405002'),('405002'),('405001'),('405003'),('405006'),('240011'),('240011'),('240011'),('240011'),('240011'),('240011'),('240010'),('240010'),('240010'),('240009'),('240009'),('240009'),('240009'),('240008'),('240008'),('240008'),('240007'),('240007'),('240007'),('240007'),('240007'),('240007'),('240005'),('240005'),('240005'),('240005'),('240005'),('240004'),('240004'),('240004'),('240004'),('240004'),('240003'),('240003'),('240003'),('240003'),('240002'),('240002'),('240002'),('240002'),('240002'),('240002'),('240002'),('240001'),('240001'),('240001'),('240001'),('240001'),('240012'),('240012'),('240012'),('240012'),('240012'),('240013'),('240014'),('240015'),('240015'),('240015'),('240015'),('240015'),('240015'),('240015'),('240015'),('240016'),('240016'),('240016'),('240016'),('240016'),('240016'),('240017'),('240017'),('240017'),('357001'),('357001'),('235006'),('235006'),('235007'),('235007'),('235007'),('235007'),('235007'),('056023'),('056023'),('056023'),('056023'),('056023'),('046015'),('019005'),('019005'),('126014'),('126014'),('126014'),('126014'),('126014'),('126014'),('241003'),('241003'),('241003'),('241003'),('241003'),('241003'),('241002'),('241002'),('241002'),('241002'),('241002'),('241002'),('241001'),('241001'),('241001'),('241001'),('241001'),('240020'),('240020'),('240020'),('240020'),('240020'),('240020'),('240019'),('240019'),('240019'),('242001'),('242002'),('242004'),('242005'),('242006'),('089002'),('089002'),('089002'),('089002'),('089002'),('089002'),('406001'),('406002'),('406003'),('406004'),('406004'),('243001'),('243005'),('243006'),('243007'),('243008'),('408001'),('408001'),('408001'),('408001'),('408001'),('366005'),('366005'),('016035'),('016035'),('016035'),('016035'),('077010'),('996004'),('996004'),('996004'),('996004'),('996004'),('996004'),('996004'),('996004'),('025064'),('025064'),('025064'),('025064'),('011019'),('011019'),('011019'),('011019'),('011019'),('115123'),('115123'),('504026'),('039007'),('039009'),('039008'),('039008'),('039010'),('039010'),('039011'),('039012'),('180072'),('240021'),('240021'),('240021'),('240021'),('240021'),('240021'),('240021'),('240023'),('240023'),('240023'),('240023'),('405008'),('405008'),('525002'),('410002'),('410002'),('410004'),('410005'),('410005'),('410006'),('410007'),('410007'),('410008'),('410009'),('410010'),('410011'),('410011'),('410012'),('410012'),('410013'),('410013'),('410014'),('410014'),('410016'),('410016'),('344006'),('240031'),('240031'),('240031'),('240031'),('240030'),('240030'),('240030'),('240030'),('240029'),('240029'),('240029'),('240029'),('240028'),('240028'),('240028'),('240028'),('240027'),('240027'),('240026'),('240026'),('240026'),('240025'),('240025'),('240025'),('240025'),('240024'),('240024'),('240034'),('240034'),('240034'),('240033'),('240033'),('240033'),('240032'),('240032'),('240032'),('240032'),('411001'),('411002'),('203020'),('069025'),('069025'),('069025'),('069025'),('069025'),('069025'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244001'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244002'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244009'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244008'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244007'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244006'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244004'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244003'),('244014'),('244014'),('244014'),('244014'),('244014'),('244014'),('244014'),('244014'),('244013'),('244013'),('244013'),('244013'),('244013'),('244013'),('244013'),('244013'),('244012'),('244012'),('244012'),('244012'),('244012'),('244012'),('244012'),('244012'),('244011'),('244011'),('244011'),('244011'),('244011'),('244011'),('244011'),('244011'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244016'),('244017'),('244017'),('244017'),('244017'),('244017'),('244017'),('244017'),('244017'),('244017'),('240040'),('240037'),('405009'),('405009'),('405009'),('405010'),('405010'),('240043'),('240043'),('504028'),('504040'),('800001'),('410019'),('410019'),('410020'),('410020'),('410020'),('410021'),('410021'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244018'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244019'),('244020'),('244020'),('244020'),('244020'),('244020'),('244020'),('244020'),('244020'),('413001'),('344007'),('082045'),('082045'),('082045'),('082045'),('082045'),('010031'),('010031'),('010031'),('010031'),('010032'),('010032'),('010032'),('010032'),('010033'),('010033'),('010033'),('010033'),('010033'),('010034'),('010034'),('010034'),('010034'),('010035'),('010035'),('010035'),('010035'),('504044'),('515016'),('515016'),('515016'),('515016'),('801002'),('801003'),('801004'),('801005'),('802001'),('801001'),('414001'),('141029'),('803001'),('803002'),('803004'),('803005'),('803006'),('803007'),('803008'),('803009'),('803013'),('803014'),('803015'),('803016'),('803017'),('410022'),('410023'),('410023'),('803019'),('415002'),('415001'),('244021'),('244021'),('244021'),('244021'),('244021'),('244021'),('244021'),('011020'),('011020'),('011020'),('011020'),('011023'),('011023'),('011023'),('011023'),('011022'),('011022'),('011022'),('011022'),('011022'),('011022'),('011021'),('011021'),('011021'),('011021'),('025065'),('025065'),('025065'),('025065'),('165037'),('165037'),('165038'),('165038'),('165038'),('165039'),('416001'),('416001'),('416001'),('416001'),('416001'),('416002'),('416003'),('417001'),('418001'),('504045'),('504045'),('504045'),('803022'),('240022'),('240022'),('240022'),('240022'),('420001'),('420001'),('420001'),('420001'),('804010'),('804005'),('804002'),('804018'),('804013'),('511019'),('511016'),('511015'),('511032'),('511031'),('511030'),('511027'),('511026'),('511025'),('511033'),('511023'),('133034'),('133034'),('133034'),('133033'),('169011'),('169011'),('169011'),('169011'),('169011'),('344008'),('244022'),('244022'),('244022'),('244022'),('244022'),('244022'),('244022'),('244026'),('244026'),('244026'),('244026'),('244026'),('244026'),('244025'),('244025'),('244025'),('244025'),('244025'),('244025'),('244025'),('244025'),('244030'),('244030'),('244030'),('244030'),('244030'),('244030'),('244030'),('244030'),('244023'),('244023'),('244023'),('244023'),('244023'),('244023'),('244024'),('244024'),('244024'),('244024'),('244024'),('244024'),('244024'),('244024'),('244027'),('244027'),('244027'),('244027'),('244027'),('244027'),('244027'),('244027'),('244028'),('244028'),('244028'),('244028'),('244028'),('244028'),('244028'),('244028'),('244029'),('244029'),('244029'),('244029'),('244029'),('244029'),('244029'),('244029'),('244031'),('244031'),('244031'),('244031'),('244031'),('244031'),('244031'),('244031'),('082046'),('082046'),('082046'),('082046'),('082047'),('082047'),('082048'),('082048'),('126015'),('126015'),('126016'),('126016'),('126016'),('126016'),('126016'),('416005'),('421001'),('421001'),('421002'),('016037'),('016037'),('016037'),('016037'),('016036'),('016036'),('016036'),('016036'),('115124'),('115124'),('115126'),('240049'),('240049'),('240048'),('240048'),('240047'),('240047'),('240046'),('240046'),('240045'),('240044'),('244032'),('244033'),('422002'),('422004'),('422004'),('422004'),('422005'),('422005'),('184013'),('184013'),('184013'),('805001'),('805002'),('805003'),('805004'),('805005'),('056024'),('056024'),('056024'),('423001'),('344010'),('235009'),('235009'),('235009'),('235009'),('212014'),('212014'),('056025'),('056025'),('056025'),('056026'),('056026'),('056026'),('056026'),('056026'),('056026'),('244034'),('244034'),('244034'),('244034'),('244034'),('244034'),('244035'),('244035'),('244035'),('244035'),('244035'),('244035'),('244035'),('244036'),('244036'),('244036'),('244036'),('244036'),('244036'),('244036'),('244037'),('244037'),('244037'),('244037'),('244037'),('244037'),('244037'),('244038'),('244038'),('244038'),('244038'),('244038'),('244038'),('244038'),('244039'),('244039'),('244039'),('244039'),('244039'),('244039'),('244039'),('203015'),('245002'),('245002'),('245001'),('245001'),('056029'),('056030'),('056032'),('424001'),('056034'),('056034'),('056034'),('056034'),('056033'),('056033'),('056033'),('805006'),('805007'),('805008'),('805009'),('805010'),('422008'),('422008'),('422007'),('422007'),('422006'),('422006'),('422010'),('422009'),('422009'),('422011'),('422011'),('209004'),('209004'),('150022'),('100002'),('056035'),('056035'),('056035'),('023036'),('023036'),('185005'),('246001'),('246001'),('247001'),('247001'),('247001'),('247001'),('247001'),('247001'),('247001'),('247002'),('247002'),('425001'),('416006'),('416006'),('165042'),('165041'),('165040'),('165043'),('010040'),('010039'),('010038'),('010036'),('248001'),('248002'),('248003'),('248004'),('248005'),('249001'),('249003'),('249004'),('249005'),('250007'),('250001'),('250002'),('250003'),('250004'),('250005'),('250006'),('250008'),('250009'),('250010'),('250011'),('250012'),('250013'),('251001'),('251002'),('806001'),('806002'),('235010'),('243009'),('249007'),('249008'),('249009'),('011024'),('011025'),('429001'),('429001'),('429002'),('429002'),('429003'),('429003');
-select field from t1 group by field;
-drop table t1;
-
-#
-# test of problem with date fields
-#
-create table t1 (a char(16), b date, c datetime);
-insert into t1 SET a='test 2000-01-01', b='2000-01-01', c='2000-01-01';
-select * from t1 where c = '2000-01-01';
-select * from t1 where b = '2000-01-01';
-drop table t1;
-
-#
-# Test of delete when the delete will cause a node to disappear and reappear
-# (This assumes a block size of 1024)
-#
-
-create table t1 (a bigint not null, primary key (a,a,a,a,a,a,a,a,a,a));
-insert into t1 values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23);
-delete from t1 where a=26;
-drop table t1;
-create table t1 (a bigint not null, primary key (a,a,a,a,a,a,a,a,a,a));
-insert into t1 values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23),(27);
-delete from t1 where a=27;
-drop table t1;
-
-#
-# Test of ORDER BY (By found by Dean Edmonds)
-#
-
-create table t1 (ID int not null primary key, TransactionID int not null);
-insert into t1 (ID, TransactionID) values (1, 87), (2, 89), (3, 92), (4, 94), (5, 486), (6, 490), (7, 753), (9, 828), (10, 832), (11, 834), (12, 840);
-create table t2 (ID int not null primary key, GroupID int not null);
- insert into t2 (ID, GroupID) values (87, 87), (89, 89), (92, 92), (94, 94), (486, 486), (490, 490),(753, 753), (828, 828), (832, 832), (834, 834), (840, 840);
-create table t3 (ID int not null primary key, DateOfAction date not null);
-insert into t3 (ID, DateOfAction) values (87, '1999-07-19'), (89, '1999-07-19'), (92, '1999-07-19'), (94, '1999-07-19'), (486, '1999-07-18'), (490, '2000-03-27'), (753, '2000-03-28'), (828, '1999-07-27'), (832, '1999-07-27'),(834, '1999-07-27'), (840, '1999-07-27');
-select t3.DateOfAction, t1.TransactionID from t1 join t2 join t3 where t2.ID = t1.TransactionID and t3.ID = t2.GroupID order by t3.DateOfAction, t1.TransactionID;
-select t3.DateOfAction, t1.TransactionID from t1 join t2 join t3 where t2.ID = t1.TransactionID and t3.ID = t2.GroupID order by t1.TransactionID,t3.DateOfAction;
-drop table t1,t2,t3;
-
-#
-# Test of found bug in group on text key
-#
-
-CREATE TABLE t1 (
- f1 int(11) DEFAULT '0' NOT NULL,
- f2 varchar(16) DEFAULT '' NOT NULL,
- f5 text,
- KEY index_name (f1,f2,f5(16))
- );
-INSERT INTO t1 VALUES (0,'traktor','1111111111111');
-INSERT INTO t1 VALUES (1,'traktor','1111111111111111111111111');
-select count(*) from t1 where f2='traktor';
-drop table t1;
-
-#
-# Test of lock tables
-#
-
-create table t1 ( n int auto_increment primary key);
-lock tables t1 write;
-insert into t1 values(NULL);
-unlock tables;
-check table t1;
-lock tables t1 write, t1 as t0 read;
-insert into t1 values(NULL);
-unlock tables;
-check table t1;
-lock tables t1 write, t1 as t0 read, t1 as t2 read;
-insert into t1 values(NULL);
-unlock tables;
-check table t1;
-lock tables t1 write, t1 as t0 write, t1 as t2 read;
-insert into t1 values(NULL);
-unlock tables;
-check table t1;
-lock tables t1 write, t1 as t0 write, t1 as t2 read, t1 as t3 read;
-insert into t1 values(NULL);
-unlock tables;
-check table t1;
-lock tables t1 write, t1 as t0 write, t1 as t2 write;
-insert into t1 values(NULL);
-unlock tables;
-check table t1;
-drop table t1;
-
-#
-# Test of procedure
-#
-
-create table t1 (i int, j int);
-insert into t1 values (1,2), (3,4), (5,6), (7,8);
-select * from t1 procedure analyse();
-create table t2 select * from t1 procedure analyse();
-select * from t2;
-drop table t1,t2;
-
-#
-# Bug when using comparions of strings and integers.
-#
-
-CREATE TABLE t1 (id CHAR(12) not null, PRIMARY KEY (id));
-insert into t1 values ('000000000001'),('000000000002');
-explain select * from t1 where id=000000000001;
-select * from t1 where id=000000000001;
-delete from t1 where id=000000000002;
-select * from t1;
-drop table t1;
-
-#
-# Test of DATE_ADD
-#
-
-CREATE TABLE t1 (
- visitor_id int(10) unsigned DEFAULT '0' NOT NULL,
- group_id int(10) unsigned DEFAULT '0' NOT NULL,
- hits int(10) unsigned DEFAULT '0' NOT NULL,
- sessions int(10) unsigned DEFAULT '0' NOT NULL,
- ts timestamp(14),
- PRIMARY KEY (visitor_id,group_id)
-)/*! type=MyISAM */;
-INSERT INTO t1 VALUES (465931136,7,2,2,20000318160952);
-INSERT INTO t1 VALUES (173865424,2,2,2,20000318233615);
-INSERT INTO t1 VALUES (173865424,8,2,2,20000318233615);
-INSERT INTO t1 VALUES (173865424,39,2,2,20000318233615);
-INSERT INTO t1 VALUES (173865424,7,2,2,20000318233615);
-INSERT INTO t1 VALUES (173865424,3,2,2,20000318233615);
-INSERT INTO t1 VALUES (173865424,6,2,2,20000318233615);
-INSERT INTO t1 VALUES (173865424,60,2,2,20000318233615);
-INSERT INTO t1 VALUES (173865424,1502,2,2,20000318233615);
-INSERT INTO t1 VALUES (48985536,2,2,2,20000319013932);
-INSERT INTO t1 VALUES (48985536,8,2,2,20000319013932);
-INSERT INTO t1 VALUES (48985536,39,2,2,20000319013932);
-INSERT INTO t1 VALUES (48985536,7,2,2,20000319013932);
-INSERT INTO t1 VALUES (465931136,3,2,2,20000318160951);
-INSERT INTO t1 VALUES (465931136,119,1,1,20000318160953);
-INSERT INTO t1 VALUES (465931136,2,1,1,20000318160950);
-INSERT INTO t1 VALUES (465931136,8,1,1,20000318160950);
-INSERT INTO t1 VALUES (465931136,39,1,1,20000318160950);
-INSERT INTO t1 VALUES (1092858576,14,1,1,20000319013445);
-INSERT INTO t1 VALUES (357917728,3,2,2,20000319145026);
-INSERT INTO t1 VALUES (357917728,7,2,2,20000319145027);
-select visitor_id,max(ts) as mts from t1 group by visitor_id
-having mts < DATE_SUB(NOW(),INTERVAL 3 MONTH);
-select visitor_id,max(ts) as mts from t1 group by visitor_id
-having DATE_ADD(mts,INTERVAL 3 MONTH) < NOW();
-drop table t1;
-
-#
-# Test of rename table
-#
-
-create table t0 SELECT 1,"table 1";
-create table t2 SELECT 2,"table 2";
-create table t3 SELECT 3,"table 3";
-rename table t0 to t1;
-rename table t3 to t4, t2 to t3, t1 to t2, t4 to t1;
-select * from t1;
-rename table t3 to t4, t2 to t3, t1 to t2, t4 to t1;
-rename table t3 to t4, t2 to t3, t1 to t2, t4 to t1;
-select * from t1;
-# The following should give errors;
-rename table t1 to t2;
-rename table t1 to t1;
-rename table t3 to t4, t2 to t3, t1 to t2, t4 to t2;
-show tables like "t_";
-rename table t3 to t1, t2 to t3, t1 to t2, t4 to t1;
-rename table t3 to t4, t5 to t3, t1 to t2, t4 to t1;
-
-select * from t1;
-select * from t2;
-select * from t3;
-drop table if exists t1,t2,t3,t4;
-
-#
-# Test bug with long primary key
-#
-
-create table t1
-(
- SEQNO numeric(12 ) not null,
- MOTYPEID numeric(12 ) not null,
- MOINSTANCEID numeric(12 ) not null,
- ATTRID numeric(12 ) not null,
- VALUE varchar(120) not null,
- primary key (SEQNO, MOTYPEID, MOINSTANCEID, ATTRID, VALUE )
-);
-INSERT INTO t1 VALUES (1, 1, 1, 1, 'a');
-INSERT INTO t1 VALUES (1, 1, 1, 1, 'b');
-INSERT INTO t1 VALUES (1, 1, 1, 1, 'a'); # This should give an error
-drop table t1;
-
-#
-# Test of database indirection
-#
-
-use kf96;
-
-create table test.t1 (a int);
-insert into test.t1 values(1);
-update test.t1 set a=2 where a=1;
-delete from test.t1;
-use test;
-alter table t1 add b int, rename ok.t2;
-lock table ok.t2 WRITE;
-alter table ok.t2 rename ok.t3;
-lock table ok.t3 WRITE;
-alter table ok.t3 rename test.t4;
-drop table t4;
-UNLOCK TABLES;
-
-select count(ok.station.stationsnr) from ok.station;
-
-#
-# Test create and destroy of databases
-#
-
-create database bench_test;
-create table bench_test.test (a int);
-drop database bench_test;
-create database bench_test;
-create table bench_test.test (a int) raid_type=1;
-drop database bench_test;
-
-#
-# These should give errors:
-#
-create table gurgel.test (a int);
-select count(ok.station.stationsnr) from station;
-select count(station.stationsnr) from test.station;
-select count(gurgel.station.stationsnr) from ok.station;
-select count(gurgel.station.stationsnr) from gurgel.station;
-select 1 from ok.station order by 2;
-select 1 from ok.station group by 2;
-select 1 from ok.station order by ok.station.gurgel;
-select count(*),stationsnr from ok.station;
-create table `a/a` (a int);
-create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa int);
-create table a (`aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` int);
-
-#
-# Test of REPLACE with ISAM and MyISAM
-#
-
-CREATE TABLE t1 (
- gesuchnr int(11) DEFAULT '0' NOT NULL,
- benutzer_id int(11) DEFAULT '0' NOT NULL,
- TitelGesuch varchar(60) DEFAULT '' NOT NULL,
- text text DEFAULT '' NOT NULL,
- seconds int(11) DEFAULT '0' NOT NULL,
- neu char(1) DEFAULT '' NOT NULL,
- eingang date DEFAULT '0000-00-00' NOT NULL,
- bewerber_id int(10) unsigned DEFAULT '0' NOT NULL,
- server_id tinyint(4) DEFAULT '0' NOT NULL,
- deleted char(1) DEFAULT '' NOT NULL,
- KEY berwerber_id (bewerber_id),
- PRIMARY KEY (gesuchnr,benutzer_id),
- KEY benutzer_id (benutzer_id)
-) type=ISAM;
-
-replace into t1 (gesuchnr,benutzer_id) values (1,1);
-replace into t1 (gesuchnr,benutzer_id) values (1,1);
-alter table t1 type=myisam;
-replace into t1 (gesuchnr,benutzer_id) values (1,1);
-drop table t1;
-
-#
-# test of MERGE
-#
-create table t1 (a int not null primary key auto_increment, message char(20));
-create table t2 (a int not null primary key auto_increment, message char(20));
-INSERT INTO t1 (message) VALUES ("Testing"),("table"),("t1");
-INSERT INTO t2 (message) VALUES ("Testing"),("table"),("t2");
-create table t3 (a int not null, b char(20), key(a)) type=MERGE UNION=(t1,t2);
-select * from t3;
-select * from t3 order by a desc;
-drop table t3;
-insert into t1 select NULL,message from t2;
-insert into t2 select NULL,message from t1;
-insert into t1 select NULL,message from t2;
-insert into t2 select NULL,message from t1;
-insert into t1 select NULL,message from t2;
-insert into t2 select NULL,message from t1;
-insert into t1 select NULL,message from t2;
-insert into t2 select NULL,message from t1;
-insert into t1 select NULL,message from t2;
-insert into t2 select NULL,message from t1;
-insert into t1 select NULL,message from t2;
-create table t3 (a int not null, b char(20), key(a)) type=MERGE UNION=(t1,t2);
-explain select * from t3 where a < 10;
-explain select * from t3 where a > 10 and a < 20;
-select * from t3 where a = 10;
-select * from t3 where a < 10;
-select * from t3 where a > 10 and a < 20;
-explain select a from t3 order by a desc limit 10;
-select a from t3 order by a desc limit 10;
-select a from t3 order by a desc limit 300,10;
-
-# The following should give errors
-create table t4 (a int not null, b char(10), key(a)) type=MERGE UNION=(t1,t2);
-
-drop table if exists t1,t2,t3,t4;
-
-create table t1 (c char(10)) type=myisam;
-create table t2 (c char(10)) type=myisam;
-create table t3 (c char(10)) union=(t1,t2) type=merge;
-insert into t1 (c) values ('test1');
-insert into t1 (c) values ('test1');
-insert into t1 (c) values ('test1');
-insert into t2 (c) values ('test2');
-insert into t2 (c) values ('test2');
-insert into t2 (c) values ('test2');
-select * from t3;
-flush tables;
-select * from t3;
-delete from t3;
-select * from t3;
-select * from t1;
-drop table t3,t2,t1;
-
-#
-# Test of fulltext
-#
-CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b));
-INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),('Full-text indexes', 'are called collections'),('Only MyISAM tables','support collections'),('Function MATCH ... AGAINST()','is used to do a search'),('Full-text search in MySQL', 'implements vector space model');
-select * from t1 where MATCH(a,b) AGAINST ("collections");
-select * from t1 where MATCH(a,b) AGAINST ("indexes");
-select * from t1 where MATCH(a,b) AGAINST ("indexes collections");
-delete from t1 where a like "MySQL%";
-drop table t1;
-
-#
-# Test of Berkeley DB
-#
-
-CREATE TABLE t1 (
- id int(11) NOT NULL auto_increment,
- parent_id int(11) DEFAULT '0' NOT NULL,
- level tinyint(4) DEFAULT '0' NOT NULL,
- PRIMARY KEY (id),
- KEY parent_id (parent_id),
- KEY level (level)
-) type=bdb;
-INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),(24,4,2),(28,5,2),(29,5,2),(30,5,2),(31,6,2),(32,6,2),(33,6,2),(203,7,2),(202,7,2),(20,3,2),(157,0,0),(193,5,2),(40,7,2),(2,1,1),(15,2,2),(6,1,1),(34,6,2),(35,6,2),(16,3,2),(7,1,1),(36,7,2),(18,3,2),(26,5,2),(27,5,2),(183,4,2),(38,7,2),(25,5,2),(37,7,2),(21,4,2),(19,3,2),(5,1,1),(179,5,2);
-update t1 set parent_id=parent_id+100;
-select * from t1 where parent_id=102;
-update t1 set id=id+1000;
-update t1 set id=1024 where id=1009;
-select * from t1;
-update ignore t1 set id=id+1; # This will change all rows
-select * from t1;
-update ignore t1 set id=1023 where id=1010;
-select * from t1 where parent_id=102;
-drop table t1;
-
-create table t1 (n int not null primary key) type=bdb;
-set autocommit=0;
-insert into t1 values (4);
-select n, "before rollback" from t1;
-rollback;
-select n, "after rollback" from t1;
-insert into t1 values (4);
-select n, "before commit" from t1;
-commit;
-select n, "after commit" from t1;
-commit;
-drop table t1;
-set autocommit=1;
-
-CREATE TABLE t1 (ID INTEGER NOT NULL PRIMARY KEY, NAME VARCHAR(64)) TYPE=BDB;
-INSERT INTO t1 VALUES (1, 'Jochen');
-select * from t1;
-drop table t1;
-
-CREATE TABLE t1 ( _userid VARCHAR(60) NOT NULL PRIMARY KEY) TYPE=BDB;
-set autocommit=0;
-INSERT INTO t1 SET _userid='marc@anyware.co.uk';
-COMMIT;
-SELECT * FROM t1;
-SELECT _userid FROM t1 WHERE _userid='marc@anyware.co.uk';
-drop table t1;
-set autocommit=1;
-
-CREATE TABLE t1 (id char(8) not null primary key, val int not null) type=bdb;
-insert into t1 values ('pippo', 12);
-insert into t1 values ('pippo', 12); # Gives error
-delete from t1;
-delete from t1 where id = 'pippo';
-select * from t1;
-
-insert into t1 values ('pippo', 12);
-set autocommit=0;
-delete from t1;
-rollback;
-select * from t1;
-delete from t1;
-commit;
-select * from t1;
-drop table t1;
-set autocommit=1;
-
-#
-# Test when reading on part of unique key
-#
-CREATE TABLE t1 (
- user_id int(10) DEFAULT '0' NOT NULL,
- name varchar(100),
- phone varchar(100),
- ref_email varchar(100) DEFAULT '' NOT NULL,
- detail varchar(200),
- PRIMARY KEY (user_id,ref_email)
-)type=bdb;
-
-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');
-select * from t1 where user_id=10292;
-INSERT INTO t1 VALUES (10291,'sanjeev','29153373','sansh777@hotmail.com','xxx'),(10293,'shirish','2333604','shirish@yahoo.com','ddsds');
-select * from t1 where user_id=10292;
-select * from t1 where user_id>=10292;
-select * from t1 where user_id>10292;
-select * from t1 where user_id<10292;
-drop table t1;
-
-#
-# Test of ALTER TABLE and BDB tables
-#
-
-create table t1 (col1 int not null, col2 char(4) not null, primary key(col1));
-alter table t1 type=BDB;
-insert into t1 values ('1','1'),('5','2'),('2','3'),('3','4'),('4','4');
-select * from t1;
-update t1 set col2='7' where col1='4';
-select * from t1;
-alter table t1 add co3 int not null;
-select * from t1;
-update t1 set col2='9' where col1='2';
-select * from t1;
-drop table t1;
-
-#
-# INSERT INTO BDB tables
-#
-
-create table t1 (a int not null , b int, primary key (a)) type = BDB;
-create table t2 (a int not null , b int, primary key (a)) type = myisam;
-insert into t1 VALUES (1,3) , (2,3), (3,3);
-select * from t1;
-insert into t2 select * from t1;
-select * from t2;
-delete from t1 where b = 3;
-select * from t1;
-insert into t1 select * from t2;
-select * from t1;
-select * from t2;
-drop table t1,t2;
-
-#
-# Search on unique key
-#
-
-CREATE TABLE t1 (
- id int(11) NOT NULL auto_increment,
- ggid varchar(32) binary DEFAULT '' NOT NULL,
- email varchar(64) DEFAULT '' NOT NULL,
- passwd varchar(32) binary DEFAULT '' NOT NULL,
- PRIMARY KEY (id),
- UNIQUE ggid (ggid)
-) TYPE=BDB;
-
-insert into t1 (ggid,passwd) values ('test1','xxx');
-insert into t1 (ggid,passwd) values ('test2','yyy');
-
-select * from t1 where ggid='test1';
-select * from t1 where passwd='xxx';
-select * from t1 where id=2;
-drop table t1;
-
-#
-# ORDER BY on not primary key
-#
-
-CREATE TABLE t1 (
- user_name varchar(12),
- password text,
- subscribed char(1),
- user_id int(11) DEFAULT '0' NOT NULL,
- quota bigint(20),
- weight double,
- access_date date,
- access_time time,
- approved datetime,
- dummy_primary_key int(11) NOT NULL auto_increment,
- PRIMARY KEY (dummy_primary_key)
-) TYPE=BDB;
-INSERT INTO t1 VALUES ('user_0','somepassword','N',0,0,0,'2000-09-07','23:06:59','2000-09-07 23:06:59',1);
-INSERT INTO t1 VALUES ('user_1','somepassword','Y',1,1,1,'2000-09-07','23:06:59','2000-09-07 23:06:59',2);
-INSERT INTO t1 VALUES ('user_2','somepassword','N',2,2,1.4142135623731,'2000-09-07','23:06:59','2000-09-07 23:06:59',3);
-INSERT INTO t1 VALUES ('user_3','somepassword','Y',3,3,1.7320508075689,'2000-09-07','23:06:59','2000-09-07 23:06:59',4);
-INSERT INTO t1 VALUES ('user_4','somepassword','N',4,4,2,'2000-09-07','23:06:59','2000-09-07 23:06:59',5);
-select user_name, password , subscribed, user_id, quota, weight, access_date, access_time, approved, dummy_primary_key from t1 order by user_name;
-drop table t1;
diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result
index 86d2c3932ba..52999dfaf10 100644
--- a/mysql-test/r/func_time.result
+++ b/mysql-test/r/func_time.result
@@ -6,8 +6,8 @@ now()-now() weekday(curdate())-weekday(now()) unix_timestamp()-unix_timestamp(no
0 0 0
from_unixtime(unix_timestamp("1994-03-02 10:11:12")) from_unixtime(unix_timestamp("1994-03-02 10:11:12"),"%Y-%m-%d %h:%i:%s") from_unixtime(unix_timestamp("1994-03-02 10:11:12"))+0
1994-03-02 10:11:12 1994-03-02 10:11:12 19940302101112
-sec_to_time(9001) sec_to_time(9001)+0 time_to_sec("15:12:22")
-02:30:01 23001 54742
+sec_to_time(9001) sec_to_time(9001)+0 time_to_sec("15:12:22") sec_to_time(time_to_sec("0:30:47")/6.21)
+02:30:01 23001 54742 00:04:57
now()-curdate()*1000000-curtime()
0
strcmp(current_timestamp(),concat(current_date()," ",current_time()))
diff --git a/mysql-test/r/gemini.result b/mysql-test/r/gemini.result
index 46e14d3eee6..0b43b4f5192 100644
--- a/mysql-test/r/gemini.result
+++ b/mysql-test/r/gemini.result
@@ -362,3 +362,9 @@ _userid
marc@anyware.co.uk
_userid
marc@anyware.co.uk
+f1
+65
+379
+468
+469
+508
diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result
index aa372737b29..84a3151577c 100644
--- a/mysql-test/r/innodb.result
+++ b/mysql-test/r/innodb.result
@@ -475,3 +475,7 @@ a
1
2
4
+id name value uid
+1 one one value 101
+3 three three value 103
+6 two other value 102
diff --git a/mysql-test/r/rpl_get_lock.result b/mysql-test/r/rpl_get_lock.result
new file mode 100644
index 00000000000..c261ee2861b
--- /dev/null
+++ b/mysql-test/r/rpl_get_lock.result
@@ -0,0 +1,4 @@
+get_lock("lock",3)
+1
+n
+1
diff --git a/mysql-test/std_data/gemini.dat b/mysql-test/std_data/gemini.dat
new file mode 100644
index 00000000000..c2e1045f5ac
--- /dev/null
+++ b/mysql-test/std_data/gemini.dat
@@ -0,0 +1,5 @@
+65,-1,1
+379,-1,1
+468,-1,1
+469,-1,1
+508,-1,1
diff --git a/mysql-test/t/backup.test b/mysql-test/t/backup.test
index e55ed4ca17b..43ea6fd19ad 100644
--- a/mysql-test/t/backup.test
+++ b/mysql-test/t/backup.test
@@ -4,7 +4,7 @@ connection con1;
set SQL_LOG_BIN=0;
drop table if exists t1;
create table t1(n int);
---replace_result "errno = 2" "errno = X" "errno = 22" "errno = X"
+--replace_result "errno = 2" "errno = X" "errno = 22" "errno = X" "errno = 23" "errno = X"
backup table t1 to '../bogus';
backup table t1 to '../tmp';
drop table t1;
diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test
index ff44bc1ce1c..ec1f64307e4 100644
--- a/mysql-test/t/func_time.test
+++ b/mysql-test/t/func_time.test
@@ -7,7 +7,8 @@ select from_days(to_days("960101")),to_days(960201)-to_days("19960101"),to_days(
select period_add("9602",-12),period_diff(199505,"9404") ;
select now()-now(),weekday(curdate())-weekday(now()),unix_timestamp()-unix_timestamp(now());
select from_unixtime(unix_timestamp("1994-03-02 10:11:12")),from_unixtime(unix_timestamp("1994-03-02 10:11:12"),"%Y-%m-%d %h:%i:%s"),from_unixtime(unix_timestamp("1994-03-02 10:11:12"))+0;
-select sec_to_time(9001),sec_to_time(9001)+0,time_to_sec("15:12:22");
+select sec_to_time(9001),sec_to_time(9001)+0,time_to_sec("15:12:22"),
+ sec_to_time(time_to_sec("0:30:47")/6.21);
select now()-curdate()*1000000-curtime();
select strcmp(current_timestamp(),concat(current_date()," ",current_time()));
select date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w");
diff --git a/mysql-test/t/gemini.test b/mysql-test/t/gemini.test
index 3bbd4d4f23d..9d4451c3551 100644
--- a/mysql-test/t/gemini.test
+++ b/mysql-test/t/gemini.test
@@ -338,3 +338,18 @@ SELECT * FROM t1;
SELECT _userid FROM t1 WHERE _userid='marc@anyware.co.uk';
drop table t1;
set autocommit=1;
+
+#
+# Test of load data infile
+#
+
+CREATE TABLE if not exists `t1` (
+ `f1` int(11) unsigned NOT NULL default '0',
+ `f2` tinyint(3) unsigned NOT NULL default '0',
+ `f3` tinyint(3) unsigned NOT NULL default '0',
+ PRIMARY KEY (`f1`)
+) TYPE=Gemini;
+lock table t1 write;
+load data infile ''../../std_data/gemini.dat' ignore into table t1 fields terminated by ',';
+select f1 from t1;
+drop table t1;
diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test
index 84b861a9c47..5530e2b1f54 100644
--- a/mysql-test/t/innodb.test
+++ b/mysql-test/t/innodb.test
@@ -161,6 +161,20 @@ delete from t1;
commit;
select * from t1;
drop table t1;
+
+#
+# Test of active transactions
+#
+
+create table t1 (a integer) type=innodb;
+begin;
+rename table t1 to t2;
+create table t1 (b integer) type=innodb;
+insert into t1 values (1);
+rollback;
+drop table t1;
+rename table t2 to t1;
+drop table t1;
set autocommit=1;
#
@@ -414,8 +428,8 @@ drop table t1;
#
CREATE TABLE t1 (a int unsigned NOT NULL) type=innodb;
---error 1031
-INSERT DELAYED INTO t1 VALUES (1);
+# Can't test this in 3.23
+# INSERT DELAYED INTO t1 VALUES (1);
INSERT INTO t1 VALUES (1);
SELECT * FROM t1;
DROP TABLE t1;
@@ -476,3 +490,25 @@ delete from t1 where a=3;
insert into t1 values (NULL);
select * from t1;
drop table t1;
+
+#Slashdot bug
+create table t1
+ (
+ id int auto_increment primary key,
+ name varchar(32) not null,
+ value text not null,
+ uid int not null,
+ unique key(name,uid)
+ ) type=innodb;
+insert into t1 values (1,'one','one value',101),
+ (2,'two','two value',102),(3,'three','three value',103);
+set insert_id=5;
+replace into t1 (value,name,uid) values ('other value','two',102);
+delete from t1 where uid=102;
+set insert_id=5;
+replace into t1 (value,name,uid) values ('other value','two',102);
+set insert_id=6;
+replace into t1 (value,name,uid) values ('other value','two',102);
+select * from t1;
+drop table t1;
+
diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test
index 59da525990c..6820242d562 100644
--- a/mysql-test/t/merge.test
+++ b/mysql-test/t/merge.test
@@ -35,9 +35,13 @@ show create table t3;
# The following should give errors
create table t4 (a int not null, b char(10), key(a)) type=MERGE UNION=(t1,t2);
+--error 1016
+select * from t4;
+--error 1212
+create table t5 (a int not null, b char(10), key(a)) type=MERGE UNION=(test.t1,test_2.t2);
# Because of windows, it's important that we drop the merge tables first!
-drop table if exists t4,t3,t1,t2;
+drop table if exists t5,t4,t3,t1,t2;
create table t1 (c char(10)) type=myisam;
create table t2 (c char(10)) type=myisam;
diff --git a/mysql-test/t/rpl_get_lock.test b/mysql-test/t/rpl_get_lock.test
new file mode 100644
index 00000000000..45adf99ed21
--- /dev/null
+++ b/mysql-test/t/rpl_get_lock.test
@@ -0,0 +1,16 @@
+source include/master-slave.inc;
+connection master;
+create table t1(n int);
+insert into t1 values(get_lock("lock",2));
+dirty_close master;
+connection master1;
+save_master_pos;
+connection slave;
+sync_with_master;
+select get_lock("lock",3);
+select * from t1;
+connection master1;
+drop table t1;
+save_master_pos;
+connection slave;
+sync_with_master;
diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test
index 95b5a0fb0f1..0e0d79e7d16 100644
--- a/mysql-test/t/show_check.test
+++ b/mysql-test/t/show_check.test
@@ -9,7 +9,7 @@ optimize table t1;
check table t1,t2;
repair table t1,t2;
check table t2,t1;
-lock tables t1 read;
+lock tables t1 write;
check table t2,t1;
show columns from t1;
show full columns from t1;
diff --git a/mysys/charset.c b/mysys/charset.c
index c17c6113b57..f778afb4144 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -393,16 +393,16 @@ CHARSET_INFO *get_charset(uint cs_number, myf flags)
my_bool set_default_charset(uint cs, myf flags)
{
- CHARSET_INFO *new;
+ CHARSET_INFO *new_charset;
DBUG_ENTER("set_default_charset");
DBUG_PRINT("enter",("character set: %d",(int) cs));
- new = get_charset(cs, flags);
- if (!new)
+ new_charset = get_charset(cs, flags);
+ if (!new_charset)
{
DBUG_PRINT("error",("Couldn't set default character set"));
DBUG_RETURN(TRUE); /* error */
}
- default_charset_info = new;
+ default_charset_info = new_charset;
DBUG_RETURN(FALSE);
}
@@ -424,17 +424,17 @@ CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags)
my_bool set_default_charset_by_name(const char *cs_name, myf flags)
{
- CHARSET_INFO *new;
+ CHARSET_INFO *new_charset;
DBUG_ENTER("set_default_charset_by_name");
DBUG_PRINT("enter",("character set: %s", cs_name));
- new = get_charset_by_name(cs_name, flags);
- if (!new)
+ new_charset = get_charset_by_name(cs_name, flags);
+ if (!new_charset)
{
DBUG_PRINT("error",("Couldn't set default character set"));
DBUG_RETURN(TRUE); /* error */
}
- default_charset_info = new;
+ default_charset_info = new_charset;
DBUG_RETURN(FALSE);
}
diff --git a/mysys/default.c b/mysys/default.c
index 126c0270a17..e2e80f36a68 100644
--- a/mysys/default.c
+++ b/mysys/default.c
@@ -146,7 +146,7 @@ void load_defaults(const char *conf_file, const char **groups,
&group))
goto err;
#endif
-#ifdef __EMX__
+#if defined(__EMX__) || defined(OS2)
if (getenv("ETC") &&
search_default_file(&args, &alloc, getenv("ETC"), conf_file,
default_ext, &group))
@@ -363,7 +363,7 @@ void print_defaults(const char *conf_file, const char **groups)
GetWindowsDirectory(name,sizeof(name));
printf("%s\\%s%s ",name,conf_file,have_ext ? "" : windows_ext);
#endif
-#ifdef __EMX__
+#if defined(__EMX__) || defined(OS2)
if (getenv("ETC"))
printf("%s\\%s%s ", getenv("ETC"), conf_file, default_ext);
#endif
diff --git a/mysys/getopt.c b/mysys/getopt.c
index a2a3b5bbec9..774cf3b82f4 100644
--- a/mysys/getopt.c
+++ b/mysys/getopt.c
@@ -38,7 +38,7 @@ Cambridge, MA 02139, USA. */
#include <config.h>
#endif
-#if (!defined (__STDC__) || !__STDC__) && !defined(MSDOS)
+#if (!defined (__STDC__) || !__STDC__) && !defined(MSDOS) && !defined(OS2)
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
#ifndef const
@@ -176,7 +176,9 @@ static char *posixly_correct;
/* Avoid depending on library functions or files
whose names are inconsistent. */
+#ifndef OS2
char *getenv (const char *);
+#endif
static char *
my_index (const char *str, int chr)
diff --git a/mysys/getopt1.c b/mysys/getopt1.c
index 6068a036e7b..bff76d6e5b2 100644
--- a/mysys/getopt1.c
+++ b/mysys/getopt1.c
@@ -27,7 +27,7 @@ Cambridge, MA 02139, USA. */
#include <global.h>
#include "getopt.h"
-#if (!defined (__STDC__) || !__STDC__) && !defined(MSDOS)
+#if (!defined (__STDC__) || !__STDC__) && !defined(MSDOS) && !defined(OS2)
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
#ifndef const
diff --git a/mysys/hash.c b/mysys/hash.c
index dba910ee4ae..acb5a9b4310 100644
--- a/mysys/hash.c
+++ b/mysys/hash.c
@@ -178,7 +178,10 @@ uint calc_hashnr_caseup(const byte *key, uint len)
#endif
-inline uint rec_hashnr(HASH *hash,const byte *record)
+#ifndef _FORTREC_
+inline
+#endif
+uint rec_hashnr(HASH *hash,const byte *record)
{
uint length;
byte *key=hash_key(hash,record,&length,0);
diff --git a/mysys/list.c b/mysys/list.c
index 0a6d900d6b9..c9c863d4cc2 100644
--- a/mysys/list.c
+++ b/mysys/list.c
@@ -72,11 +72,11 @@ void list_free(LIST *root, pbool free_data)
LIST *list_cons(void *data, LIST *list)
{
- LIST *new=(LIST*) my_malloc(sizeof(LIST),MYF(MY_FAE));
- if (!new)
+ LIST *new_charset=(LIST*) my_malloc(sizeof(LIST),MYF(MY_FAE));
+ if (!new_charset)
return 0;
- new->data=data;
- return list_add(list,new);
+ new_charset->data=data;
+ return list_add(list,new_charset);
}
diff --git a/mysys/mf_casecnv.c b/mysys/mf_casecnv.c
index 82575af0e76..125f54b2594 100644
--- a/mysys/mf_casecnv.c
+++ b/mysys/mf_casecnv.c
@@ -32,14 +32,16 @@
void caseup_str(my_string str)
{
#ifdef USE_MB
- register uint32 l;
- register char *end=str+(uint) strlen(str);
if (use_mb(default_charset_info))
+ {
+ register uint32 l;
+ register char *end=str+(uint) strlen(str);
while (*str)
{
if ((l=my_ismbchar(default_charset_info, str,end))) str+=l;
else *str=toupper(*str),++str;
}
+ }
else
#endif
while ((*str = toupper(*str)) != 0)
@@ -51,14 +53,16 @@ void caseup_str(my_string str)
void casedn_str(my_string str)
{
#ifdef USE_MB
- register uint32 l;
- register char *end=str+(uint) strlen(str);
if (use_mb(default_charset_info))
+ {
+ register uint32 l;
+ register char *end=str+(uint) strlen(str);
while (*str)
{
if ((l=my_ismbchar(default_charset_info, str,end))) str+=l;
else *str=tolower(*str),++str;
}
+ }
else
#endif
while ((*str= tolower(*str)) != 0)
@@ -71,14 +75,16 @@ void casedn_str(my_string str)
void caseup(my_string str, uint length)
{
#ifdef USE_MB
- register uint32 l;
- register char *end=str+length;
if (use_mb(default_charset_info))
+ {
+ register uint32 l;
+ register char *end=str+length;
while (str<end)
{
if ((l=my_ismbchar(default_charset_info, str,end))) str+=l;
else *str=toupper(*str),++str;
}
+ }
else
#endif
for ( ; length>0 ; length--, str++)
@@ -90,14 +96,16 @@ void caseup(my_string str, uint length)
void casedn(my_string str, uint length)
{
#ifdef USE_MB
- register uint32 l;
- register char *end=str+length;
if (use_mb(default_charset_info))
+ {
+ register uint32 l;
+ register char *end=str+length;
while (str<end)
{
if ((l=my_ismbchar(default_charset_info, str,end))) str+=l;
else *str=tolower(*str),++str;
}
+ }
else
#endif
for ( ; length>0 ; length--, str++)
@@ -144,10 +152,10 @@ skipp:
int my_strcasecmp(const char *s, const char *t)
{
#ifdef USE_MB
- register uint32 l;
- register const char *end=s+(uint) strlen(s);
if (use_mb(default_charset_info))
{
+ register uint32 l;
+ register const char *end=s+(uint) strlen(s);
while (s<end)
{
if ((l=my_ismbchar(default_charset_info, s,end)))
@@ -173,10 +181,10 @@ int my_strcasecmp(const char *s, const char *t)
int my_casecmp(const char *s, const char *t, uint len)
{
#ifdef USE_MB
- register uint32 l;
- register const char *end=s+len;
if (use_mb(default_charset_info))
{
+ register uint32 l;
+ register const char *end=s+len;
while (s<end)
{
if ((l=my_ismbchar(default_charset_info, s,end)))
diff --git a/mysys/mf_dirname.c b/mysys/mf_dirname.c
index f4b9e011215..399082a238b 100644
--- a/mysys/mf_dirname.c
+++ b/mysys/mf_dirname.c
@@ -24,7 +24,7 @@ uint dirname_length(const char *name)
{
register my_string pos,gpos;
#ifdef FN_DEVCHAR
- if ((pos=strrchr(name,FN_DEVCHAR)) == 0)
+ if ((pos=(char*)strrchr(name,FN_DEVCHAR)) == 0)
#endif
pos=(char*) name-1;
diff --git a/mysys/mf_format.c b/mysys/mf_format.c
index f90e646289f..5063d6ca831 100644
--- a/mysys/mf_format.c
+++ b/mysys/mf_format.c
@@ -52,7 +52,7 @@ my_string fn_format(my_string to, const char *name, const char *dsk,
pack_dirname(dev,dev); /* Put in ./.. and ~/.. */
if (flag & 4)
(void) unpack_dirname(dev,dev); /* Replace ~/.. with dir */
- if ((pos=strchr(name,FN_EXTCHAR)) != NullS)
+ if ((pos=(char*)strchr(name,FN_EXTCHAR)) != NullS)
{
if ((flag & 2) == 0) /* Skall vi byta extension ? */
{
diff --git a/mysys/mf_path.c b/mysys/mf_path.c
index 3158c45470c..9a88b938e2c 100644
--- a/mysys/mf_path.c
+++ b/mysys/mf_path.c
@@ -74,7 +74,7 @@ my_string my_path(my_string to, const char *progname,
/* test if file without filename is found in path */
/* Returns to if found and to has dirpart if found, else NullS */
-#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__)
+#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2)
#define F_OK 0
#define PATH_SEP ';'
#define PROGRAM_EXTENSION ".exe"
diff --git a/mysys/mf_qsort.c b/mysys/mf_qsort.c
index 5676a9255a5..ed79aab6fd9 100644
--- a/mysys/mf_qsort.c
+++ b/mysys/mf_qsort.c
@@ -66,7 +66,7 @@ do { \
typedef struct st_stack
{
char *low,*high;
-} STACK;
+} stack_node;
#define PUSH(LOW,HIGH) {stack_ptr->low = LOW; stack_ptr++->high = HIGH;}
#define POP(LOW,HIGH) {LOW = (--stack_ptr)->low; HIGH = stack_ptr->high;}
@@ -98,7 +98,7 @@ qsort_t qsort(void *base_ptr, size_t count, size_t size, qsort_cmp cmp)
#endif
{
char *low, *high, *pivot;
- STACK stack[STACK_SIZE], *stack_ptr;
+ stack_node stack[STACK_SIZE], *stack_ptr;
my_bool ptr_cmp;
/* Handle the simple case first */
/* This will also make the rest of the code simpler */
diff --git a/mysys/mf_tempfile.c b/mysys/mf_tempfile.c
index b2c0e89b9e4..2cdd720edbd 100644
--- a/mysys/mf_tempfile.c
+++ b/mysys/mf_tempfile.c
@@ -25,7 +25,7 @@
#endif
#ifdef HAVE_TEMPNAM
-#ifndef MSDOS
+#if !defined( MSDOS) && !defined(OS2)
extern char **environ;
#endif
#endif
@@ -122,12 +122,19 @@ File create_temp_file(char *to, const char *dir, const char *prefix,
to[1]= 0;
dir=to;
}
- old_env=environ;
+#ifdef OS2
+ // changing environ variable doesn't work with VACPP
+ char buffer[256];
+ sprintf( buffer, "TMP=%s", dir);
+ putenv( buffer);
+#else
+ old_env= (char**) environ;
if (dir)
{ /* Don't use TMPDIR if dir is given */
- environ=temp_env;
+ environ=(const char**) temp_env;
temp_env[0]=0;
}
+#endif
if ((res=tempnam((char*) dir, (char*) prefix)))
{
strmake(to,res,FN_REFLEN-1);
@@ -142,7 +149,9 @@ File create_temp_file(char *to, const char *dir, const char *prefix,
{
DBUG_PRINT("error",("Got error: %d from tempnam",errno));
}
- environ=old_env;
+#ifndef OS2
+ environ=(const char**) old_env;
+#endif
}
#else
{
diff --git a/mysys/my_clock.c b/mysys/my_clock.c
index d13d69a7b88..e7d1758fa2e 100644
--- a/mysys/my_clock.c
+++ b/mysys/my_clock.c
@@ -18,14 +18,14 @@
#define USES_TYPES
#include "global.h"
-#if !defined(_MSC_VER) && !defined(__BORLANDC__)
+#if !defined(_MSC_VER) && !defined(__BORLANDC__) && !defined(OS2)
#include "mysys_priv.h"
#include <sys/times.h>
#endif
long my_clock(void)
{
-#if !defined(MSDOS) && !defined(__WIN__)
+#if !defined(MSDOS) && !defined(__WIN__) && !defined(OS2)
struct tms tmsbuf;
VOID(times(&tmsbuf));
return (tmsbuf.tms_utime + tmsbuf.tms_stime);
diff --git a/mysys/my_copy.c b/mysys/my_copy.c
index be131873118..9b02d84d063 100644
--- a/mysys/my_copy.c
+++ b/mysys/my_copy.c
@@ -81,7 +81,7 @@ int my_copy(const char *from, const char *to, myf MyFlags)
if (MyFlags & MY_HOLD_ORIGINAL_MODES && new_file_stat)
DBUG_RETURN(0); /* File copyed but not stat */
VOID(chmod(to, stat_buff.st_mode & 07777)); /* Copy modes */
-#if !defined(MSDOS) && !defined(__WIN__) && !defined(__EMX__)
+#if !defined(MSDOS) && !defined(__WIN__) && !defined(__EMX__) && !defined(OS2)
VOID(chown(to, stat_buff.st_uid,stat_buff.st_gid)); /* Copy ownership */
#endif
#if !defined(VMS) && !defined(__ZTC__)
diff --git a/mysys/my_create.c b/mysys/my_create.c
index ee5d9aa41f3..5a10b0fd8b5 100644
--- a/mysys/my_create.c
+++ b/mysys/my_create.c
@@ -20,7 +20,7 @@
#include <my_dir.h>
#include "mysys_err.h"
#include <errno.h>
-#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__)
+#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2)
#include <share.h>
#endif
@@ -48,7 +48,7 @@ File my_create(const char *FileName, int CreateFlags, int access_flags,
#elif defined(VMS)
fd = open((my_string) FileName, access_flags | O_CREAT, 0,
"ctx=stm","ctx=bin");
-#elif defined(MSDOS) || defined(__WIN__) || defined(__EMX__)
+#elif defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2)
if (access_flags & O_SHARE)
fd = sopen((my_string) FileName, access_flags | O_CREAT | O_BINARY,
SH_DENYNO, MY_S_IREAD | MY_S_IWRITE);
diff --git a/mysys/my_getwd.c b/mysys/my_getwd.c
index b49737b2a61..6bdea813fe4 100644
--- a/mysys/my_getwd.c
+++ b/mysys/my_getwd.c
@@ -28,6 +28,9 @@
#include <dos.h>
#include <direct.h>
#endif
+#if defined(OS2)
+#include <direct.h>
+#endif
#ifdef __EMX__
// chdir2 support also drive change
@@ -93,16 +96,16 @@ int my_setwd(const char *dir, myf MyFlags)
int res;
size_s length;
my_string start,pos;
-#if defined(VMS) || defined(MSDOS)
+#if defined(VMS) || defined(MSDOS) || defined(OS2)
char buff[FN_REFLEN];
#endif
DBUG_ENTER("my_setwd");
DBUG_PRINT("my",("dir: '%s' MyFlags %d", dir, MyFlags));
start=(my_string) dir;
-#if defined(MSDOS) /* MSDOS chdir can't change drive */
+#if defined(MSDOS) || defined(OS2) /* OS2/MSDOS chdir can't change drive */
#if !defined(_DDL) && !defined(WIN32)
- if ((pos=strchr(dir,FN_DEVCHAR)) != 0)
+ if ((pos=(char*) strchr(dir,FN_DEVCHAR)) != 0)
{
uint drive,drives;
@@ -110,8 +113,13 @@ int my_setwd(const char *dir, myf MyFlags)
drive=(uint) (toupper(dir[0])-'A'+1); drives= (uint) -1;
if ((pos-(byte*) dir) == 2 && drive > 0 && drive < 32)
{
+#ifdef OS2
+ _chdrive(drive);
+ drives = _getdrive();
+#else
_dos_setdrive(drive,&drives);
_dos_getdrive(&drives);
+#endif
}
if (drive != drives)
{
diff --git a/mysys/my_init.c b/mysys/my_init.c
index b5005b82478..c3b9cecf86e 100644
--- a/mysys/my_init.c
+++ b/mysys/my_init.c
@@ -74,7 +74,7 @@ void my_init(void)
pthread_init(); /* Must be called before DBUG_ENTER */
#endif
my_thread_global_init();
-#ifndef __WIN__
+#if !defined( __WIN__) && !defined(OS2)
sigfillset(&my_signals); /* signals blocked by mf_brkhant */
#endif
#endif /* THREAD */
diff --git a/mysys/my_lib.c b/mysys/my_lib.c
index bb4474b9ce7..d183be58231 100644
--- a/mysys/my_lib.c
+++ b/mysys/my_lib.c
@@ -27,7 +27,9 @@
# include <dirent.h>
# define NAMLEN(dirent) strlen((dirent)->d_name)
#else
+#ifndef OS2
# define dirent direct
+#endif
# define NAMLEN(dirent) (dirent)->d_namlen
# if defined(HAVE_SYS_NDIR_H)
# include <sys/ndir.h>
@@ -50,6 +52,11 @@
#include <iodef.h>
#include <descrip.h>
#endif
+
+#ifdef OS2
+#include "my_os2dirsrch.h"
+#endif
+
#if defined(THREAD) && defined(HAVE_READDIR_R)
#define READDIR(A,B,C) ((errno=readdir_r(A,B,&C)) != 0 || !C)
#else
@@ -337,9 +344,7 @@ my_string directory_file_name (my_string dst, const char *src)
*****************************************************************************
*/
-MY_DIR *my_dir(path, MyFlags)
-const char *path;
-myf MyFlags;
+MY_DIR *my_dir(const char *path, myf MyFlags)
{
struct fileinfo *fnames;
char *buffer, *obuffer, *tempptr;
@@ -475,9 +480,7 @@ error:
** At MSDOS you always get stat of files, but time is in packed MSDOS-format
******************************************************************************/
-MY_DIR *my_dir(path, MyFlags)
-const char *path;
-myf MyFlags;
+MY_DIR *my_dir(const char* path, myf MyFlags)
{
struct fileinfo *fnames;
char *buffer, *obuffer, *tempptr;
diff --git a/mysys/my_lock.c b/mysys/my_lock.c
index a3508018837..c002f447f59 100644
--- a/mysys/my_lock.c
+++ b/mysys/my_lock.c
@@ -38,12 +38,6 @@
int my_lock(File fd, int locktype, my_off_t start, my_off_t length,
myf MyFlags)
{
-#ifdef __EMX__
- FILELOCK LockArea = {0,0}, UnlockArea = {0,0};
- APIRET rc = 0;
- fpos_t oldpos;
- int lockflags = 0;
-#endif
#ifdef HAVE_FCNTL
int value;
ALARM_VARIABLES;
@@ -56,54 +50,12 @@ int my_lock(File fd, int locktype, my_off_t start, my_off_t length,
#else
if (my_disable_locking)
DBUG_RETURN(0);
-#if defined(__EMX__)
- if (locktype == F_UNLCK) {
- UnlockArea.lOffset = start;
- if (length)
- UnlockArea.lRange = length;
- else
- UnlockArea.lRange = 0x7FFFFFFFL;
- } else
- if (locktype == F_RDLCK || locktype == F_WRLCK) {
- if (locktype == F_RDLCK) lockflags |= 1;
- LockArea.lOffset = start;
- if (length)
- LockArea.lRange = length;
- else
- LockArea.lRange = 0x7FFFFFFFL;
- } else {
- my_errno = EINVAL;
- DBUG_RETURN(-1);
- }
- if (!LockArea.lRange && !UnlockArea.lRange)
+
+#if defined(__EMX__) || defined(OS2)
+
+ if (!_lock64( fd, locktype, start, length, MyFlags))
DBUG_RETURN(0);
- if (MyFlags & MY_DONT_WAIT) {
- if (!(rc = DosSetFileLocks(fd,&UnlockArea,&LockArea,0,lockflags)))
- DBUG_RETURN(0); /* Lock was OK */
- if (rc == 175 && locktype == F_RDLCK) {
- lockflags &= ~1;
- rc = DosSetFileLocks(fd,&UnlockArea,&LockArea,0,lockflags);
- }
- if (rc == 33) { /* Lock Violation */
- DBUG_PRINT("info",("Was locked, trying with timeout"));
- rc = DosSetFileLocks(fd,&UnlockArea,&LockArea,MY_HOW_OFTEN_TO_ALARM * 1000,lockflags);
- }
- if (!rc) DBUG_RETURN(0);
- if (rc == 33) errno = EAGAIN;
- else {
- errno = EINVAL;
- printf("Error: DosSetFileLocks() == %d\n",rc);
- }
- } else {
- while (rc = DosSetFileLocks(fd,&UnlockArea,&LockArea,
- MY_HOW_OFTEN_TO_ALARM * 1000,lockflags) && (rc == 33 || rc == 175)) {
- printf(".");
- if (rc == 175) lockflags &= ~1;
- }
- if (!rc) DBUG_RETURN(0);
- errno = EINVAL;
- printf("Error: DosSetFileLocks() == %d\n",rc);
- }
+
#elif defined(HAVE_LOCKING)
/* Windows */
{
diff --git a/mysys/my_malloc.c b/mysys/my_malloc.c
index 6cae6fe3a4d..c2df22ec7ec 100644
--- a/mysys/my_malloc.c
+++ b/mysys/my_malloc.c
@@ -33,7 +33,7 @@ gptr my_malloc(unsigned int Size, myf MyFlags)
if (!Size)
Size=1; /* Safety */
- if ((point = malloc(Size)) == NULL)
+ if ((point = (char*)malloc(Size)) == NULL)
{
my_errno=errno;
if (MyFlags & MY_FAE)
diff --git a/mysys/my_mkdir.c b/mysys/my_mkdir.c
index 773cd26cb03..3685312132c 100644
--- a/mysys/my_mkdir.c
+++ b/mysys/my_mkdir.c
@@ -28,8 +28,8 @@ int my_mkdir(const char *dir, int Flags, myf MyFlags)
DBUG_ENTER("my_dir");
DBUG_PRINT("enter",("dir: %s",dir));
-#ifdef __WIN__
- if (mkdir(dir))
+#if defined(__WIN__) || defined(OS2)
+ if (mkdir((char*) dir))
#else
if (mkdir((char*) dir, Flags & my_umask_dir))
#endif
diff --git a/mysys/my_open.c b/mysys/my_open.c
index fcf1be575c8..2ed1af1eca1 100644
--- a/mysys/my_open.c
+++ b/mysys/my_open.c
@@ -20,7 +20,7 @@
#include "mysys_err.h"
#include <my_dir.h>
#include <errno.h>
-#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__)
+#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2)
#include <share.h>
#endif
@@ -35,7 +35,7 @@ File my_open(const char *FileName, int Flags, myf MyFlags)
DBUG_ENTER("my_open");
DBUG_PRINT("my",("Name: '%s' Flags: %d MyFlags: %d",
FileName, Flags, MyFlags));
-#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__)
+#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2)
if (Flags & O_SHARE)
fd = sopen((my_string) FileName, (Flags & ~O_SHARE) | O_BINARY, SH_DENYNO,
MY_S_IREAD | MY_S_IWRITE);
diff --git a/mysys/my_os2cond.c b/mysys/my_os2cond.c
new file mode 100644
index 00000000000..c436ad9a0e9
--- /dev/null
+++ b/mysys/my_os2cond.c
@@ -0,0 +1,188 @@
+/* Copyright (C) Yuri Dario & 2000 MySQL AB
+ All the above parties has a full, independent copyright to
+ the following code, including the right to use the code in
+ any manner without any demands from the other parties.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/*****************************************************************************
+** The following is a simple implementation of posix conditions
+*****************************************************************************/
+
+#undef SAFE_MUTEX /* Avoid safe_mutex redefinitions */
+#include "mysys_priv.h"
+#if defined(THREAD) && defined(OS2)
+#include <m_string.h>
+//#undef getpid
+#include <process.h>
+#include <sys/timeb.h>
+
+int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
+{
+ APIRET rc = 0;
+ HEV event;
+ cond->waiting=0;
+ /* Warp3 FP29 or Warp4 FP4 or better required */
+ rc = DosCreateEventSem( NULL, &cond->semaphore, 0x0800, 0);
+ if (rc)
+ return ENOMEM;
+
+ return 0;
+}
+
+int pthread_cond_destroy(pthread_cond_t *cond)
+{
+ APIRET rc;
+
+ do {
+ rc = DosCloseEventSem(cond->semaphore);
+ if (rc == 301) DosPostEventSem(cond->semaphore);
+ } while (rc == 301);
+ if (rc)
+ return EINVAL;
+
+ return 0;
+}
+
+
+int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
+{
+ APIRET rc;
+ int rval;
+
+ rval = 0;
+ cond->waiting++;
+
+ if (mutex) pthread_mutex_unlock(mutex);
+
+ rc = DosWaitEventSem(cond->semaphore,SEM_INDEFINITE_WAIT);
+ if (rc != 0)
+ rval = EINVAL;
+
+ if (mutex) pthread_mutex_lock(mutex);
+
+ cond->waiting--;
+
+ return rval;
+}
+
+int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
+ struct timespec *abstime)
+{
+ struct timeb curtime;
+ int result;
+ long timeout;
+ APIRET rc;
+ int rval;
+
+ _ftime(&curtime);
+ timeout= ((long) (abstime->ts_sec - curtime.time)*1000L +
+ (long)((abstime->ts_nsec/1000) - curtime.millitm)/1000L);
+ if (timeout < 0) /* Some safety */
+ timeout = 0L;
+
+ rval = 0;
+ cond->waiting++;
+
+ if (mutex) pthread_mutex_unlock(mutex);
+
+ rc = DosWaitEventSem(cond->semaphore, timeout);
+ if (rc != 0)
+ rval = ETIME;
+
+ if (mutex) pthread_mutex_lock(mutex);
+
+ cond->waiting--;
+
+ return rval;
+}
+
+
+int pthread_cond_signal(pthread_cond_t *cond)
+{
+ APIRET rc;
+
+ /* Bring the next thread off the condition queue: */
+ rc = DosPostEventSem(cond->semaphore);
+ return 0;
+}
+
+
+int pthread_cond_broadcast(pthread_cond_t *cond)
+{
+ int i;
+ APIRET rc;
+
+ /*
+ * Enter a loop to bring all threads off the
+ * condition queue:
+ */
+ i = cond->waiting;
+ while (i--) rc = DosPostEventSem(cond->semaphore);
+
+ return 0 ;
+}
+
+
+int pthread_attr_init(pthread_attr_t *connect_att)
+{
+ connect_att->dwStackSize = 0;
+ connect_att->dwCreatingFlag = 0;
+ connect_att->priority = 0;
+ return 0;
+}
+
+int pthread_attr_setstacksize(pthread_attr_t *connect_att,DWORD stack)
+{
+ connect_att->dwStackSize=stack;
+ return 0;
+}
+
+int pthread_attr_setprio(pthread_attr_t *connect_att,int priority)
+{
+ connect_att->priority=priority;
+ return 0;
+}
+
+int pthread_attr_destroy(pthread_attr_t *connect_att)
+{
+ bzero((gptr) connect_att,sizeof(*connect_att));
+ return 0;
+}
+
+/****************************************************************************
+** Fix localtime_r() to be a bit safer
+****************************************************************************/
+
+struct tm *localtime_r(const time_t *timep,struct tm *tmp)
+{
+ if (*timep == (time_t) -1) /* This will crash win32 */
+ {
+ bzero(tmp,sizeof(*tmp));
+ }
+ else
+ {
+ struct tm *res=localtime(timep);
+ if (!res) /* Wrong date */
+ {
+ bzero(tmp,sizeof(*tmp)); /* Keep things safe */
+ return 0;
+ }
+ *tmp= *res;
+ }
+ return tmp;
+}
+#endif /* __WIN__ */
diff --git a/mysys/my_os2dirsrch.c b/mysys/my_os2dirsrch.c
new file mode 100644
index 00000000000..36f56d3ed2e
--- /dev/null
+++ b/mysys/my_os2dirsrch.c
@@ -0,0 +1,182 @@
+/* Copyright (C) Yuri Dario & 2000 MySQL AB
+ All the above parties has a full, independent copyright to
+ the following code, including the right to use the code in
+ any manner without any demands from the other parties.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/* Win32 directory search emulation */
+
+#if defined(OS2)
+
+//#define _DEBUG
+
+long _findfirst( char* path, struct _finddata_t* dos_file)
+{
+ HDIR hdir = HDIR_CREATE;
+ APIRET rc;
+ FILEFINDBUF3 buf3;
+ ULONG entries = 1;
+
+#ifdef _DEBUG
+ printf( "_findfirst path %s\n", path);
+#endif
+
+ memset( &buf3, 0, sizeof( buf3));
+ rc = DosFindFirst(
+ path, /* Address of the ASCIIZ path name of the file or subdirectory to be found. */
+ &hdir, /* Address of the handle associated with this DosFindFirst request. */
+ FILE_NORMAL | FILE_DIRECTORY, /* Attribute value that determines the file objects to be searched for. */
+ &buf3, /* Result buffer. */
+ sizeof( buf3), /* The length, in bytes, of pfindbuf. */
+ &entries, /* Pointer to the number of entries: */
+ FIL_STANDARD); /* The level of file information required. */
+
+#ifdef _DEBUG
+ printf( "_findfirst rc=%d hdir=%d entries=%d->%s\n", rc, hdir, entries, buf3.achName);
+#endif
+
+ if (rc /* && entries == 0 */)
+ return -1;
+
+ if (dos_file) {
+ memset( dos_file, 0, sizeof( struct _finddata_t));
+ strcpy( dos_file->name, buf3.achName);
+ dos_file->size = buf3.cbFile;
+ dos_file->attrib = buf3.attrFile;
+ }
+ return (ULONG) hdir;
+}
+
+
+long _findnext( long hdir, struct _finddata_t* dos_file)
+{
+ APIRET rc;
+ FILEFINDBUF3 buf3;
+ ULONG entries = 1;
+
+ memset( &buf3, 0, sizeof( buf3));
+ rc = DosFindNext(
+ hdir,
+ &buf3, /* Result buffer. */
+ sizeof( buf3), /* The length, in bytes, of pfindbuf. */
+ &entries); /* Pointer to the number of entries: */
+
+#ifdef _DEBUG
+ printf( "_findnext rc=%d hdir=%d entries=%d->%s\n", rc, hdir, entries, buf3.achName);
+#endif
+
+ if (rc /* && entries == 0 */)
+ return -1;
+
+ if (dos_file) {
+ memset( dos_file, 0, sizeof( struct _finddata_t));
+ strcpy( dos_file->name, buf3.achName);
+ dos_file->size = buf3.cbFile;
+ dos_file->attrib = buf3.attrFile;
+ }
+ return 0;
+}
+
+void _findclose( long hdir)
+{
+ APIRET rc;
+
+ rc = DosFindClose( hdir);
+#ifdef _DEBUG
+ printf( "_findclose rc=%d hdir=%d\n", rc, hdir);
+#endif
+}
+
+DIR* opendir( char* path)
+{
+ DIR* dir = (DIR*) calloc( 1, sizeof( DIR));
+ char buffer[260];
+ APIRET rc;
+ ULONG entries = 1;
+
+ strcpy( buffer, path);
+ strcat( buffer, "*.*");
+
+#ifdef _DEBUG
+ printf( "_findfirst path %s\n", buffer);
+#endif
+
+ dir->hdir = HDIR_CREATE;
+ memset( &dir->buf3, 0, sizeof( dir->buf3));
+ rc = DosFindFirst(
+ buffer, /* Address of the ASCIIZ path name of the file or subdirectory to be found. */
+ &dir->hdir, /* Address of the handle associated with this DosFindFirst request. */
+ FILE_NORMAL | FILE_DIRECTORY, /* Attribute value that determines the file objects to be searched for. */
+ &dir->buf3, /* Result buffer. */
+ sizeof( dir->buf3), /* The length, in bytes, of pfindbuf. */
+ &entries, /* Pointer to the number of entries: */
+ FIL_STANDARD); /* The level of file information required. */
+
+#ifdef _DEBUG
+ printf( "opendir rc=%d hdir=%d entries=%d->%s\n", rc, dir->hdir, entries, dir->buf3.achName);
+#endif
+
+ if (rc /* && entries == 0 */)
+ return NULL;
+
+ return dir;
+}
+
+struct dirent* readdir( DIR* dir)
+{
+ APIRET rc;
+ //FILEFINDBUF3 buf3;
+ ULONG entries = 1;
+
+ if (!dir->buf3.achName[0]) // file not found on previous query
+ return NULL;
+
+ // copy last file name
+ strcpy( dir->ent.d_name, dir->buf3.achName);
+
+ // query next file
+ memset( &dir->buf3, 0, sizeof( dir->buf3));
+ rc = DosFindNext(
+ dir->hdir,
+ &dir->buf3, /* Result buffer. */
+ sizeof( dir->buf3), /* The length, in bytes, of pfindbuf. */
+ &entries); /* Pointer to the number of entries: */
+
+#ifdef _DEBUG
+ printf( "_findnext rc=%d hdir=%d entries=%d->%s\n", rc, dir->hdir, entries, dir->buf3.achName);
+#endif
+
+ if (rc /* && entries == 0 */)
+ strcpy( dir->buf3.achName, ""); // reset name for next query
+
+ return &dir->ent;
+}
+
+int closedir (DIR *dir)
+{
+ APIRET rc;
+
+ rc = DosFindClose( dir->hdir);
+#ifdef _DEBUG
+ printf( "_findclose rc=%d hdir=%d\n", rc, dir->hdir);
+#endif
+ free(dir);
+ return 0;
+}
+
+
+#endif // OS2
diff --git a/mysys/my_os2dirsrch.h b/mysys/my_os2dirsrch.h
new file mode 100644
index 00000000000..2afe0f609f1
--- /dev/null
+++ b/mysys/my_os2dirsrch.h
@@ -0,0 +1,77 @@
+/* Copyright (C) Yuri Dario & 2000 MySQL AB
+ All the above parties has a full, independent copyright to
+ the following code, including the right to use the code in
+ any manner without any demands from the other parties.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/* Win32 directory search emulation */
+
+#ifndef __MY_OS2DIRSRCH2_H__
+#define __MY_OS2DIRSRCH2_H__
+
+#ifdef __cplusplus_00
+extern "C" {
+#endif
+
+struct _finddata_t
+{
+ unsigned attrib;
+ //unsigned long time_create; /* -1 for FAT file systems */
+ //unsigned long time_access; /* -1 for FAT file systems */
+ //unsigned long time_write;
+ unsigned long size;
+ char name[260];
+ //uint16 wr_date;
+ //uint16 wr_time;
+};
+
+struct dirent
+{
+ //unsigned attrib;
+ //unsigned long time_create; /* -1 for FAT file systems */
+ //unsigned long time_access; /* -1 for FAT file systems */
+ //unsigned long time_write;
+ //unsigned long size;
+ char d_name[260];
+ //uint16 wr_date;
+ //uint16 wr_time;
+};
+
+struct DIR
+{
+ HDIR hdir;
+ FILEFINDBUF3 buf3;
+ struct dirent ent;
+};
+
+DIR *opendir ( char *);
+struct dirent *readdir (DIR *);
+int closedir (DIR *);
+
+//#define _A_NORMAL FILE_NORMAL
+//#define _A_SUBDIR FILE_DIRECTORY
+//#define _A_RDONLY FILE_READONLY
+
+//long _findfirst( char*, struct _finddata_t*);
+//long _findnext( long, struct _finddata_t*);
+//void _findclose( long);
+
+#ifdef __cplusplus_00
+}
+#endif
+
+#endif // __MY_OS2DIRSRCH2_H__
diff --git a/mysys/my_os2dlfcn.c b/mysys/my_os2dlfcn.c
new file mode 100644
index 00000000000..0b0b5518eff
--- /dev/null
+++ b/mysys/my_os2dlfcn.c
@@ -0,0 +1,74 @@
+/* Copyright (C) Yuri Dario & 2000 MySQL AB
+ All the above parties has a full, independent copyright to
+ the following code, including the right to use the code in
+ any manner without any demands from the other parties.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/*
+ * dlfcn::Unix dynamic loading for OS/2
+ *
+ * Compatibility layer for dynamic loading.
+ * Only minimal implementation
+ *
+*/
+
+#define RTLD_LAZY 0
+#define RTLD_NOW 0
+
+void* dlopen( char* path, int flag);
+char* dlerror( void);
+void* dlsym( void* hmod, char* fn);
+void dlclose( void* hmod);
+
+char fail[ 256];
+
+void* dlopen( char* path, int flag)
+{
+ APIRET rc;
+ HMODULE hmod;
+
+ rc = DosLoadModule( fail, sizeof( fail), path, &hmod);
+ if (rc)
+ return NULL;
+
+ return (void*) hmod;
+}
+
+char* dlerror( void)
+{
+ return fail;
+}
+
+void* dlsym( void* hmod, char* fn)
+{
+ APIRET rc;
+ PFN addr;
+
+ rc = DosQueryProcAddr( (HMODULE) hmod, 0l, fn, &addr);
+ if (rc)
+ return NULL;
+
+ return (void*) addr;
+}
+
+void dlclose( void* hmod)
+{
+ APIRET rc;
+
+ rc = DosFreeModule( (HMODULE) hmod);
+
+}
diff --git a/mysys/my_os2dlfcn.h0 b/mysys/my_os2dlfcn.h0
new file mode 100644
index 00000000000..7f84d430230
--- /dev/null
+++ b/mysys/my_os2dlfcn.h0
@@ -0,0 +1,39 @@
+/* Copyright (C) Yuri Dario & 2000 MySQL AB
+ All the above parties has a full, independent copyright to
+ the following code, including the right to use the code in
+ any manner without any demands from the other parties.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+/*
+ * dlfcn::Unix dynamic loading for OS/2
+ *
+ * Compatibility layer for dynamic loading.
+ * Only minimal implementation
+ *
+*/
+
+#ifndef __DLFCN_H__
+#define __DLFCN_H__
+
+#define RTLD_LAZY 0
+#define RTLD_NOW 0
+
+void* dlopen( char* path, int flag);
+char* dlerror( void);
+void* dlsym( void* hmod, char* fn);
+void dlclose( void* hmod);
+
+#endif
diff --git a/mysys/my_os2file64.c b/mysys/my_os2file64.c
new file mode 100644
index 00000000000..8964e562ea1
--- /dev/null
+++ b/mysys/my_os2file64.c
@@ -0,0 +1,341 @@
+/* Copyright (C) Yuri Dario & 2000 MySQL AB
+ All the above parties has a full, independent copyright to
+ the following code, including the right to use the code in
+ any manner without any demands from the other parties.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+void _OS2errno( APIRET rc);
+longlong _lseek64( int fd, longlong offset, int seektype);
+int _lock64( int fd, int locktype, my_off_t start,
+ my_off_t length, myf MyFlags);
+int _sopen64( const char *name, int oflag, int shflag, int mask);
+
+//
+// this class is used to define a global c++ variable, that
+// is initialized before main() gets called.
+//
+class File64bit
+{
+ public:
+ File64bit(); /* default constructor */
+} initFile64bit;
+
+static APIRET (* APIENTRY _DosOpenL)(PCSZ pszFileName,
+ PHFILE phf,
+ PULONG pulAction,
+ LONGLONG cbFile,
+ ULONG ulAttribute,
+ ULONG fsOpenFlags,
+ ULONG fsOpenMode,
+ PEAOP2 peaop2);
+static APIRET (* APIENTRY _DosSetFilePtrL)(HFILE hFile,
+ LONGLONG ib,
+ ULONG method,
+ PLONGLONG ibActual);
+static APIRET (* APIENTRY _DosSetFileLocksL)(HFILE hFile,
+ PFILELOCKL pflUnlock,
+ PFILELOCKL pflLock,
+ ULONG timeout,
+ ULONG flags);
+
+#define EIO EINVAL
+#define ESPIPE EBADSEEK
+
+
+static unsigned char const errno_tab[] =
+{
+ 0 , EINVAL, ENOENT, ENOENT, EMFILE, /* 0..4 */
+ EACCES, EBADF, EIO, ENOMEM, EIO, /* 5..9 */
+ EINVAL, ENOEXEC,EINVAL, EINVAL, EINVAL, /* 10..14 */
+ ENOENT, EBUSY, EXDEV, ENOENT, EROFS, /* 15..19 */
+ EIO, EIO, EIO, EIO, EIO, /* 20..24 */
+ EIO, EIO, EIO, ENOSPC, EIO, /* 25..29 */
+ EIO, EIO, EACCES, EACCES, EIO, /* 30..34 */
+ EIO, EIO, EIO, EIO, ENOSPC, /* 35..39 */
+ EIO, EIO, EIO, EIO, EIO, /* 40..44 */
+ EIO, EIO, EIO, EIO, EIO, /* 45..49 */
+ EIO, EIO, EIO, EIO, EBUSY, /* 50..54 */
+ EIO, EIO, EIO, EIO, EIO, /* 55..59 */
+ EIO, ENOSPC, ENOSPC, EIO, EIO, /* 60..64 */
+ EACCES, EIO, EIO, EIO, EIO, /* 65..69 */
+ EIO, EIO, EIO, EROFS, EIO, /* 70..74 */
+ EIO, EIO, EIO, EIO, EIO, /* 75..79 */
+ EEXIST, EIO, ENOENT, EIO, EIO, /* 80..84 */
+ EIO, EIO, EINVAL, EIO, EAGAIN, /* 85..89 */
+ EIO, EIO, EIO, EIO, EIO, /* 90..94 */
+ EINTR, EIO, EIO, EIO, EACCES, /* 95..99 */
+ ENOMEM, EINVAL, EINVAL, ENOMEM, EINVAL, /* 100..104 */
+ EINVAL, ENOMEM, EIO, EACCES, EPIPE, /* 105..109 */
+ ENOENT, E2BIG, ENOSPC, ENOMEM, EBADF, /* 110..114 */
+ EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 115..119 */
+ EINVAL, EINVAL, EINVAL, ENOENT, EINVAL, /* 120..124 */
+ ENOENT, ENOENT, ENOENT, ECHILD, ECHILD, /* 125..129 */
+ EACCES, EINVAL, ESPIPE, EINVAL, EINVAL, /* 130..134 */
+ EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 135..139 */
+ EINVAL, EINVAL, EBUSY, EINVAL, EINVAL, /* 140..144 */
+ EINVAL, EINVAL, EINVAL, EBUSY, EINVAL, /* 145..149 */
+ EINVAL, EINVAL, ENOMEM, EINVAL, EINVAL, /* 150..154 */
+ EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 155..159 */
+ EINVAL, EINVAL, EINVAL, EINVAL, EAGAIN, /* 160..164 */
+ EINVAL, EINVAL, EACCES, EINVAL, EINVAL, /* 165..169 */
+ EBUSY, EINVAL, EINVAL, EINVAL, EINVAL, /* 170..174 */
+ EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 175..179 */
+ EINVAL, EINVAL, EINVAL, EINVAL, ECHILD, /* 180..184 */
+ EINVAL, EINVAL, ENOENT, EINVAL, EINVAL, /* 185..189 */
+ ENOEXEC,ENOEXEC,ENOEXEC,ENOEXEC,ENOEXEC, /* 190..194 */
+ ENOEXEC,ENOEXEC,ENOEXEC,ENOEXEC,ENOEXEC, /* 195..199 */
+ ENOEXEC,ENOEXEC,ENOEXEC,ENOENT, EINVAL, /* 200..204 */
+ EINVAL, ENAMETOOLONG, EINVAL, EINVAL, EINVAL, /* 205..209 */
+ EINVAL, EINVAL, EACCES, ENOEXEC,ENOEXEC, /* 210..214 */
+ EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 215..219 */
+ EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 220..224 */
+ EINVAL, EINVAL, EINVAL, ECHILD, EINVAL, /* 225..229 */
+ EINVAL, EBUSY, EAGAIN, ENOTCONN, EINVAL, /* 230..234 */
+ EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 235..239 */
+ EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 240..244 */
+ EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 245..249 */
+ EACCES, EACCES, EINVAL, ENOENT, EINVAL, /* 250..254 */
+ EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 255..259 */
+ EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 260..264 */
+ EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 265..269 */
+ EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 270..274 */
+ EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 275..279 */
+ EINVAL, EINVAL, EINVAL, EINVAL, EEXIST, /* 280..284 */
+ EEXIST, EINVAL, EINVAL, EINVAL, EINVAL, /* 285..289 */
+ ENOMEM, EMFILE, EINVAL, EINVAL, EINVAL, /* 290..294 */
+ EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 295..299 */
+ EINVAL, EBUSY, EINVAL, ESRCH, EINVAL, /* 300..304 */
+ ESRCH, EINVAL, EINVAL, EINVAL, ESRCH, /* 305..309 */
+ EINVAL, ENOMEM, EINVAL, EINVAL, EINVAL, /* 310..314 */
+ EINVAL, E2BIG, ENOENT, EIO, EIO, /* 315..319 */
+ EINVAL, EINVAL, EINVAL, EINVAL, EAGAIN, /* 320..324 */
+ EINVAL, EINVAL, EINVAL, EIO, ENOENT, /* 325..329 */
+ EACCES, EACCES, EACCES, ENOENT, ENOMEM /* 330..334 */
+};
+
+/*
+ * Initialize 64bit file access: dynamic load of WSeB API
+*/
+ File64bit :: File64bit()
+{
+ HMODULE hDoscalls;
+
+ if (DosQueryModuleHandle("DOSCALLS", &hDoscalls) != NO_ERROR)
+ return;
+
+ if (DosQueryProcAddr(hDoscalls, 981, NULL, (PFN *)&_DosOpenL) != NO_ERROR)
+ return;
+
+ if (DosQueryProcAddr(hDoscalls, 988, NULL, (PFN *)&_DosSetFilePtrL) != NO_ERROR) {
+ _DosOpenL = NULL;
+ return;
+ }
+
+ if (DosQueryProcAddr(hDoscalls, 986, NULL, (PFN *)&_DosSetFileLocksL) != NO_ERROR) {
+ _DosOpenL = NULL;
+ _DosSetFilePtrL = NULL;
+ return;
+ }
+ // notify success
+#ifdef MYSQL_SERVER
+ printf( "WSeB 64bit file API loaded.\n");
+#endif
+}
+
+void _OS2errno( APIRET rc)
+{
+ if (rc >= sizeof (errno_tab))
+ errno = EINVAL;
+ else
+ errno = errno_tab[rc];
+}
+
+longlong _lseek64( int fd, longlong offset, int seektype)
+{
+ APIRET rc;
+ longlong actual;
+
+ if (_DosSetFilePtrL)
+ rc = _DosSetFilePtrL( fd, offset, seektype, &actual);
+ else {
+ ULONG ulActual;
+ rc = DosSetFilePtr( fd, (long) offset, seektype, &ulActual);
+ actual = ulActual;
+ }
+
+ if (!rc)
+ return( actual);/* NO_ERROR */
+
+ // set errno
+ _OS2errno( rc);
+ // seek failed
+ return(-1);
+}
+
+inline _SetFileLocksL(HFILE hFile,
+ PFILELOCKL pflUnlock,
+ PFILELOCKL pflLock,
+ ULONG timeout,
+ ULONG flags)
+{
+ if (_DosSetFileLocksL)
+ return _DosSetFileLocksL( hFile, pflUnlock, pflLock, timeout, flags);
+
+ FILELOCK flUnlock = { pflUnlock->lOffset, pflUnlock->lRange };
+ FILELOCK flLock = { pflLock->lOffset, pflLock->lRange };
+ return DosSetFileLocks( hFile, &flUnlock, &flLock, timeout, flags);
+}
+
+int _lock64( int fd, int locktype, my_off_t start,
+ my_off_t length, myf MyFlags)
+{
+ FILELOCKL LockArea = {0,0}, UnlockArea = {0,0};
+ ULONG readonly = 0;
+ APIRET rc = -1;
+
+ switch( locktype) {
+ case F_UNLCK:
+ UnlockArea.lOffset = start;
+ UnlockArea.lRange = length ? length : LONGLONG_MAX;
+ break;
+
+ case F_RDLCK:
+ case F_WRLCK:
+ LockArea.lOffset = start;
+ LockArea.lRange = length ? length : LONGLONG_MAX;
+ readonly = (locktype == F_RDLCK ? 1 : 0);
+ break;
+
+ default:
+ errno = EINVAL;
+ rc = -1;
+ break;
+ }
+
+ if (MyFlags & MY_DONT_WAIT) {
+
+ rc = _SetFileLocksL( fd, &UnlockArea, &LockArea, 0, readonly);
+ //printf( "fd %d, locktype %d, rc %d (dont_wait)\n", fd, locktype, rc);
+ if (rc == 33) { /* Lock Violation */
+
+ DBUG_PRINT("info",("Was locked, trying with timeout"));
+ rc = _SetFileLocksL( fd, &UnlockArea, &LockArea, 1 * 1000, readonly);
+ //printf( "fd %d, locktype %d, rc %d (dont_wait with timeout)\n", fd, locktype, rc);
+ }
+
+ } else {
+
+ while( rc = _SetFileLocksL( fd, &UnlockArea, &LockArea, 0, readonly) && (rc == 33)) {
+ printf(".");
+ DosSleep(1 * 1000);
+ }
+ //printf( "fd %d, locktype %d, rc %d (wait2)\n", fd, locktype, rc);
+ }
+
+ if (!rc)
+ return( 0);/* NO_ERROR */
+
+ // set errno
+ _OS2errno( rc);
+ // lock failed
+ return(-1);
+}
+
+int _sopen64( const char *name, int oflag, int shflag, int mask)
+{
+ int fail_errno;
+ APIRET rc = 0;
+ HFILE hf = 0;
+ ULONG ulAction = 0;
+ LONGLONG cbFile = 0;
+ ULONG ulAttribute = FILE_NORMAL;
+ ULONG fsOpenFlags = 0;
+ ULONG fsOpenMode = 0;
+
+ /* Extract the access mode and sharing mode bits. */
+ fsOpenMode = (shflag & 0xFF) | (oflag & 0x03);
+
+ /* Translate ERROR_OPEN_FAILED to ENOENT unless O_EXCL is set (see
+ below). */
+ fail_errno = ENOENT;
+
+ /* Compute `open_flag' depending on `flags'. Note that _SO_CREAT is
+ set for O_CREAT. */
+
+ if (oflag & O_CREAT)
+ {
+ if (oflag & O_EXCL)
+ {
+ fsOpenFlags = OPEN_ACTION_FAIL_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW;
+ fail_errno = EEXIST;
+ }
+ else if (oflag & O_TRUNC)
+ fsOpenFlags = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW;
+ else
+ fsOpenFlags = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW;
+
+ if (mask & S_IWRITE)
+ ulAttribute = FILE_NORMAL;
+ else
+ ulAttribute = FILE_READONLY;
+
+ }
+ else if (oflag & O_TRUNC)
+ fsOpenFlags = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW;
+ else
+ fsOpenFlags = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW;
+
+ /* Try to open the file and handle errors. */
+ if (_DosOpenL)
+ rc = _DosOpenL( name, &hf, &ulAction, cbFile,
+ ulAttribute, fsOpenFlags, fsOpenMode, NULL);
+ else
+ rc = DosOpen( name, &hf, &ulAction, (LONG) cbFile,
+ ulAttribute, fsOpenFlags, fsOpenMode, NULL);
+
+ if (rc == ERROR_OPEN_FAILED)
+ {
+ errno = fail_errno;
+ return -1;
+ }
+ if (rc != 0)
+ {
+ // set errno
+ _OS2errno( rc);
+ return -1;
+ }
+
+ if (oflag & O_APPEND)
+ _lseek64( hf, 0L, SEEK_END);
+
+ return hf;
+}
+
+inline int open( const char *name, int oflag)
+{
+ return _sopen64( name, oflag, OPEN_SHARE_DENYNONE, S_IREAD | S_IWRITE);
+}
+
+inline int open( const char *name, int oflag, int mask)
+{
+ return _sopen64( name, oflag, OPEN_SHARE_DENYNONE, mask);
+}
+
+inline int sopen( const char *name, int oflag, int shflag, int mask)
+{
+ return _sopen64( name, oflag, shflag, mask);
+}
diff --git a/mysys/my_os2mutex.c b/mysys/my_os2mutex.c
new file mode 100644
index 00000000000..0ae6ae86d8c
--- /dev/null
+++ b/mysys/my_os2mutex.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
+ * All rights reserved.
+ *
+ * Modified and extended by Antony T Curtis <antony.curtis@olcs.net>
+ * for use with OS/2.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by John Birrell.
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+#include <stdlib.h>
+#include <errno.h>
+#ifdef _THREAD_SAFE
+//#include <pthread.h>
+//#include "pthread_private.h"
+
+int
+pthread_mutex_init(pthread_mutex_t * mutex,
+ const pthread_mutexattr_t * mutex_attr)
+{
+ APIRET rc = 0;
+
+ rc = DosCreateMutexSem(NULL,mutex,0,0);
+
+ /* Return the completion status: */
+ return (0);
+}
+
+int
+pthread_mutex_destroy(pthread_mutex_t * mutex)
+{
+ APIRET rc = 0;
+
+
+ do {
+ rc = DosCloseMutexSem(*mutex);
+ if (rc == 301) DosReleaseMutexSem(*mutex);
+ } while (rc == 301);
+
+ *mutex = 0;
+
+ /* Return the completion status: */
+ return (0);
+}
+
+
+int
+pthread_mutex_lock(pthread_mutex_t * mutex)
+{
+ int ret = 0;
+ int status = 0;
+ APIRET rc = 0;
+
+ rc = DosRequestMutexSem(*mutex,SEM_INDEFINITE_WAIT);
+ if (rc)
+ return(EINVAL);
+ /* Return the completion status: */
+ return (0);
+}
+
+int
+pthread_mutex_unlock(pthread_mutex_t * mutex)
+{
+ int ret = 0;
+ APIRET rc = 0;
+ int status;
+
+ rc = DosReleaseMutexSem(*mutex);
+
+ /* Return the completion status: */
+ return (0);
+}
+#endif
diff --git a/mysys/my_os2thread.c b/mysys/my_os2thread.c
new file mode 100644
index 00000000000..017ba7f316b
--- /dev/null
+++ b/mysys/my_os2thread.c
@@ -0,0 +1,126 @@
+/* Copyright (C) Yuri Dario & 2000 MySQL AB
+ All the above parties has a full, independent copyright to
+ the following code, including the right to use the code in
+ any manner without any demands from the other parties.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+/*****************************************************************************
+** Simulation of posix threads calls for OS/2
+*****************************************************************************/
+
+#include "mysys_priv.h"
+#if defined(THREAD) && defined(OS2)
+#include <m_string.h>
+#include <process.h>
+
+static pthread_mutex_t THR_LOCK_thread;
+
+struct pthread_map
+{
+ HANDLE pthreadself;
+ pthread_handler func;
+ void * param;
+};
+
+void win_pthread_init(void)
+{
+ pthread_mutex_init(&THR_LOCK_thread,NULL);
+}
+
+/*
+** We have tried to use '_beginthreadex' instead of '_beginthread' here
+** but in this case the program leaks about 512 characters for each
+** created thread !
+** As we want to save the created thread handler for other threads to
+** use and to be returned by pthread_self() (instead of the Win32 pseudo
+** handler), we have to go trough pthread_start() to catch the returned handler
+** in the new thread.
+*/
+
+static pthread_handler_decl(pthread_start,param)
+{
+ pthread_handler func=((struct pthread_map *) param)->func;
+ void *func_param=((struct pthread_map *) param)->param;
+ my_thread_init(); /* Will always succeed in windows */
+ pthread_mutex_lock(&THR_LOCK_thread); /* Wait for beginthread to return */
+ win_pthread_self=((struct pthread_map *) param)->pthreadself;
+ pthread_mutex_unlock(&THR_LOCK_thread);
+ free((char*) param); /* Free param from create */
+ pthread_exit((void*) (*func)(func_param));
+ return 0; /* Safety */
+}
+
+
+int pthread_create(pthread_t *thread_id, pthread_attr_t *attr,
+ pthread_handler func, void *param)
+{
+ HANDLE hThread;
+ struct pthread_map *map;
+ DBUG_ENTER("pthread_create");
+
+ if (!(map=(struct pthread_map *)malloc(sizeof(*map))))
+ DBUG_RETURN(-1);
+ map->func=func;
+ map->param=param;
+ pthread_mutex_lock(&THR_LOCK_thread);
+#ifdef __BORLANDC__
+ hThread=(HANDLE)_beginthread((void(_USERENTRY *)(void *)) pthread_start,
+ attr->dwStackSize ? attr->dwStackSize :
+ 65535, (void*) map);
+#elif defined( OS2)
+ hThread=(HANDLE)_beginthread((void( _Optlink *)(void *)) pthread_start, NULL,
+ attr->dwStackSize ? attr->dwStackSize :
+ 65535, (void*) map);
+#else
+ hThread=(HANDLE)_beginthread((void( __cdecl *)(void *)) pthread_start,
+ attr->dwStackSize ? attr->dwStackSize :
+ 65535, (void*) map);
+#endif
+ DBUG_PRINT("info", ("hThread=%lu",(long) hThread));
+ *thread_id=map->pthreadself=hThread;
+ pthread_mutex_unlock(&THR_LOCK_thread);
+
+ if (hThread == (HANDLE) -1)
+ {
+ int error=errno;
+ DBUG_PRINT("error",
+ ("Can't create thread to handle request (error %d)",error));
+ DBUG_RETURN(error ? error : -1);
+ }
+#ifdef OS2
+ my_pthread_setprio(hThread, attr->priority);
+#else
+ VOID(SetThreadPriority(hThread, attr->priority)) ;
+#endif
+ DBUG_RETURN(0);
+}
+
+
+void pthread_exit(void *a)
+{
+ _endthread();
+}
+
+/* This is neaded to get the macro pthread_setspecific to work */
+
+int win_pthread_setspecific(void *a,void *b,uint length)
+{
+ memcpy(a,b,length);
+ return 0;
+}
+
+#endif
diff --git a/mysys/my_os2tls.c b/mysys/my_os2tls.c
new file mode 100644
index 00000000000..25d543d0768
--- /dev/null
+++ b/mysys/my_os2tls.c
@@ -0,0 +1,144 @@
+/* Copyright (C) Yuri Dario & 2000 MySQL AB
+ All the above parties has a full, independent copyright to
+ the following code, including the right to use the code in
+ any manner without any demands from the other parties.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA */
+
+DWORD TlsAlloc( void);
+BOOL TlsFree( DWORD);
+PVOID TlsGetValue( DWORD);
+BOOL TlsSetValue( DWORD, PVOID);
+
+#define TLS_MINIMUM_AVAILABLE 64
+
+
+PULONG tls_storage; /* TLS local storage */
+DWORD tls_bits[2]; /* TLS in-use bits */
+pthread_mutex_t tls_mutex; /* TLS mutex for in-use bits */
+
+DWORD TlsAlloc( void)
+{
+ DWORD index = -1;
+ DWORD mask, tibidx;
+ int i;
+
+ if (tls_storage == NULL) {
+
+ APIRET rc;
+
+ // allocate memory for TLS storage
+ rc = DosAllocThreadLocalMemory( 1, &tls_storage);
+ if (rc) {
+ fprintf( stderr, "DosAllocThreadLocalMemory error: return code = %u\n", rc);
+ }
+
+ // create a mutex
+ if (pthread_mutex_init( &tls_mutex, NULL))
+ fprintf( stderr, "Failed to init TLS mutex\n");
+ }
+
+ pthread_mutex_lock( &tls_mutex);
+
+ tibidx = 0;
+ if (tls_bits[0] == 0xFFFFFFFF) {
+ if (tls_bits[1] == 0xFFFFFFFF) {
+ fprintf( stderr, "tid#%d, no more TLS bits available\n", _threadid);
+ pthread_mutex_unlock( &tls_mutex);
+ return -1;
+ }
+ tibidx = 1;
+ }
+ for( i=0; i<32; i++) {
+ mask = (1 << i);
+ if ((tls_bits[ tibidx] & mask) == 0) {
+ tls_bits[ tibidx] |= mask;
+ index = (tibidx*32) + i;
+ break;
+ }
+ }
+ tls_storage[index] = 0;
+
+ pthread_mutex_unlock( &tls_mutex);
+
+ //fprintf( stderr, "tid#%d, TlsAlloc index %d\n", _threadid, index);
+
+ return index;
+}
+
+BOOL TlsFree( DWORD index)
+{
+ int tlsidx;
+ DWORD mask;
+
+ if (index >= TLS_MINIMUM_AVAILABLE)
+ return NULL;
+
+ pthread_mutex_lock( &tls_mutex);
+
+ tlsidx = 0;
+ if (index > 32) {
+ tlsidx++;
+ }
+ mask = (1 << index);
+ if (tls_bits[ tlsidx] & mask) {
+ tls_bits[tlsidx] &= ~mask;
+ tls_storage[index] = 0;
+ pthread_mutex_unlock( &tls_mutex);
+ return TRUE;
+ }
+
+ pthread_mutex_unlock( &tls_mutex);
+ return FALSE;
+}
+
+
+PVOID TlsGetValue( DWORD index)
+{
+ if (index >= TLS_MINIMUM_AVAILABLE)
+ return NULL;
+
+ // verify if memory has been allocated for this thread
+ if (*tls_storage == NULL) {
+ // allocate memory for indexes
+ *tls_storage = (ULONG)calloc( TLS_MINIMUM_AVAILABLE, sizeof(int));
+ //fprintf( stderr, "tid#%d, tls_storage %x\n", _threadid, *tls_storage);
+ }
+
+ ULONG* tls_array = (ULONG*) *tls_storage;
+ return (PVOID) tls_array[ index];
+}
+
+BOOL TlsSetValue( DWORD index, PVOID val)
+{
+
+ // verify if memory has been allocated for this thread
+ if (*tls_storage == NULL) {
+ // allocate memory for indexes
+ *tls_storage = (ULONG)calloc( TLS_MINIMUM_AVAILABLE, sizeof(int));
+ //fprintf( stderr, "tid#%d, tls_storage %x\n", _threadid, *tls_storage);
+ }
+
+ if (index >= TLS_MINIMUM_AVAILABLE)
+ return FALSE;
+
+ ULONG* tls_array = (ULONG*) *tls_storage;
+ //fprintf( stderr, "tid#%d, TlsSetValue array %08x index %d -> %08x (old)\n", _threadid, tls_array, index, tls_array[ index]);
+ tls_array[ index] = (ULONG) val;
+ //fprintf( stderr, "tid#%d, TlsSetValue array %08x index %d -> %08x\n", _threadid, tls_array, index, val);
+
+ return TRUE;
+}
diff --git a/mysys/my_pthread.c b/mysys/my_pthread.c
index a3a193650df..8bdbc0f7fd8 100644
--- a/mysys/my_pthread.c
+++ b/mysys/my_pthread.c
@@ -145,7 +145,7 @@ struct tm *localtime_r(const time_t *clock, struct tm *res)
** Author: Gary Wisniewski <garyw@spidereye.com.au>, much modified by Monty
****************************************************************************/
-#if !defined(HAVE_SIGWAIT) && !defined(HAVE_mit_thread) && !defined(sigwait) && !defined(__WIN__) && !defined(HAVE_rts_threads) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS)
+#if !defined(HAVE_SIGWAIT) && !defined(HAVE_mit_thread) && !defined(sigwait) && !defined(__WIN__) && !defined(HAVE_rts_threads) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS) && !defined(OS2)
#if !defined(DONT_USE_SIGSUSPEND)
diff --git a/mysys/my_realloc.c b/mysys/my_realloc.c
index c9d8edd6ddf..7ab75d47619 100644
--- a/mysys/my_realloc.c
+++ b/mysys/my_realloc.c
@@ -49,7 +49,7 @@ gptr my_realloc(gptr oldpoint, uint Size, myf MyFlags)
free(oldpoint);
}
#else
- if ((point = realloc(oldpoint,Size)) == NULL)
+ if ((point = (char*)realloc(oldpoint,Size)) == NULL)
{
if (MyFlags & MY_FREE_ON_ERROR)
my_free(oldpoint,MyFLAGS);
diff --git a/mysys/my_redel.c b/mysys/my_redel.c
index 0cc17481dab..16ec77394d2 100644
--- a/mysys/my_redel.c
+++ b/mysys/my_redel.c
@@ -91,7 +91,7 @@ int my_copystat(const char *from, const char *to, int MyFlags)
return 1;
VOID(chmod(to, statbuf.st_mode & 07777)); /* Copy modes */
-#if !defined(MSDOS) && !defined(__WIN__) && !defined(__EMX__)
+#if !defined(MSDOS) && !defined(__WIN__) && !defined(__EMX__) && !defined(OS2)
if (statbuf.st_nlink > 1 && MyFlags & MY_LINK_WARNING)
{
if (MyFlags & MY_LINK_WARNING)
diff --git a/mysys/my_static.c b/mysys/my_static.c
index 3fc68455841..00061893cdc 100644
--- a/mysys/my_static.c
+++ b/mysys/my_static.c
@@ -20,7 +20,7 @@
a shared library
*/
-#ifndef stdin
+#if !defined(stdin) || defined(OS2)
#include "mysys_priv.h"
#include "my_static.h"
#include "my_alarm.h"
diff --git a/mysys/my_tempnam.c b/mysys/my_tempnam.c
index ac982538668..7da037e8d49 100644
--- a/mysys/my_tempnam.c
+++ b/mysys/my_tempnam.c
@@ -26,7 +26,7 @@
#endif
#ifdef HAVE_TEMPNAM
-#ifndef MSDOS
+#if !defined( MSDOS) && !defined(OS2)
extern char **environ;
#endif
#endif
@@ -91,14 +91,23 @@ my_string my_tempnam(const char *dir, const char *pfx,
temp[1]= 0;
dir=temp;
}
- old_env=environ;
+#ifdef OS2
+ // changing environ variable doesn't work with VACPP
+ char buffer[256];
+ sprintf( buffer, "TMP=%s", dir);
+ putenv( buffer);
+#else
+ old_env=(char**)environ;
if (dir)
{ /* Don't use TMPDIR if dir is given */
- environ=temp_env;
+ environ=(const char**)temp_env;
temp_env[0]=0;
}
+#endif
res=tempnam((char*) dir,(my_string) pfx); /* Use stand. dir with prefix */
- environ=old_env;
+#ifndef OS2
+ environ=(const char**)old_env;
+#endif
if (!res)
DBUG_PRINT("error",("Got error: %d from tempnam",errno));
return res;
diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c
index dab281e4dc6..e1f9e23912e 100644
--- a/mysys/my_thr_init.c
+++ b/mysys/my_thr_init.c
@@ -72,7 +72,7 @@ my_bool my_thread_global_init(void)
pthread_mutex_init(&THR_LOCK_heap,MY_MUTEX_INIT_FAST);
pthread_mutex_init(&THR_LOCK_net,MY_MUTEX_INIT_FAST);
pthread_mutex_init(&THR_LOCK_charset,MY_MUTEX_INIT_FAST);
-#ifdef __WIN__
+#if defined( __WIN__) || defined(OS2)
win_pthread_init();
#endif
#ifndef HAVE_LOCALTIME_R
@@ -160,11 +160,11 @@ void my_thread_end(void)
pthread_cond_destroy(&tmp->suspend);
#endif
pthread_mutex_destroy(&tmp->mutex);
-#if !defined(__WIN__) || defined(USE_TLS)
+#if (!defined(__WIN__) && !defined(OS2)) || defined(USE_TLS)
free(tmp);
#endif
}
-#if !defined(__WIN__) || defined(USE_TLS)
+#if (!defined(__WIN__) && !defined(OS2)) || defined(USE_TLS)
pthread_setspecific(THR_KEY_mysys,0);
#endif
}
diff --git a/mysys/my_write.c b/mysys/my_write.c
index 61d6c7d2180..640043192ef 100644
--- a/mysys/my_write.c
+++ b/mysys/my_write.c
@@ -19,6 +19,46 @@
#include "mysys_err.h"
#include <errno.h>
+#ifdef OS2
+
+int _write64( int fd, const void *buffer, unsigned int count)
+{
+ APIRET rc;
+ ULONG actual;
+
+ rc = DosWrite( fd, (PVOID) buffer, count, &actual);
+
+ switch (rc) {
+ case 0: /* NO_ERROR */
+ errno = 0;
+ return( actual);
+ break;
+ case ERROR_INVALID_FUNCTION:
+ errno = EPERM;
+ break;
+ case ERROR_ACCESS_DENIED:
+ errno = EACCESS;
+ break;
+ case ERROR_INVALID_HANDLE:
+ errno = EBADF;
+ break;
+ case ERROR_DISK_FULL:
+ errno = ENOSPC;
+ break;
+ default:
+ errno = EINVAL;
+ break;
+ }
+ // write failed
+ return(-1);
+}
+
+// redirect call
+#define write _write64
+
+#endif // OS2
+
+
/* Write a chunk of bytes to a file */
uint my_write(int Filedes, const byte *Buffer, uint Count, myf MyFlags)
diff --git a/mysys/test_charset.c b/mysys/test_charset.c
index a04bdbd9a58..6a5183d2cd3 100644
--- a/mysys/test_charset.c
+++ b/mysys/test_charset.c
@@ -22,7 +22,7 @@
#include <stdio.h>
-extern void _print_csinfo();
+extern void _print_csinfo(CHARSET_INFO *cs);
int main(int argc, char **argv) {
const char *the_set = MYSQL_CHARSET;
diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c
index 3c641e01d7b..f51f27b7f51 100644
--- a/mysys/thr_alarm.c
+++ b/mysys/thr_alarm.c
@@ -37,7 +37,7 @@
static my_bool alarm_aborted=1;
my_bool thr_alarm_inited=0;
-#if !defined(__WIN__) && !defined(__EMX__)
+#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2)
static pthread_mutex_t LOCK_alarm;
static sigset_t full_signal_set;
@@ -460,7 +460,7 @@ static void *alarm_handler(void *arg __attribute__((unused)))
** thr_alarm for OS/2
*****************************************************************************/
-#elif defined(__EMX__)
+#elif defined(__EMX__) || defined(OS2)
#define INCL_BASE
#define INCL_NOPMAPI
@@ -775,8 +775,10 @@ static sig_handler print_signal_warning(int sig)
#ifdef DONT_REMEMBER_SIGNAL
sigset(sig,print_signal_warning); /* int. thread system calls */
#endif
+#ifndef OS2
if (sig == SIGALRM)
alarm(2); /* reschedule alarm */
+#endif
}
#endif /* USE_ONE_SIGNAL_HAND */
@@ -793,6 +795,7 @@ static void *signal_hand(void *arg __attribute__((unused)))
VOID(pthread_cond_signal(&COND_thread_count)); /* Tell main we are ready */
pthread_mutex_unlock(&LOCK_thread_count);
+#ifndef OS2
sigemptyset(&set); /* Catch all signals */
sigaddset(&set,SIGINT);
sigaddset(&set,SIGQUIT);
@@ -809,6 +812,7 @@ static void *signal_hand(void *arg __attribute__((unused)))
#else
puts("Starting signal handling thread");
#endif
+#endif /* OS2 */
printf("server alarm: %d thread alarm: %d\n",
THR_SERVER_ALARM,THR_CLIENT_ALARM);
DBUG_PRINT("info",("Starting signal and alarm handling thread"));
@@ -831,7 +835,9 @@ static void *signal_hand(void *arg __attribute__((unused)))
case SIGINT:
case SIGQUIT:
case SIGTERM:
+#ifndef OS2
case SIGHUP:
+#endif
printf("Aborting nicely\n");
end_thr_alarm();
break;
@@ -841,11 +847,13 @@ static void *signal_hand(void *arg __attribute__((unused)))
exit(1);
return 0; /* Keep some compilers happy */
#endif
+#ifndef OS2
#ifdef USE_ONE_SIGNAL_HAND
case THR_SERVER_ALARM:
process_alarm(sig);
break;
#endif
+#endif /* OS2 */
}
}
}
@@ -866,6 +874,7 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
pthread_cond_init(&COND_thread_count,NULL);
/* Start a alarm handling thread */
+#ifndef OS2
sigemptyset(&set);
sigaddset(&set,SIGINT);
sigaddset(&set,SIGQUIT);
@@ -883,6 +892,7 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
sigaddset(&set,THR_CLIENT_ALARM);
VOID(pthread_sigmask(SIG_UNBLOCK, &set, (sigset_t*) 0));
#endif
+#endif /* OS2 */
pthread_attr_init(&thr_attr);
pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_PROCESS);
diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c
index 7d86d0c9524..d2b3960d6b5 100644
--- a/mysys/thr_lock.c
+++ b/mysys/thr_lock.c
@@ -115,7 +115,7 @@ my_bool init_thr_lock()
static uint found_errors=0;
static int check_lock(struct st_lock_list *list, const char* lock_type,
- const char *where, my_bool same_thread)
+ const char *where, my_bool same_thread, bool no_cond)
{
THR_LOCK_DATA *data,**prev;
uint count=0;
@@ -148,6 +148,13 @@ static int check_lock(struct st_lock_list *list, const char* lock_type,
lock_type,where);
return 1;
}
+ if (no_cond && data->cond)
+ {
+ fprintf(stderr,
+ "Warning: Found active lock with not reset cond %s: %s\n",
+ lock_type,where);
+ return 1;
+ }
prev= &data->next;
}
if (data)
@@ -172,10 +179,10 @@ static void check_locks(THR_LOCK *lock, const char *where,
uint old_found_errors=found_errors;
if (found_errors < MAX_FOUND_ERRORS)
{
- if (check_lock(&lock->write,"write",where,1) |
- check_lock(&lock->write_wait,"write_wait",where,0) |
- check_lock(&lock->read,"read",where,0) |
- check_lock(&lock->read_wait,"read_wait",where,0))
+ if (check_lock(&lock->write,"write",where,1,1) |
+ check_lock(&lock->write_wait,"write_wait",where,0,0) |
+ check_lock(&lock->read,"read",where,0,1) |
+ check_lock(&lock->read_wait,"read_wait",where,0,0))
found_errors++;
if (found_errors < MAX_FOUND_ERRORS)
@@ -326,6 +333,7 @@ void thr_lock_data_init(THR_LOCK *lock,THR_LOCK_DATA *data, void *param)
data->thread=pthread_self();
data->thread_id=my_thread_id(); /* for debugging */
data->status_param=param;
+ data->cond=0;
}
@@ -366,16 +374,16 @@ static my_bool wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data,
}
/* Set up control struct to allow others to abort locks */
- pthread_mutex_lock(&thread_var->mutex);
thread_var->current_mutex= &data->lock->mutex;
thread_var->current_cond= cond;
- pthread_mutex_unlock(&thread_var->mutex);
data->cond=cond;
- do
+ while (!thread_var->abort || in_wait_list)
{
pthread_cond_wait(cond,&data->lock->mutex);
- } while (data->cond == cond && (!thread_var->abort || in_wait_list));
+ if (data->cond != cond)
+ break;
+ }
if (data->cond || data->type == TL_UNLOCK)
{
@@ -416,6 +424,7 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type)
DBUG_ENTER("thr_lock");
data->next=0;
+ data->cond=0; /* safety */
data->type=lock_type;
data->thread=pthread_self(); /* Must be reset ! */
data->thread_id=my_thread_id(); /* Must be reset ! */
@@ -977,6 +986,10 @@ my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data)
lock->write_wait.data=data;
check_locks(lock,"upgrading lock",0);
}
+ else
+ {
+ check_locks(lock,"waiting for lock",0);
+ }
DBUG_RETURN(wait_for_lock(&lock->write_wait,data,1));
}
diff --git a/mysys/tree.c b/mysys/tree.c
index cf9ce0caafa..d3d67b83810 100644
--- a/mysys/tree.c
+++ b/mysys/tree.c
@@ -159,7 +159,7 @@ static void delete_tree_element(TREE *tree, TREE_ELEMENT *element)
(*tree->free)(ELEMENT_KEY(tree,element), free_free, tree->custom_arg);
delete_tree_element(tree,element->right);
if (tree->with_delete)
- my_free((void*) element,MYF(0));
+ my_free((char*) element,MYF(0));
}
}
diff --git a/os2/ChangeLog.os2 b/os2/ChangeLog.os2
new file mode 100644
index 00000000000..34547262fe2
--- /dev/null
+++ b/os2/ChangeLog.os2
@@ -0,0 +1,23 @@
+
+2001/06/12
+ - fixed support for > 2GB file size, needs also DosOpenL
+ - mixed 64bit/32bit file size support, dinamic loading of
+ 64bit API.
+
+2001/06/03
+ - added support for > 2GB file size
+
+2001/06/02
+ - fixed file locking code
+
+2001/05/29
+ - 3.23.38 build
+
+2001/05/20
+ - rint fix
+ - isam O_RDONLY table handled fix
+
+2001/05/19
+ - new TLS code, fixed parser crashes and many other problems.
+ - fixed pthread_cond_timedwait, now handle manager expires
+
diff --git a/os2/MySQL-All.icc b/os2/MySQL-All.icc
new file mode 100644
index 00000000000..1bd8a1dd89f
--- /dev/null
+++ b/os2/MySQL-All.icc
@@ -0,0 +1,13 @@
+
+// create directories
+for dir in "..\\bin", "..\\lib", "..\\obj", "..\\obj\\zlib", "..\\obj\\readline" {
+ run "if not exist "dir" mkdir "dir
+}
+
+// build sequence
+run "vacbld MySQL-Lib.icc -showprogress=10 -showwarning"
+run "vacbld MySQL-Client.icc -showprogress=10 -showwarning"
+run "vacbld MySQL-Sql.icc -showprogress=10 -showwarning"
+
+// need only for utilities and test applications
+run "vacbld MySQL-Util.icc -showprogress=10 -showwarning"
diff --git a/os2/MySQL-Client.icc b/os2/MySQL-Client.icc
new file mode 100644
index 00000000000..e00fe28a3c9
--- /dev/null
+++ b/os2/MySQL-Client.icc
@@ -0,0 +1,87 @@
+// disable code inlining when building static libs
+InlineCode = "no"
+
+// include common options
+include "MySQL-Opt.icc"
+include "MySQL-Source.icc"
+
+option ProjectOptions = MySQLOptions
+ //, link(defaultlibsname, "readline.lib")
+{
+
+ option file(genobject, "..\\OBJ\\ZLIB\\")
+ {
+ target "..\\bin\\mysql.dll"
+ {
+ // optimized precompiled headers
+ option macros('global', 'yes')
+ {
+ source type('cpp') client_pch
+ }
+ // target source files
+ source zlib
+ if debug_build {
+ source type('cpp') dbug
+ }
+ source type('cpp') my_sys
+ source type('cpp') my_sys_cli
+ source type('cpp') strings
+ source type('cpp') mysqlclientlib
+ }
+ }
+
+ option file(genobject, "..\\OBJ\\READLINE\\")
+ {
+ target "..\\bin\\mysql.exe"
+ {
+ // optimized precompiled headers
+ option macros('global', 'yes')
+ {
+ source type('cpp') client_pch //, 'sql_string.h'
+ }
+ // target source files
+ //source readline
+ source type('cpp') "..\\client\\mysql.cc"
+ }
+ }
+
+ target "..\\bin\\mysqladmin.exe"
+ {
+ // optimized precompiled headers
+ option macros('global', 'yes')
+ {
+ source type('cpp') client_pch //, 'sql_string.h'
+ }
+ // target source files
+ source type('cpp') "..\\client\\mysqladmin.c"
+ }
+
+ target "..\\bin\\mysqldump.exe"
+ {
+ // optimized precompiled headers
+ option macros('global', 'yes')
+ {
+ source type('cpp') client_pch
+ }
+ // target source files
+ source type('cpp') "..\\client\\mysqldump.c"
+ }
+
+ target "..\\bin\\mysqlshow.exe"
+ {
+ // target source files
+ source type('cpp') "..\\client\\mysqlshow.c"
+ }
+
+ target "..\\bin\\mysqlimport.exe"
+ {
+ // target source files
+ source type('cpp') "..\\client\\mysqlimport.c"
+ }
+
+ target "..\\bin\\mysqltest.exe"
+ {
+ source type('cpp') "..\\client\\mysqltest.c"
+ }
+
+}
diff --git a/os2/MySQL-Client.irs b/os2/MySQL-Client.irs
new file mode 100644
index 00000000000..4b5a9e3475a
--- /dev/null
+++ b/os2/MySQL-Client.irs
@@ -0,0 +1,2335 @@
+31 Run Specifications: Version 1.1
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+39 E:\rd\mysql\vacpp-3.23.40\bin\mysql.exe
+1
+0
+0
+5 Local
+0
+44 E:\rd\mysql\vacpp-3.23.40\bin\mysqladmin.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\mysqldump.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\mysqlshow.exe
+1
+0
+0
+5 Local
+0
+45 E:\rd\mysql\vacpp-3.23.40\bin\mysqlimport.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\mysqltest.exe
+1
+0
+0
+5 Local
+0
diff --git a/os2/MySQL-Lib.icc b/os2/MySQL-Lib.icc
new file mode 100644
index 00000000000..51f55ed8302
--- /dev/null
+++ b/os2/MySQL-Lib.icc
@@ -0,0 +1,72 @@
+// disable code inlining when building static libs
+InlineCode = "no"
+
+// include common options
+include "MySQL-Opt.icc"
+include "MySQL-Source.icc"
+
+option ProjectOptions = MySQLOptions
+{
+
+ option file(genobject, "..\\OBJ\\ZLIB\\")
+ {
+ target "..\\lib\\common.lib"
+ {
+ // optimized precompiled headers
+ option macros('global', 'yes')
+ {
+ source type('cpp') client_pch //, 'sql_string.h'
+ }
+ // target source files
+ source zlib
+ if debug_build {
+ source type('cpp') dbug
+ }
+ source type('cpp') heap
+ //source type('cpp') merge
+ source type('cpp') my_sys
+ source type('cpp') my_sys_cli
+ source type('cpp') my_sys_sql
+ source type('cpp') strings
+ }
+ }
+
+/*
+ option file(genobject, "..\\OBJ\\READLINE\\")
+ {
+ target "..\\lib\\readline.lib"
+ {
+ // optimized precompiled headers
+ option macros('global', 'yes')
+ {
+ source type('cpp') client_pch //, 'sql_string.h'
+ }
+ // target source files
+ source readline
+ }
+ }
+*/
+
+ target "..\\lib\\myisam.lib"
+ {
+ // optimized precompiled headers
+ option macros('global', 'yes')
+ {
+ source type('cpp') client_pch //, 'sql_string.h'
+ }
+ // target source files
+ source type('cpp') myisam
+ }
+
+ target "..\\lib\\isam.lib"
+ {
+ // optimized precompiled headers
+ option macros('global', 'yes')
+ {
+ source type('cpp') client_pch //, 'sql_string.h'
+ }
+ // target source files
+ source type('cpp') isam
+ }
+
+}
diff --git a/os2/MySQL-Opt.icc b/os2/MySQL-Opt.icc
new file mode 100644
index 00000000000..5f5cdb7c72f
--- /dev/null
+++ b/os2/MySQL-Opt.icc
@@ -0,0 +1,53 @@
+// set to 1 to enable debug code
+debug_build = 0
+
+// common options
+option BaseOptions = link(defaultlibsname, "tcpip32.lib")
+ ,link(libsearchpath, "..\\lib\\")
+ ,link(libsearchpath, "..\\bin\\")
+ ,link(pmtype, vio)
+ ,link(linkwithmultithreadlib, "yes")
+ ,link(linkwithsharedlib, "no")
+ ,gen(initauto, "yes")
+ ,define("__MT__", )
+ ,define("HAVE_BSD_SIGNALS", )
+ ,define("INCL_DOS", )
+ ,define("INCL_DOSERRORS", )
+ ,define("INCL_LONGLONG", )
+ ,define("OS2", )
+ ,define("USE_TLS", )
+ ,lang(signedchars, yes)
+ ,incl(searchpath, "..")
+ ,incl(searchpath, "..\\include")
+ ,incl(searchpath, "..\\my_sys")
+ ,incl(searchpath, "..\\regex")
+ ,incl(searchpath, "..\\sql")
+ ,incl(searchpath, "\\rd\\mysql\\zlib-1.1.3")
+ ,incl(searchpath, "\\rd\\mysql\\ufc")
+ ,incl(searchpath, "..\\os2")
+
+option ReleaseOptions = link(debug, "no")
+ , define("DBUG_OFF", )
+ , gen(arch, "pentium")
+ , opt(tune, "pentium2")
+ , opt(level, "0")
+ , opt(stackchaining, no)
+ , opt(size, yes)
+ , opt(autoinline, InlineCode)
+ , opt(inline, InlineCode)
+ , opt(schedule, no)
+
+option DebugOptions = link(debug, "yes")
+ , gen(debug, "yes")
+ , define("DBUG_ON", )
+
+
+if debug_build {
+
+option MySQLOptions = BaseOptions, DebugOptions
+
+} else {
+
+option MySQLOptions = BaseOptions, ReleaseOptions
+
+}
diff --git a/os2/MySQL-ReadLine.icc b/os2/MySQL-ReadLine.icc
new file mode 100644
index 00000000000..3f63b0815e6
--- /dev/null
+++ b/os2/MySQL-ReadLine.icc
@@ -0,0 +1,27 @@
+// disable code inlining when building static libs
+InlineCode = "no"
+
+// include common options
+include "MySQL-Opt.icc"
+include "MySQL-Source.icc"
+
+option ProjectOptions = MySQLOptions
+{
+
+
+
+ option file(genobject, "..\\OBJ\\READLINE\\")
+ {
+ target "..\\lib\\readline.lib"
+ {
+ // optimized precompiled headers
+ option macros('global', 'yes')
+ {
+ source type('cpp') client_pch //, 'sql_string.h'
+ }
+ // target source files
+ source readline
+ }
+ }
+
+}
diff --git a/os2/MySQL-Source.icc b/os2/MySQL-Source.icc
new file mode 100644
index 00000000000..48780857185
--- /dev/null
+++ b/os2/MySQL-Source.icc
@@ -0,0 +1,298 @@
+group client_pch =
+ 'os2.h',
+ 'assert.h', 'direct.h', 'errno.h', 'nerrno.h',
+ 'limits.h', 'io.h', 'math.h',
+ 'stdio.h', 'stdlib.h', 'stddef.h',
+ 'sys/stat.h', 'sys/types.h', 'sys/time.h',
+ 'types.h', 'string.h', 'stdarg.h',
+
+ 'my_base.h', 'config-os2.h', 'my_dir.h',
+ 'global.h', 'thr_alarm.h', 'm_string.h',
+ 'mysql.h', 'zconf.h', 'zlib.h', 'mysys_err.h',
+ //'my_os2dirsrch.h',
+ 'm_ctype.h',
+ 'mysqld_error.h',
+ 'my_list.h', 'my_sys.h', 'my_net.h',
+ 'myisam.h', 'myisampack.h', '.\myisam\myisamdef.h'
+
+group mysqlclientlib =
+ "..\\client\\readline.cc",
+ "..\\client\\sql_string.cc",
+ "..\\client\\completion_hash.cc",
+ //"..\\libmysql\\dll.c",
+ "..\\libmysql\\libmysql.c",
+ "..\\libmysql\\errmsg.c",
+ "..\\libmysql\\get_password.c",
+ "..\\libmysql\\net.c",
+ "..\\libmysql\\password.c",
+ "..\\libmysql\\violite.c"
+
+group zlib =
+ "\\rd\\mysql\\zlib-1.1.3\\compress.c", "\\rd\\mysql\\zlib-1.1.3\\crc32.c",
+ "\\rd\\mysql\\zlib-1.1.3\\deflate.c", "\\rd\\mysql\\zlib-1.1.3\\gzio.c", "\\rd\\mysql\\zlib-1.1.3\\infblock.c",
+ "\\rd\\mysql\\zlib-1.1.3\\infcodes.c", "\\rd\\mysql\\zlib-1.1.3\\inffast.c",
+ "\\rd\\mysql\\zlib-1.1.3\\inflate.c", "\\rd\\mysql\\zlib-1.1.3\\inftrees.c",
+ "\\rd\\mysql\\zlib-1.1.3\\infutil.c", "\\rd\\mysql\\zlib-1.1.3\\trees.c", "\\rd\\mysql\\zlib-1.1.3\\uncompr.c",
+ "\\rd\\mysql\\zlib-1.1.3\\zutil.c", "\\rd\\mysql\\zlib-1.1.3\\adler32.c"
+
+group ufc =
+ "\\rd\\mysql\\ufc\\crypt.c",
+ "\\rd\\mysql\\ufc\\crypt_util.c",
+ "\\rd\\mysql\\ufc\\crypt-entry.c"
+
+group sql =
+ "..\\sql\\convert.cc",
+ "..\\sql\\derror.cc",
+ "..\\sql\\field.cc",
+ "..\\sql\\field_conv.cc",
+ "..\\sql\\filesort.cc",
+ "..\\sql\\ha_heap.cc",
+ "..\\sql\\ha_isam.cc",
+ "..\\sql\\ha_isammrg.cc",
+ "..\\sql\\ha_myisam.cc",
+ "..\\sql\\ha_myisammrg.cc",
+ "..\\sql\\handler.cc",
+ "..\\sql\\hash_filo.cc",
+ "..\\sql\\hostname.cc",
+ "..\\sql\\init.cc",
+ "..\\sql\\item.cc",
+ "..\\sql\\item_buff.cc",
+ "..\\sql\\item_cmpfunc.cc",
+ "..\\sql\\item_create.cc",
+ "..\\sql\\item_func.cc",
+ "..\\sql\\item_strfunc.cc",
+ "..\\sql\\item_sum.cc",
+ "..\\sql\\item_timefunc.cc",
+ "..\\sql\\item_uniq.cc",
+ "..\\sql\\key.cc",
+ "..\\sql\\lock.cc",
+ "..\\sql\\log.cc",
+ "..\\sql\\log_event.cc",
+ "..\\sql\\md5.c",
+ "..\\sql\\mf_iocache.cc",
+ "..\\sql\\mini_client.cc",
+ "..\\sql\\mini_client_errors.c",
+ "..\\sql\\mysqld.cc",
+ "..\\sql\\net_pkg.cc",
+ "..\\sql\\net_serv.cc",
+ "..\\sql\\opt_ft.cc",
+ "..\\sql\\opt_range.cc",
+ "..\\sql\\OPT_SUM.cc",
+ "..\\sql\\password.c",
+ "..\\sql\\procedure.cc",
+ "..\\sql\\records.cc",
+ "..\\sql\\slave.cc",
+ "..\\sql\\sql_acl.cc",
+ "..\\sql\\sql_analyse.cc",
+ "..\\sql\\sql_base.cc",
+ "..\\sql\\sql_cache.cc",
+ "..\\sql\\sql_class.cc",
+ "..\\sql\\sql_crypt.cc",
+ "..\\sql\\sql_db.cc",
+ "..\\sql\\sql_delete.cc",
+ "..\\sql\\sql_insert.cc",
+ "..\\sql\\sql_lex.cc",
+ "..\\sql\\sql_list.cc",
+ "..\\sql\\sql_load.cc",
+ "..\\sql\\sql_manager.cc",
+ "..\\sql\\sql_map.cc",
+ "..\\sql\\sql_parse.cc",
+ "..\\sql\\sql_rename.cc",
+ "..\\sql\\sql_repl.cc",
+ "..\\sql\\sql_select.cc",
+ "..\\sql\\sql_show.cc",
+ "..\\sql\\sql_string.cc",
+ "..\\sql\\sql_table.cc",
+ "..\\sql\\sql_test.cc",
+ "..\\sql\\sql_update.cc",
+ "..\\sql\\sql_udf.cc",
+ "..\\sql\\sql_yacc.cc",
+ "..\\sql\\table.cc",
+ "..\\sql\\thr_malloc.cc",
+ "..\\sql\\time.cc",
+ "..\\sql\\unireg.cc",
+ "..\\sql\\violite.c"
+
+group isam =
+ "..\\isam\\changed.c", "..\\isam\\close.c",
+ "..\\isam\\create.c", "..\\isam\\delete.c", "..\\isam\\extra.c",
+ "..\\isam\\info.c", "..\\isam\\log.c", "..\\isam\\open.c",
+ "..\\isam\\panic.c", "..\\isam\\range.c",
+ "..\\isam\\rfirst.c", "..\\isam\\rkey.c", "..\\isam\\rlast.c",
+ "..\\isam\\rnext.c", "..\\isam\\rprev.c", "..\\isam\\rrnd.c",
+ "..\\isam\\rsame.c", "..\\isam\\rsamepos.c",
+ "..\\isam\\static.c", "..\\isam\\update.c",
+ "..\\isam\\write.c", "..\\isam\\_cache.c",
+ "..\\isam\\_dbug.c", "..\\isam\\_dynrec.c",
+ "..\\isam\\_key.c", "..\\isam\\_locking.c",
+ "..\\isam\\_packrec.c", "..\\isam\\_page.c",
+ "..\\isam\\_search.c", "..\\isam\\_statrec.c"
+
+group strings =
+ "..\\strings\\bchange.c",
+ "..\\strings\\bmove.c",
+ "..\\strings\\bmove_upp.c",
+ "..\\strings\\ctype-big5.c",
+ "..\\strings\\ctype-czech.c",
+ "..\\strings\\ctype-euc_kr.c",
+ "..\\strings\\ctype-gb2312.c",
+ "..\\strings\\ctype-gbk.c",
+ "..\\strings\\ctype-sjis.c",
+ "..\\strings\\ctype-tis620.c",
+ "..\\strings\\ctype-ujis.c",
+ "..\\strings\\ctype_extra_sources.c",
+ "..\\strings\\ctype_autoconf.c",
+ "..\\strings\\ctype.c",
+ "..\\strings\\int2str.c",
+ "..\\strings\\is_prefix.c",
+ "..\\strings\\llstr.c",
+ "..\\strings\\longlong2str.c",
+ "..\\strings\\str2int.c",
+ "..\\strings\\strappend.c",
+ "..\\strings\\strcend.c",
+ "..\\strings\\strcont.c",
+ "..\\strings\\strend.c",
+ "..\\strings\\strfill.c",
+ "..\\strings\\strinstr.c",
+ "..\\strings\\strmake.c",
+ "..\\strings\\strmov.c",
+ "..\\strings\\strnlen.c",
+ "..\\strings\\strnmov.c",
+ "..\\strings\\strtoull.c",
+ "..\\strings\\strxmov.c",
+ "..\\strings\\strxnmov.c"
+
+
+ group heap = "..\\heap\\hp_block.c", "..\\heap\\hp_clear.c",
+ "..\\heap\\hp_close.c", "..\\heap\\hp_create.c", "..\\heap\\hp_delete.c",
+ "..\\heap\\hp_extra.c", "..\\heap\\hp_hash.c",
+ "..\\heap\\hp_info.c", "..\\heap\\hp_open.c",
+ "..\\heap\\hp_panic.c", "..\\heap\\hp_rename.c",
+ "..\\heap\\hp_rfirst.c", "..\\heap\\hp_rkey.c",
+ "..\\heap\\hp_rlast.c", "..\\heap\\hp_rnext.c",
+ "..\\heap\\hp_rprev.c", "..\\heap\\hp_rrnd.c",
+ "..\\heap\\hp_rsame.c", "..\\heap\\hp_scan.c",
+ "..\\heap\\hp_static.c", "..\\heap\\hp_update.c",
+ "..\\heap\\hp_write.c", "..\\heap\\_check.c", "..\\heap\\_rectest.c"
+
+
+ group merge = "..\\merge\\close.c", "..\\merge\\create.c", "..\\merge\\delete.c",
+ "..\\merge\\extra.c", "..\\merge\\info.c", "..\\merge\\open.c",
+ "..\\merge\\panic.c", "..\\merge\\rrnd.c", "..\\merge\\rsame.c",
+ "..\\merge\\static.c", "..\\merge\\update.c",
+ "..\\merge\\_locking.c"
+
+
+ group myisammrg = "..\\myisammrg\\myrg_close.c",
+ "..\\myisammrg\\myrg_create.c", "..\\myisammrg\\myrg_delete.c",
+ "..\\myisammrg\\myrg_extra.c", "..\\myisammrg\\myrg_info.c",
+ "..\\myisammrg\\myrg_locking.c",
+ "..\\myisammrg\\myrg_open.c", "..\\myisammrg\\myrg_panic.c",
+ "..\\myisammrg\\myrg_queue.c",
+ "..\\myisammrg\\myrg_rfirst.c", "..\\myisammrg\\myrg_rkey.c",
+ "..\\myisammrg\\myrg_rlast.c", "..\\myisammrg\\myrg_rnext.c",
+ "..\\myisammrg\\myrg_rprev.c", "..\\myisammrg\\myrg_rrnd.c",
+ "..\\myisammrg\\myrg_rsame.c",
+ "..\\myisammrg\\myrg_static.c",
+ "..\\myisammrg\\myrg_update.c"
+
+ group my_sys = "..\\mysys\\array.c", "..\\mysys\\charset.c",
+ "..\\mysys\\checksum.c", "..\\mysys\\default.c", "..\\mysys\\errors.c",
+ "..\\mysys\\getopt.c", "..\\mysys\\getopt1.c",
+ "..\\mysys\\getvar.c", "..\\mysys\\hash.c", "..\\mysys\\list.c",
+ "..\\mysys\\mf_brkhant.c", "..\\mysys\\mf_cache.c",
+ "..\\mysys\\mf_casecnv.c", "..\\mysys\\mf_dirname.c",
+ "..\\mysys\\mf_fn_ext.c", "..\\mysys\\mf_format.c",
+ "..\\mysys\\mf_getdate.c",
+ "..\\mysys\\mf_iocache2.c", "..\\mysys\\mf_keycache.c",
+ "..\\mysys\\mf_loadpath.c", "..\\mysys\\mf_pack.c",
+ "..\\mysys\\mf_pack2.c", "..\\mysys\\mf_path.c",
+ "..\\mysys\\mf_qsort2.c",
+ //"..\\mysys\\mf_qsort.c",
+ "..\\mysys\\mf_radix.c", "..\\mysys\\mf_same.c",
+ "..\\mysys\\mf_sort.c", "..\\mysys\\mf_soundex.c",
+ "..\\mysys\\mf_stripp.c", "..\\mysys\\mf_tempfile.c",
+ "..\\mysys\\mf_unixpath.c", "..\\mysys\\mf_wcomp.c",
+ "..\\mysys\\mf_wfile.c", "..\\mysys\\mulalloc.c",
+ "..\\mysys\\my_alarm.c", "..\\mysys\\my_alloc.c",
+ "..\\mysys\\my_append.c", "..\\mysys\\my_bitmap.c",
+ "..\\mysys\\my_chsize.c", "..\\mysys\\my_clock.c",
+ "..\\mysys\\my_compress.c", "..\\mysys\\my_copy.c",
+ "..\\mysys\\my_create.c", "..\\mysys\\my_delete.c",
+ "..\\mysys\\my_div.c", "..\\mysys\\my_error.c",
+ "..\\mysys\\my_fopen.c", "..\\mysys\\my_fstream.c",
+ "..\\mysys\\my_getwd.c", "..\\mysys\\my_init.c",
+ "..\\mysys\\my_lib.c", "..\\mysys\\my_lock.c",
+ "..\\mysys\\my_lockmem.c", "..\\mysys\\my_lread.c",
+ "..\\mysys\\my_lwrite.c", "..\\mysys\\my_malloc.c",
+ "..\\mysys\\my_messnc.c", "..\\mysys\\my_mkdir.c",
+ "..\\mysys\\my_net.c", "..\\mysys\\my_once.c",
+ "..\\mysys\\my_open.c",
+ "..\\mysys\\my_os2cond.c",
+ "..\\mysys\\my_os2dlfcn.c",
+ "..\\mysys\\my_os2dirsrch.c",
+ "..\\mysys\\my_os2mutex.c", "..\\mysys\\my_os2thread.c",
+ "..\\mysys\\my_os2tls.c",
+ "..\\mysys\\my_os2file64.c",
+ "..\\mysys\\my_pread.c", "..\\mysys\\my_pthread.c",
+ "..\\mysys\\my_quick.c", "..\\mysys\\my_read.c",
+ "..\\mysys\\my_realloc.c", "..\\mysys\\my_redel.c",
+ "..\\mysys\\my_rename.c", "..\\mysys\\my_seek.c",
+ "..\\mysys\\my_static.c", "..\\mysys\\my_tempnam.c",
+ "..\\mysys\\my_thr_init.c", "..\\mysys\\my_vsnprintf.c",
+ "..\\mysys\\my_write.c", "..\\mysys\\ptr_cmp.c",
+ "..\\mysys\\queues.c", "..\\mysys\\raid.cc",
+ "..\\mysys\\safemalloc.c", "..\\mysys\\string.c",
+ "..\\mysys\\thr_alarm.c",
+ "..\\mysys\\thr_mutex.c", "..\\mysys\\thr_rwlock.c",
+ "..\\mysys\\tree.c", "..\\mysys\\typelib.c"
+
+ group my_sys_cli = "..\\mysys\\mf_iocache.c"
+ group my_sys_sql = "..\\mysys\\thr_lock.c"
+
+ group myisam = "..\\myisam\\ft_parser.c",
+ "..\\myisam\\ft_search.c", "..\\myisam\\ft_static.c",
+ "..\\myisam\\ft_stopwords.c", "..\\myisam\\ft_update.c",
+ "..\\myisam\\mi_cache.c", "..\\myisam\\mi_changed.c",
+ "..\\myisam\\mi_check.c", "..\\myisam\\mi_checksum.c",
+ "..\\myisam\\mi_close.c", "..\\myisam\\mi_create.c",
+ "..\\myisam\\mi_dbug.c", "..\\myisam\\mi_delete.c",
+ "..\\myisam\\mi_delete_all.c", "..\\myisam\\mi_delete_table.c",
+ "..\\myisam\\mi_dynrec.c", "..\\myisam\\mi_extra.c",
+ "..\\myisam\\mi_info.c", "..\\myisam\\mi_key.c",
+ "..\\myisam\\mi_locking.c", "..\\myisam\\mi_log.c",
+ "..\\myisam\\mi_open.c", "..\\myisam\\mi_packrec.c",
+ "..\\myisam\\mi_page.c", "..\\myisam\\mi_panic.c",
+ "..\\myisam\\mi_range.c", "..\\myisam\\mi_rename.c",
+ "..\\myisam\\mi_rfirst.c", "..\\myisam\\mi_rkey.c",
+ "..\\myisam\\mi_rlast.c", "..\\myisam\\mi_rnext.c",
+ "..\\myisam\\mi_rnext_same.c", "..\\myisam\\mi_rprev.c",
+ "..\\myisam\\mi_rrnd.c", "..\\myisam\\mi_rsame.c",
+ "..\\myisam\\mi_rsamepos.c", "..\\myisam\\mi_scan.c",
+ "..\\myisam\\mi_search.c", "..\\myisam\\mi_static.c",
+ "..\\myisam\\mi_statrec.c", "..\\myisam\\mi_unique.c",
+ "..\\myisam\\mi_update.c", "..\\myisam\\mi_write.c",
+ "..\\myisam\\sort.c"
+
+ group dbug = "..\\dbug\\dbug.c", "..\\dbug\\factorial.c", "..\\dbug\\sanity.c"
+
+ group readline = "..\\readline\\bind.c", "..\\readline\\callback.c",
+ "..\\readline\\complete.c", "..\\readline\\display.c",
+ //"..\\readline\\emacs_keymap.c",
+ "..\\readline\\funmap.c", "..\\readline\\histexpand.c",
+ "..\\readline\\histfile.c", "..\\readline\\history.c",
+ "..\\readline\\histsearch.c", "..\\readline\\input.c",
+ "..\\readline\\isearch.c", "..\\readline\\keymaps.c",
+ "..\\readline\\kill.c", "..\\readline\\macro.c",
+ "..\\readline\\nls.c", "..\\readline\\parens.c",
+ "..\\readline\\readline.c", "..\\readline\\rltty.c",
+ "..\\readline\\search.c", "..\\readline\\shell.c",
+ "..\\readline\\signals.c", "..\\readline\\terminal.c",
+ "..\\readline\\tilde.c", "..\\readline\\undo.c",
+ "..\\readline\\util.c",
+ //"..\\readline\\vi_keymap.c",
+ "..\\readline\\vi_mode.c", "..\\readline\\xmalloc.c"
+
+group regex = "..\\regex\\regcomp.c", "..\\regex\\regerror.c",
+ "..\\regex\\regexec.c", "..\\regex\\regfree.c", "..\\regex\\reginit.c"
+
diff --git a/os2/MySQL-Sql.icc b/os2/MySQL-Sql.icc
new file mode 100644
index 00000000000..addb645e2db
--- /dev/null
+++ b/os2/MySQL-Sql.icc
@@ -0,0 +1,117 @@
+// disable code inlining when building static libs
+InlineCode = "no"
+
+// include common options
+include "MySQL-Opt.icc"
+include "MySQL-Source.icc"
+
+option ProjectOptions = MySQLOptions
+ , define( "MYSQL_SERVER", "")
+{
+
+ option file(genobject, "..\\OBJ\\ZLIB\\")
+ {
+ target "..\\bin\\mysqld.exe"
+ {
+ // optimized precompiled headers
+ option macros('global', 'yes')
+ {
+ //source type('cpp') gpch
+ source type('cpp') 'os2.h'
+ source type('cpp')
+ //'ctype.h',
+ 'string.h', 'assert.h', 'share.h', 'stdarg.h', 'stdio.h',
+ 'stdlib.h', 'stddef.h', 'math.h', 'io.h', 'limits.h',
+ 'process.h', 'errno.h', 'nerrno.h', 'sys/types.h',
+ 'sys/time.h', 'sys/stat.h', 'sys/param.h', 'sys/ioccom.h',
+ 'sys/filio.h', 'sys/sockio.h', 'sys/ioctlos2.h','sys/ioctl.h', 'types.h'
+
+ source type('cpp')
+ 'global.h', 'my_base.h', 'config-os2.h',
+ 'my_dir.h', 'my_sys.h', 'mysql.h',
+ 'my_bitmap.h', 'violite.h', 'mysql_priv.h',
+ 'm_string.h', 'm_ctype.h'
+
+ source type('cpp') 'myisam.h'
+ source type('cpp') 'myisampack.h'
+ source type('cpp') '.\myisam\myisamdef.h'
+
+ source type('cpp') 'sql_string.h'
+ source type('cpp') 'item.h'
+ source type('cpp') 'unireg.h'
+ source type('cpp') 'field.h'
+ source type('cpp') 'sql_lex.h'
+ source type('cpp') 'sql_list.h'
+ source type('cpp') 'md5.h'
+ source type('cpp') 'sql_acl.h'
+ source type('cpp') 'slave.h'
+ source type('cpp') 'ha_myisam.h'
+ source type('cpp') 'procedure.h'
+ source type('cpp') 'sql_select.h'
+ source type('cpp') 'errmsg.h'
+ source type('cpp') 't_ctype.h'
+ source type('cpp') 'direct.h'
+ source type('cpp') 'mysys_err.h'
+ source type('cpp') 'zconf.h'
+ source type('cpp') 'zlib.h'
+ source type('cpp') 'my_tree.h'
+ source type('cpp') '..\mysys\my_static.h'
+ source type('cpp') 'netdb.h'
+ source type('cpp') 'thr_alarm.h'
+ source type('cpp') 'heap.h'
+ source type('cpp') '..\myisam\fulltext.h'
+ source type('cpp') '..\myisam\ftdefs.h'
+ source type('cpp') 'myisammrg.h'
+
+ }
+ source type('cpp') 'sys/un.h'
+ source type('cpp') 'ha_heap.h'
+ source type('cpp') 'ha_myisammrg.h'
+ source type('cpp') 'opt_ft.h'
+ source type('cpp') 'hash_filo.h'
+ source type('cpp') 'mini_client.h'
+ source type('cpp') 'sql_repl.h'
+ source type('cpp') 'netinet/in_systm.h'
+ source type('cpp') 'netinet/tcp.h'
+ source type('cpp') 'sql_analyse.h'
+ source type('cpp') 'item_create.h'
+ source type('cpp') '..\mysys\mysys_priv.h'
+ source type('cpp') 'sys/utime.h'
+ source type('cpp') 'sys/select.h'
+
+ // target source files
+ source "rint.obj"
+ source zlib, ufc, regex, 'strings\bmove_upp.c'
+ if debug_build {
+ source type('cpp') dbug
+ }
+ source type('cpp') heap
+ source type('cpp') isam
+ source type('cpp') merge
+ source type('cpp') myisam
+ source type('cpp') myisammrg
+ source type('cpp') my_sys
+ source type('cpp') my_sys_sql
+ source type('cpp') strings
+ source type('cpp') sql
+ }
+ }
+/*
+ option define( "MYSQL_SERVER", "")
+ {
+ target "..\\bin\\mysqlbinlog.exe"
+ {
+ // optimized precompiled headers
+ option macros('global', 'yes')
+ {
+ //source type('cpp') client_pch //, 'sql_string.h'
+ }
+ // target source files
+ source type('cpp')
+ "..\\sql\\mysqlbinlog.cc",
+ "..\\sql\\mini_client.cc",
+ "..\\sql\\net_serv.cc"
+ }
+ }
+*/
+}
diff --git a/os2/MySQL-Util.icc b/os2/MySQL-Util.icc
new file mode 100644
index 00000000000..61b1f53bc5f
--- /dev/null
+++ b/os2/MySQL-Util.icc
@@ -0,0 +1,134 @@
+// disable code inlining when building static libs
+InlineCode = "no"
+
+// include common options
+include "MySQL-Opt.icc"
+include "MySQL-Source.icc"
+
+option ProjectOptions = MySQLOptions
+ , link(defaultlibsname, "common.lib")
+ , link(defaultlibsname, "myisam.lib")
+ , link(defaultlibsname, "isam.lib")
+ , link(defaultlibsname, "mysql.lib")
+{
+
+ target "..\\bin\\myisamchk.exe"
+ {
+ // optimized precompiled headers
+ option macros('global', 'yes')
+ {
+ source type('cpp') client_pch
+ }
+ source type('cpp') "..\\myisam\\myisamchk.c"
+ }
+
+ target "..\\bin\\myisamlog.exe"
+ {
+ // optimized precompiled headers
+ option macros('global', 'yes')
+ {
+ source type('cpp') client_pch
+ }
+
+ // target source files
+ source type('cpp') "..\\myisam\\myisamlog.c"
+ }
+
+ target "..\\bin\\myisampack.exe"
+ {
+ // optimized precompiled headers
+ option macros('global', 'yes')
+ {
+ source type('cpp') client_pch
+ }
+ // target source files
+ source type('cpp') "..\\myisam\\myisampack.c"
+ }
+
+ target "..\\bin\\test\\is_test1.exe"
+ {
+ // target source files
+ source type('cpp') "..\\isam\\test1.c"
+ }
+ target "..\\bin\\test\\is_test2.exe"
+ {
+ // target source files
+ source type('cpp') "..\\isam\\test2.c"
+ }
+ target "..\\bin\\test\\mi_test1.exe"
+ {
+ // target source files
+ source type('cpp') "..\\myisam\\mi_test1.c"
+ }
+ target "..\\bin\\test\\mi_test2.exe"
+ {
+ // target source files
+ source type('cpp') "..\\myisam\\mi_test2.c"
+ }
+ target "..\\bin\\test\\ft_eval.exe"
+ {
+ // target source files
+ source type('cpp') "..\\myisam\\ft_eval.c"
+ }
+ target "..\\bin\\test\\ft_test1.exe"
+ {
+ // target source files
+ source type('cpp') "..\\myisam\\ft_test1.c"
+ }
+
+ //target "..\\bin\\test\\testhash.exe"
+ {
+ // target source files
+ //source type('cpp') "..\\mysys\\testhash.c"
+ }
+
+ target "..\\bin\\test\\test_charset.exe"
+ {
+ // target source files
+ source type('cpp') "..\\mysys\\test_charset.c"
+ }
+
+ target "..\\bin\\test\\hp_test1.exe"
+ {
+ // target source files
+ source type('cpp') "..\\heap\\hp_test1.c"
+ }
+ target "..\\bin\\test\\hp_test2.exe"
+ {
+ // target source files
+ source type('cpp') "..\\heap\\hp_test2.c"
+ }
+
+ option define( "MAIN", "")
+ {
+ target "..\\bin\\test\\thr_lock.exe"
+ {
+ // target source files
+ source type('cpp') "..\\mysys\\thr_lock.c"
+ }
+ }
+
+ target "..\\bin\\test\\insert_test.exe"
+ {
+ // optimized precompiled headers
+ option macros('global', 'yes')
+ {
+ source type('cpp') client_pch
+ }
+ source type('cpp') "..\\client\\insert_test.c"
+ }
+ target "..\\bin\\test\\select_test.exe"
+ {
+ source type('cpp') "..\\client\\select_test.c"
+ }
+ target "..\\bin\\test\\thread_test.exe"
+ {
+ // optimized precompiled headers
+ option macros('global', 'yes')
+ {
+ source type('cpp') client_pch
+ }
+ source type('cpp') "..\\client\\thread_test.c"
+ }
+
+}
diff --git a/os2/MySQL-Util.irs b/os2/MySQL-Util.irs
new file mode 100644
index 00000000000..01a1f62a483
--- /dev/null
+++ b/os2/MySQL-Util.irs
@@ -0,0 +1,3067 @@
+31 Run Specifications: Version 1.1
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamchk.exe
+1
+0
+0
+5 Local
+0
+43 E:\rd\mysql\vacpp-3.23.40\bin\myisamlog.exe
+1
+0
+0
+5 Local
+0
+44 E:\rd\mysql\vacpp-3.23.40\bin\myisampack.exe
+1
+0
+0
+5 Local
+0
+47 E:\rd\mysql\vacpp-3.23.40\bin\test\is_test1.exe
+1
+0
+0
+5 Local
+0
+47 E:\rd\mysql\vacpp-3.23.40\bin\test\is_test2.exe
+1
+0
+0
+5 Local
+0
+47 E:\rd\mysql\vacpp-3.23.40\bin\test\mi_test1.exe
+1
+0
+0
+5 Local
+0
+47 E:\rd\mysql\vacpp-3.23.40\bin\test\mi_test2.exe
+1
+0
+0
+5 Local
+0
+46 E:\rd\mysql\vacpp-3.23.40\bin\test\ft_eval.exe
+1
+0
+0
+5 Local
+0
+47 E:\rd\mysql\vacpp-3.23.40\bin\test\ft_test1.exe
+1
+0
+0
+5 Local
+0
+51 E:\rd\mysql\vacpp-3.23.40\bin\test\test_charset.exe
+1
+0
+0
+5 Local
+0
+47 E:\rd\mysql\vacpp-3.23.40\bin\test\hp_test1.exe
+1
+0
+0
+5 Local
+0
+47 E:\rd\mysql\vacpp-3.23.40\bin\test\hp_test2.exe
+1
+0
+0
+5 Local
+0
+47 E:\rd\mysql\vacpp-3.23.40\bin\test\thr_lock.exe
+1
+0
+0
+5 Local
+0
+50 E:\rd\mysql\vacpp-3.23.40\bin\test\insert_test.exe
+1
+0
+0
+5 Local
+0
+50 E:\rd\mysql\vacpp-3.23.40\bin\test\select_test.exe
+1
+0
+0
+5 Local
+0
+50 E:\rd\mysql\vacpp-3.23.40\bin\test\thread_test.exe
+1
+0
+0
+5 Local
+0
diff --git a/os2/MySQL-binlog.icc b/os2/MySQL-binlog.icc
new file mode 100644
index 00000000000..d441198f5e0
--- /dev/null
+++ b/os2/MySQL-binlog.icc
@@ -0,0 +1,68 @@
+// disable code inlining when building static libs
+InlineCode = "no"
+
+// include common options
+include "MySQL-Opt.icc"
+include "MySQL-Source.icc"
+
+option ProjectOptions = MySQLOptions
+ , define( "MYSQL_SERVER", "")
+ , link(defaultlibsname, "common.lib")
+ , link(defaultlibsname, "myisam.lib")
+ , link(defaultlibsname, "isam.lib")
+ , link(defaultlibsname, "mysql.lib")
+{
+ option define( "MYSQL_SERVER", "")
+ {
+ target "..\\bin\\mysqlbinlog.exe"
+ {
+ // optimized precompiled headers
+ option macros('global', 'yes')
+ {
+ source type('cpp') 'os2.h'
+ source type('cpp') 'errno.h', 'nerrno.h'
+ source type('cpp') 'config-os2.h', 'mysql_com.h'
+/*
+ source type('cpp')
+ 'global.h', 'my_base.h', 'config-os2.h',
+ 'my_dir.h', 'my_sys.h', 'mysql.h',
+ 'my_bitmap.h', 'violite.h',
+ 'mysql_priv.h',
+ 'm_string.h'
+*/
+ }
+ // target source files
+ source type('cpp')
+ "..\\sql\\mysqlbinlog.cc"
+ option macros('global', 'yes')
+ {
+ source type('cpp') 'sys/stat.h'
+ }
+ source type('cpp') "..\\sql\\mini_client.cc"
+ option macros('global', 'yes')
+ {
+ source type('cpp') 'os2.h'
+ source type('cpp') 'math.h'
+ source type('cpp') 'stdio.h'
+ source type('cpp') 'stdlib.h'
+ source type('cpp') 'stddef.h'
+ source type('cpp') 'limits.h'
+ source type('cpp') 'sys/types.h'
+ source type('cpp') 'sys/time.h'
+ source type('cpp') 'types.h'
+ source type('cpp') 'stdarg.h'
+ source type('cpp') 'string.h'
+ }
+ source type('cpp') "..\\sql\\net_serv.cc",
+ "..\\sql\\mini_client_errors.c"
+ option macros('global', 'yes')
+ {
+ source type('cpp') 'assert.h'
+ }
+ source type('cpp') "..\\sql\\violite.c",
+ "..\\sql\\password.c"
+ //"..\\sql\\thr_malloc.cc"
+ }
+ }
+
+}
diff --git a/os2/MySQL-binlog.irs b/os2/MySQL-binlog.irs
new file mode 100644
index 00000000000..8d094544f1c
--- /dev/null
+++ b/os2/MySQL-binlog.irs
@@ -0,0 +1,7 @@
+31 Run Specifications: Version 1.1
+45 E:\rd\mysql\vacpp-3.23.40\bin\mysqlbinlog.exe
+1
+0
+0
+5 Local
+0
diff --git a/os2/MySQL-sql.irs b/os2/MySQL-sql.irs
new file mode 100644
index 00000000000..dc0b016d8d4
--- /dev/null
+++ b/os2/MySQL-sql.irs
@@ -0,0 +1,13 @@
+31 Run Specifications: Version 1.1
+40 E:\rd\mysql\vacpp-3.23.40\bin\mysqld.exe
+1
+0
+0
+5 Local
+0
+40 E:\rd\mysql\vacpp-3.23.40\bin\mysqld.exe
+1
+0
+0
+5 Local
+0
diff --git a/os2/build-all.cmd b/os2/build-all.cmd
new file mode 100644
index 00000000000..9cb9ef6ea44
--- /dev/null
+++ b/os2/build-all.cmd
@@ -0,0 +1,11 @@
+
+mkdir ..\bin
+mkdir ..\bin\test
+mkdir ..\lib
+mkdir ..\obj
+mkdir ..\obj\zlib
+
+vacbld MySQL-Lib.icc -showprogress=10 -showwarning >> build-all.log
+vacbld MySQL-Client.icc -showprogress=10 -showwarning >> build-all.log
+vacbld MySQL-Sql.icc -showprogress=10 -showwarning >> build-all.log
+vacbld MySQL-Util.icc -showprogress=10 -showwarning >> build-all.log
diff --git a/os2/build-all.log b/os2/build-all.log
new file mode 100644
index 00000000000..a5a64db316f
--- /dev/null
+++ b/os2/build-all.log
@@ -0,0 +1,39 @@
+Item 237 of 47475 (0%) ... source file ..\mysys\list.c
+Item 4357 of 29226 (15%) ... source region "extern int _Optlink _spawnve(int, const char *, const char ..."
+Item 10021 of 16290 (62%) ... initializer [0x7319920] for uchar to_upper_latin1[]
+Item 11487 of 15248 (75%) ... kernel-provided extension source file \rd\mysql\zlib-1.1.3\crc32.c
+Item 12920 of 15380 (84%) ... body of function [0x6dca980] int my_strcoll_czech(const uchar *, const uchar *)
+Item 13952 of 16411 (85%) ... output object file E:\rd\mysql\vacpp-3.23.33\os2\ft_search.obj
+Item 14083 of 16542 (85%) ... publish library or executable marker
+Item 1278 of 16668 (8%) ... source region "typedef STARTDATA *PSTARTDATA;"
+Item 6013 of 8617 (70%) ... kernel-provided extension source file \rd\mysql\zlib-1.1.3\trees.c
+Item 6962 of 8581 (81%) ... initializer [0x229bf00] for const char @485 (static target)[23] "Failed in mysql_init()"
+Item 7519 of 9019 (83%) ... initializer [0x2337bc0] for const char @630 (static target)[20] "No query specified
+"
+Item 8502 of 10001 (85%) ... publish library or executable marker
+Item 182 of 49201 (0%) ... source file ..\myisam\mi_statrec.c
+Item 2136 of 46089 (5%) ... source region "class Item_sum_udf_float :public Item_udf_sum { public: Item_sum_udf_float ..."
+Item 11112 of 25912 (43%) ... source region "extern uint _nisam_get_key(N_KEYDEF *keyinfo ..."
+Item 13919 of 24304 (57%) ... initializer [0x1ec6f10] for const short yypgoto[]
+Item 15179 of 23800 (64%) ... kernel-provided extension source file \rd\mysql\zlib-1.1.3\trees.c
+Item 17342 of 24056 (72%) ... initializer [0x29d1180] for __vftType __vft10Field_date5Field[46]
+Item 17912 of 24406 (73%) ... body of function [0x1d1df40] void Item_func_case::print(String *)
+Item 18247 of 24721 (74%) ... template instantiation (0x2b9dd20) of declaration of class I_List<thread_info> (2b9dc20)
+Item 18775 of 25165 (75%) ... initializer [0x2c45600] for __vftType __vft18Item_func_get_lock4Item[34]
+Item 19066 of 25369 (75%) ... initializer [0x2c800d0] for const char @2105 (static target)[22] "parser stack overflow"
+Item 19395 of 25535 (76%) ... body of function [0x171eef0] db_type ha_checktype(db_type)
+Item 19682 of 25654 (77%) ... body of function [0x17f1860] void kill_mysql()
+Item 20070 of 25717 (78%) ... body of function [0x183e570] Item *create_func_date_format(Item *, Item *)
+Item 20541 of 25764 (80%) ... body of function [0x1802b40] uint acl_get(const char *, const char *, const char *, const char *, const char *)
+Item 21017 of 25874 (81%) ... body of function [0x2c55180] String *field_str::get_max_arg(String *)
+Item 21406 of 25988 (82%) ... initializer [0x372d950] for const char @2567 (static target)[7] "%s(%d)"
+Item 22411 of 25867 (87%) ... body of function [0x161b160] Item_func_udf_int::Item_func_udf_int(udf_func *)
+Item 23345 of 25805 (90%) ... initializer [0x3447840] for const char @2709 (static target)[27] "waiting for handler insert"
+Item 23783 of 26226 (91%) ... initializer [0x39a95b0] for const char @2766 (static target)[25] "Creating delayed handler"
+Item 24887 of 27330 (91%) ... body of function [0x2b075a0] Item_load_file::~Item_load_file()
+Item 25018 of 27461 (91%) ... body of function [0x2cf5e50] Item_sum::Item_sum()
+Item 25267 of 27710 (91%) ... body of function [0x1c93d80] bool select_export::send_data(List<Item> &)
+Item 25484 of 27927 (91%) ... body of function [0x116e840] Item *create_func_ascii(Item *)
+Item 3212 of 9073 (35%) ... source region "extern int _mi_cmp_static_record(MI_INFO *info,const byte ..."
+Item 7171 of 8564 (84%) ... code csect _test_handle from library E:\bin\IBMCPP40\LIB\CPPRMS40.LIB
+Item 8345 of 9738 (86%) ... target E:\rd\mysql\vacpp-3.23.33\os2\..\bin\test\testhash.exe
diff --git a/os2/mysql.base b/os2/mysql.base
new file mode 100644
index 00000000000..4f0886e0697
--- /dev/null
+++ b/os2/mysql.base
@@ -0,0 +1,127 @@
+#include "mysql.ih"
+
+<WARPIN VERSION <$WARPIN_VERSION>>
+<HEAD>
+
+<PCK INDEX=1
+ PACKAGEID="TCX Datakonsult AB\MySQL for OS/2\SQL Database Engine\<$MySQL\Ver>"
+ TARGET="?:\usr\local\mysql" BASE
+ TITLE="SQL Database Engine"
+ EXECUTE="$(1)\bootstrap.cmd [bootstrap]"
+ CONFIG.SYS="SET EMXOPT=-h1024 | UNIQUE(-h)"
+ CREATEOBJECT="WPFolder|MySQL <$MySQL.Ver>|<WP_DESKTOP>|OBJECTID=<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_FOLDER>"
+ CREATEOBJECT="WPProgram|Console|<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_FOLDER>|EXENAME=$(1)\bin\mysql.exe;STARTUPDIR=$(1)\bin;ICONFILE=$(1)\bin\icons\mysql-client.ico;OBJECTID=<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_CONSOLE>;"
+ CREATEOBJECT="WPProgram|Start server|<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_FOLDER>|EXENAME=$(1)\bin\mysqld.exe;ICONFILE=$(1)\bin\icons\mysql-startserver.ico;OBJECTID=<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_START>;"
+ CREATEOBJECT="WPProgram|Shutdown server|<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_FOLDER>|EXENAME=$(1)\bin\mysqladmin.exe;STARTUPDIR=$(1)\bin;PARAMETERS=-u root shutdown;ICONFILE=$(1)\bin\icons\mysql-shutdownserver.ico;OBJECTID=<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_SHUTDOWN>;"
+ CREATEOBJECT="WPProgram|Readme first|<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_FOLDER>|EXENAME=e.exe;PARAMETERS=$(1)\readme.os2;OBJECTID=<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_README>;"
+ SELECT
+ >This package will install MySQL for OS/2 SQL engine
+</PCK>
+
+<PCK INDEX=2
+ PACKAGEID="TCX Datakonsult AB\MySQL for OS/2\Developement Kit\<$MySQL\Ver>"
+ TARGET="?:\usr\local\mysql"
+ TITLE="Developement Kit"
+ SELECT
+ >This package will install MySQL for OS/2 sdk
+</PCK>
+
+<PCK INDEX=3
+ PACKAGEID="TCX Datakonsult AB\MySQL for OS/2\PDF manual\<$MySQL\Ver>"
+ TARGET="?:\usr\local\mysql"
+ TITLE="PDF manual"
+ EXTERNAL="mysql-3-23-28-gamma-pdf.wpi"
+ CREATEOBJECT="WPShadow|PDF Manual|<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_FOLDER>|SHADOWID=$(1)\docs\manual.pdf"
+ SELECT
+ >This package will install MySQL for OS/2 documentation
+</PCK>
+
+<PCK INDEX=4
+ PACKAGEID="TCX Datakonsult AB\MySQL for OS/2\INF manual\<$MySQL\Ver>"
+ TARGET="?:\usr\local\mysql"
+ TITLE="INF manual"
+ EXTERNAL="mysql-3-23-28-gamma-inf.wpi"
+ CREATEOBJECT="WPProgram|MySQL Manual|<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_FOLDER>|EXENAME=view.exe;PARAMETERS=$(1)\docs\manual.inf;ICONFILE=$(1)\bin\icons\mysql-manual.ico;OBJECTID=<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_INFMANUAL>;"
+ SELECT
+ >This package will install MySQL for OS/2 documentation
+</PCK>
+
+<PCK INDEX=5
+ PACKAGEID="TCX Datakonsult AB\MySQL for OS/2\Test suite\<$MySQL\Ver>"
+ TARGET="?:\usr\local\mysql"
+ TITLE="Test suite"
+ EXTERNAL="mysql-<$MySQL-Ver>-test.wpi"
+ CREATEOBJECT="WPProgram|Run MySQL Test Suite|<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_FOLDER>|EXENAME=$(5)\mysql-test\mysql-test.cmd;PARAMETERS=$(1)\docs\manual.inf;ICONFILE=$(1)\bin\icons\mysql-manual.ico;OBJECTID=<MYSQL_<$MySQL.Major>_<$MySQL.Minor>_TESTSUITE>;"
+ SELECT
+ >This package will install MySQL for OS/2 test suite
+</PCK>
+
+</HEAD>
+
+<!-- Here come the different pages. They are linked by
+ the <NEXTBUTTON> tags, which must have a target.
+ Each page must have a TYPE= attribute, which tells
+ WarpIn what will be visible on that page. -->
+
+<BODY>
+
+<!-- page1: introduction ->>
+<PAGE INDEX=1 TYPE=README>
+<TEXT>
+</TEXT>
+<NEXTBUTTON TARGET=2>~Next</NEXTBUTTON>
+<README FORMAT=HTML>
+
+<P>Welcome to the latest port of MySQL for <B>OS/2 and eComStation</B>.
+
+<P>You are about to install <B>MySQL <$MySQL.Ver></B>
+
+<BR>
+<BR>
+<P>Select "Next" to continue.
+
+<P>Select "Cancel" to abort installation.
+</README>
+</PAGE>
+
+<!-- show readme.os2 -->
+<PAGE INDEX=2 TYPE=README>
+<NEXTBUTTON TARGET=3>~Next</NEXTBUTTON>
+<TEXT>
+</TEXT>
+<README FORMAT=PLAIN EXTRACTFROMPCK="1">readme.os2</README>
+</PAGE>
+
+<!-- show GPL license -->
+<PAGE INDEX=3 TYPE=README>
+<NEXTBUTTON TARGET=4>~I agree</NEXTBUTTON>
+<TEXT>
+By pressing the "I agree" button, you agree to all terms and conditions to the below licence agreement.
+</TEXT>
+<README FORMAT=HTML EXTRACTFROMPCK="1">license.htm</README>
+</PAGE>
+
+
+<!-- The TYPE=CONTAINER will list the packages which can be installed. -->
+
+<PAGE INDEX=4 TYPE=CONTAINER>
+<NEXTBUTTON TARGET=5>~Next</NEXTBUTTON>
+<TEXT>
+Please select the packages which are to be installed. You may change the target paths for the packages.
+</TEXT>
+</PAGE>
+
+<!-- Here's another TYPE=TEXT page before we install.
+ The special target "0" indicates that after this page we
+ should start installation.
+ Note that the TYPE=INSTALL page (which we had in Alpha #3)
+ is no longer supported. -->
+
+<PAGE INDEX=5 TYPE=TEXT>
+<NEXTBUTTON TARGET=0>I~nstall</NEXTBUTTON>
+<TEXT>
+Press "Install" to begin installing this archive.</TEXT>
+</PAGE>
+
+</BODY>
+</WARPIN>
diff --git a/os2/mysql.ih b/os2/mysql.ih
new file mode 100644
index 00000000000..71978c4135a
--- /dev/null
+++ b/os2/mysql.ih
@@ -0,0 +1,7 @@
+#define WARPIN_VERSION "0.9.12"
+#define MySQL.Major 3
+#define MySQL.Minor 23
+#define MySQL.Rev 40
+#define MySQL\VER 3\23\40
+#define MySQL.VER 3.23.40
+#define MySQL-VER 3-23-40
diff --git a/os2/readme.os2 b/os2/readme.os2
new file mode 100644
index 00000000000..9936dd15369
--- /dev/null
+++ b/os2/readme.os2
@@ -0,0 +1,190 @@
+MySQL 3.23.40 for OS/2 Warp build 1
+====================================================
+
+Contents
+--------
+Welcome to the latest port of MySQL for OS/2 and eComStation.
+
+Modules included in this build:
+ - protocol data compression
+ - transaction support
+ - perl BDB/BDI support (not in this package)
+ - Library and header files for C/CPP developers included
+
+This package has been built using IBM VAC++ 4.0
+
+The MySQL server is distributed under the GPL license. Please refer to
+the file COPYING for the license information.
+
+The MySQL client library is distributed under the LGPL license.
+Please refer to the file COPYING for the license information.
+
+Most of the MySQL clients are distributed under the GPL license, but
+some files may be in the public domain.
+
+The latest information about MySQL can be found at: http://www.mysql.com
+
+To get the latest information about this port please subscribe to our
+newsgroup/mailinglist mysql2 at www.egroups.com.
+
+To see what MySQL can do, take a look at the features section in the
+manual. For future plans see the TODO appendix in the manual.
+
+New features/bug fixes history is in the news appendix in the manual.
+
+For the currently known bugs/misfeatures (known errors) see the bugs
+appendix in the manual. The OS/2 section contains notes that are
+specific to the MySQL OS/2 and eComStation version.
+
+Please note that MySQL is a constantly moving target. New builds for
+Linux are made available every week. This port may therefore be a few
+minor versions after the latest Linux/Win32 builds but its generally
+more stable than the "latest and greates" port.
+
+MySQL is brought to you by: TcX DataKonsult AB & MySQL Finland AB
+
+This port is brought to you by:
+
+Yuri Dario <mc6530@mclink.it>, development, porting
+Timo Maier <tam@gmx.de>, documentation, testing
+John M Alfredsson <jma@jmast.se>, documentation, testing
+
+
+Installation
+------------
+Prerequisite:
+
+- OS/2 Warp 3 with FP ?? or later,
+ OS/2 Warp 4 with FP ?? or later,
+ OS/2 Warp Server for e-Business,
+ eComStation 1.0 (prev 1/2 OK)
+- TCPIP 4.x installed (requires 32-bit tcpip stack)
+- WarpIN installer 0.9.12 (ftp://ftp.os2.org/xworkplace/warpin-0-9-12.zip)
+
+Note: probably some fixpak level is required on both Warp3&Warp4 to
+ support >2GB file sizes.
+
+Save the installation archives into a temporary folder and double click
+on the main package; otherwise you can drop the mysql package in your
+WarpIN object or type
+
+ WARPIN MYSQL-3-23-??-B1.WPI
+
+from the command line.
+The configuration file for MySQL is named my.cnf and it is placed into
+your %ETC% directory. Usually it located into the boot driver under
+
+ x:\MPTN\ETC
+
+If the installation detect an existing configuration file, this will be
+renamed to my.cnf.bak; your current settings aren't migrated to current
+installation. This file is not deleted by uninstall process.
+Startup options for MySQL daemon could be added there.
+
+As default, client connections uses data compression: if you don't like it,
+remove the following from your %ETC%\my.cnf
+
+ [client]
+ compress
+
+The server switches automatically compression mode on client request.
+
+SMP systems: while my developement system is a SMP one, and here MySQL seems
+to run fine with two processors enabled, keep in mind that both EMX runtime
+and current thread model are not SMP safe.
+
+This release comes with DLL client library MYSQL.DLL: it is installed by
+default into mysql\bin together with client applications. Copy it to your
+x:\OS2\DLL or another directory in your LIBPATH to run command line
+utilities from every place.
+
+
+Documentation
+-------------
+Documentation is provided in separate files. You can use either
+the PDF documentation (requires Adobe Acrobat Reader) or the
+INF documentation (requires OS/2 view or NewView).
+
+The PDF documentation is found in MYSQL-3-23-28-PDF.WPI and
+the INF documentation is found in MYSQL-3-23-28-INF.WPI
+
+The latest documentation can always be downloaded from
+http://www.mysql.com. However this documentation may
+no fully apply to this port.
+The INF documentation could contain errors because of semi-automatic
+translation from texi original.
+
+Support
+-------
+Since MySQL is a OpenSource freeware product there are no
+formal support options available.
+
+Please subscribe to mysql2 at www.egroups.com to get in contact
+with other users using this port.
+
+http://www.egroups.com/group/mysql2
+
+This newsgroup/mailinglist is the official "home" of this port.
+
+
+Know problems
+-------------
+alter_table.test and show_check are failing, reporting a different status
+message: actually seems only a different text, no bugs in table checking.
+
+
+Apache/2 + PHP
+--------------
+To avoid problems with different socket when you use PHP and Apache
+webserver, get the PHP4 module from the Apache Server for OS/2 homepage
+http://silk.apana.org.au/apache/
+
+
+Developing MySQL
+----------------
+If you want to help us develop MySQL for OS2/eComStation please join
+the mysql2 mailinglist at www.egroups.com and ask for help to set up
+your environment!
+
+All questions that are specific to the OS2/eComStation version should
+be posted to this list! Please remember to include all relevant
+information that may help solve your problem.
+
+
+Building MySQL (EMX)
+--------------------
+NOTE: these instructions are outdated
+
+db-3.2.x: before compiling MySQL, you need to setup Berkeley DB. Untar
+the distribution, enter dist directory and run
+
+attrib -r * /s
+sh -c s_config
+
+to create proper aclocal macros and configure headers.
+
+In the src directory you will find patches used to build this release
+of MySQL.
+You can run 'sh -c config.status' to create current makefiles without
+running autoconf & configure.
+
+apply previous patches (if not already included)
+sh -c autoconf (upgrade scripts)
+sh -c configure.os2 (config system)
+edit config.status:
+ s%@MYSQL_UNIX_ADDR@%\\socket\\MySQL%g
+ s%@LN_CP_F@%cp.exe%g
+ replace -O2 -m486 with -mpentiumpro
+sh -c config.status (upgrade makefiles again)
+edit libmysql\Makefile
+ remove all occurences of -Zexe
+ replace libmysqlclient with libmysql (case sensitive search)
+edit client\Makefile
+ replace libmysqlclient with libmysql (case sensitive search)
+make
+
+After config.status, you have to edit include\mysql_version.h and correct
+the socket definition (\\socket\\MySQL is correct).
+If you go with configure, you have to change LN_CP_F macro from 'ln -s' to
+'cp' and correct all makefiles (sh -c config.status will do it).
+
diff --git a/os2/rint.cmd b/os2/rint.cmd
new file mode 100644
index 00000000000..522eff166bf
--- /dev/null
+++ b/os2/rint.cmd
@@ -0,0 +1,4 @@
+REM -DLONG_DOUBLE
+REM -DFLOAT
+REM none -> double
+gcc -Zomf -c -x assembler-with-cpp rint.s
diff --git a/os2/rint.obj b/os2/rint.obj
new file mode 100644
index 00000000000..41c766c6661
--- /dev/null
+++ b/os2/rint.obj
Binary files differ
diff --git a/os2/rint.s b/os2/rint.s
new file mode 100644
index 00000000000..7f6569ed72c
--- /dev/null
+++ b/os2/rint.s
@@ -0,0 +1,32 @@
+/ rint.s (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
+
+#include <emx/asm386.h>
+
+#define FUNC MATHSUFFIX2(rint)
+
+ .globl LABEL(FUNC)
+
+ .text
+
+ ALIGN
+
+/ double _rint (double x)
+
+#define cw1 0(%esp)
+#define cw2 2(%esp)
+/define ret_addr 4(%esp)
+#define x 8(%esp)
+
+LABEL(FUNC):
+ PROFILE_NOFRAME
+ subl $4, %esp
+ fstcww cw1
+ movw cw1, %ax
+ andw $0xf3ff, %ax /* round to nearest or even */
+ movw %ax, cw2
+ fldcww cw2
+ FLD x /* x */
+ frndint
+ fldcww cw1
+ addl $4, %esp
+ EPILOGUE(FUNC)
diff --git a/sql-bench/bench-init.pl.sh b/sql-bench/bench-init.pl.sh
index adfa114f569..0c4b1cb1b6a 100644
--- a/sql-bench/bench-init.pl.sh
+++ b/sql-bench/bench-init.pl.sh
@@ -31,7 +31,7 @@
# $server Object for current server
# $limits Hash reference to limits for benchmark
-$benchmark_version="2.13";
+$benchmark_version="2.14";
use Getopt::Long;
require "$pwd/server-cfg" || die "Can't read Configuration file: $!\n";
@@ -295,6 +295,35 @@ sub do_query
die "\nError executing '$query':\n$DBI::errstr\n";
}
+#
+# Run a query X times
+#
+
+sub time_fetch_all_rows
+{
+ my($test_text,$result_text,$query,$dbh,$test_count)=@_;
+ my($i,$loop_time,$end_time,$count,$rows,$estimated);
+
+ print $test_text . "\n" if (defined($test_text));
+ $count=$rows=0;
+ $loop_time=new Benchmark;
+ for ($i=1 ; $i <= $test_count ; $i++)
+ {
+ $count++;
+ $rows+=fetch_all_rows($dbh,$query) or die $DBI::errstr;
+ $end_time=new Benchmark;
+ last if ($estimated=predict_query_time($loop_time,$end_time,\$count,$i,
+ $test_count));
+ }
+ $end_time=new Benchmark;
+ if ($estimated)
+ { print "Estimated time"; }
+ else
+ { print "Time"; }
+ print " for $result_text ($count:$rows) " .
+ timestr(timediff($end_time, $loop_time),"all") . "\n\n";
+}
+
#
# Handle estimated time of the server is too slow
diff --git a/sql-bench/test-insert.sh b/sql-bench/test-insert.sh
index b8f20b123a5..655e38b1b0e 100644
--- a/sql-bench/test-insert.sh
+++ b/sql-bench/test-insert.sh
@@ -562,7 +562,7 @@ if ($limits->{'group_functions'})
fetch_all_rows($dbh,"select min(id) from bench1");
fetch_all_rows($dbh,"select max(id) from bench1");
fetch_all_rows($dbh,"select sum(id+0.0) from bench1");
- fetch_all_rows($dbh,"select min(id3),max(id3),sum(id3 +0.0) from bench1");
+ fetch_all_rows($dbh,"select min(id3),max(id3),sum(id3-0.0) from bench1");
if ($limits->{'group_func_sql_min_str'})
{
fetch_all_rows($dbh,"select min(dummy1),max(dummy1) from bench1");
@@ -579,7 +579,7 @@ if ($limits->{'group_functions'})
$count++;
- $sth=$dbh->prepare($query="select count(*),sum(id+0.0),min(id),max(id),avg(id+0.0) from bench1") or die $DBI::errstr;
+ $sth=$dbh->prepare($query="select count(*),sum(id+0.0),min(id),max(id),avg(id-0.0) from bench1") or die $DBI::errstr;
$sth->execute or die $DBI::errstr;
@row=$sth->fetchrow_array;
if ($row[0] != $total_rows ||
@@ -1007,6 +1007,43 @@ if ($server->small_rollback_segment())
$dbh = $server->connect();
}
+###
+### Test speed of IN( value list)
+###
+
+if ($limits->{'left_outer_join'})
+{
+ if ($opt_lock_tables)
+ {
+ $sth = $dbh->do("UNLOCK TABLES") || die $DBI::errstr;
+ }
+ print "\n";
+ do_many($dbh,$server->create("bench2",
+ ["id int NOT NULL"],
+ ["primary key (id)"]));
+
+ $max_tests=min(($limits->{'query_size'}-50)/6, $opt_loop_count);
+
+ if ($opt_lock_tables)
+ {
+ $sth = $dbh->do("LOCK TABLES bench1 READ, bench2 WRITE") ||
+ die $DBI::errstr;
+ }
+ test_where_in("bench1","bench2","id",1,10);
+ test_where_in("bench1","bench2","id",11,min(100,$max_tests));
+ test_where_in("bench1","bench2","id",101,min(1000,$max_tests));
+ if ($opt_lock_tables)
+ {
+ $sth = $dbh->do("UNLOCK TABLES") || die $DBI::errstr;
+ }
+ $sth = $dbh->do("DROP TABLE bench2" . $server->{'drop_attr'}) ||
+ die $DBI::errstr;
+ if ($opt_lock_tables)
+ {
+ $sth = $dbh->do("LOCK TABLES bench1 WRITE") || die $DBI::errstr;
+ }
+}
+
####
#### Test INSERT INTO ... SELECT
####
@@ -1067,7 +1104,6 @@ if ($limits->{'insert_select'})
}
}
-
####
#### Do some deletes on the table
####
@@ -1605,3 +1641,38 @@ sub check_or_range
print " for $check ($count:$found): " .
timestr(timediff($end_time, $loop_time),"all") . "\n";
}
+
+#
+# General test of SELECT ... WHERE id in(value-list)
+#
+
+sub test_where_in
+{
+ my ($t1,$t2,$id,$from,$to)= @_;
+
+ return if ($from >= $to);
+
+ $query="SELECT $t1.* FROM $t1 WHERE $id IN (";
+ for ($i=1 ; $i <= $to ; $i++)
+ {
+ $query.="$i,";
+ }
+ $query=substr($query,0,length($query)-1) . ")";
+
+ # Fill join table to have the same id's as 'query'
+ for ($i= $from ; $i <= $to ; $i++)
+ {
+ $dbh->do("insert into $t2 values($i)") or die $DBI::errstr;
+ }
+ if ($opt_fast && defined($server->{vacuum}))
+ {
+ $server->vacuum(1,\$dbh,"bench1");
+ }
+
+ time_fetch_all_rows("Testing SELECT ... WHERE id in ($to values)",
+ "select_in", $query, $dbh,
+ $range_loop_count);
+ time_fetch_all_rows(undef, "select_join_in",
+ "SELECT $t1.* FROM $t2 left outer join $t1 on ($t1.$id=$t2.$id)",
+ $dbh, $range_loop_count);
+}
diff --git a/sql-bench/test-select.sh b/sql-bench/test-select.sh
index 3c7efe3c5c2..1ecad5804c5 100644
--- a/sql-bench/test-select.sh
+++ b/sql-bench/test-select.sh
@@ -136,12 +136,12 @@ if ($limits->{'group_functions'})
print "Test if the database has a query cache\n";
# First ensure that the table is read into memory
- fetch_all_rows($dbh,"select sum(idn+$tmp),sum(rev_idn+$tmp) from bench1");
+ fetch_all_rows($dbh,"select sum(idn+$tmp),sum(rev_idn-$tmp) from bench1");
$loop_time=new Benchmark;
for ($tests=0 ; $tests < $opt_loop_count ; $tests++)
{
- fetch_all_rows($dbh,"select sum(idn+$tests),sum(rev_idn+$tests) from bench1");
+ fetch_all_rows($dbh,"select sum(idn+$tests),sum(rev_idn-$tests) from bench1");
}
$end_time=new Benchmark;
print "Time for select_query_cache ($opt_loop_count): " .
@@ -153,7 +153,7 @@ if ($limits->{'group_functions'})
$loop_time=new Benchmark;
for ($tests=0 ; $tests < $opt_loop_count ; $tests++)
{
- fetch_all_rows($dbh,"select sum(idn+$tests),sum(rev_idn+$tests) from bench1");
+ fetch_all_rows($dbh,"select sum(idn+$tests),sum(rev_idn-$tests) from bench1");
}
$end_time=new Benchmark;
print "Time for select_query_cache2 ($opt_loop_count): " .
diff --git a/sql/field.cc b/sql/field.cc
index 78f57c5ceb5..01178efbdb1 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -2295,7 +2295,7 @@ void Field_timestamp::store(longlong nr)
}
else
#endif
- longstore(ptr,timestamp);
+ longstore(ptr,(ulong)timestamp);
}
@@ -4122,7 +4122,7 @@ ulonglong Field_blob::get_id(const char *from)
ulonglong id = 0;
ulong length=get_length(from);
if (length)
- longlongget(id, from+packlength);
+ uint8korr(id, from+packlength);
return id;
}
diff --git a/sql/field.h b/sql/field.h
index b5d7c613701..b9d8e1957c9 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -38,8 +38,8 @@ public:
static void operator delete(void *ptr_arg, size_t size) {} /*lint -e715 */
enum utype { NONE,DATE,SHIELD,NOEMPTY,CASEUP,PNR,BGNR,PGNR,YES,NO,REL,
- CHECK,EMPTY,UNKNOWN,CASEDN,NEXT_NUMBER,INTERVAL_FIELD,BIT_FIELD,
- TIMESTAMP_FIELD,CAPITALIZE,BLOB_FIELD};
+ CHECK,EMPTY,UNKNOWN_FIELD,CASEDN,NEXT_NUMBER,INTERVAL_FIELD,
+ BIT_FIELD, TIMESTAMP_FIELD,CAPITALIZE,BLOB_FIELD};
char *ptr; // Position to field in record
uchar *null_ptr; // Byte where null_bit is
uint8 null_bit; // And position to it
@@ -300,6 +300,7 @@ public:
void store(const char *to,uint length);
void store(double nr);
void store(longlong nr);
+ void reset(void) { ptr[0]=0; }
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
@@ -328,6 +329,7 @@ public:
void store(const char *to,uint length);
void store(double nr);
void store(longlong nr);
+ void reset(void) { ptr[0]=ptr[1]=0; }
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
@@ -356,6 +358,7 @@ public:
void store(const char *to,uint length);
void store(double nr);
void store(longlong nr);
+ void reset(void) { ptr[0]=ptr[1]=ptr[2]=0; }
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
@@ -389,6 +392,7 @@ public:
void store(const char *to,uint length);
void store(double nr);
void store(longlong nr);
+ void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; }
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
@@ -423,6 +427,7 @@ public:
void store(const char *to,uint length);
void store(double nr);
void store(longlong nr);
+ void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0; }
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
@@ -449,6 +454,7 @@ public:
void store(const char *to,uint length);
void store(double nr);
void store(longlong nr);
+ void reset(void) { bzero(ptr,sizeof(float)); }
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
@@ -480,6 +486,7 @@ public:
void store(const char *to,uint length);
void store(double nr);
void store(longlong nr);
+ void reset(void) { bzero(ptr,sizeof(double)); }
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
@@ -505,6 +512,7 @@ public:
void store(const char *to, uint length) { null[0]=1; }
void store(double nr) { null[0]=1; }
void store(longlong nr) { null[0]=1; }
+ void reset(void) {}
double val_real(void) { return 0.0;}
longlong val_int(void) { return 0;}
String *val_str(String *value,String *value2)
@@ -528,6 +536,7 @@ public:
void store(const char *to,uint length);
void store(double nr);
void store(longlong nr);
+ void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; }
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
@@ -588,6 +597,7 @@ public:
void store(const char *to,uint length);
void store(double nr);
void store(longlong nr);
+ void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; }
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
@@ -615,6 +625,7 @@ public:
void store(double nr);
void store(longlong nr);
void store_time(TIME *ltime,timestamp_type type);
+ void reset(void) { ptr[0]=ptr[1]=ptr[2]=0; }
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
@@ -643,6 +654,7 @@ public:
void store(const char *to,uint length);
void store(double nr);
void store(longlong nr);
+ void reset(void) { ptr[0]=ptr[1]=ptr[2]=0; }
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
@@ -673,6 +685,7 @@ public:
void store(double nr);
void store(longlong nr);
void store_time(TIME *ltime,timestamp_type type);
+ void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0; }
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
@@ -874,6 +887,14 @@ public:
uint max_length= ~(uint) 0);
ulonglong get_id(const char *from);
const char *unpack_id(char *to, const char *from, const char *bdata);
+ inline void get_ptr_from_key_image(char **str,char *key_str)
+ {
+ *str = key_str + sizeof(uint16);
+ }
+ inline uint get_length_from_key_image(char *key_str)
+ {
+ return uint2korr(key_str);
+ }
enum_field_types blobtype() { return (packlength == 1 ? FIELD_TYPE_TINY_BLOB : FIELD_TYPE_BLOB);}
#endif
char *pack_key(char *to, const char *from, uint max_length);
@@ -914,6 +935,7 @@ public:
void store(const char *to,uint length);
void store(double nr);
void store(longlong nr);
+ void reset() { bzero(ptr,packlength); }
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 3519467fbea..92886242a4a 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -362,6 +362,8 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
}
make_sortkey(param,sort_keys[idx++],ref_pos);
}
+ else
+ file->unlock_row();
}
(void) file->extra(HA_EXTRA_NO_CACHE); /* End cacheing of records */
file->rnd_end();
diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc
index 4a923e039c4..e05fdafcbc4 100644
--- a/sql/gen_lex_hash.cc
+++ b/sql/gen_lex_hash.cc
@@ -472,7 +472,7 @@ int main(int argc,char **argv)
int error;
MY_INIT(argv[0]);
- start_value=2663113L; best_t1=1175350L; best_t2=7404531L; best_type=4; /* mode=4327 add=3 type: 0 */
+ start_value=6130115L; best_t1=3632784L; best_t2=86437L; best_type=3; /* mode=4229 add=2 type: 0 */
if (get_options(argc,(char **) argv))
exit(1);
diff --git a/sql/ha_gemini.cc b/sql/ha_gemini.cc
index e80d9a001e6..e8130c55fc7 100644
--- a/sql/ha_gemini.cc
+++ b/sql/ha_gemini.cc
@@ -93,6 +93,7 @@ bool gemini_init(void)
DBUG_ENTER("gemini_init");
+ gemini_basedir=mysql_home;
/* If datadir isn't set, bail out */
if (*mysql_real_data_home == '\0')
{
@@ -955,7 +956,7 @@ int ha_gemini::handleIndexEntry(const byte * record, dsmRecid_t recid,
thd = current_thd;
key_info=table->key_info+keynr;
- thereIsAnull = false;
+ thereIsAnull = FALSE;
rc = createKeyString(record, key_info, theKey.akey.keystr,
sizeof(theKey.apad),&keyStringLen,
(short)pindexNumbers[keynr],
@@ -1067,7 +1068,7 @@ int ha_gemini::createKeyString(const byte * record, KEY *pkeyinfo,
isNull = record[key_part->null_offset] & key_part->null_bit;
if(isNull)
- *thereIsAnull = true;
+ *thereIsAnull = TRUE;
rc = gemFieldToIdxComponent(pos,
(unsigned long) key_part_length,
@@ -1107,7 +1108,7 @@ int ha_gemini::update_row(const byte * old_record, byte * new_record)
}
for (uint keynr=0 ; keynr < table->keys ; keynr++)
{
- if(key_cmp(keynr,old_record, new_record,false))
+ if(key_cmp(keynr,old_record, new_record,FALSE))
{
error = handleIndexEntry(old_record,lastRowid,KEY_DELETE,keynr);
if(error)
@@ -2430,8 +2431,8 @@ int ha_gemini::analyze(THD* thd, HA_CHECK_OPT* check_opt)
uint saveIsolation;
dsmMask_t saveLockMode;
- check_opt->quick = true;
- check_opt->optimize = true; // Tells check not to get table lock
+ check_opt->quick = TRUE;
+ check_opt->optimize = TRUE; // Tells check not to get table lock
saveLockMode = lockMode;
saveIsolation = thd->gemini.tx_isolation;
thd->gemini.tx_isolation = ISO_READ_UNCOMMITTED;
@@ -2503,7 +2504,7 @@ int ha_gemini::check(THD* thd, HA_CHECK_OPT* check_opt)
error = fetch_row(thd->gemini.context,buf);
if(!error)
{
- if(key_cmp(i,buf,indexBuf,false))
+ if(key_cmp(i,buf,indexBuf,FALSE))
{
gemini_msg((dsmContext_t *)thd->gemini.context,
@@ -2534,7 +2535,7 @@ int ha_gemini::check(THD* thd, HA_CHECK_OPT* check_opt)
}
}
- key_cmp(i,indexBuf,prevBuf,true);
+ key_cmp(i,indexBuf,prevBuf,TRUE);
bcopy((void *)indexBuf,(void *)prevBuf,table->rec_buff_length);
if(!error)
diff --git a/sql/ha_gemini.h b/sql/ha_gemini.h
index 3bfe85bfba2..96c0cdd4241 100644
--- a/sql/ha_gemini.h
+++ b/sql/ha_gemini.h
@@ -205,3 +205,4 @@ int gemini_set_option_long(int optid, long optval);
const int gemini_blocksize = BLKSIZE;
const int gemini_recbits = DEFAULT_RECBITS;
+extern "C" void uttrace(void);
diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc
index 254fa6970a7..5920ce86116 100644
--- a/sql/ha_innobase.cc
+++ b/sql/ha_innobase.cc
@@ -185,6 +185,47 @@ convert_error_code_to_mysql(
}
}
+extern "C" {
+/*****************************************************************
+Prints info of a THD object (== user session thread) to the
+standatd output. NOTE that mysql/innobase/trx/trx0trx.c must contain
+the prototype for this function! */
+
+void
+innobase_mysql_print_thd(
+/*=====================*/
+ void* input_thd)/* in: pointer to a MySQL THD object */
+{
+ THD* thd;
+
+ thd = (THD*) input_thd;
+
+ printf("MySQL thread id %lu, query id %lu",
+ thd->thread_id, thd->query_id);
+ if (thd->host) {
+ printf(" %s", thd->host);
+ }
+
+ if (thd->ip) {
+ printf(" %s", thd->ip);
+ }
+
+ if (thd->user) {
+ printf(" %s", thd->user);
+ }
+
+ if (thd->proc_info) {
+ printf(" %s", thd->proc_info);
+ }
+
+ if (thd->query) {
+ printf(" %0.100s", thd->query);
+ }
+
+ printf("\n");
+}
+}
+
/*************************************************************************
Gets the InnoDB transaction handle for a MySQL handler object, creates
an InnoDB transaction struct if the corresponding MySQL thread struct still
@@ -204,6 +245,8 @@ check_trx_exists(
dbug_assert(thd != NULL);
trx = trx_allocate_for_mysql();
+ trx->mysql_thd = thd;
+
thd->transaction.all.innobase_tid = trx;
/* The execution of a single SQL statement is denoted by
@@ -504,7 +547,15 @@ innobase_init(void)
if (!innobase_data_file_path)
{
fprintf(stderr,
- "Can't initialize InnoDB as 'innodb_data_file_path' is not set\n");
+ "Cannot initialize InnoDB as 'innodb_data_file_path' is not set.\n"
+ "If you do not want to use transactional InnoDB tables, add a line\n"
+ "skip-innodb\n"
+ "to the [mysqld] section of init parameters in your my.cnf\n"
+ "or my.ini. If you want to use InnoDB tables, add for example,\n"
+ "innodb_data_file_path = /mysql/data/ibdata1:20M\n"
+ "More information on setting the parameters you find in the\n"
+ "manual.\n");
+
innodb_skip=1;
DBUG_RETURN(FALSE); // Continue without innobase
}
@@ -638,7 +689,7 @@ innobase_commit(
if (trx_handle != (void*)&innodb_dummy_stmt_trx_handle) {
trx_commit_for_mysql(trx);
- trx_mark_sql_stat_end(trx);
+ trx_mark_sql_stat_end_do_not_start_new(trx);
} else {
trx_mark_sql_stat_end(trx);
}
@@ -677,6 +728,7 @@ innobase_rollback(
if (trx_handle != (void*)&innodb_dummy_stmt_trx_handle) {
error = trx_rollback_for_mysql(trx);
+ trx_mark_sql_stat_end_do_not_start_new(trx);
} else {
error = trx_rollback_last_sql_stat_for_mysql(trx);
trx_mark_sql_stat_end(trx);
@@ -826,10 +878,6 @@ ha_innobase::open(
DBUG_RETURN(1);
}
- /* MySQL allocates the buffer for ref */
-
- ref_length = buff_len;
-
/* Get pointer to a table object in InnoDB dictionary cache */
if (NULL == (ib_table = dict_table_get(norm_name, NULL))) {
@@ -866,10 +914,20 @@ ha_innobase::open(
primary_key = 0;
key_used_on_scan = 0;
+
+ /* MySQL allocates the buffer for ref */
+
+ ref_length = table->key_info->key_length
+ + table->key_info->key_parts + 10;
+
+ /* One byte per key field is consumed to the SQL NULL
+ info of the field; we add also 10 bytes of safety margin */
} else {
((row_prebuilt_t*)innobase_prebuilt)
->clust_index_was_generated = TRUE;
+ ref_length = DATA_ROW_ID_LEN + 10;
+
dbug_assert(key_used_on_scan == MAX_KEY);
}
@@ -1334,6 +1392,15 @@ ha_innobase::write_row(
auto_inc = table->next_number_field->val_int();
+ /* In replication and also otherwise the auto-inc column
+ can be set with SET INSERT_ID. Then we must look at
+ user_thd->next_insert_id. If it is nonzero and the user
+ has not supplied a value, we must use it. */
+
+ if (auto_inc == 0 && user_thd->next_insert_id != 0) {
+ auto_inc = user_thd->next_insert_id;
+ }
+
if (auto_inc != 0) {
/* This call will calculate the max of the
current value and the value supplied by the user, if
@@ -2218,29 +2285,29 @@ ha_innobase::external_lock(
if (trx->n_mysql_tables_in_use == 0) {
trx_mark_sql_stat_end(trx);
}
-
+ thd->transaction.all.innodb_active_trans = 1;
trx->n_mysql_tables_in_use++;
if (prebuilt->select_lock_type != LOCK_NONE) {
- trx->mysql_n_tables_locked++;
+ trx->mysql_n_tables_locked++;
}
} else {
trx->n_mysql_tables_in_use--;
if (trx->n_mysql_tables_in_use == 0) {
- trx->mysql_n_tables_locked = 0;
+ trx->mysql_n_tables_locked = 0;
- if (trx->has_search_latch) {
+ if (trx->has_search_latch) {
- trx_search_latch_release_if_reserved(trx);
- }
+ trx_search_latch_release_if_reserved(trx);
+ }
- if (!(thd->options
- & (OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN))) {
- innobase_commit(thd, trx);
- }
+ if (!(thd->options
+ & (OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN))) {
+ innobase_commit(thd, trx);
+ }
}
}
@@ -2636,6 +2703,10 @@ ha_innobase::records_in_range(
DBUG_ENTER("records_in_range");
+ if (prebuilt->trx) {
+ prebuilt->trx->op_info = "estimating range size";
+ }
+
active_index = keynr;
key = table->key_info + active_index;
@@ -2668,6 +2739,10 @@ ha_innobase::records_in_range(
my_free((char*) key_val_buff2, MYF(0));
+ if (prebuilt->trx) {
+ prebuilt->trx->op_info = "";
+ }
+
DBUG_RETURN((ha_rows) n_rows);
}
@@ -2687,10 +2762,15 @@ ha_innobase::estimate_number_of_rows(void)
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
dict_table_t* ib_table;
+ if (prebuilt->trx) {
+ prebuilt->trx->op_info =
+ "estimating upper bound of table size";
+ }
+
DBUG_ENTER("info");
ib_table = prebuilt->table;
-
+
dict_update_statistics(ib_table);
data_file_length = ((ulonglong)
@@ -2699,6 +2779,10 @@ ha_innobase::estimate_number_of_rows(void)
/* The minimum clustered index record size is 20 bytes */
+ if (prebuilt->trx) {
+ prebuilt->trx->op_info = "";
+ }
+
return((ha_rows) (1000 + data_file_length / 20));
}
@@ -2737,6 +2821,10 @@ ha_innobase::info(
DBUG_ENTER("info");
+ if (prebuilt->trx) {
+ prebuilt->trx->op_info = "calculating table stats";
+ }
+
ib_table = prebuilt->table;
if (flag & HA_STATUS_TIME) {
@@ -2799,6 +2887,10 @@ ha_innobase::info(
trx_get_error_info(prebuilt->trx));
}
+ if (prebuilt->trx) {
+ prebuilt->trx->op_info = "";
+ }
+
DBUG_VOID_RETURN;
}
diff --git a/sql/ha_innobase.h b/sql/ha_innobase.h
index d129e00ba6e..daa987dd757 100644
--- a/sql/ha_innobase.h
+++ b/sql/ha_innobase.h
@@ -83,7 +83,7 @@ class ha_innobase: public handler
HA_NO_WRITE_DELAYED |
HA_PRIMARY_KEY_IN_READ_INDEX |
HA_DROP_BEFORE_CREATE |
- HA_NOT_READ_AFTER_KEY | HA_NO_PREFIX_CHAR_KEYS),
+ HA_NO_PREFIX_CHAR_KEYS),
last_dup_key((uint) -1),
start_of_scan(0)
{
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index 7d7bae1112b..c192443da0a 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -231,8 +231,16 @@ int ha_myisam::close(void)
int ha_myisam::write_row(byte * buf)
{
statistic_increment(ha_write_count,&LOCK_status);
+
+ /* If we have a timestamp column, update it to the current time */
+
if (table->time_stamp)
update_timestamp(buf+table->time_stamp-1);
+
+ /*
+ If we have an auto_increment column and we are writing a changed row
+ or a new row, then update the auto_increment value in the record.
+ */
if (table->next_number_field && buf == table->record[0])
update_auto_increment();
return mi_write(file,buf);
diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc
index ddfd48a0e71..abcf81806ad 100644
--- a/sql/ha_myisammrg.cc
+++ b/sql/ha_myisammrg.cc
@@ -86,7 +86,6 @@ int ha_myisammrg::delete_row(const byte * buf)
int ha_myisammrg::index_read(byte * buf, const byte * key,
uint key_len, enum ha_rkey_function find_flag)
{
-// return (my_errno=HA_ERR_WRONG_COMMAND);
statistic_increment(ha_read_key_count,&LOCK_status);
int error=myrg_rkey(file,buf,active_index, key, key_len, find_flag);
table->status=error ? STATUS_NOT_FOUND: 0;
@@ -96,7 +95,6 @@ int ha_myisammrg::index_read(byte * buf, const byte * key,
int ha_myisammrg::index_read_idx(byte * buf, uint index, const byte * key,
uint key_len, enum ha_rkey_function find_flag)
{
-// return (my_errno=HA_ERR_WRONG_COMMAND);
statistic_increment(ha_read_key_count,&LOCK_status);
int error=myrg_rkey(file,buf,index, key, key_len, find_flag);
table->status=error ? STATUS_NOT_FOUND: 0;
@@ -105,7 +103,6 @@ int ha_myisammrg::index_read_idx(byte * buf, uint index, const byte * key,
int ha_myisammrg::index_next(byte * buf)
{
-// return (my_errno=HA_ERR_WRONG_COMMAND);
statistic_increment(ha_read_next_count,&LOCK_status);
int error=myrg_rnext(file,buf,active_index);
table->status=error ? STATUS_NOT_FOUND: 0;
@@ -114,7 +111,6 @@ int ha_myisammrg::index_next(byte * buf)
int ha_myisammrg::index_prev(byte * buf)
{
-// return (my_errno=HA_ERR_WRONG_COMMAND);
statistic_increment(ha_read_prev_count,&LOCK_status);
int error=myrg_rprev(file,buf, active_index);
table->status=error ? STATUS_NOT_FOUND: 0;
@@ -123,7 +119,6 @@ int ha_myisammrg::index_prev(byte * buf)
int ha_myisammrg::index_first(byte * buf)
{
-// return (my_errno=HA_ERR_WRONG_COMMAND);
statistic_increment(ha_read_first_count,&LOCK_status);
int error=myrg_rfirst(file, buf, active_index);
table->status=error ? STATUS_NOT_FOUND: 0;
@@ -132,7 +127,6 @@ int ha_myisammrg::index_first(byte * buf)
int ha_myisammrg::index_last(byte * buf)
{
-// return (my_errno=HA_ERR_WRONG_COMMAND);
statistic_increment(ha_read_last_count,&LOCK_status);
int error=myrg_rlast(file, buf, active_index);
table->status=error ? STATUS_NOT_FOUND: 0;
diff --git a/sql/handler.cc b/sql/handler.cc
index 94910b24622..fbf5144c090 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -286,6 +286,7 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans)
my_error(ER_ERROR_DURING_COMMIT, MYF(0), error);
error=1;
}
+ trans->innodb_active_trans=0;
}
#endif
#ifdef HAVE_GEMINI_DB
@@ -337,6 +338,7 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans)
my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), error);
error=1;
}
+ trans->innodb_active_trans=0;
}
#endif
#ifdef HAVE_GEMINI_DB
diff --git a/sql/handler.h b/sql/handler.h
index bbb67ace2b2..b190cedd040 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -128,6 +128,7 @@ typedef struct st_thd_trans {
void *bdb_tid;
void *innobase_tid;
void *gemini_tid;
+ bool innodb_active_trans;
} THD_TRANS;
enum enum_tx_isolation { ISO_READ_UNCOMMITTED, ISO_READ_COMMITTED,
@@ -268,6 +269,7 @@ public:
virtual int extra(enum ha_extra_function operation)=0;
virtual int reset()=0;
virtual int external_lock(THD *thd, int lock_type)=0;
+ virtual void unlock_row() {}
virtual int start_stmt(THD *thd) {return 0;}
virtual int delete_all_rows();
virtual longlong get_auto_increment();
diff --git a/sql/hostname.cc b/sql/hostname.cc
index fed9e60b574..bc812341337 100644
--- a/sql/hostname.cc
+++ b/sql/hostname.cc
@@ -26,7 +26,7 @@
#ifdef __cplusplus
extern "C" { // Because of SCO 3.2V4.2
#endif
-#ifndef __WIN__
+#if !defined( __WIN__) && !defined(OS2)
#include <sys/resource.h>
#ifdef HAVE_SYS_UN_H
#include <sys/un.h>
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 66a50eb0ec0..3ef5ed5d7a3 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -259,10 +259,14 @@ double Item_func_plus::val()
longlong Item_func_plus::val_int()
{
- longlong value=args[0]->val_int()+args[1]->val_int();
- if ((null_value=args[0]->null_value || args[1]->null_value))
- return 0;
- return value;
+ if (hybrid_type == INT_RESULT)
+ {
+ longlong value=args[0]->val_int()+args[1]->val_int();
+ if ((null_value=args[0]->null_value || args[1]->null_value))
+ return 0;
+ return value;
+ }
+ return (longlong) Item_func_plus::val();
}
double Item_func_minus::val()
@@ -275,12 +279,17 @@ double Item_func_minus::val()
longlong Item_func_minus::val_int()
{
- longlong value=args[0]->val_int() - args[1]->val_int();
- if ((null_value=args[0]->null_value || args[1]->null_value))
- return 0;
- return value;
+ if (hybrid_type == INT_RESULT)
+ {
+ longlong value=args[0]->val_int() - args[1]->val_int();
+ if ((null_value=args[0]->null_value || args[1]->null_value))
+ return 0;
+ return value;
+ }
+ return (longlong) Item_func_minus::val();
}
+
double Item_func_mul::val()
{
double value=args[0]->val()*args[1]->val();
@@ -291,10 +300,14 @@ double Item_func_mul::val()
longlong Item_func_mul::val_int()
{
- longlong value=args[0]->val_int()*args[1]->val_int();
- if ((null_value=args[0]->null_value || args[1]->null_value))
- return 0; /* purecov: inspected */
- return value;
+ if (hybrid_type == INT_RESULT)
+ {
+ longlong value=args[0]->val_int()*args[1]->val_int();
+ if ((null_value=args[0]->null_value || args[1]->null_value))
+ return 0; /* purecov: inspected */
+ return value;
+ }
+ return (longlong) Item_func_mul::val();
}
@@ -309,11 +322,15 @@ double Item_func_div::val()
longlong Item_func_div::val_int()
{
- longlong value=args[0]->val_int();
- longlong val2=args[1]->val_int();
- if ((null_value= val2 == 0 || args[0]->null_value || args[1]->null_value))
- return 0;
- return value/val2;
+ if (hybrid_type == INT_RESULT)
+ {
+ longlong value=args[0]->val_int();
+ longlong val2=args[1]->val_int();
+ if ((null_value= val2 == 0 || args[0]->null_value || args[1]->null_value))
+ return 0;
+ return value/val2;
+ }
+ return (longlong) Item_func_div::val();
}
void Item_func_div::fix_length_and_dec()
@@ -1382,6 +1399,23 @@ void item_user_lock_free(void)
void item_user_lock_release(ULL *ull)
{
ull->locked=0;
+ if (mysql_bin_log.is_open())
+ {
+ THD *thd = current_thd;
+ int save_errno;
+ char buf[256];
+ String tmp(buf,sizeof(buf));
+ tmp.length(0);
+ tmp.append("SELECT release_lock(\"");
+ tmp.append(ull->key,ull->key_length);
+ tmp.append("\")");
+ save_errno=thd->net.last_errno;
+ thd->net.last_errno=0;
+ thd->query_length=tmp.length();
+ Query_log_event qev(thd,tmp.ptr());
+ mysql_bin_log.write(&qev);
+ thd->net.last_errno=save_errno;
+ }
if (--ull->count)
pthread_cond_signal(&ull->cond);
else
@@ -1428,7 +1462,7 @@ longlong Item_func_get_lock::val_int()
struct timespec abstime;
THD *thd=current_thd;
ULL *ull;
- int error;
+ int error=0;
pthread_mutex_lock(&LOCK_user_locks);
@@ -1466,23 +1500,23 @@ longlong Item_func_get_lock::val_int()
/* structure is now initialized. Try to get the lock */
/* Set up control struct to allow others to abort locks */
- pthread_mutex_lock(&thd->mysys_var->mutex);
thd->proc_info="User lock";
thd->mysys_var->current_mutex= &LOCK_user_locks;
thd->mysys_var->current_cond= &ull->cond;
- pthread_mutex_unlock(&thd->mysys_var->mutex);
+#ifdef HAVE_TIMESPEC_TS_SEC
+ abstime.ts_sec=time((time_t*) 0)+(time_t) timeout;
+ abstime.ts_nsec=0;
+#else
abstime.tv_sec=time((time_t*) 0)+(time_t) timeout;
abstime.tv_nsec=0;
- while ((error=pthread_cond_timedwait(&ull->cond,&LOCK_user_locks,&abstime))
- != ETIME && error != ETIMEDOUT && ull->locked)
- {
- if (thd->killed || abort_loop)
- {
- error=EINTR; // Return NULL
- break;
- }
- }
+#endif
+
+ while (!thd->killed &&
+ (error=pthread_cond_timedwait(&ull->cond,&LOCK_user_locks,&abstime))
+ != ETIME && error != ETIMEDOUT && ull->locked) ;
+ if (thd->killed)
+ error=EINTR; // Return NULL
if (ull->locked)
{
if (!--ull->count)
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 9d69b713611..12561fe4326 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1008,8 +1008,8 @@ String *Item_func_encrypt::val_str(String *str)
if (arg_count == 1)
{ // generate random salt
time_t timestamp=current_thd->query_start();
- salt[0] = bin_to_ascii(timestamp & 0x3f);
- salt[1] = bin_to_ascii((timestamp >> 5) & 0x3f);
+ salt[0] = bin_to_ascii( (ulong) timestamp & 0x3f);
+ salt[1] = bin_to_ascii(( (ulong) timestamp >> 5) & 0x3f);
salt[2] = 0;
salt_ptr=salt;
}
@@ -1102,7 +1102,7 @@ void Item_func_soundex::fix_length_and_dec()
*/
extern "C" {
-extern char *soundex_map; // In mysys/static.c
+extern const char *soundex_map; // In mysys/static.c
}
static char get_scode(char *ptr)
diff --git a/sql/lex.h b/sql/lex.h
index 8e03570d93b..1d481aa7c85 100644
--- a/sql/lex.h
+++ b/sql/lex.h
@@ -205,6 +205,7 @@ static SYMBOL symbols[] = {
{ "LOAD", SYM(LOAD),0,0},
{ "LOCAL", SYM(LOCAL_SYM),0,0},
{ "LOCK", SYM(LOCK_SYM),0,0},
+ { "LOCKS", SYM(LOCKS_SYM),0,0},
{ "LOGS", SYM(LOGS_SYM),0,0},
{ "LONG", SYM(LONG_SYM),0,0},
{ "LONGBLOB", SYM(LONGBLOB),0,0},
diff --git a/sql/log.cc b/sql/log.cc
index 8976cb87375..51bf077895a 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -149,11 +149,11 @@ void MYSQL_LOG::init(enum_log_type log_type_arg)
void MYSQL_LOG::close_index()
{
- if(index_file >= 0)
- {
- my_close(index_file, MYF(0));
- index_file = -1;
- }
+ if (index_file >= 0)
+ {
+ my_close(index_file, MYF(0));
+ index_file = -1;
+ }
}
void MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg,
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 8275896710a..64ad4cadf8e 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -355,7 +355,7 @@ int Log_event::write_header(IO_CACHE* file)
{
char buf[LOG_EVENT_HEADER_LEN];
char* pos = buf;
- int4store(pos, when); // timestamp
+ int4store(pos, (ulong) when); // timestamp
pos += 4;
*pos++ = get_type_code(); // event type code
int4store(pos, server_id);
@@ -553,7 +553,11 @@ void Log_event::print_timestamp(FILE* file, time_t* ts)
{
ts = &when;
}
+#ifdef MYSQL_SERVER
localtime_r(ts,&tm_tmp);
+#else
+ localtime(ts);
+#endif
fprintf(file,"%02d%02d%02d %2d:%02d:%02d",
tm_tmp.tm_year % 100,
diff --git a/sql/md5.c b/sql/md5.c
index a19f8639f3a..baf45350473 100644
--- a/sql/md5.c
+++ b/sql/md5.c
@@ -123,10 +123,11 @@ void my_MD5Init (my_MD5_CTX *context) /* context */
operation, processing another message block, and updating the
context.
*/
-void my_MD5Update (context, input, inputLen)
-my_MD5_CTX *context; /* context */
-unsigned char *input; /* input block */
-unsigned int inputLen; /* length of input block */
+
+void MD5Update (
+my_MD5_CTX *context, /* context */
+unsigned char *input, /* input block */
+unsigned int inputLen) /* length of input block */
{
unsigned int i, idx, partLen;
@@ -164,9 +165,9 @@ unsigned int inputLen; /* length of input block */
/* MD5 finalization. Ends an MD5 message-digest operation, writing the
the message digest and zeroizing the context.
*/
-void my_MD5Final (digest, context)
-unsigned char digest[16]; /* message digest */
-my_MD5_CTX *context; /* context */
+void my_MD5Final (
+unsigned char digest[16], /* message digest */
+MD5_CTX *context) /* context */
{
unsigned char bits[8];
unsigned int idx, padLen;
@@ -193,9 +194,9 @@ my_MD5_CTX *context; /* context */
/* MD5 basic transformation. Transforms state based on block.
*/
-static void MD5Transform (state, block)
-UINT4 state[4];
-unsigned char block[64];
+static void MD5Transform (
+UINT4 state[4],
+unsigned char block[64])
{
UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
@@ -287,10 +288,10 @@ unsigned char block[64];
/* Encodes input (UINT4) into output (unsigned char). Assumes len is
a multiple of 4.
*/
-static void Encode (output, input, len)
-unsigned char *output;
-UINT4 *input;
-unsigned int len;
+static void Encode (
+unsigned char *output,
+UINT4 *input,
+unsigned int len)
{
unsigned int i, j;
@@ -306,10 +307,10 @@ unsigned int len;
/* Decodes input (unsigned char) into output (UINT4). Assumes len is
a multiple of 4.
*/
-static void Decode (output, input, len)
-UINT4 *output;
-unsigned char *input;
-unsigned int len;
+static void Decode (
+UINT4 *output,
+unsigned char *input,
+unsigned int len)
{
unsigned int i, j;
diff --git a/sql/mini_client.cc b/sql/mini_client.cc
index 31181ee2580..994f788f423 100644
--- a/sql/mini_client.cc
+++ b/sql/mini_client.cc
@@ -23,10 +23,23 @@
*/
#define DONT_USE_RAID
-#if defined(__WIN__) || defined(WIN32)
+#if defined(__WIN__)
#include <winsock.h>
#include <odbcinst.h>
+/* Disable alarms */
+typedef my_bool ALARM;
+#define thr_alarm_init(A) (*(A))=0
+#define thr_alarm_in_use(A) (*(A))
+#define thr_end_alarm(A)
+#define thr_alarm(A,B,C) local_thr_alarm((A),(B),(C))
+inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)),ALARM *C __attribute__((unused)))
+{
+ *A=1;
+ return 0;
+}
+#define thr_got_alarm(A) 0
#endif
+
#include <global.h>
#include <mysql_com.h>
#include <violite.h>
@@ -45,6 +58,11 @@
#define net_write_timeout net_write_timeout1
#endif
+#if defined( OS2) && defined( MYSQL_SERVER)
+#undef ER
+#define ER CER
+#endif
+
extern ulong net_read_timeout;
extern "C" { // Because of SCO 3.2V4.2
@@ -68,7 +86,7 @@ extern "C" { // Because of SCO 3.2V4.2
#ifdef HAVE_SYS_UN_H
# include <sys/un.h>
#endif
-#if defined(THREAD) && !defined(__WIN__)
+#if defined(THREAD)
#include <my_pthread.h> /* because of signal() */
#include <thr_alarm.h>
#endif
@@ -101,6 +119,9 @@ static MYSQL_DATA *mc_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
#if defined(MSDOS) || defined(__WIN__)
#define ERRNO WSAGetLastError()
#define perror(A)
+#elif defined(OS2)
+#define ERRNO sock_errno()
+#define SOCKET_ERROR -1
#else
#include <sys/errno.h>
#define ERRNO errno
@@ -254,7 +275,7 @@ static void mc_free_old_query(MYSQL *mysql)
static int mc_sock_connect(my_socket s, const struct sockaddr *name,
uint namelen, uint to)
{
-#if defined(__WIN__)
+#if defined(__WIN__) || defined(OS2)
return connect(s, (struct sockaddr*) name, namelen);
#else
int flags, res, s_err;
@@ -349,18 +370,18 @@ mc_net_safe_read(MYSQL *mysql)
{
DBUG_PRINT("error",("Wrong connection or packet. fd: %s len: %d",
vio_description(net->vio),len));
- if(errno != EINTR)
+ if (socket_errno != EINTR)
+ {
+ mc_end_server(mysql);
+ if(net->last_errno != ER_NET_PACKET_TOO_LARGE)
{
- mc_end_server(mysql);
- if(net->last_errno != ER_NET_PACKET_TOO_LARGE)
- {
- net->last_errno=CR_SERVER_LOST;
- strmov(net->last_error,ER(net->last_errno));
- }
- else
- strmov(net->last_error, "Packet too large - increase \
+ net->last_errno=CR_SERVER_LOST;
+ strmov(net->last_error,ER(net->last_errno));
+ }
+ else
+ strmov(net->last_error, "Packet too large - increase \
max_allowed_packet on this server");
- }
+ }
return(packet_error);
}
if (net->read_pos[0] == 255)
@@ -470,7 +491,7 @@ mc_simple_command(MYSQL *mysql,enum enum_server_command command,
if (net_write_command(net,(uchar) command,arg,
length ? length :(uint) strlen(arg)))
{
- DBUG_PRINT("error",("Can't send command to server. Error: %d",errno));
+ DBUG_PRINT("error",("Can't send command to server. Error: %d",socket_errno));
mc_end_server(mysql);
if (mc_mysql_reconnect(mysql) ||
net_write_command(net,(uchar) command,arg,
@@ -502,9 +523,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
uint pkt_length;
NET *net= &mysql->net;
thr_alarm_t alarmed;
-#if !defined(__WIN__)
ALARM alarm_buff;
-#endif
#ifdef __WIN__
HANDLE hPipe=INVALID_HANDLE_VALUE;
@@ -554,9 +573,9 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
if (mc_sock_connect(sock,(struct sockaddr *) &UNIXaddr, sizeof(UNIXaddr),
mysql->options.connect_timeout) <0)
{
- DBUG_PRINT("error",("Got error %d on connect to local server",ERRNO));
+ DBUG_PRINT("error",("Got error %d on connect to local server",socket_errno));
net->last_errno=CR_CONNECTION_ERROR;
- sprintf(net->last_error,ER(net->last_errno),unix_socket,ERRNO);
+ sprintf(net->last_error,ER(net->last_errno),unix_socket,socket_errno);
goto error;
}
}
@@ -604,7 +623,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
if ((sock = socket(AF_INET,SOCK_STREAM,0)) == SOCKET_ERROR)
{
net->last_errno=CR_IPSOCK_ERROR;
- sprintf(net->last_error,ER(net->last_errno),ERRNO);
+ sprintf(net->last_error,ER(net->last_errno),socket_errno);
goto error;
}
net->vio = vio_new(sock,VIO_TYPE_TCPIP,FALSE);
@@ -641,7 +660,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
if (!(hp=gethostbyname(host)))
{
net->last_errno=CR_UNKNOWN_HOST;
- sprintf(net->last_error, ER(CR_UNKNOWN_HOST), host, errno);
+ sprintf(net->last_error, ER(CR_UNKNOWN_HOST), host, socket_errno);
goto error;
}
memcpy(&sock_addr.sin_addr,hp->h_addr, (size_t) hp->h_length);
@@ -649,11 +668,12 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
#endif
sock_addr.sin_port = (ushort) htons((ushort) port);
if (mc_sock_connect(sock,(struct sockaddr *) &sock_addr, sizeof(sock_addr),
- mysql->options.connect_timeout) <0)
+ mysql->options.connect_timeout) <0)
{
- DBUG_PRINT("error",("Got error %d on connect to '%s'",ERRNO,host));
+ DBUG_PRINT("error",("Got error %d on connect to '%s'",
+ socket_errno,host));
net->last_errno= CR_CONN_HOST_ERROR;
- sprintf(net->last_error ,ER(CR_CONN_HOST_ERROR), host, ERRNO);
+ sprintf(net->last_error ,ER(CR_CONN_HOST_ERROR), host, socket_errno);
if (thr_alarm_in_use(&alarmed))
thr_end_alarm(&alarmed);
goto error;
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 11cacf44e8c..49ca09098dd 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -27,7 +27,9 @@
#include <my_base.h> /* Needed by field.h */
#include <my_bitmap.h>
+#ifdef __EMX__
#undef write // remove pthread.h macro definition for EMX
+#endif
typedef ulong table_map; /* Used for table bits in join */
typedef ulong key_map; /* Used for finding keys */
@@ -111,7 +113,7 @@ char* query_table_status(THD *thd,const char *db,const char *table_name);
#define FLUSH_TIME 0 /* Don't flush tables */
#define MAX_CONNECT_ERRORS 10 // errors before disabling host
-#ifdef __WIN__
+#if defined(__WIN__) || defined(OS2)
#define IF_WIN(A,B) (A)
#undef FLUSH_TIME
#define FLUSH_TIME 1800 /* Flush every half hour */
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 17f201dfbc8..b228d0e4b15 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -64,7 +64,9 @@ extern "C" { // Because of SCO 3.2V4.2
#include <grp.h>
#endif
-#ifndef __WIN__
+#if defined(OS2)
+# include <sys/un.h>
+#elif !defined( __WIN__)
#include <sys/resource.h>
#ifdef HAVE_SYS_UN_H
# include <sys/un.h>
@@ -372,6 +374,10 @@ HANDLE hEventShutdown;
static NTService Service; // Service object for WinNT
#endif
+#ifdef OS2
+pthread_cond_t eventShutdown;
+#endif
+
static void start_signal_handler(void);
static void *signal_hand(void *arg);
static void set_options(void);
@@ -419,7 +425,7 @@ static void close_connections(void)
(void) pthread_mutex_unlock(&LOCK_manager);
/* kill connection thread */
-#if !defined(__WIN__) && !defined(__EMX__)
+#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2)
DBUG_PRINT("quit",("waiting for select thread: %lx",select_thread));
(void) pthread_mutex_lock(&LOCK_thread_count);
@@ -517,12 +523,14 @@ static void close_connections(void)
if (tmp->mysys_var)
{
tmp->mysys_var->abort=1;
- if (tmp->mysys_var->current_mutex)
+ pthread_mutex_lock(&tmp->mysys_var->mutex);
+ if (tmp->mysys_var->current_cond)
{
pthread_mutex_lock(tmp->mysys_var->current_mutex);
pthread_cond_broadcast(tmp->mysys_var->current_cond);
pthread_mutex_unlock(tmp->mysys_var->current_mutex);
}
+ pthread_mutex_unlock(&tmp->mysys_var->mutex);
}
}
(void) pthread_mutex_unlock(&LOCK_thread_count); // For unlink from list
@@ -590,6 +598,8 @@ void kill_mysql(void)
// SetEvent(hEventShutdown);
// CloseHandle(hEvent);
}
+#elif defined(OS2)
+ pthread_cond_signal( &eventShutdown); // post semaphore
#elif defined(HAVE_PTHREAD_KILL)
if (pthread_kill(signal_thread,SIGTERM)) /* End everything nicely */
{
@@ -606,7 +616,10 @@ void kill_mysql(void)
/* Force server down. kill all connections and threads and exit */
-#ifndef __WIN__
+#if defined(OS2)
+extern "C" void kill_server(int sig_ptr)
+#define RETURN_FROM_KILL_SERVER return
+#elif !defined(__WIN__)
static void *kill_server(void *sig_ptr)
#define RETURN_FROM_KILL_SERVER return 0
#else
@@ -629,7 +642,7 @@ static void __cdecl kill_server(int sig_ptr)
else
sql_print_error(ER(ER_GOT_SIGNAL),my_progname,sig); /* purecov: inspected */
-#if defined(USE_ONE_SIGNAL_HAND) && !defined(__WIN__)
+#if defined(USE_ONE_SIGNAL_HAND) && !defined(__WIN__) && !defined(OS2)
my_thread_init(); // If this is a new thread
#endif
close_connections();
@@ -637,7 +650,9 @@ static void __cdecl kill_server(int sig_ptr)
unireg_abort(1); /* purecov: inspected */
else
unireg_end(0);
+#ifndef OS2
pthread_exit(0); /* purecov: deadcode */
+#endif
RETURN_FROM_KILL_SERVER;
}
@@ -659,7 +674,7 @@ static sig_handler print_signal_warning(int sig)
#ifdef DONT_REMEMBER_SIGNAL
sigset(sig,print_signal_warning); /* int. thread system calls */
#endif
-#ifndef __WIN__
+#if !defined(__WIN__) && !defined(OS2)
if (sig == SIGALRM)
alarm(2); /* reschedule alarm */
#endif
@@ -669,7 +684,9 @@ static sig_handler print_signal_warning(int sig)
void unireg_end(int signal_number __attribute__((unused)))
{
clean_up();
+#ifndef OS2
pthread_exit(0); // Exit is in main thread
+#endif
}
@@ -770,7 +787,7 @@ static void set_ports()
static void set_user(const char *user)
{
-#ifndef __WIN__
+#if !defined(__WIN__) && !defined(OS2)
struct passwd *ent;
// don't bother if we aren't superuser
@@ -818,7 +835,7 @@ static void set_user(const char *user)
static void set_root(const char *path)
{
-#if !defined(__WIN__) && !defined(__EMX__)
+#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2)
if (chroot(path) == -1)
{
sql_perror("chroot");
@@ -877,7 +894,7 @@ static void server_init(void)
}
if (listen(ip_sock,(int) back_log) < 0)
sql_print_error("Warning: listen() on TCP/IP failed with error %d",
- errno);
+ socket_errno);
}
if (mysqld_chroot)
@@ -964,7 +981,7 @@ static void server_init(void)
#endif
if (listen(unix_sock,(int) back_log) < 0)
sql_print_error("Warning: listen() on Unix socket failed with error %d",
- errno);
+ socket_errno);
}
#endif
DBUG_PRINT("info",("server started"));
@@ -1019,6 +1036,7 @@ sig_handler end_thread_signal(int sig __attribute__((unused)))
void end_thread(THD *thd, bool put_in_cache)
{
DBUG_ENTER("end_thread");
+ thd->cleanup();
(void) pthread_mutex_lock(&LOCK_thread_count);
thread_count--;
delete thd;
@@ -1111,13 +1129,17 @@ static sig_handler abort_thread(int sig __attribute__((unused)))
** the signal thread is ready before continuing
******************************************************************************/
-#ifdef __WIN__
+#if defined(__WIN__) || defined(OS2)
static void init_signals(void)
{
int signals[] = {SIGINT,SIGILL,SIGFPE,SIGSEGV,SIGTERM,SIGABRT } ;
for (uint i=0 ; i < sizeof(signals)/sizeof(int) ; i++)
signal( signals[i], kill_server) ;
+#if defined(__WIN__)
signal(SIGBREAK,SIG_IGN); //ignore SIGBREAK for NT
+#else
+ signal(SIGBREAK, kill_server);
+#endif
}
static void start_signal_handler(void)
@@ -1213,8 +1235,13 @@ the thread stack. Please read http://www.mysql.com/doc/L/i/Linux.html\n\n",
#ifdef HAVE_STACKTRACE
if(!(test_flags & TEST_NO_STACKTRACE))
+ {
+#ifdef HAVE_GEMINI_DB
+ utrace();
+#endif
print_stacktrace(thd ? (gptr) thd->thread_stack : (gptr) 0,
thread_stack);
+ }
if (thd)
{
fprintf(stderr, "Trying to get some variables.\n\
@@ -1238,6 +1265,12 @@ information that should help you find out what is causing the crash\n");
exit(1);
}
+#ifndef SA_RESETHAND
+#define SA_RESETHAND 0
+#endif
+#ifndef SA_NODEFER
+#define SA_NODEFER 0
+#endif
static void init_signals(void)
{
@@ -1246,12 +1279,14 @@ static void init_signals(void)
sigset(THR_KILL_SIGNAL,end_thread_signal);
sigset(THR_SERVER_ALARM,print_signal_warning); // Should never be called!
- struct sigaction sa; sa.sa_flags = 0;
- sigemptyset(&sa.sa_mask);
- sigprocmask(SIG_SETMASK,&sa.sa_mask,NULL);
if (!(test_flags & TEST_NO_STACKTRACE) || (test_flags & TEST_CORE_ON_SIGNAL))
{
+ struct sigaction sa;
+ sa.sa_flags = SA_RESETHAND | SA_NODEFER;
+ sigemptyset(&sa.sa_mask);
+ sigprocmask(SIG_SETMASK,&sa.sa_mask,NULL);
+
init_stacktrace();
sa.sa_handler=handle_segfault;
sigaction(SIGSEGV, &sa, NULL);
@@ -1501,6 +1536,29 @@ int __stdcall handle_kill(ulong ctrl_type)
}
#endif
+#ifdef OS2
+pthread_handler_decl(handle_shutdown,arg)
+{
+ my_thread_init();
+
+ // wait semaphore
+ pthread_cond_wait( &eventShutdown, NULL);
+
+ // close semaphore and kill server
+ pthread_cond_destroy( &eventShutdown);
+
+ // exit main loop on main thread, so kill will be done from
+ // main thread (this is thread 2)
+ abort_loop = 1;
+
+ // unblock select()
+ so_cancel( ip_sock);
+ so_cancel( unix_sock);
+
+ return 0;
+}
+#endif
+
const char *load_default_groups[]= { "mysqld","server",0 };
#ifdef HAVE_LIBWRAP
@@ -1586,7 +1644,7 @@ int main(int argc, char **argv)
load_defaults("my",load_default_groups,&argc,&argv);
defaults_argv=argv;
mysql_tmpdir=getenv("TMPDIR"); /* Use this if possible */
-#ifdef __WIN__
+#if defined( __WIN__) || defined(OS2)
if (!mysql_tmpdir)
mysql_tmpdir=getenv("TEMP");
if (!mysql_tmpdir)
@@ -1675,7 +1733,7 @@ int main(int argc, char **argv)
my_pthread_attr_setprio(&connection_attrib,WAIT_PRIOR);
pthread_attr_setscope(&connection_attrib, PTHREAD_SCOPE_SYSTEM);
-#ifdef SET_RLIMIT_NOFILE
+#if defined( SET_RLIMIT_NOFILE) || defined( OS2)
/* connections and databases neads lots of files */
{
uint wanted_files=10+(uint) max(max_connections*5,
@@ -1884,6 +1942,14 @@ The server will not act as a slave.");
Service.SetShutdownEvent(hEventShutdown);
}
#endif
+#ifdef OS2
+ {
+ pthread_cond_init( &eventShutdown, NULL);
+ pthread_t hThread;
+ if (pthread_create(&hThread,&connection_attrib,handle_shutdown,0))
+ sql_print_error("Warning: Can't create thread to handle shutdown requests");
+ }
+#endif
if (
#ifdef HAVE_BERKELEY_DB
@@ -2092,6 +2158,7 @@ static int bootstrap(FILE *file)
(void) pthread_mutex_unlock(&LOCK_thread_count);
error= thd->fatal_error;
net_end(&thd->net);
+ thd->cleanup();
delete thd;
return error;
}
@@ -2223,8 +2290,10 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
}
#ifdef HAVE_SYS_UN_H
FD_SET(unix_sock,&clientFDs);
+#ifdef HAVE_FCNTL
socket_flags=fcntl(unix_sock, F_GETFL, 0);
#endif
+#endif
DBUG_PRINT("general",("Waiting for connections."));
while (!abort_loop)
@@ -2236,10 +2305,10 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
#else
if (select((int) max_used_connection,&readFDs,0,0,0) < 0)
{
- if (errno != EINTR)
+ if (socket_errno != EINTR)
{
if (!select_errors++ && !abort_loop) /* purecov: inspected */
- sql_print_error("mysqld: Got error %d from select",errno); /* purecov: inspected */
+ sql_print_error("mysqld: Got error %d from select",socket_errno); /* purecov: inspected */
}
continue;
}
@@ -2375,6 +2444,11 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
create_new_thread(thd);
}
+#ifdef OS2
+ // kill server must be invoked from thread 1!
+ kill_server(MYSQL_KILL_SIGNAL);
+#endif
+
#ifdef __NT__
pthread_mutex_lock(&LOCK_thread_count);
handler_count--;
@@ -4512,6 +4586,29 @@ static uint set_maximum_open_files(uint max_file_limit)
}
#endif
+#ifdef OS2
+static uint set_maximum_open_files(uint max_file_limit)
+{
+ LONG cbReqCount;
+ ULONG cbCurMaxFH, cbCurMaxFH0;
+ APIRET ulrc;
+
+ // get current limit
+ cbReqCount = 0;
+ DosSetRelMaxFH( &cbReqCount, &cbCurMaxFH0);
+
+ // set new limit
+ cbReqCount = max_file_limit - cbCurMaxFH0;
+ ulrc = DosSetRelMaxFH( &cbReqCount, &cbCurMaxFH);
+ if (ulrc) {
+ sql_print_error("Warning: DosSetRelMaxFH couldn't increase number of open files to more than %d",
+ cbCurMaxFH0);
+ cbCurMaxFH = cbCurMaxFH0;
+ }
+
+ return cbCurMaxFH;
+}
+#endif
/*
Return a bitfield from a string of substrings separated by ','
diff --git a/sql/net_serv.cc b/sql/net_serv.cc
index cde27d4933a..be08065b589 100644
--- a/sql/net_serv.cc
+++ b/sql/net_serv.cc
@@ -83,9 +83,15 @@ void sql_print_error(const char *format,...);
#define RETRY_COUNT mysqld_net_retry_count
extern ulong mysqld_net_retry_count;
#else
+
+#ifdef OS2 /* avoid name conflict */
+#define thr_alarm_t thr_alarm_t_net
+#define ALARM ALARM_net
+#endif
+
typedef my_bool thr_alarm_t;
typedef my_bool ALARM;
-#define thr_alarm_init(A) (*A)=0
+#define thr_alarm_init(A) (*(A))=0
#define thr_alarm_in_use(A) (*(A))
#define thr_end_alarm(A)
#define thr_alarm(A,B,C) local_thr_alarm((A),(B),(C))
@@ -136,7 +142,7 @@ int my_net_init(NET *net, Vio* vio)
if (vio != 0) /* If real connection */
{
net->fd = vio_fd(vio); /* For perl DBI/DBD */
-#if defined(MYSQL_SERVER) && !defined(___WIN__) && !defined(__EMX__)
+#if defined(MYSQL_SERVER) && !defined(___WIN__) && !defined(__EMX__) && !defined(OS2)
if (!(test_flags & TEST_BLOCKING))
vio_blocking(vio, FALSE);
#endif
@@ -187,7 +193,7 @@ static my_bool net_realloc(NET *net, ulong length)
void net_clear(NET *net)
{
#ifndef EXTRA_DEBUG
- int count;
+ int count; // One may get 'unused' warning
bool is_blocking=vio_is_blocking(net->vio);
if (is_blocking)
vio_blocking(net->vio, FALSE);
@@ -338,7 +344,7 @@ net_real_write(NET *net,const char *packet,ulong len)
int length;
char *pos,*end;
thr_alarm_t alarmed;
-#if !defined(__WIN__)
+#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2)
ALARM alarm_buff;
#endif
uint retry_count=0;
@@ -396,7 +402,7 @@ net_real_write(NET *net,const char *packet,ulong len)
if ((int) (length=vio_write(net->vio,pos,(int) (end-pos))) <= 0)
{
my_bool interrupted = vio_should_retry(net->vio);
-#if (!defined(__WIN__) && !defined(__EMX__))
+#if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2))
if ((interrupted || length==0) && !thr_alarm_in_use(&alarmed))
{
if (!thr_alarm(&alarmed,(uint) net_write_timeout,&alarm_buff))
@@ -521,7 +527,7 @@ my_real_read(NET *net, ulong *complen)
uint i,retry_count=0;
ulong len=packet_error;
thr_alarm_t alarmed;
-#if (!defined(__WIN__) && !defined(__EMX__)) || defined(MYSQL_SERVER)
+#if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2)) || defined(MYSQL_SERVER)
ALARM alarm_buff;
#endif
my_bool net_blocking=vio_is_blocking(net->vio);
@@ -548,7 +554,7 @@ my_real_read(NET *net, ulong *complen)
DBUG_PRINT("info",("vio_read returned %d, errno: %d",
length, vio_errno(net->vio)));
-#if (!defined(__WIN__) && !defined(__EMX__)) || defined(MYSQL_SERVER)
+#if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2)) || defined(MYSQL_SERVER)
/*
We got an error that there was no data on the socket. We now set up
an alarm to not 'read forever', change the socket to non blocking
diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt
index 4ae22776344..6097679b3d3 100644
--- a/sql/share/czech/errmsg.txt
+++ b/sql/share/czech/errmsg.txt
@@ -14,198 +14,198 @@
"isamchk",
"NE",
"ANO",
-"Nemohu vytvo-Bøit soubor '%-.64s' (chybový kód: %d)",-A
-"Nemohu vytvo-Bøit tabulku '%-.64s' (chybový kód: %d)",-A
-"Nemohu vytvo-Bøit databázi '%-.64s', chyba %d",-A
-"Nemohu vytvo-Bøit databázi '%-.64s', databáze ji¾ existuje",-A
-"Nemohu zru-B¹it databázi '%-.64s', databáze neexistuje",-A
-"Chyba p-Bøi ru¹ení databáze (nemohu vymazat '%-.64s', chyba %d)",-A
-"Chyba p-Bøi ru¹ení databáze (nemohu vymazat adresáø '%-.64s', chyba %d)",-A
-"Chyba p-Bøi výmazu '%-.64s' (chybový kód: %d)",-A
-"Nemohu -Bèíst záznam v systémové tabulce",-A
-"Nemohu z-Bískat stav '%-.64s' (chybový kód: %d)",-A
-"Chyba p-Bøi zji¹»ování pracovní adresáø (chybový kód: %d)",-A
-"Nemohu uzamknout soubor (chybov-Bý kód: %d)",-A
-"Nemohu otev-Bøít soubor '%-.64s' (chybový kód: %d)",-A
-"Nemohu naj-Bít soubor '%-.64s' (chybový kód: %d)",-A
-"Nemohu -Bèíst adresáø '%-.64s' (chybový kód: %d)",-A
-"Nemohu zm-Bìnit adresáø na '%-.64s' (chybový kód: %d)",-A
-"Z-Báznam byl zmìnìn od posledního ètení v tabulce '%-.64s'",-A
-"Disk je pln-Bý (%s), èekám na uvolnìní nìjakého místa ...",-A
-"Nemohu zapsat, zdvojen-Bý klíè v tabulce '%-.64s'",-A
-"Chyba p-Bøi zavírání '%-.64s' (chybový kód: %d)",-A
-"Chyba p-Bøi ètení souboru '%-.64s' (chybový kód: %d)",-A
-"Chyba p-Bøi pøejmenování '%-.64s' na '%-.64s' (chybový kód: %d)",-A
-"Chyba p-Bøi zápisu do souboru '%-.64s' (chybový kód: %d)",-A
-"'%-.64s' je zam-Bèen proti zmìnám",-A
-"T-Bøídìní pøeru¹eno",-A
+"Nemohu vytvo-Bøit soubor '%-.64s' (chybový kód: %d)",
+"Nemohu vytvo-Bøit tabulku '%-.64s' (chybový kód: %d)",
+"Nemohu vytvo-Bøit databázi '%-.64s', chyba %d",
+"Nemohu vytvo-Bøit databázi '%-.64s', databáze ji¾ existuje",
+"Nemohu zru-B¹it databázi '%-.64s', databáze neexistuje",
+"Chyba p-Bøi ru¹ení databáze (nemohu vymazat '%-.64s', chyba %d)",
+"Chyba p-Bøi ru¹ení databáze (nemohu vymazat adresáø '%-.64s', chyba %d)",
+"Chyba p-Bøi výmazu '%-.64s' (chybový kód: %d)",
+"Nemohu -Bèíst záznam v systémové tabulce",
+"Nemohu z-Bískat stav '%-.64s' (chybový kód: %d)",
+"Chyba p-Bøi zji¹»ování pracovní adresáø (chybový kód: %d)",
+"Nemohu uzamknout soubor (chybov-Bý kód: %d)",
+"Nemohu otev-Bøít soubor '%-.64s' (chybový kód: %d)",
+"Nemohu naj-Bít soubor '%-.64s' (chybový kód: %d)",
+"Nemohu -Bèíst adresáø '%-.64s' (chybový kód: %d)",
+"Nemohu zm-Bìnit adresáø na '%-.64s' (chybový kód: %d)",
+"Z-Báznam byl zmìnìn od posledního ètení v tabulce '%-.64s'",
+"Disk je pln-Bý (%s), èekám na uvolnìní nìjakého místa ...",
+"Nemohu zapsat, zdvojen-Bý klíè v tabulce '%-.64s'",
+"Chyba p-Bøi zavírání '%-.64s' (chybový kód: %d)",
+"Chyba p-Bøi ètení souboru '%-.64s' (chybový kód: %d)",
+"Chyba p-Bøi pøejmenování '%-.64s' na '%-.64s' (chybový kód: %d)",
+"Chyba p-Bøi zápisu do souboru '%-.64s' (chybový kód: %d)",
+"'%-.64s' je zam-Bèen proti zmìnám",
+"T-Bøídìní pøeru¹eno",
"Pohled '%-.64s' pro '%-.64s' neexistuje",
-"Obsluha tabulky vr-Bátila chybu %d",-A
-"Obsluha tabulky '%-.64s' nem-Bá tento parametr",-A
-"Nemohu naj-Bít záznam v '%-.64s'",-A
-"Nespr-Bávná informace v souboru '%-.64s'",-A
-"Nespr-Bávný klíè pro tabulku '%-.64s'. Pokuste se ho opravit",-A
-"Star-Bý klíèový soubor pro '%-.64s'. Opravte ho.",-A
-"'%-.64s' je jen pro -Bètení",-A
-"M-Bálo pamìti. Pøestartujte daemona a zkuste znovu (je potøeba %d bytù)",-A
-"M-Bálo pamìti pro tøídìní. Zvy¹te velikost tøídícího bufferu",-A
-"Neo-Bèekávaný konec souboru pøi ètení '%-.64s' (chybový kód: %d)",-A
-"P-Bøíli¹ mnoho spojení",-A
-"M-Bálo prostoru/pamìti pro thread",-A
-"Nemohu zjistit jm-Béno stroje pro Va¹i adresu",-A
-"Chyba p-Bøi ustavování spojení",-A
-"P-Bøístup pro u¾ivatele '%-.32s@%-.64s' k databázi '%-.64s' není povolen",-A
-"P-Bøístup pro u¾ivatele '%-.32s@%-.64s' (s heslem %s)",-A
-"Nebyla vybr-Bána ¾ádná databáze",-A
-"Nezn-Bámý pøíkaz",-A
-"Sloupec '%-.64s' nem-Bù¾e být null",-A
-"Nezn-Bámá databáze '%-.64s'",-A
-"Tabulka '%-.64s' ji-B¾ existuje",-A
-"Nezn-Bámá tabulka '%-.64s'",-A
-"Sloupec '%-.64s' v %s nen-Bí zcela jasný",-A
-"Prob-Bíhá ukonèování práce serveru",-A
-"Nezn-Bámý sloupec '%-.64s' v %s",-A
-"Pou-B¾ité '%-.64s' nebylo v group by",-A
-"Nemohu pou-B¾ít group na '%-.64s'",-A
-"P-Bøíkaz obsahuje zároveò funkci sum a sloupce",-A
-"Po-Bèet sloupcù neodpovídá zadané hodnotì",-A
-"Jm-Béno identifikátoru '%-.64s' je pøíli¹ dlouhé",-A
-"Zdvojen-Bé jméno sloupce '%-.64s'",-A
-"Zdvojen-Bé jméno klíèe '%-.64s'",-A
-"Zvojen-Bý klíè '%-.64s' (èíslo klíèe %d)",-A
-"Chybn-Bá specifikace sloupce '%-.64s'",-A
-"%s bl-Bízko '%-.64s' na øádku %d",-A
-"V-Býsledek dotazu je prázdný",-A
-"Nejednozna-Bèná tabulka/alias: '%-.64s'",-A
-"Chybn-Bá defaultní hodnota pro '%-.64s'",-A
-"Definov-Báno více primárních klíèù",-A
-"Zad-Báno pøíli¹ mnoho klíèù, je povoleno nejvíce %d klíèù",-A
-"Zad-Báno pøíli¹ mnoho èást klíèù, je povoleno nejvíce %d èástí",-A
-"Zadan-Bý klíè byl pøíli¹ dlouhý, nejvìt¹í délka klíèe je %d",-A
-"Kl-Bíèový sloupec '%-.64s' v tabulce neexistuje",-A
-"Blob sloupec '%-.64s' nem-Bù¾e být pou¾it jako klíè",-A
-"P-Bøíli¹ velká délka sloupce '%-.64s' (nejvíce %d). Pou¾ijte BLOB",-A
-"M-Bù¾ete mít pouze jedno AUTO pole a to musí být definováno jako klíè",-A
-"%s: p-Bøipraven na spojení\n",-A
-"%s: norm-Bální ukonèení\n",-A
-"%s: p-Bøijat signal %d, konèím\n",-A
-"%s: ukon-Bèení práce hotovo\n",-A
-"%s: n-Básilné uzavøení threadu %ld u¾ivatele '%-.64s'\n",-A
-"Nemohu vytvo-Bøit IP socket",-A
-"Tabulka '%-.64s' nem-Bá index odpovídající CREATE INDEX. Vytvoøte tabulku znovu",-A
-"Argument separ-Bátoru polo¾ek nebyl oèekáván. Pøeètìte si manuál",-A
-"Nen-Bí mo¾né pou¾ít pevný rowlength s BLOBem. Pou¾ijte 'fields terminated by'.",-A
-"Soubor '%-.64s' mus-Bí být v adresáøi databáze nebo èitelný pro v¹echny",-A
-"Soubor '%-.64s' ji-B¾ existuje",-A
-"Z-Báznamù: %ld Vymazáno: %ld Pøeskoèeno: %ld Varování: %ld",-A
-"Z-Báznamù: %ld Zdvojených: %ld",-A
-"Chybn-Bá podèást klíèe -- není to øetìzec nebo je del¹í ne¾ délka èásti klíèe",-A
-"Nen-Bí mo¾né vymazat v¹echny polo¾ky s ALTER TABLE. Pou¾ijte DROP TABLE",-A
-"Nemohu zru-B¹it '%-.64s' (provést DROP). Zkontrolujte, zda neexistují záznamy/klíèe",-A
-"Z-Báznamù: %ld Zdvojených: %ld Varování: %ld",-A
-"INSERT TABLE '%-.64s' nen-Bí dovoleno v seznamu tabulek FROM",-A
-"Nezn-Bámá identifikace threadu: %lu",-A
-"Nejste vlastn-Bíkem threadu %lu",-A
-"Nejsou pou-B¾ity ¾ádné tabulky",-A
-"P-Bøíli¹ mnoho øetìzcù pro sloupec %s a SET",-A
-"Nemohu vytvo-Bøit jednoznaèné jméno logovacího souboru %s.(1-999)\n",-A
-"Tabulka '%-.64s' byla zam-Bèena s READ a nemù¾e být zmìnìna",-A
-"Tabulka '%-.64s' nebyla zam-Bèena s LOCK TABLES",-A
-"Blob polo-B¾ka '%-.64s' nemù¾e mít defaultní hodnotu",-A
-"Nep-Bøípustné jméno databáze '%-.64s'",-A
-"Nep-Bøípustné jméno tabulky '%-.64s'",-A
-"Zadan-Bý SELECT by procházel pøíli¹ mnoho záznamù a trval velmi dlouho. Zkontrolujte tvar WHERE a je-li SELECT v poøádku, pou¾ijte SET OPTION SQL_BIG_SELECTS=1",-A
-"Nezn-Bámá chyba",-A
-"Nezn-Bámá procedura %s",-A
-"Chybn-Bý poèet parametrù procedury %s",-A
-"Chybn-Bé parametry procedury %s",-A
-"Nezn-Bámá tabulka '%-.64s' v %s",-A
-"Polo-B¾ka '%-.64s' je zadána dvakrát",-A
-"Nespr-Bávné pou¾ití funkce group",-A
-"Tabulka '%-.64s' pou-B¾ívá roz¹íøení, které v této verzi MySQL není",-A
-"Tabulka mus-Bí mít alespoò jeden sloupec",-A
-"Tabulka '%-.64s' je pln-Bá",-A
-"Nezn-Bámá znaková sada: '%-.64s'",-A
-"P-Bøíli¹ mnoho tabulek, MySQL jich mù¾e mít v joinu jen %d",-A
-"P-Bøíli¹ mnoho polo¾ek",-A
-"-BØádek je pøíli¹ velký. Maximální velikost øádku, nepoèítaje polo¾ky blob, je %d. Musíte zmìnit nìkteré polo¾ky na blob",-A
-"P-Bøeteèení zásobníku threadu: pou¾ito %ld z %ld. Pou¾ijte 'mysqld -O thread_stack=#' k zadání vìt¹ího zásobníku",-A
-"V OUTER JOIN byl nalezen k-Bøí¾ový odkaz. Provìøte ON podmínky",-A
-"Sloupec '%-.32s' je pou-B¾it s UNIQUE nebo INDEX, ale není definován jako NOT NULL",-A
-"Nemohu na-Bèíst funkci '%-.64s'",-A
+"Obsluha tabulky vr-Bátila chybu %d",
+"Obsluha tabulky '%-.64s' nem-Bá tento parametr",
+"Nemohu naj-Bít záznam v '%-.64s'",
+"Nespr-Bávná informace v souboru '%-.64s'",
+"Nespr-Bávný klíè pro tabulku '%-.64s'. Pokuste se ho opravit",
+"Star-Bý klíèový soubor pro '%-.64s'. Opravte ho.",
+"'%-.64s' je jen pro -Bètení",
+"M-Bálo pamìti. Pøestartujte daemona a zkuste znovu (je potøeba %d bytù)",
+"M-Bálo pamìti pro tøídìní. Zvy¹te velikost tøídícího bufferu",
+"Neo-Bèekávaný konec souboru pøi ètení '%-.64s' (chybový kód: %d)",
+"P-Bøíli¹ mnoho spojení",
+"M-Bálo prostoru/pamìti pro thread",
+"Nemohu zjistit jm-Béno stroje pro Va¹i adresu",
+"Chyba p-Bøi ustavování spojení",
+"P-Bøístup pro u¾ivatele '%-.32s@%-.64s' k databázi '%-.64s' není povolen",
+"P-Bøístup pro u¾ivatele '%-.32s@%-.64s' (s heslem %s)",
+"Nebyla vybr-Bána ¾ádná databáze",
+"Nezn-Bámý pøíkaz",
+"Sloupec '%-.64s' nem-Bù¾e být null",
+"Nezn-Bámá databáze '%-.64s'",
+"Tabulka '%-.64s' ji-B¾ existuje",
+"Nezn-Bámá tabulka '%-.64s'",
+"Sloupec '%-.64s' v %s nen-Bí zcela jasný",
+"Prob-Bíhá ukonèování práce serveru",
+"Nezn-Bámý sloupec '%-.64s' v %s",
+"Pou-B¾ité '%-.64s' nebylo v group by",
+"Nemohu pou-B¾ít group na '%-.64s'",
+"P-Bøíkaz obsahuje zároveò funkci sum a sloupce",
+"Po-Bèet sloupcù neodpovídá zadané hodnotì",
+"Jm-Béno identifikátoru '%-.64s' je pøíli¹ dlouhé",
+"Zdvojen-Bé jméno sloupce '%-.64s'",
+"Zdvojen-Bé jméno klíèe '%-.64s'",
+"Zvojen-Bý klíè '%-.64s' (èíslo klíèe %d)",
+"Chybn-Bá specifikace sloupce '%-.64s'",
+"%s bl-Bízko '%-.64s' na øádku %d",
+"V-Býsledek dotazu je prázdný",
+"Nejednozna-Bèná tabulka/alias: '%-.64s'",
+"Chybn-Bá defaultní hodnota pro '%-.64s'",
+"Definov-Báno více primárních klíèù",
+"Zad-Báno pøíli¹ mnoho klíèù, je povoleno nejvíce %d klíèù",
+"Zad-Báno pøíli¹ mnoho èást klíèù, je povoleno nejvíce %d èástí",
+"Zadan-Bý klíè byl pøíli¹ dlouhý, nejvìt¹í délka klíèe je %d",
+"Kl-Bíèový sloupec '%-.64s' v tabulce neexistuje",
+"Blob sloupec '%-.64s' nem-Bù¾e být pou¾it jako klíè",
+"P-Bøíli¹ velká délka sloupce '%-.64s' (nejvíce %d). Pou¾ijte BLOB",
+"M-Bù¾ete mít pouze jedno AUTO pole a to musí být definováno jako klíè",
+"%s: p-Bøipraven na spojení\n",
+"%s: norm-Bální ukonèení\n",
+"%s: p-Bøijat signal %d, konèím\n",
+"%s: ukon-Bèení práce hotovo\n",
+"%s: n-Básilné uzavøení threadu %ld u¾ivatele '%-.64s'\n",
+"Nemohu vytvo-Bøit IP socket",
+"Tabulka '%-.64s' nem-Bá index odpovídající CREATE INDEX. Vytvoøte tabulku znovu",
+"Argument separ-Bátoru polo¾ek nebyl oèekáván. Pøeètìte si manuál",
+"Nen-Bí mo¾né pou¾ít pevný rowlength s BLOBem. Pou¾ijte 'fields terminated by'.",
+"Soubor '%-.64s' mus-Bí být v adresáøi databáze nebo èitelný pro v¹echny",
+"Soubor '%-.64s' ji-B¾ existuje",
+"Z-Báznamù: %ld Vymazáno: %ld Pøeskoèeno: %ld Varování: %ld",
+"Z-Báznamù: %ld Zdvojených: %ld",
+"Chybn-Bá podèást klíèe -- není to øetìzec nebo je del¹í ne¾ délka èásti klíèe",
+"Nen-Bí mo¾né vymazat v¹echny polo¾ky s ALTER TABLE. Pou¾ijte DROP TABLE",
+"Nemohu zru-B¹it '%-.64s' (provést DROP). Zkontrolujte, zda neexistují záznamy/klíèe",
+"Z-Báznamù: %ld Zdvojených: %ld Varování: %ld",
+"INSERT TABLE '%-.64s' nen-Bí dovoleno v seznamu tabulek FROM",
+"Nezn-Bámá identifikace threadu: %lu",
+"Nejste vlastn-Bíkem threadu %lu",
+"Nejsou pou-B¾ity ¾ádné tabulky",
+"P-Bøíli¹ mnoho øetìzcù pro sloupec %s a SET",
+"Nemohu vytvo-Bøit jednoznaèné jméno logovacího souboru %s.(1-999)\n",
+"Tabulka '%-.64s' byla zam-Bèena s READ a nemù¾e být zmìnìna",
+"Tabulka '%-.64s' nebyla zam-Bèena s LOCK TABLES",
+"Blob polo-B¾ka '%-.64s' nemù¾e mít defaultní hodnotu",
+"Nep-Bøípustné jméno databáze '%-.64s'",
+"Nep-Bøípustné jméno tabulky '%-.64s'",
+"Zadan-Bý SELECT by procházel pøíli¹ mnoho záznamù a trval velmi dlouho. Zkontrolujte tvar WHERE a je-li SELECT v poøádku, pou¾ijte SET OPTION SQL_BIG_SELECTS=1",
+"Nezn-Bámá chyba",
+"Nezn-Bámá procedura %s",
+"Chybn-Bý poèet parametrù procedury %s",
+"Chybn-Bé parametry procedury %s",
+"Nezn-Bámá tabulka '%-.64s' v %s",
+"Polo-B¾ka '%-.64s' je zadána dvakrát",
+"Nespr-Bávné pou¾ití funkce group",
+"Tabulka '%-.64s' pou-B¾ívá roz¹íøení, které v této verzi MySQL není",
+"Tabulka mus-Bí mít alespoò jeden sloupec",
+"Tabulka '%-.64s' je pln-Bá",
+"Nezn-Bámá znaková sada: '%-.64s'",
+"P-Bøíli¹ mnoho tabulek, MySQL jich mù¾e mít v joinu jen %d",
+"P-Bøíli¹ mnoho polo¾ek",
+"-BØádek je pøíli¹ velký. Maximální velikost øádku, nepoèítaje polo¾ky blob, je %d. Musíte zmìnit nìkteré polo¾ky na blob",
+"P-Bøeteèení zásobníku threadu: pou¾ito %ld z %ld. Pou¾ijte 'mysqld -O thread_stack=#' k zadání vìt¹ího zásobníku",
+"V OUTER JOIN byl nalezen k-Bøí¾ový odkaz. Provìøte ON podmínky",
+"Sloupec '%-.32s' je pou-B¾it s UNIQUE nebo INDEX, ale není definován jako NOT NULL",
+"Nemohu na-Bèíst funkci '%-.64s'",
"Nemohu inicializovat funkci '%-.64s'; %-.80s",
-"Pro sd-Bílenou knihovnu nejsou povoleny cesty",-A
-"Funkce '%-.64s' ji-B¾ existuje",-A
-"Nemohu otev-Bøít sdílenou knihovnu '%-.64s' (errno: %d %s)",-A
-"Nemohu naj-Bít funkci '%-.64s' v knihovnì'",-A
-"Funkce '%-.64s' nen-Bí definována",-A
-"Stroj '%-.64s' je zablokov-Bán kvùli mnoha chybám pøi pøipojování. Odblokujete pou¾itím 'mysqladmin flush-hosts'",-A
-"Stroj '%-.64s' nem-Bá povoleno se k tomuto MySQL serveru pøipojit",-A
-"Pou-B¾íváte MySQL jako anonymní u¾ivatel a anonymní u¾ivatelé nemají povoleno mìnit hesla",-A
-"Na zm-Bìnu hesel ostatním musíte mít právo provést update tabulek v databázi mysql",-A
-"V tabulce user nen-Bí ¾ádný odpovídající øádek",-A
-"Nalezen-Bých øádkù: %ld Zmìnìno: %ld Varování: %ld",-A
-"Nemohu vytvo-Bøit nový thread (errno %d). Pokud je je¹tì nìjaká volná pamì», podívejte se do manuálu na èást o chybách specifických pro jednotlivé operaèní systémy",-A
-"Po-Bèet sloupcù neodpovídá poètu hodnot na øádku %ld",-A
-"Nemohu znovuotev-Bøít tabulku: '%-.64s',-A
-"Neplatn-Bé u¾ití hodnoty NULL",-A
-"Regul-Bární výraz vrátil chybu '%-.64s'",-A
-"Pokud nen-Bí ¾ádná GROUP BY klauzule, není dovoleno souèasné pou¾ití GROUP polo¾ek (MIN(),MAX(),COUNT()...) s ne GROUP polo¾kami",-A
-"Neexistuje odpov-Bídající grant pro u¾ivatele '%-.32s' na stroji '%-.64s'",-A
-"%-.16s p-Bøíkaz nepøístupný pro u¾ivatele: '%-.32s@%-.64s' pro tabulku '%-.64s'",-A
-"%-.16s p-Bøíkaz nepøístupný pro u¾ivatele: '%-.32s@%-.64s' pro sloupec '%-.64s' v tabulce '%-.64s'",-A
-"Neplatn-Bý pøíkaz GRANT/REVOKE. Prosím, pøeètìte si v manuálu, jaká privilegia je mo¾né pou¾ít.",-A
-"Argument p-Bøíkazu GRANT u¾ivatel nebo stroj je pøíli¹ dlouhý",-A
+"Pro sd-Bílenou knihovnu nejsou povoleny cesty",
+"Funkce '%-.64s' ji-B¾ existuje",
+"Nemohu otev-Bøít sdílenou knihovnu '%-.64s' (errno: %d %s)",
+"Nemohu naj-Bít funkci '%-.64s' v knihovnì'",
+"Funkce '%-.64s' nen-Bí definována",
+"Stroj '%-.64s' je zablokov-Bán kvùli mnoha chybám pøi pøipojování. Odblokujete pou¾itím 'mysqladmin flush-hosts'",
+"Stroj '%-.64s' nem-Bá povoleno se k tomuto MySQL serveru pøipojit",
+"Pou-B¾íváte MySQL jako anonymní u¾ivatel a anonymní u¾ivatelé nemají povoleno mìnit hesla",
+"Na zm-Bìnu hesel ostatním musíte mít právo provést update tabulek v databázi mysql",
+"V tabulce user nen-Bí ¾ádný odpovídající øádek",
+"Nalezen-Bých øádkù: %ld Zmìnìno: %ld Varování: %ld",
+"Nemohu vytvo-Bøit nový thread (errno %d). Pokud je je¹tì nìjaká volná pamì», podívejte se do manuálu na èást o chybách specifických pro jednotlivé operaèní systémy",
+"Po-Bèet sloupcù neodpovídá poètu hodnot na øádku %ld",
+"Nemohu znovuotev-Bøít tabulku: '%-.64s',
+"Neplatn-Bé u¾ití hodnoty NULL",
+"Regul-Bární výraz vrátil chybu '%-.64s'",
+"Pokud nen-Bí ¾ádná GROUP BY klauzule, není dovoleno souèasné pou¾ití GROUP polo¾ek (MIN(),MAX(),COUNT()...) s ne GROUP polo¾kami",
+"Neexistuje odpov-Bídající grant pro u¾ivatele '%-.32s' na stroji '%-.64s'",
+"%-.16s p-Bøíkaz nepøístupný pro u¾ivatele: '%-.32s@%-.64s' pro tabulku '%-.64s'",
+"%-.16s p-Bøíkaz nepøístupný pro u¾ivatele: '%-.32s@%-.64s' pro sloupec '%-.64s' v tabulce '%-.64s'",
+"Neplatn-Bý pøíkaz GRANT/REVOKE. Prosím, pøeètìte si v manuálu, jaká privilegia je mo¾né pou¾ít.",
+"Argument p-Bøíkazu GRANT u¾ivatel nebo stroj je pøíli¹ dlouhý",
"Tabulka '%-64s.%s' neexistuje",
-"Neexistuje odpov-Bídající grant pro u¾ivatele '%-.32s' na stroji '%-.64s' pro tabulku '%-.64s'",-A
-"Pou-B¾itý pøíkaz není v této verzi MySQL povolen",-A
-"Va-B¹e syntaxe je nìjaká divná",-A
-"Zpo-B¾dìný insert threadu nebyl schopen získat po¾adovaný zámek pro tabulku %-.64s",-A
-"P-Bøíli¹ mnoho zpo¾dìných threadù",-A
-"Zru-B¹eno spojení %ld do databáze: '%-.64s' u¾ivatel: '%-.64s' (%s)",-A
-"Zji-B¹tìn pøíchozí packet del¹í ne¾ 'max_allowed_packet'",-A
-"Zji-B¹tìna chyba pøi ètení z roury spojení",-A
-"Zji-B¹tìna chyba fcntl()",-A
-"P-Bøíchozí packety v chybném poøadí",-A
-"Nemohu rozkomprimovat komunika-Bèní packet",-A
-"Zji-B¹tìna chyba pøi ètení komunikaèního packetu",-A
-"Zji-B¹tìn timeout pøi ètení komunikaèního packetu",-A
-"Zji-B¹tìna chyba pøi zápisu komunikaèního packetu",-A
-"Zji-B¹tìn timeout pøi zápisu komunikaèního packetu",-A
-"V-Býsledný øetìzec je del¹í ne¾ max_allowed_packet",-A
-"Typ pou-B¾ité tabulky nepodporuje BLOB/TEXT sloupce",-A
-"Typ pou-B¾ité tabulky nepodporuje AUTO_INCREMENT sloupce",-A
-"INSERT DELAYED nen-Bí mo¾no s tabulkou '%-.64s' pou¾ít, proto¾e je zamèená pomocí LOCK TABLES",-A
-"Nespr-Bávné jméno sloupce '%-.100s'",-A
-"Handler pou-B¾ité tabulky neumí indexovat sloupce '%-.64s'",-A
-"V-B¹echny tabulky v MERGE tabulce nejsou definovány stejnì",-A
-"Kv-Bùli unique constraintu nemozu zapsat do tabulky '%-.64s'",-A
-"BLOB sloupec '%-.64s' je pou-B¾it ve specifikaci klíèe bez délky",-A
-"V-B¹echny èásti primárního klíèe musejí být NOT NULL; pokud potøebujete NULL, pou¾ijte UNIQUE",-A
-"V-Býsledek obsahuje více ne¾ jeden øádek",-A
-"Tento typ tabulky vy-B¾aduje primární klíè",-A
-"Tato verze MySQL nen-Bí zkompilována s podporou RAID",-A
-"Update tabulky bez WHERE s kl-Bíèem není v módu bezpeèných update dovoleno",-A
-"Kl-Bíè '%-.64s' v tabulce '%-.64s' neexistuje",-A
-"Nemohu otev-Bøít tabulku",-A
+"Neexistuje odpov-Bídající grant pro u¾ivatele '%-.32s' na stroji '%-.64s' pro tabulku '%-.64s'",
+"Pou-B¾itý pøíkaz není v této verzi MySQL povolen",
+"Va-B¹e syntaxe je nìjaká divná",
+"Zpo-B¾dìný insert threadu nebyl schopen získat po¾adovaný zámek pro tabulku %-.64s",
+"P-Bøíli¹ mnoho zpo¾dìných threadù",
+"Zru-B¹eno spojení %ld do databáze: '%-.64s' u¾ivatel: '%-.64s' (%s)",
+"Zji-B¹tìn pøíchozí packet del¹í ne¾ 'max_allowed_packet'",
+"Zji-B¹tìna chyba pøi ètení z roury spojení",
+"Zji-B¹tìna chyba fcntl()",
+"P-Bøíchozí packety v chybném poøadí",
+"Nemohu rozkomprimovat komunika-Bèní packet",
+"Zji-B¹tìna chyba pøi ètení komunikaèního packetu",
+"Zji-B¹tìn timeout pøi ètení komunikaèního packetu",
+"Zji-B¹tìna chyba pøi zápisu komunikaèního packetu",
+"Zji-B¹tìn timeout pøi zápisu komunikaèního packetu",
+"V-Býsledný øetìzec je del¹í ne¾ max_allowed_packet",
+"Typ pou-B¾ité tabulky nepodporuje BLOB/TEXT sloupce",
+"Typ pou-B¾ité tabulky nepodporuje AUTO_INCREMENT sloupce",
+"INSERT DELAYED nen-Bí mo¾no s tabulkou '%-.64s' pou¾ít, proto¾e je zamèená pomocí LOCK TABLES",
+"Nespr-Bávné jméno sloupce '%-.100s'",
+"Handler pou-B¾ité tabulky neumí indexovat sloupce '%-.64s'",
+"V-B¹echny tabulky v MERGE tabulce nejsou definovány stejnì",
+"Kv-Bùli unique constraintu nemozu zapsat do tabulky '%-.64s'",
+"BLOB sloupec '%-.64s' je pou-B¾it ve specifikaci klíèe bez délky",
+"V-B¹echny èásti primárního klíèe musejí být NOT NULL; pokud potøebujete NULL, pou¾ijte UNIQUE",
+"V-Býsledek obsahuje více ne¾ jeden øádek",
+"Tento typ tabulky vy-B¾aduje primární klíè",
+"Tato verze MySQL nen-Bí zkompilována s podporou RAID",
+"Update tabulky bez WHERE s kl-Bíèem není v módu bezpeèných update dovoleno",
+"Kl-Bíè '%-.64s' v tabulce '%-.64s' neexistuje",
+"Nemohu otev-Bøít tabulku",
"Handler tabulky nepodporuje check/repair",
-"Proveden-Bí tohoto pøíkazu není v transakci dovoleno",-A
-"Chyba %d p-Bøi COMMIT",-A
-"Chyba %d p-Bøi ROLLBACK",-A
-"Chyba %d p-Bøi FLUSH_LOGS",-A
-"Chyba %d p-Bøi CHECKPOINT",-A
-"Spojen-Bí %ld do databáze: '%-.64s' u¾ivatel: '%-.32s' stroj: `%-.64s' (%-.64s) bylo pøeru¹eno",-A
-"Handler tabulky nepodporuje bin-Bární dump",-A
-"Binlog uzav-Bøen pøi pokusu o FLUSH MASTER",-A
-"P-Bøebudování indexu dumpnuté tabulky '%-.64s' nebylo úspì¹né",-A
+"Proveden-Bí tohoto pøíkazu není v transakci dovoleno",
+"Chyba %d p-Bøi COMMIT",
+"Chyba %d p-Bøi ROLLBACK",
+"Chyba %d p-Bøi FLUSH_LOGS",
+"Chyba %d p-Bøi CHECKPOINT",
+"Spojen-Bí %ld do databáze: '%-.64s' u¾ivatel: '%-.32s' stroj: `%-.64s' (%-.64s) bylo pøeru¹eno",
+"Handler tabulky nepodporuje bin-Bární dump",
+"Binlog uzav-Bøen pøi pokusu o FLUSH MASTER",
+"P-Bøebudování indexu dumpnuté tabulky '%-.64s' nebylo úspì¹né",
"Chyba masteru: '%-.64s'",
-"S-Bí»ová chyba pøi ètení z masteru",-A
-"S-Bí»ová chyba pøi zápisu na master",-A
-"-B®ádný sloupec nemá vytvoøen fulltextový index",-A
-"Nemohu prov-Bést zadaný pøíkaz, proto¾e existují aktivní zamèené tabulky nebo aktivní transakce",-A
-"Nezn-Bámá systémová promìnná '%-.64'",-A
-"Tabulka '%-.64s' je ozna-Bèena jako poru¹ená a mìla by být opravena",-A
-"Tabulka '%-.64s' je ozna-Bèena jako poru¹ená a poslední (automatická?) oprava se nezdaøila",-A
+"S-Bí»ová chyba pøi ètení z masteru",
+"S-Bí»ová chyba pøi zápisu na master",
+"-B®ádný sloupec nemá vytvoøen fulltextový index",
+"Nemohu prov-Bést zadaný pøíkaz, proto¾e existují aktivní zamèené tabulky nebo aktivní transakce",
+"Nezn-Bámá systémová promìnná '%-.64'",
+"Tabulka '%-.64s' je ozna-Bèena jako poru¹ená a mìla by být opravena",
+"Tabulka '%-.64s' je ozna-Bèena jako poru¹ená a poslední (automatická?) oprava se nezdaøila",
"Warning: Some non-transactional changed tables couldn't be rolled back",
"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again',
"This operation cannot be performed with a running slave, run SLAVE STOP first",
@@ -222,6 +222,7 @@
"CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error when executing command %s: %-.128s",
diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt
index f511a5d177c..805740664d0 100644
--- a/sql/share/danish/errmsg.txt
+++ b/sql/share/danish/errmsg.txt
@@ -216,6 +216,7 @@
"CREATE DATABASE er ikke tilladt mens en tråd holder på globalt read lock",
"Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error when executing command %s: %-.128s",
diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt
index 91237c691c0..245ff40cf86 100644
--- a/sql/share/dutch/errmsg.txt
+++ b/sql/share/dutch/errmsg.txt
@@ -217,6 +217,7 @@
"CREATE DATABASE niet toegestaan terwijl thread een globale 'read lock' bezit",
"Foutieve parameters voor %s",
"%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error when executing command %s: %-.128s",
diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt
index d120575d9af..185d8ffbe33 100644
--- a/sql/share/english/errmsg.txt
+++ b/sql/share/english/errmsg.txt
@@ -213,6 +213,7 @@
"CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error when executing command %s: %-.128s",
diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt
index 929b97e6146..5023ead91e7 100644
--- a/sql/share/estonian/errmsg.txt
+++ b/sql/share/estonian/errmsg.txt
@@ -217,6 +217,7 @@
"CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error when executing command %s: %-.128s",
diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt
index 03589a91c77..1f282dc078d 100644
--- a/sql/share/french/errmsg.txt
+++ b/sql/share/french/errmsg.txt
@@ -213,6 +213,7 @@
"CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error when executing command %s: %-.128s",
diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt
index deded796403..dd744ecab46 100644
--- a/sql/share/german/errmsg.txt
+++ b/sql/share/german/errmsg.txt
@@ -216,6 +216,7 @@
"CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error when executing command %s: %-.128s",
diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt
index c6255689ee4..850bac1756b 100644
--- a/sql/share/greek/errmsg.txt
+++ b/sql/share/greek/errmsg.txt
@@ -213,6 +213,7 @@
"CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error when executing command %s: %-.128s",
diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt
index fbedda7e329..6e1d1af015e 100644
--- a/sql/share/hungarian/errmsg.txt
+++ b/sql/share/hungarian/errmsg.txt
@@ -215,6 +215,7 @@
"CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error when executing command %s: %-.128s",
diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt
index f419ddb7e0c..5d10578a6cf 100644
--- a/sql/share/italian/errmsg.txt
+++ b/sql/share/italian/errmsg.txt
@@ -213,6 +213,7 @@
"CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error when executing command %s: %-.128s",
diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt
index 2f4b72f8cc1..1ed9b4aa346 100644
--- a/sql/share/japanese/errmsg.txt
+++ b/sql/share/japanese/errmsg.txt
@@ -215,6 +215,7 @@
"CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error when executing command %s: %-.128s",
diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt
index f5f5539b8a2..8b2d689bff5 100644
--- a/sql/share/korean/errmsg.txt
+++ b/sql/share/korean/errmsg.txt
@@ -213,6 +213,7 @@
"CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error when executing command %s: %-.128s",
diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt
index d87da187577..267eae13d67 100644
--- a/sql/share/norwegian-ny/errmsg.txt
+++ b/sql/share/norwegian-ny/errmsg.txt
@@ -215,6 +215,7 @@
"CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error when executing command %s: %-.128s",
diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt
index 1d54c9aec03..8a7112ac0c1 100644
--- a/sql/share/norwegian/errmsg.txt
+++ b/sql/share/norwegian/errmsg.txt
@@ -215,6 +215,7 @@
"CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error when executing command %s: %-.128s",
diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt
index 1c93fcc7f8f..6ae12f7bff1 100644
--- a/sql/share/polish/errmsg.txt
+++ b/sql/share/polish/errmsg.txt
@@ -217,6 +217,7 @@
"CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error when executing command %s: %-.128s",
diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt
index 29a52900b24..787fae883ea 100644
--- a/sql/share/portuguese/errmsg.txt
+++ b/sql/share/portuguese/errmsg.txt
@@ -1,6 +1,6 @@
/* Copyright Abandoned 1997 TCX DataKonsult AB & Monty Program KB & Detron HB
This file is public domain and comes with NO WARRANTY of any kind */
-/* Updated by Roberto M. Serqueira - martinsc@uol.com.br - 05.24.2001 */
+/* Updated by Roberto de Martin Serqueira - martinsc@uol.com.br - 08.20.2001 */
"hashchk",
"isamchk",
"não",
@@ -35,14 +35,14 @@
"Manipulador de tabela para '%-.64s' não tem esta opção",
"Não pode encontrar registro em '%-.64s'",
"Informação incorreta no arquivo '%-.64s'",
-"Arquivo chave incorreto para tabela '%-.64s'. Tente reparar",
+"Arquivo de índice incorreto para tabela '%-.64s'. Tente reparar",
"Arquivo chave desatualizado para tabela '%-.64s'. Repare-o!",
"Tabela '%-.64s' é somente para leitura",
"Sem memória. Reinicie o programa e tente novamente (necessita de %d bytes)",
"Sem memória para ordenação. Aumente tamanho do 'buffer' de ordenação",
"Encontrado fim de arquivo inesperado ao ler arquivo '%-.64s' (erro no. %d)",
"Excesso de conexões",
-"Sem memória. Verifique se o mysqld ou algum outro processo está usando toda memória disponível. Se não, você pode ter que usar 'ulimit' para permitir ao mysqld usar mais memória ou se você pode adicionar mais área de 'swap'",
+"Sem memória. Verifique se o mysqld ou algum outro processo está usando toda memória disponível. Se não, você pode ter que usar 'ulimit' para permitir ao mysqld usar mais memória ou você pode adicionar mais área de 'swap'",
"Não pode obter nome do 'host' para seu endereço",
"Negociação de acesso falhou",
"Acesso negado para o usuário '%-.32s@%-.64s' ao banco de dados '%-.64s'",
@@ -58,7 +58,7 @@
"Coluna '%-.64s' desconhecida em '%-.64s'",
"'%-.64s' não está em 'GROUP BY'",
"Não pode agrupar em '%-.64s'",
-"Cláusula contém funções de soma e colunas juntos",
+"Cláusula contém funções de soma e colunas juntas",
"Contagem de colunas não confere com a contagem de valores",
"Nome identificador '%-.100s' é longo demais",
"Nome da coluna '%-.64s' duplicado",
@@ -72,27 +72,27 @@
"Definida mais de uma chave primária",
"Especificadas chaves demais. O máximo permitido são %d chaves",
"Especificadas partes de chave demais. O máximo permitido são %d partes",
-"Chave especificada longa demais. O comprimento máximo permitido é %d",
+"Chave especificada longa demais. O comprimento de chave máximo permitido é %d",
"Coluna chave '%-.64s' não existe na tabela",
"Coluna BLOB '%-.64s' não pode ser utilizada na especificação de chave para o tipo de tabela usado",
"Comprimento da coluna '%-.64s' grande demais (max = %d). Use BLOB em seu lugar",
-"Definição incorreta de tabela. Somente é permitido um campo auto-incrementado e ele tem que ser definido como chave",
+"Definição incorreta de tabela. Somente é permitido um único campo auto-incrementado e ele tem que ser definido como chave",
"%s: Pronto para conexões\n",
"%s: 'Shutdown' normal\n",
"%s: Obteve sinal %d. Abortando!\n",
"%s: 'Shutdown' completo\n",
"%s: Forçando finalização da 'thread' %ld - usuário '%-.32s'\n",
-"Não pode criar 'socket' IP",
+"Não pode criar 'IP socket'",
"Tabela '%-.64s' não possui um índice como o usado em CREATE INDEX. Recrie a tabela",
"Argumento separador de campos não é o esperado. Confira no manual",
"Você não pode usar comprimento de linha fixo com BLOBs. Favor usar 'fields terminated by'",
-"Arquivo '%-.64s' tem que estar no diretório do banco de dados ou ter leitura permitida para todos",
+"Arquivo '%-.64s' tem que estar no diretório do banco de dados ou ter leitura possível para todos",
"Arquivo '%-.80s' já existe",
"Registros: %ld - Deletados: %ld - Ignorados: %ld - Avisos: %ld",
"Registros: %ld - Duplicados: %ld",
-"Parte de chave incorreta. A parte de chave usada não é um 'string' ou o comprimento usado é maior do que a parte de chave",
+"Parte de chave incorreta. A parte de chave usada não é um 'string' ou o comprimento usado é maior do que a parte de chave ou o manipulador de tabelas não aceita partes de chaves únicas",
"Você não pode deletar todas as colunas com ALTER TABLE. Use DROP TABLE em seu lugar",
-"Não pode fazer DROP '%-.64s'. Confira se este campo/chave existe",
+"Não pode fazer DROP '%-.64s'. Confira se esta coluna/chave existe",
"Registros: %ld - Duplicados: %ld - Avisos: %ld",
"INSERT TABLE '%-.64s' não é permitido em lista de tabelas FROM",
"'Id' de 'thread' %lu desconhecido",
@@ -112,14 +112,14 @@
"Parâmetros incorretos para a 'procedure' '%-.64s'",
"Tabela '%-.64s' desconhecida em '%-.32s'",
"Coluna '%-.64s' especificada duas vezes",
-"Uso inválido da função GROUP",
+"Uso inválido de função de grupo",
"Tabela '%-.64s' usa uma extensão que não existe nesta versão do MySQL",
"Uma tabela tem que ter pelo menos uma (1) coluna",
"Tabela '%-.64s' está cheia",
"Conjunto de caracteres '%-.64s' desconhecido",
"Tabelas demais. O MySQL pode usar somente %d tabelas em um JOIN",
"Colunas demais",
-"Tamanho de linha grande demais. O máximo tamanho de linha, não contando BLOBs, é de %d. Você tem que mudar alguns campos para BLOBs",
+"Tamanho de linha grande demais. O máximo tamanho de linha, não contando BLOBs, é %d. Você tem que mudar alguns campos para BLOBs",
"Estouro da pilha do 'thread'. Usados %ld de uma pilha de %ld . Use 'mysqld -O thread_stack=#' para especificar uma pilha maior, se necessário",
"Dependência cruzada encontrada em OUTER JOIN. Examine suas condições ON",
"Coluna '%-.64s' é usada com UNIQUE ou INDEX, mas não está definida como NOT NULL",
@@ -136,7 +136,7 @@
"Você tem que ter o privilégio para atualizar tabelas no banco de dados mysql para ser capaz de mudar a senha de outros",
"Não pode encontrar nenhuma linha que combine na tabela user",
"Linhas que combinaram: %ld - Alteradas: %ld - Avisos: %ld",
-"Não pode criar uma nova 'thread' (erro no. %d). Se você não estiver sem memória disponível, você pode consultar o manual sobre uma possível falha dependente do sistema operacional",
+"Não pode criar uma nova 'thread' (erro no. %d). Se você não estiver sem memória disponível, você pode consultar o manual sobre um possível 'bug' dependente do sistema operacional",
"Contagem de colunas não confere com a contagem de valores na linha %ld",
"Não pode reabrir a tabela '%-.64s',
"Uso inválido do valor NULL",
@@ -151,22 +151,22 @@
"Não existe tal 'grant' definido para o usuário '%-.32s' no 'host' '%-.64s', na tabela '%-.64s'",
"Comando usado não é permitido para esta versão do MySQL",
"Você tem um erro de sintaxe no seu SQL",
-"'Thread' de inserção retardada ('delayed') não conseguiu obter trava solicitada na tabela '%-.64s'",
+"'Thread' de inserção retardada ('delayed') não conseguiu obter trava solicitada para tabela '%-.64s'",
"Excesso de 'threads' retardadas ('delayed') em uso",
"Conexão %ld abortou para o banco de dados '%-.64s' - usuário '%-.32s' (%-.64s)",
"Obteve um pacote maior do que 'max_allowed_packet'",
-"Obteve um erro de leitura no 'pipe' de conexão",
+"Obteve um erro de leitura no 'pipe' da conexão",
"Obteve um erro em fcntl()",
"Obteve pacotes fora de ordem",
"Não conseguiu descomprimir pacote de comunicação",
"Obteve um erro na leitura de pacotes de comunicação",
"Obteve expiração de tempo ('timeout') na leitura de pacotes de comunicação",
-"Obteve um erro na gravação de pacotes de comunicação",
+"Obteve um erro na escrita de pacotes de comunicação",
"Obteve expiração de tempo ('timeout') na escrita de pacotes de comunicação",
"'String' resultante é mais longa do que 'max_allowed_packet'",
"Tipo de tabela usado não permite colunas BLOB/TEXT",
"Tipo de tabela usado não permite colunas AUTO_INCREMENT",
-"INSERT DELAYED não pode ser usado com a tabela '%-.64s', porque está travada com LOCK TABLES",
+"INSERT DELAYED não pode ser usado com a tabela '%-.64s', porque ela está travada com LOCK TABLES",
"Nome de coluna '%-.100s' incorreto",
"O manipulador de tabela usado não pode indexar a coluna '%-.64s'",
"Tabelas no MERGE não estão todas definidas identicamente",
@@ -176,7 +176,7 @@
"O resultado consistiu em mais do que uma linha",
"Este tipo de tabela requer uma chave primária",
"Esta versão do MySQL não foi compilada com suporte a RAID",
-"Você está usando modo de atualização seguro e tentou atualizar uma tabela sem um WHERE que use uma coluna tipo KEY",
+"Você está usando modo de atualização seguro e tentou atualizar uma tabela sem um WHERE que use uma coluna de KEY",
"Chave '%-.64s' não existe na tabela '%-.64s'",
"Não pode abrir a tabela",
"O manipulador de tabela não suporta check/repair",
@@ -188,7 +188,7 @@
"Conexão %ld abortada ao banco de dados '%-.64s' - usuário '%-.32s' - 'host' `%-.64s' ('%-.64s')",
"O manipulador de tabela não suporta DUMP binário de tabela",
"Binlog fechado. Não pode fazer RESET MASTER",
-"Falhou na reconstrução do índice da tabela 'dumped' '%-.64s'",
+"Falhou na reconstrução do índice da tabela '%-.64s' 'dumped'",
"Erro no 'master' '%-.64s'",
"Erro de rede na leitura do 'master'",
"Erro de rede na gravação do 'master'",
@@ -207,12 +207,13 @@
"Usuário '%-.64s' já possui 'max_user_connections' conexões ativas",
"Você pode usar apenas expressões de constante com SET",
"Excedido tempo de espera (timeout) do travamento",
-"O número total de travamentos excede o tamanho de travamento da tabela",
-"Travamentos de atualização não podem ser obtidos durante um READ UNCOMMITTED na transação",
-"DROP DATABASE não permitido enquanto uma 'thread' está assegurando um travamento global de leitura",
-"CREATE DATABASE não permitido enquanto uma 'thread' está assegurando um travamento global de leitura",
-"Wrong arguments to %s",
-"%-.32s@%-.64s is not allowed to create new users",
+"O número total de travamentos excede o tamanho da tabela de travamentos",
+"Travamentos de atualização não podem ser obtidos durante uma transação de READ UNCOMMITTED",
+"DROP DATABASE não permitido enquanto uma 'thread' está mantendo um travamento global de leitura",
+"CREATE DATABASE não permitido enquanto uma 'thread' está mantendo um travamento global de leitura",
+"Argumentos errados para %s",
+"Não é permitido a %-.32s@%-.64s criar novos usuários",
+"Incorrect table definition; All MERGE tables must be in the same database",
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error when executing command %s: %-.128s",
diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt
index 8f957302f30..a09a8046b29 100644
--- a/sql/share/romanian/errmsg.txt
+++ b/sql/share/romanian/errmsg.txt
@@ -217,6 +217,7 @@
"CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error when executing command %s: %-.128s",
diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt
index dc350a242a3..e4de072bf67 100644
--- a/sql/share/russian/errmsg.txt
+++ b/sql/share/russian/errmsg.txt
@@ -216,6 +216,7 @@
"CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error when executing command %s: %-.128s",
diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt
index f7db353db3f..9b4491a3258 100644
--- a/sql/share/slovak/errmsg.txt
+++ b/sql/share/slovak/errmsg.txt
@@ -221,6 +221,7 @@
"CREATE DATABASE not allowed while thread is holding global read lock",
"Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
"Error connecting to master: %-.128s",
"Error running query on master: %-.128s",
"Error when executing command %s: %-.128s",
diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt
index f10908a33ba..165fcb1d538 100644
--- a/sql/share/spanish/errmsg.txt
+++ b/sql/share/spanish/errmsg.txt
@@ -214,6 +214,7 @@
"CREATE DATABASE no permitido mientras un thread está ejerciendo un bloqueo de lectura global",
"Wrong arguments to %s",
"%-.32s@%-.64s is not allowed to create new users",
+"Incorrect table definition; All MERGE tables must be in the same database",
"Error de coneccion a master: %-128s",
"Error executando el query en master: %-128%",
"Error de %s: %-128%",
diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt
index 5bdbf78e6cf..095a05faf34 100644
--- a/sql/share/swedish/errmsg.txt
+++ b/sql/share/swedish/errmsg.txt
@@ -212,11 +212,12 @@
"DROP DATABASE är inte tillåtet när man har ett globalt läs-lås",
"CREATE DATABASE är inte tillåtet när man har ett globalt läs-lås",
"Felaktiga argument till %s",
-"%-.32s@%-.64s har inte rättigheter att skapa nya användare",
+"%-.32s@%-.64s har inte rättighet att skapa nya användare",
+"Felaktig tabell definition: Alla tabeller i en MERGE tabell måste vara i samma databas",
"Fick fel vid anslutning till master: %-.128s",
"Fick fel vid utförande av command på mastern: %-.128s",
"Fick fel vid utförande av %s: %-.128s",
"Felaktig använding av %s and %s",
"SELECT kommandona har olika antal kolumner"
"Kan inte utföra kommandot emedan du har ett READ lås",
-"Blandning av transaktionella och icke-transaktionella tabeller är stoppat",
+"Blandning av transaktionella och icke-transaktionella tabeller är inaktiverat",
diff --git a/sql/slave.cc b/sql/slave.cc
index 27637107b11..6b79e639a90 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -767,7 +767,7 @@ static int init_slave_thread(THD* thd)
thd->mysys_var=my_thread_var;
thd->dbug_thread_id=my_thread_id();
-#ifndef __WIN__
+#if !defined(__WIN__) && !defined(OS2)
sigset_t set;
VOID(sigemptyset(&set)); // Get mask in use
VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals));
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 820785a1d1f..bc2222ffa48 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -366,7 +366,7 @@ static uint get_access(TABLE *form,uint fieldnr)
/*
- return a number with if sorted put string in this order:
+ return a number which, if sorted 'desc', puts strings in this order:
no wildcards
wildcards
empty string
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 2a9043cc0d7..57679b510e3 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -352,11 +352,9 @@ bool close_cached_tables(THD *thd, bool if_wait_for_refresh,
*/
if (!tables)
kill_delayed_threads();
- pthread_mutex_lock(&thd->mysys_var->mutex);
thd->mysys_var->current_mutex= &LOCK_open;
thd->mysys_var->current_cond= &COND_refresh;
thd->proc_info="Flushing tables";
- pthread_mutex_unlock(&thd->mysys_var->mutex);
close_old_data_files(thd,thd->open_tables,1,1);
bool found=1;
@@ -672,13 +670,12 @@ void wait_for_refresh(THD *thd)
{
/* Wait until the current table is up to date */
const char *proc_info;
- pthread_mutex_lock(&thd->mysys_var->mutex);
thd->mysys_var->current_mutex= &LOCK_open;
thd->mysys_var->current_cond= &COND_refresh;
proc_info=thd->proc_info;
thd->proc_info="Waiting for table";
- pthread_mutex_unlock(&thd->mysys_var->mutex);
- (void) pthread_cond_wait(&COND_refresh,&LOCK_open);
+ if (!thd->killed)
+ (void) pthread_cond_wait(&COND_refresh,&LOCK_open);
pthread_mutex_unlock(&LOCK_open); // Must be unlocked first
pthread_mutex_lock(&thd->mysys_var->mutex);
@@ -1387,7 +1384,7 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type)
{
int error;
-#ifdef __WIN__
+#if defined( __WIN__) || defined(OS2)
/* Win32 can't drop a file that is open */
if (lock_type == TL_WRITE_ALLOW_READ
#ifdef HAVE_GEMINI_DB
@@ -1397,7 +1394,7 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type)
{
lock_type= TL_WRITE;
}
-#endif /* __WIN__ */
+#endif /* __WIN__ || OS2 */
table_list->table=table;
table->grant= table_list->grant;
@@ -2169,7 +2166,7 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
{
in_use->killed=1;
pthread_mutex_lock(&in_use->mysys_var->mutex);
- if (in_use->mysys_var->current_mutex)
+ if (in_use->mysys_var->current_cond)
{
pthread_mutex_lock(in_use->mysys_var->current_mutex);
pthread_cond_broadcast(in_use->mysys_var->current_cond);
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 13c60641db0..b77166d0bc0 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -106,7 +106,7 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0),
mysys_var=0;
net.vio=0;
ull=0;
- system_thread=0;
+ system_thread=cleanup_done=0;
#ifdef __WIN__
real_id = 0;
#endif
@@ -155,15 +155,11 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0),
#endif
}
-THD::~THD()
+/* Do operations that may take a long time */
+
+void THD::cleanup(void)
{
- DBUG_ENTER("~THD()");
- /* Close connection */
- if (net.vio)
- {
- vio_delete(net.vio);
- net_end(&net);
- }
+ DBUG_ENTER("THD::cleanup");
ha_rollback(this);
if (locked_tables)
{
@@ -183,6 +179,21 @@ THD::~THD()
ha_close_connection(this);
}
#endif
+ cleanup_done=1;
+ DBUG_VOID_RETURN;
+}
+
+THD::~THD()
+{
+ DBUG_ENTER("~THD()");
+ /* Close connection */
+ if (net.vio)
+ {
+ vio_delete(net.vio);
+ net_end(&net);
+ }
+ if (!cleanup_done)
+ cleanup();
if (global_read_lock)
unlock_global_read_lock(this);
if (ull)
@@ -221,12 +232,12 @@ void THD::prepare_to_die()
pthread_mutex_lock(&mysys_var->mutex);
if (!system_thread) // Don't abort locks
mysys_var->abort=1;
- if (mysys_var->current_mutex)
- {
- pthread_mutex_lock(mysys_var->current_mutex);
- pthread_cond_broadcast(mysys_var->current_cond);
- pthread_mutex_unlock(mysys_var->current_mutex);
- }
+ if (mysys_var->current_cond)
+ {
+ pthread_mutex_lock(mysys_var->current_mutex);
+ pthread_cond_broadcast(mysys_var->current_cond);
+ pthread_mutex_unlock(mysys_var->current_mutex);
+ }
pthread_mutex_unlock(&mysys_var->mutex);
}
}
diff --git a/sql/sql_class.h b/sql/sql_class.h
index adbf3bd8008..a99bce0d6bc 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -291,7 +291,7 @@ public:
bool no_errors, allow_sum_func, password, fatal_error;
bool query_start_used,last_insert_id_used,insert_id_used;
bool system_thread,in_lock_tables,global_read_lock;
- bool query_error, bootstrap;
+ bool query_error, bootstrap, cleanup_done;
bool volatile killed;
LOG_INFO* current_linfo;
// if we do a purge of binary logs, log index info of the threads
@@ -305,6 +305,7 @@ public:
THD();
~THD();
+ void cleanup(void);
bool store_globals();
#ifdef SIGNAL_WITH_VIO_CLOSE
inline void set_active_vio(Vio* vio)
@@ -335,11 +336,9 @@ public:
const char* msg)
{
const char* old_msg = proc_info;
- pthread_mutex_lock(&mysys_var->mutex);
mysys_var->current_mutex = mutex;
mysys_var->current_cond = cond;
proc_info = msg;
- pthread_mutex_unlock(&mysys_var->mutex);
return old_msg;
}
inline void exit_cond(const char* old_msg)
@@ -374,7 +373,7 @@ public:
{
#ifdef USING_TRANSACTIONS
return (transaction.all.bdb_tid != 0 ||
- transaction.all.innobase_tid != 0 ||
+ transaction.all.innodb_active_trans != 0 ||
transaction.all.gemini_tid != 0);
#else
return 0;
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index 3c5a6efd9a5..ed9ceaae383 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -364,7 +364,9 @@ bool mysql_change_db(THD *thd,const char *name)
}
(void) sprintf(path,"%s/%s",mysql_data_home,dbname);
- unpack_dirname(path,path); // Convert if not unix
+ length=unpack_dirname(path,path); // Convert if not unix
+ if (length && path[length-1] == FN_LIBCHAR)
+ path[length-1]=0; // remove ending '\'
if (access(path,F_OK))
{
net_printf(&thd->net,ER_BAD_DB_ERROR,dbname);
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index d9b6970b72d..1a855c927a4 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -151,6 +151,8 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
break;
}
}
+ else
+ table->file->unlock_row(); // Row failed selection, release lock on it
}
thd->proc_info="end";
end_read_record(&info);
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index f53dd12016b..1d2805d8e90 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -509,7 +509,7 @@ public:
COPY_INFO info;
I_List<delayed_row> rows;
uint group_count;
- TABLE_LIST *table_list; // Argument
+ TABLE_LIST table_list; // Argument
delayed_insert()
:locks_in_memory(0),
@@ -538,10 +538,12 @@ public:
delayed_row *row;
while ((row=rows.get()))
delete row;
- pthread_mutex_destroy(&mutex);
if (table)
close_thread_tables(&thd);
VOID(pthread_mutex_lock(&LOCK_thread_count));
+ pthread_mutex_destroy(&mutex);
+ pthread_cond_destroy(&cond);
+ pthread_cond_destroy(&cond_client);
thd.unlink(); // Must be unlinked under lock
x_free(thd.query);
thd.user=thd.host=0;
@@ -636,7 +638,9 @@ static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list)
pthread_mutex_unlock(&LOCK_delayed_create);
DBUG_RETURN(0);
}
- tmp->table_list=table_list; // Needed to open table
+ tmp->table_list= *table_list; // Needed to open table
+ tmp->table_list.db= tmp->thd.db;
+ tmp->table_list.name= tmp->table_list.real_name=tmp->thd.query;
tmp->lock();
pthread_mutex_lock(&tmp->mutex);
if ((error=pthread_create(&tmp->thd.real_id,&connection_attrib,
@@ -869,13 +873,11 @@ void kill_delayed_threads(void)
if (tmp->thd.mysys_var)
{
pthread_mutex_lock(&tmp->thd.mysys_var->mutex);
- if (tmp->thd.mysys_var->current_mutex)
+ if (tmp->thd.mysys_var->current_cond)
{
- if (&tmp->mutex != tmp->thd.mysys_var->current_mutex)
- pthread_mutex_lock(tmp->thd.mysys_var->current_mutex);
+ pthread_mutex_lock(tmp->thd.mysys_var->current_mutex);
pthread_cond_broadcast(tmp->thd.mysys_var->current_cond);
- if (&tmp->mutex != tmp->thd.mysys_var->current_mutex)
- pthread_mutex_unlock(tmp->thd.mysys_var->current_mutex);
+ pthread_mutex_unlock(tmp->thd.mysys_var->current_mutex);
}
pthread_mutex_unlock(&tmp->thd.mysys_var->mutex);
}
@@ -900,10 +902,11 @@ static pthread_handler_decl(handle_delayed_insert,arg)
thd->thread_id=thread_id++;
thd->end_time();
threads.append(thd);
+ thd->killed=abort_loop;
pthread_mutex_unlock(&LOCK_thread_count);
pthread_mutex_lock(&di->mutex);
-#ifndef __WIN__ /* Win32 calls this in pthread_create */
+#if !defined( __WIN__) && !defined(OS2) /* Win32 calls this in pthread_create */
if (my_thread_init())
{
strmov(thd->net.last_error,ER(thd->net.last_errno=ER_OUT_OF_RESOURCES));
@@ -922,7 +925,7 @@ static pthread_handler_decl(handle_delayed_insert,arg)
}
thd->mysys_var=my_thread_var;
thd->dbug_thread_id=my_thread_id();
-#ifndef __WIN__
+#if !defined(__WIN__) && !defined(OS2)
sigset_t set;
VOID(sigemptyset(&set)); // Get mask in use
VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals));
@@ -930,7 +933,7 @@ static pthread_handler_decl(handle_delayed_insert,arg)
/* open table */
- if (!(di->table=open_ltable(thd,di->table_list,TL_WRITE_DELAYED)))
+ if (!(di->table=open_ltable(thd,&di->table_list,TL_WRITE_DELAYED)))
{
thd->fatal_error=1; // Abort waiting inserts
goto end;
@@ -938,7 +941,7 @@ static pthread_handler_decl(handle_delayed_insert,arg)
if (di->table->file->has_transactions())
{
thd->fatal_error=1;
- my_error(ER_ILLEGAL_HA, MYF(0), di->table_list->real_name);
+ my_error(ER_ILLEGAL_HA, MYF(0), di->table_list.real_name);
goto end;
}
di->table->copy_blobs=1;
@@ -990,14 +993,12 @@ static pthread_handler_decl(handle_delayed_insert,arg)
#endif
/* Information for pthread_kill */
- pthread_mutex_lock(&di->thd.mysys_var->mutex);
di->thd.mysys_var->current_mutex= &di->mutex;
di->thd.mysys_var->current_cond= &di->cond;
- pthread_mutex_unlock(&di->thd.mysys_var->mutex);
di->thd.proc_info=0;
DBUG_PRINT("info",("Waiting for someone to insert rows"));
- for ( ; ;)
+ while (!thd->killed)
{
int error;
#if (defined(HAVE_BROKEN_COND_TIMEDWAIT) || defined(HAVE_LINUXTHREADS))
@@ -1021,10 +1022,13 @@ static pthread_handler_decl(handle_delayed_insert,arg)
break;
}
}
+ /* We can't lock di->mutex and mysys_var->mutex at the same time */
+ pthread_mutex_unlock(&di->mutex);
pthread_mutex_lock(&di->thd.mysys_var->mutex);
di->thd.mysys_var->current_mutex= 0;
di->thd.mysys_var->current_cond= 0;
pthread_mutex_unlock(&di->thd.mysys_var->mutex);
+ pthread_mutex_lock(&di->mutex);
}
if (di->tables_in_use && ! thd->lock)
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index d7f273bfaa4..c2793da78f3 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -86,6 +86,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
bool is_fifo=0;
LOAD_FILE_INFO lf_info;
char * db = table_list->db ? table_list->db : thd->db;
+ bool using_transactions;
DBUG_ENTER("mysql_load");
if (escaped->length() > 1 || enclosed->length() > 1)
@@ -170,7 +171,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
else
{
unpack_filename(name,ex->file_name);
-#ifndef __WIN__
+#if !defined(__WIN__) && !defined(OS2)
MY_STAT stat_info;
if (!my_stat(name,&stat_info,MYF(MY_WME)))
DBUG_RETURN(-1);
@@ -270,8 +271,11 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
free_blobs(table); /* if pack_blob was used */
table->copy_blobs=0;
thd->count_cuted_fields=0; /* Don`t calc cuted fields */
+ using_transactions = table->file->has_transactions();
if (error)
{
+ if (using_transactions)
+ ha_autocommit_or_rollback(thd,error);
if (!opt_old_rpl_compat && mysql_bin_log.is_open())
{
Delete_file_log_event d(thd);
@@ -286,7 +290,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
if(!thd->slave_thread)
mysql_update_log.write(thd,thd->query,thd->query_length);
- if (!table->file->has_transactions())
+ if (!using_transactions)
thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
if (mysql_bin_log.is_open())
{
@@ -303,7 +307,9 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
mysql_bin_log.write(&e);
}
}
- DBUG_RETURN(0);
+ if (using_transactions)
+ error=ha_autocommit_or_rollback(thd,error);
+ DBUG_RETURN(error);
}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index dac9af6d9fb..687d325a95a 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -67,9 +67,13 @@ extern struct st_VioSSLAcceptorFd * ssl_acceptor_fd;
#ifdef __WIN__
static void test_signal(int sig_ptr)
{
-#ifndef DBUG_OFF
+#if !defined( DBUG_OFF)
MessageBox(NULL,"Test signal","DBUG",MB_OK);
#endif
+#if defined(OS2)
+ fprintf( stderr, "Test signal %d\n", sig_ptr);
+ fflush( stderr);
+#endif
}
static void init_signals(void)
{
@@ -175,7 +179,6 @@ static bool check_user(THD *thd,enum_server_command command, const char *user,
*/
static HASH hash_user_connections;
-static DYNAMIC_ARRAY user_conn_array;
extern pthread_mutex_t LOCK_user_conn;
struct user_conn {
@@ -482,7 +485,7 @@ pthread_handler_decl(handle_one_connection,arg)
pthread_detach_this_thread();
-#ifndef __WIN__ /* Win32 calls this in pthread_create */
+#if !defined( __WIN__) && !defined(OS2) /* Win32 calls this in pthread_create */
if (my_thread_init()) // needed to be called first before we call
// DBUG_ macros
{
@@ -504,9 +507,9 @@ pthread_handler_decl(handle_one_connection,arg)
thd->thread_id));
// now that we've called my_thread_init(), it is safe to call DBUG_*
-#ifdef __WIN__
+#if defined(__WIN__)
init_signals(); // IRENA; testing ?
-#else
+#elif !defined(OS2)
sigset_t set;
VOID(sigemptyset(&set)); // Get mask in use
VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals));
@@ -607,7 +610,7 @@ pthread_handler_decl(handle_bootstrap,arg)
thd->thread_stack= (char*) &thd;
thd->mysys_var=my_thread_var;
thd->dbug_thread_id=my_thread_id();
-#ifndef __WIN__
+#if !defined(__WIN__) && !defined(OS2)
sigset_t set;
VOID(sigemptyset(&set)); // Get mask in use
VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals));
@@ -960,7 +963,9 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
#ifdef __WIN__
sleep(1); // must wait after eof()
#endif
+#ifndef OS2
send_eof(net); // This is for 'quit request'
+#endif
close_connection(net);
close_thread_tables(thd); // Free before kill
free_root(&thd->mem_root,MYF(0));
@@ -2294,10 +2299,18 @@ static bool check_merge_table_access(THD *thd, char *db,
int error=0;
if (table_list)
{
- /* Force all tables to use the current database */
+ /* Check that all tables use the current database */
TABLE_LIST *tmp;
for (tmp=table_list; tmp ; tmp=tmp->next)
- tmp->db=db;
+ {
+ if (!tmp->db || !tmp->db[0])
+ tmp->db=db;
+ else if (!strcmp(tmp->db,db))
+ {
+ send_error(&thd->net,ER_UNION_TABLES_IN_DIFFERENT_DIR);
+ return 1;
+ }
+ }
error=check_table_access(thd, SELECT_ACL | UPDATE_ACL | DELETE_ACL,
table_list);
}
@@ -2804,13 +2817,11 @@ TABLE_LIST *add_table_to_list(Table_ident *table, LEX_STRING *alias,
DBUG_RETURN(0);
}
-#ifdef FN_LOWER_CASE
if (!alias) /* Alias is case sensitive */
if (!(alias_str=thd->memdup(alias_str,table->table.length+1)))
DBUG_RETURN(0);
if (lower_case_table_names)
casedn_str(table->table.str);
-#endif
if (!(ptr = (TABLE_LIST *) thd->calloc(sizeof(TABLE_LIST))))
DBUG_RETURN(0); /* purecov: inspected */
ptr->db= table->db.str ? table->db.str : (thd->db ? thd->db : (char*) "");
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 7f49d6b2680..ff1cb125ef8 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -492,12 +492,10 @@ impossible position";
log.error=0;
// tell the kill thread how to wake us up
- pthread_mutex_lock(&thd->mysys_var->mutex);
thd->mysys_var->current_mutex = log_lock;
thd->mysys_var->current_cond = &COND_binlog_update;
const char* proc_info = thd->proc_info;
thd->proc_info = "Slave connection: waiting for binlog update";
- pthread_mutex_unlock(&thd->mysys_var->mutex);
bool read_packet = 0, fatal_error = 0;
@@ -522,7 +520,8 @@ impossible position";
break;
case LOG_READ_EOF:
DBUG_PRINT("wait",("waiting for data on binary log"));
- pthread_cond_wait(&COND_binlog_update, log_lock);
+ if (!thd->killed)
+ pthread_cond_wait(&COND_binlog_update, log_lock);
break;
default:
@@ -700,6 +699,9 @@ int stop_slave(THD* thd, bool net_report )
#ifdef HAVE_TIMESPEC_TS_SEC
abstime.ts_sec=time(NULL)+2;
abstime.ts_nsec=0;
+#elif defined(__WIN__)
+ abstime.tv_sec=time((time_t*) 0)+2;
+ abstime.tv_nsec=0;
#else
struct timeval tv;
gettimeofday(&tv,0);
@@ -765,17 +767,19 @@ void kill_zombie_dump_threads(uint32 slave_server_id)
if (tmp->command == COM_BINLOG_DUMP &&
tmp->server_id == slave_server_id)
{
- // here we do not call kill_one_thread()
- // it will be slow because it will iterate through the list
- // again. Plus it double-locks LOCK_thread_count, which
- // make safe_mutex complain and abort
- // so we just to our own thread murder
+ /*
+ Here we do not call kill_one_thread() as
+ it will be slow because it will iterate through the list
+ again. Plus it double-locks LOCK_tread_count, which
+ make safe_mutex complain and abort.
+ We just to do kill the thread ourselves.
+ */
thr_alarm_kill(tmp->real_id);
tmp->killed = 1;
- pthread_mutex_lock(&tmp->mysys_var->mutex);
tmp->mysys_var->abort = 1;
- if (tmp->mysys_var->current_mutex)
+ pthread_mutex_lock(&tmp->mysys_var->mutex);
+ if (tmp->mysys_var->current_cond)
{
pthread_mutex_lock(tmp->mysys_var->current_mutex);
pthread_cond_broadcast(tmp->mysys_var->current_cond);
@@ -784,7 +788,7 @@ void kill_zombie_dump_threads(uint32 slave_server_id)
pthread_mutex_unlock(&tmp->mysys_var->mutex);
}
}
- pthread_mutex_unlock(&LOCK_thread_count);
+ pthread_mutex_unlock(&LOCK_thread_count);
}
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 12cd7a94e7f..07de0dc5b33 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -4223,6 +4223,8 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records)
if (not_used_in_distinct && found_records != join->found_records)
return 0;
}
+ else
+ info->file->unlock_row();
}
} while (!(error=info->read_record(info)));
if (error > 0) // Fatal error
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index ef5fc50b4f7..7806bef7163 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -182,6 +182,8 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
TABLE_LIST table_list;
DBUG_ENTER("mysql_find_files");
+ if (wild && !wild[0])
+ wild=0;
bzero((char*) &table_list,sizeof(table_list));
if (!(dirp = my_dir(path,MYF(MY_WME | (dir ? MY_WANT_STAT : 0)))))
@@ -200,7 +202,7 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
#endif
{
if (file->name[0] == '.' || !MY_S_ISDIR(file->mystat.st_mode) ||
- (wild && wild[0] && wild_compare(file->name,wild)))
+ (wild && wild_compare(file->name,wild)))
continue;
}
}
@@ -211,8 +213,16 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
is_prefix(file->name,tmp_file_prefix))
continue;
*ext=0;
- if (wild && wild[0] && wild_compare(file->name,wild))
- continue;
+ if (wild)
+ {
+ if (lower_case_table_names)
+ {
+ if (wild_case_compare(file->name,wild))
+ continue;
+ }
+ else if (wild_compare(file->name,wild))
+ continue;
+ }
}
/* Don't show tables where we don't have any privileges */
if (db && !(col_access & TABLE_ACLS))
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index 174d07d8ec4..e6cdd089bf1 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -542,8 +542,8 @@ String *copy_if_not_alloced(String *to,String *from,uint32 from_length)
#endif
int wild_case_compare(const char *str,const char *str_end,
- const char *wildstr,const char *wildend,
- char escape)
+ const char *wildstr,const char *wildend,
+ char escape)
{
int result= -1; // Not found, using wildcards
#ifdef USE_MB
@@ -677,7 +677,7 @@ int wild_case_compare(String &match,String &wild, char escape)
*/
int wild_compare(const char *str,const char *str_end,
- const char *wildstr,const char *wildend,char escape)
+ const char *wildstr,const char *wildend,char escape)
{
int result= -1; // Not found, using wildcards
while (wildstr != wildend)
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index f248c675e8e..d667aeb6011 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -48,11 +48,9 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists)
/* mark for close and remove all cached entries */
- pthread_mutex_lock(&thd->mysys_var->mutex);
thd->mysys_var->current_mutex= &LOCK_open;
thd->mysys_var->current_cond= &COND_refresh;
VOID(pthread_mutex_lock(&LOCK_open));
- pthread_mutex_unlock(&thd->mysys_var->mutex);
if (global_read_lock)
{
@@ -1064,19 +1062,31 @@ int mysql_optimize_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt)
int mysql_analyze_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt)
{
+#ifdef OS2
+ thr_lock_type lock_type = TL_WRITE;
+#else
+ thr_lock_type lock_type = TL_READ_NO_INSERT;
+#endif
+
DBUG_ENTER("mysql_analyze_table");
DBUG_RETURN(mysql_admin_table(thd, tables, check_opt,
- "analyze",TL_READ_NO_INSERT, 1,0,0,
+ "analyze", lock_type, 1,0,0,
&handler::analyze));
}
int mysql_check_table(THD* thd, TABLE_LIST* tables,HA_CHECK_OPT* check_opt)
{
+#ifdef OS2
+ thr_lock_type lock_type = TL_WRITE;
+#else
+ thr_lock_type lock_type = TL_READ_NO_INSERT;
+#endif
+
DBUG_ENTER("mysql_check_table");
DBUG_RETURN(mysql_admin_table(thd, tables, check_opt,
- "check",
- TL_READ_NO_INSERT, 0, 0, HA_OPEN_FOR_REPAIR,
+ "check", lock_type,
+ 0, 0, HA_OPEN_FOR_REPAIR,
&handler::check));
}
@@ -1119,16 +1129,12 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
{
strmov(new_name_buff,new_name);
fn_same(new_name_buff,table_name,3);
-#ifdef FN_LOWER_CASE
if (lower_case_table_names)
casedn_str(new_name);
if ((lower_case_table_names &&
!my_strcasecmp(new_name_buff,table_name)) ||
(!lower_case_table_names &&
!strcmp(new_name_buff,table_name)))
-#else
- if (!strcmp(new_name_buff,table_name)) // Check if name changed
-#endif
new_name=table_name; // No. Make later check easier
else
{
@@ -1600,7 +1606,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
}
}
-#if defined( __WIN__) || defined( __EMX__)
+#if defined( __WIN__) || defined( __EMX__) || defined( OS2)
// Win32 can't rename an open table, so we must close the org table!
table_name=thd->strdup(table_name); // must be saved
if (close_cached_table(thd,table))
@@ -1762,7 +1768,7 @@ copy_data_between_tables(TABLE *from,TABLE *to,
/* Turn off recovery logging since rollback of an
alter table is to delete the new table so there
is no need to log the changes to it. */
- error = ha_recovery_logging(thd,false);
+ error = ha_recovery_logging(thd,FALSE);
if (error)
{
error = 1;
@@ -1814,7 +1820,7 @@ copy_data_between_tables(TABLE *from,TABLE *to,
if (to->file->activate_all_index(thd))
error=1;
- tmp_error = ha_recovery_logging(thd,true);
+ tmp_error = ha_recovery_logging(thd,TRUE);
/*
Ensure that the new table is saved properly to disk so that we
can do a rename
@@ -1826,7 +1832,7 @@ copy_data_between_tables(TABLE *from,TABLE *to,
if (to->file->external_lock(thd,F_UNLCK))
error=1;
err:
- tmp_error = ha_recovery_logging(thd,true);
+ tmp_error = ha_recovery_logging(thd,TRUE);
free_io_cache(from);
*copied= found_count;
*deleted=delete_count;
diff --git a/sql/sql_test.cc b/sql/sql_test.cc
index d20bc74ecb2..651fd52d6c3 100644
--- a/sql/sql_test.cc
+++ b/sql/sql_test.cc
@@ -188,7 +188,10 @@ TEST_join(JOIN *join)
void mysql_print_status(THD *thd)
{
+ char current_dir[FN_REFLEN];
printf("\nStatus information:\n\n");
+ my_getwd(current_dir, sizeof(current_dir),MYF(0));
+ printf("Current dir: %s\n", current_dir);
if (thd)
thd->proc_info="locks";
thr_print_locks(); // Write some debug info
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index 2ba937be50a..8184ae3b15e 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -53,7 +53,7 @@ extern "C"
FreeLibrary((HMODULE)lib);
}
-#else
+#elif !defined(OS2)
#include <dlfcn.h>
#endif
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 113995b169c..fbf8239bf69 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -291,6 +291,8 @@ int mysql_update(THD *thd,
}
}
}
+ else
+ table->file->unlock_row();
}
end_read_record(&info);
thd->proc_info="end";
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 23bfd5422f9..2318a6d309e 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -129,6 +129,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token KILL_SYM
%token LOAD
%token LOCK_SYM
+%token LOCKS_SYM
%token UNLOCK_SYM
%token BINLOG_SYM
%token EVENTS_SYM
@@ -2855,6 +2856,7 @@ keyword:
| LAST_SYM {}
| LEVEL_SYM {}
| LOCAL_SYM {}
+ | LOCKS_SYM {}
| LOGS_SYM {}
| MAX_ROWS {}
| MASTER_SYM {}
diff --git a/sql/stacktrace.c b/sql/stacktrace.c
index ab1113f74cf..81d8debc27a 100644
--- a/sql/stacktrace.c
+++ b/sql/stacktrace.c
@@ -17,6 +17,7 @@
#include <global.h>
#include "stacktrace.h"
#include <signal.h>
+#include <my_pthread.h>
#ifdef HAVE_STACKTRACE
#include <unistd.h>
@@ -205,11 +206,17 @@ resolve it\n");
/* Produce a core for the thread */
-#ifdef HAVE_WRITE_CORE
+#ifdef HAVE_LINUXTHREADS
void write_core(int sig)
{
signal(sig, SIG_DFL);
if (fork() != 0) exit(1); // Abort main program
// Core will be written at exit
}
-#endif /* HAVE_WRITE_CORE */
+#else
+void write_core(int sig)
+{
+ signal(sig, SIG_DFL);
+ pthread_kill(pthread_self(), sig);
+}
+#endif
diff --git a/sql/stacktrace.h b/sql/stacktrace.h
index b6c0ec43a0f..980e1ea07eb 100644
--- a/sql/stacktrace.h
+++ b/sql/stacktrace.h
@@ -30,9 +30,6 @@ extern char* heap_start;
void print_stacktrace(gptr stack_bottom, ulong thread_stack);
void safe_print_str(const char* name, const char* val, int max_len);
#endif /* (defined (__i386__) || (defined(__alpha__) && defined(__GNUC__))) */
-
-#define HAVE_WRITE_CORE
-void write_core(int sig);
#endif /* HAVE_LINUXTHREADS */
/* Define empty prototypes for functions that are not implemented */
@@ -42,9 +39,7 @@ void write_core(int sig);
#define safe_print_str(A,B,C) {}
#endif /* HAVE_STACKTRACE */
-#ifndef HAVE_WRITE_CORE
-#define write_core(A) {}
-#endif
+void write_core(int sig);
#ifdef __cplusplus
}
diff --git a/strings/conf_to_src.c b/strings/conf_to_src.c
index 76316638153..89415d31820 100644
--- a/strings/conf_to_src.c
+++ b/strings/conf_to_src.c
@@ -80,7 +80,7 @@ print_array(FILE *f, const char *set, const char *name, int n)
endptr = p;
for (;;)
{
- while (isspace(*endptr))
+ while (isspace((* (unsigned char*) endptr)))
++endptr;
if (*endptr && *endptr != '#') /* not comment */
break;
@@ -90,7 +90,7 @@ print_array(FILE *f, const char *set, const char *name, int n)
}
p = val;
- while (!isspace(*endptr))
+ while (!isspace((* (unsigned char*) endptr)))
*p++ = *endptr++;
*p = '\0';
p = endptr;
diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c
index 1fb98273fec..cccf6730046 100644
--- a/strings/ctype-big5.c
+++ b/strings/ctype-big5.c
@@ -236,7 +236,7 @@ int my_strnncoll_big5(const uchar * s1, int len1, const uchar * s2, int len2)
return (int) (len1-len2);
}
-int my_strnxfrm_big5(uchar * dest, uchar * src, int len, int srclen)
+int my_strnxfrm_big5(uchar * dest, const uchar * src, int len, int srclen)
{
uint16 e;
/*uchar *d = dest; XXX: unused*/
@@ -276,7 +276,7 @@ int my_strcoll_big5(const uchar * s1, const uchar * s2)
return 0;
}
-int my_strxfrm_big5(uchar * dest, uchar * src, int len)
+int my_strxfrm_big5(uchar * dest, const uchar * src, int len)
{
uint16 e;
uchar *d = dest;
diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c
index 9628f21b8d4..a5d55789bb8 100644
--- a/strings/ctype-gbk.c
+++ b/strings/ctype-gbk.c
@@ -2610,7 +2610,7 @@ int my_strcoll_gbk(const uchar * s1, const uchar * s2)
s2, (uint) strlen((char*) s2));
}
-int my_strnxfrm_gbk(uchar * dest, uchar * src, int len, int srclen)
+int my_strnxfrm_gbk(uchar * dest, const uchar * src, int len, int srclen)
{
uint16 e;
@@ -2630,7 +2630,7 @@ int my_strnxfrm_gbk(uchar * dest, uchar * src, int len, int srclen)
return srclen;
}
-int my_strxfrm_gbk(uchar * dest, uchar * src, int len)
+int my_strxfrm_gbk(uchar * dest, const uchar * src, int len)
{
return my_strnxfrm_gbk(dest,src,len,(uint) strlen((char*) src));
}
diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c
index 9a5a91f9265..566271be845 100644
--- a/strings/ctype-sjis.c
+++ b/strings/ctype-sjis.c
@@ -228,10 +228,10 @@ int my_strcoll_sjis(const uchar *s1, const uchar *s2)
s2,(uint) strlen((char*) s2));
}
-int my_strnxfrm_sjis(uchar *dest, uchar *src, int len, int srclen)
+int my_strnxfrm_sjis(uchar *dest, const uchar *src, int len, int srclen)
{
uchar *d_end = dest + len;
- uchar *s_end = src + srclen;
+ uchar *s_end = (uchar*) src + srclen;
while (dest < d_end && src < s_end) {
if (ismbchar_sjis((char*) src, (char*) s_end)) {
*dest++ = *src++;
@@ -244,7 +244,7 @@ int my_strnxfrm_sjis(uchar *dest, uchar *src, int len, int srclen)
return srclen;
}
-int my_strxfrm_sjis(uchar *dest, uchar *src, int len)
+int my_strxfrm_sjis(uchar *dest, const uchar *src, int len)
{
return my_strnxfrm_sjis(dest, src, len, (uint) strlen((char*) src));
}
diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c
index 321487c85cb..1c0acc38e24 100644
--- a/strings/ctype-tis620.c
+++ b/strings/ctype-tis620.c
@@ -535,7 +535,7 @@ int my_strnncoll_tis620(const uchar * s1, int len1, const uchar * s2, int len2)
Arg: Destination buffer, source string, dest length and source length
Ret: Conveted string size
*/
-int my_strnxfrm_tis620(uchar * dest, uchar * src, int len, int srclen)
+int my_strnxfrm_tis620(uchar * dest, const uchar * src, int len, int srclen)
{
uint bufSize;
uchar *tmp;
@@ -567,7 +567,7 @@ int my_strcoll_tis620(const uchar * s1, const uchar * s2)
Arg: Destination buffer, String and dest buffer size
Ret: Converting string size
*/
-int my_strxfrm_tis620(uchar * dest, uchar * src, int len)
+int my_strxfrm_tis620(uchar * dest, const uchar * src, int len)
{
uint bufSize;
uchar *tmp;
diff --git a/strings/ctype.c b/strings/ctype.c
index 1178d15b515..a0e183a89d6 100644
--- a/strings/ctype.c
+++ b/strings/ctype.c
@@ -48,7 +48,7 @@ CHARSET_INFO *find_compiled_charset_by_name(const char *name)
return NULL;
}
-uint8 compiled_charset_number(const char *name)
+uint compiled_charset_number(const char *name)
{
CHARSET_INFO *cs;
for (cs = compiled_charsets; cs->number > 0; cs++)
@@ -58,7 +58,7 @@ uint8 compiled_charset_number(const char *name)
return 0; /* this mimics find_type() */
}
-const char *compiled_charset_name(uint8 charset_number)
+const char *compiled_charset_name(uint charset_number)
{
CHARSET_INFO *cs;
for (cs = compiled_charsets; cs->number > 0; cs++)
diff --git a/strings/strnlen.c b/strings/strnlen.c
index 6eb872ee08d..3d625f7d48a 100644
--- a/strings/strnlen.c
+++ b/strings/strnlen.c
@@ -29,7 +29,7 @@
uint strnlen(register const char *s, register uint maxlen)
{
- const char *end= memchr(s, '\0', maxlen);
+ const char *end= (const char *)memchr(s, '\0', maxlen);
return end ? (uint) (end - s) : maxlen;
}
diff --git a/strings/strto.c b/strings/strto.c
index eb8caab2ab6..64b1c9a5ae9 100644
--- a/strings/strto.c
+++ b/strings/strto.c
@@ -42,13 +42,17 @@
#include "my_sys.h" /* defines errno */
#include <errno.h>
-#ifdef LONGLONG
+#undef strtoull
+#undef strtoll
+#undef strtoul
+#undef strtol
+#ifdef USE_LONGLONG
#define UTYPE_MAX (~(ulonglong) 0)
#define TYPE_MIN LONGLONG_MIN
#define TYPE_MAX LONGLONG_MAX
#define longtype longlong
#define ulongtype ulonglong
-#ifdef UNSIGNED
+#ifdef USE_UNSIGNED
#define function ulongtype strtoull
#else
#define function longtype strtoll
@@ -59,7 +63,7 @@
#define TYPE_MAX LONG_MAX
#define longtype long
#define ulongtype unsigned long
-#ifdef UNSIGNED
+#ifdef USE_UNSIGNED
#define function ulongtype strtoul
#else
#define function longtype strtol
@@ -170,7 +174,7 @@ function (const char *nptr,char **endptr,int base)
if (endptr != NULL)
*endptr = (char *) s;
-#ifndef UNSIGNED
+#ifndef USE_UNSIGNED
/* Check for a value that is within the range of
`unsigned long int', but outside the range of `long int'. */
if (negative)
@@ -185,7 +189,7 @@ function (const char *nptr,char **endptr,int base)
if (overflow)
{
my_errno=ERANGE;
-#ifdef UNSIGNED
+#ifdef USE_UNSIGNED
return UTYPE_MAX;
#else
return negative ? TYPE_MIN : TYPE_MAX;
diff --git a/strings/strtoll.c b/strings/strtoll.c
index f43dae726f5..678c28649ef 100644
--- a/strings/strtoll.c
+++ b/strings/strtoll.c
@@ -19,7 +19,7 @@
#include <global.h>
#include <m_string.h>
-#if !defined(HAVE_STRTOULL) && defined(HAVE_LONG_LONG)
-#define LONGLONG
+#if !defined(HAVE_STRTOLL) && defined(HAVE_LONG_LONG)
+#define USE_LONGLONG
#include "strto.c"
#endif
diff --git a/strings/strtoul.c b/strings/strtoul.c
index bbfaa6ad22a..e49a9ebea6a 100644
--- a/strings/strtoul.c
+++ b/strings/strtoul.c
@@ -19,6 +19,6 @@
#include <global.h>
#if !defined(MSDOS) && !defined(HAVE_STRTOUL)
-#define UNSIGNED
+#define USE_UNSIGNED
#include "strto.c"
#endif
diff --git a/strings/strtoull.c b/strings/strtoull.c
index 42ce5ea4177..74dab95b801 100644
--- a/strings/strtoull.c
+++ b/strings/strtoull.c
@@ -20,7 +20,7 @@
#include <global.h>
#include <m_string.h>
#if !defined(HAVE_STRTOULL) && defined(HAVE_LONG_LONG)
-#define UNSIGNED
-#define LONGLONG
+#define USE_UNSIGNED
+#define USE_LONGLONG
#include "strto.c"
#endif