Cleanup @example blocks in manual for XML/DocBook/PS/PDF output.

parent 3059b545
...@@ -612,8 +612,8 @@ parts of queries. For example: ...@@ -612,8 +612,8 @@ parts of queries. For example:
@example @example
mysql> SELECT CONCAT(first_name, " ", last_name) mysql> SELECT CONCAT(first_name, " ", last_name)
FROM tbl_name -> FROM tbl_name
WHERE income/dependents > 10000 AND age > 30; -> WHERE income/dependents > 10000 AND age > 30;
@end example @end example
@item @item
...@@ -904,8 +904,8 @@ mysql> DROP TABLE IF EXISTS y2k; ...@@ -904,8 +904,8 @@ mysql> DROP TABLE IF EXISTS y2k;
Query OK, 0 rows affected (0.01 sec) Query OK, 0 rows affected (0.01 sec)
mysql> CREATE TABLE y2k (date date, mysql> CREATE TABLE y2k (date date,
date_time datetime, -> date_time datetime,
time_stamp timestamp); -> time_stamp timestamp);
Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec)
mysql> INSERT INTO y2k VALUES mysql> INSERT INTO y2k VALUES
...@@ -6473,7 +6473,9 @@ with @code{-fno-exceptions}. When in doubt, do the following: ...@@ -6473,7 +6473,9 @@ with @code{-fno-exceptions}. When in doubt, do the following:
@example @example
CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --enable-assembler --with-mysqld-ldflags=-all-static CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors -fno-exceptions \
-fno-rtti" ./configure --prefix=/usr/local/mysql --enable-assembler \
--with-mysqld-ldflags=-all-static
@end example @end example
...@@ -6847,9 +6849,12 @@ CC=gcc CXX=gcc CXXFLAGS="-O3 -felide-constructors" ...@@ -6847,9 +6849,12 @@ CC=gcc CXX=gcc CXXFLAGS="-O3 -felide-constructors"
@item egcs 1.0.3a @tab @item egcs 1.0.3a @tab
CC=gcc CXX=gcc CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti" CC=gcc CXX=gcc CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti"
@item gcc 2.95.2 @tab @item gcc 2.95.2 @tab
CFLAGS="-O3 -mpentiumpro" CXX=gcc CXXFLAGS="-O3 -mpentiumpro -felide-constructors -fno-exceptions -fno-rtti" CFLAGS="-O3 -mpentiumpro" CXX=gcc CXXFLAGS="-O3 -mpentiumpro \
-felide-constructors -fno-exceptions -fno-rtti"
@item pgcc 2.90.29 or newer @tab @item pgcc 2.90.29 or newer @tab
CFLAGS="-O3 -mpentiumpro -mstack-align-double" CXX=gcc CXXFLAGS="-O3 -mpentiumpro -mstack-align-double -felide-constructors -fno-exceptions -fno-rtti" CFLAGS="-O3 -mpentiumpro -mstack-align-double" CXX=gcc \
CXXFLAGS="-O3 -mpentiumpro -mstack-align-double -felide-constructors \
-fno-exceptions -fno-rtti"
@end multitable @end multitable
In most cases you can get a reasonably optimal MySQL binary by In most cases you can get a reasonably optimal MySQL binary by
...@@ -6857,14 +6862,18 @@ using the options from the above and adding the following options to the ...@@ -6857,14 +6862,18 @@ using the options from the above and adding the following options to the
configure line: configure line:
@example @example
--prefix=/usr/local/mysql --enable-assembler --with-mysqld-ldflags=-all-static --prefix=/usr/local/mysql --enable-assembler \
--with-mysqld-ldflags=-all-static
@end example @end example
The full configure line would in other words be something like the The full configure line would in other words be something like the
following for all recent gcc versions: following for all recent gcc versions:
@example @example
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 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 @end example
The binaries we provide on the MySQL web site at The binaries we provide on the MySQL web site at
...@@ -7628,7 +7637,10 @@ TCP port 3306 ...@@ -7628,7 +7637,10 @@ TCP port 3306
UNIX socket /tmp/mysql.sock UNIX socket /tmp/mysql.sock
Uptime: 16 sec 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 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 @end example
To get a feeling for what else you can do with @code{BINDIR/mysqladmin}, To get a feeling for what else you can do with @code{BINDIR/mysqladmin},
...@@ -8776,7 +8788,8 @@ that you also probably need to raise the @code{core file size} by adding ...@@ -8776,7 +8788,8 @@ that you also probably need to raise the @code{core file size} by adding
If you are linking your own MySQL client and get the error: If you are linking your own MySQL client and get the error:
@example @example
ld.so.1: ./my: fatal: libmysqlclient.so.4: open failed: No such file or directory ld.so.1: ./my: fatal: libmysqlclient.so.4:
open failed: No such file or directory
@end example @end example
When executing them, the problem can be avoided by one of the following When executing them, the problem can be avoided by one of the following
...@@ -8804,7 +8817,13 @@ some problems compiling MySQL because the Linux header files are very ...@@ -8804,7 +8817,13 @@ some problems compiling MySQL because the Linux header files are very
The following @code{configure} line should work with @code{fcc/FCC}: The following @code{configure} line should work with @code{fcc/FCC}:
@example @example
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 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 @end example
...@@ -8925,9 +8944,11 @@ You may get some warnings when compiling; those shown below can be ignored: ...@@ -8925,9 +8944,11 @@ You may get some warnings when compiling; those shown below can be ignored:
@example @example
mysqld.cc -o objs-thread/mysqld.o mysqld.cc -o objs-thread/mysqld.o
mysqld.cc: In function `void init_signals()': mysqld.cc: In function `void init_signals()':
mysqld.cc:315: warning: assignment of negative value `-1' to `long unsigned int' mysqld.cc:315: warning: assignment of negative value `-1' to
`long unsigned int'
mysqld.cc: In function `void * signal_hand(void *)': mysqld.cc: In function `void * signal_hand(void *)':
mysqld.cc:346: warning: assignment of negative value `-1' to `long unsigned int' mysqld.cc:346: warning: assignment of negative value `-1' to
`long unsigned int'
@end example @end example
In Debian GNU/Linux, if you want MySQL to start automatically when In Debian GNU/Linux, if you want MySQL to start automatically when
...@@ -9005,13 +9026,19 @@ means you can only use our binary if you have an Alpha EV6 processor. We also ...@@ -9005,13 +9026,19 @@ means you can only use our binary if you have an Alpha EV6 processor. We also
compile statically to avoid library problems. compile statically to avoid library problems.
@example @example
CC=ccc CFLAGS="-fast" CXX=cxx CXXFLAGS="-fast -noexceptions -nortti" ./configure --prefix=/usr/local/mysql --disable-shared --with-extra-charsets=complex --enable-thread-safe-client --with-mysqld-ldflags=-non_shared --with-client-ldflags=-non_shared CC=ccc CFLAGS="-fast" CXX=cxx CXXFLAGS="-fast -noexceptions -nortti" \
./configure --prefix=/usr/local/mysql --disable-shared \
--with-extra-charsets=complex --enable-thread-safe-client \
--with-mysqld-ldflags=-non_shared --with-client-ldflags=-non_shared
@end example @end example
If you want to use egcs the following configure line worked for us: If you want to use egcs the following configure line worked for us:
@example @example
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 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 @end example
Some known problems when running MySQL on Linux-Alpha: Some known problems when running MySQL on Linux-Alpha:
...@@ -9051,7 +9078,10 @@ To get MySQL to compile on Linux Ia64, we use the following compile line: ...@@ -9051,7 +9078,10 @@ To get MySQL to compile on Linux Ia64, we use the following compile line:
Using @code{gcc-2.96}: Using @code{gcc-2.96}:
@example @example
CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-O3 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql "--with-comment=Official MySQL binary" --with-extra-charsets=complex CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer" CXX=gcc \
CXXFLAGS="-O3 -fno-omit-frame-pointer -felide-constructors \
-fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql \
"--with-comment=Official MySQL binary" --with-extra-charsets=complex
@end example @end example
On Ia64 the MySQL client binaries are using shared libraries. This means On Ia64 the MySQL client binaries are using shared libraries. This means
...@@ -9637,7 +9667,8 @@ distribution unpacked! Solaris @code{tar} can't handle long file names, so ...@@ -9637,7 +9667,8 @@ distribution unpacked! Solaris @code{tar} can't handle long file names, so
you may see an error like this when you unpack MySQL: you may see an error like this when you unpack MySQL:
@example @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 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 tar: directory checksum error
@end example @end example
...@@ -9778,7 +9809,8 @@ If you are linking your own MySQL client, you might get the ...@@ -9778,7 +9809,8 @@ If you are linking your own MySQL client, you might get the
following error when you try to execute it: following error when you try to execute it:
@example @example
ld.so.1: ./my: fatal: libmysqlclient.so.#: open failed: No such file or directory ld.so.1: ./my: fatal: libmysqlclient.so.#:
open failed: No such file or directory
@end example @end example
The problem can be avoided by one of the following methods: The problem can be avoided by one of the following methods:
...@@ -9918,7 +9950,8 @@ following @code{configure} command: ...@@ -9918,7 +9950,8 @@ following @code{configure} command:
@example @example
CC=gcc CFLAGS="-O3 -fomit-frame-pointer -DHAVE_CURSES_H" \ CC=gcc CFLAGS="-O3 -fomit-frame-pointer -DHAVE_CURSES_H" \
CXX=gcc \ CXX=gcc \
CXXFLAGS="-O3 -fomit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti -DHAVE_CURSES_H" \ CXXFLAGS="-O3 -fomit-frame-pointer -felide-constructors -fno-exceptions \
-fno-rtti -DHAVE_CURSES_H" \
./configure --prefix=/usr/local/mysql ./configure --prefix=/usr/local/mysql
@end example @end example
...@@ -9997,7 +10030,8 @@ gcc (2.95.2 and up) is: ...@@ -9997,7 +10030,8 @@ gcc (2.95.2 and up) is:
@example @example
CC=gcc CFLAGS="-O2 -fno-strength-reduce" \ CC=gcc CFLAGS="-O2 -fno-strength-reduce" \
CXX=gcc CXXFLAGS="-O2 -fno-rtti -fno-exceptions -felide-constructors -fno-strength-reduce" \ CXX=gcc CXXFLAGS="-O2 -fno-rtti -fno-exceptions -felide-constructors \
-fno-strength-reduce" \
./configure --prefix=/usr/local/mysql --enable-assembler ./configure --prefix=/usr/local/mysql --enable-assembler
gmake gmake
gmake install gmake install
...@@ -10193,7 +10227,10 @@ Our binary for Mac OS X is compiled on Rhapsody 5.5 with the following ...@@ -10193,7 +10227,10 @@ Our binary for Mac OS X is compiled on Rhapsody 5.5 with the following
configure line: configure line:
@example @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 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 @end example
You might want to also add aliases to your shell's resource file to You might want to also add aliases to your shell's resource file to
...@@ -10314,7 +10351,10 @@ because it can't compile @code{.S} (assembler) files. ...@@ -10314,7 +10351,10 @@ because it can't compile @code{.S} (assembler) files.
The following configure line should work: The following configure line should work:
@example @example
CFLAGS="-DHPUX -I/opt/dce/include -fpic" 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 CFLAGS="-DHPUX -I/opt/dce/include -fpic" \
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 @end example
If you are compiling @code{gcc} 2.95 yourself, you should NOT link it with If you are compiling @code{gcc} 2.95 yourself, you should NOT link it with
...@@ -10376,7 +10416,9 @@ the definition in @file{pthread.h}. Here's the diff: ...@@ -10376,7 +10416,9 @@ the definition in @file{pthread.h}. Here's the diff:
After this, the following configure line should work: After this, the following configure line should work:
@example @example
CFLAGS="-fomit-frame-pointer -O3 -fpic" CXX=gcc CXXFLAGS="-felide-constructors -fno-exceptions -fno-rtti -O3" ./configure --prefix=/usr/local/mysql --disable-shared 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 @end example
Here is some information that a HP-UX Version 11.x user sent us about compiling Here is some information that a HP-UX Version 11.x user sent us about compiling
...@@ -10430,7 +10472,8 @@ If you get the following error from @code{configure} ...@@ -10430,7 +10472,8 @@ If you get the following error from @code{configure}
@example @example
checking for cc option to accept ANSI C... no 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. configure: error: MySQL requires a ANSI C compiler (and a C++ compiler).
Try gcc. See the Installation chapter in the Reference Manual.
@end example @end example
Check that you don't have the path to the K&R compiler before the path Check that you don't have the path to the K&R compiler before the path
...@@ -10515,7 +10558,8 @@ configuring with: ...@@ -10515,7 +10558,8 @@ configuring with:
@example @example
shell> CFLAGS=-DDONT_USE_THR_ALARM CXX=gcc \ shell> CFLAGS=-DDONT_USE_THR_ALARM CXX=gcc \
CXXFLAGS="-felide-constructors -fno-exceptions -fno-rtti -DDONT_USE_THR_ALARM" \ CXXFLAGS="-felide-constructors -fno-exceptions -fno-rtti \
-DDONT_USE_THR_ALARM" \
./configure --prefix=/usr/local/mysql --with-debug --with-low-memory ./configure --prefix=/usr/local/mysql --with-debug --with-low-memory
@end example @end example
...@@ -10622,7 +10666,8 @@ work: ...@@ -10622,7 +10666,8 @@ work:
CC="cc -pthread" CC="cc -pthread"
CFLAGS="-O4 -ansi_alias -ansi_args -fast -inline speed all -arch host" CFLAGS="-O4 -ansi_alias -ansi_args -fast -inline speed all -arch host"
CXX="cxx -pthread" CXX="cxx -pthread"
CXXFLAGS="-O4 -ansi_alias -ansi_args -fast -inline speed all -arch host -noexceptions -nortti" CXXFLAGS="-O4 -ansi_alias -ansi_args -fast -inline speed all -arch host \
-noexceptions -nortti"
export CC CFLAGS CXX CXXFLAGS export CC CFLAGS CXX CXXFLAGS
./configure \ ./configure \
--prefix=/usr/local/mysql \ --prefix=/usr/local/mysql \
...@@ -10692,11 +10737,14 @@ With the Digital compiler "C++ V6.1-029", the following should work: ...@@ -10692,11 +10737,14 @@ With the Digital compiler "C++ V6.1-029", the following should work:
@example @example
CC=cc -pthread CC=cc -pthread
CFLAGS=-O4 -ansi_alias -ansi_args -fast -inline speed -speculate all -arch host CFLAGS=-O4 -ansi_alias -ansi_args -fast -inline speed -speculate all \
-arch host
CXX=cxx -pthread CXX=cxx -pthread
CXXFLAGS=-O4 -ansi_alias -ansi_args -fast -inline speed -speculate all -arch host -noexceptions -nortti CXXFLAGS=-O4 -ansi_alias -ansi_args -fast -inline speed -speculate all \
-arch host -noexceptions -nortti
export CC CFLAGS CXX CXXFLAGS export CC CFLAGS CXX CXXFLAGS
./configure --prefix=/usr/mysql/mysql --with-mysqld-ldflags=-all-static --disable-shared --with-named-thread-libs="-lmach -lexc -lc" ./configure --prefix=/usr/mysql/mysql --with-mysqld-ldflags=-all-static \
--disable-shared --with-named-thread-libs="-lmach -lexc -lc"
@end example @end example
In some versions of OSF1, the @code{alloca()} function is broken. Fix In some versions of OSF1, the @code{alloca()} function is broken. Fix
...@@ -10788,7 +10836,8 @@ Type the following in the top-level directory of your MySQL source ...@@ -10788,7 +10836,8 @@ Type the following in the top-level directory of your MySQL source
tree: tree:
@example @example
shell> extra/replace bool curses_bool < /usr/include/curses.h > include/curses.h shell> extra/replace bool curses_bool < /usr/include/curses.h \
> include/curses.h
shell> make shell> make
@end example @end example
...@@ -10803,7 +10852,8 @@ If you are compiling with @code{gcc}, you can use the following ...@@ -10803,7 +10852,8 @@ If you are compiling with @code{gcc}, you can use the following
@example @example
CC=gcc CXX=gcc CXXFLAGS=-O3 \ CC=gcc CXX=gcc CXXFLAGS=-O3 \
./configure --prefix=/usr/local/mysql --enable-thread-safe-client --with-named-thread-libs=-lpthread ./configure --prefix=/usr/local/mysql --enable-thread-safe-client \
--with-named-thread-libs=-lpthread
@end example @end example
On Irix 6.5.11 with native Irix C and C++ compilers ver. 7.3.1.2, the On Irix 6.5.11 with native Irix C and C++ compilers ver. 7.3.1.2, the
...@@ -10812,9 +10862,10 @@ following is reported to work ...@@ -10812,9 +10862,10 @@ following is reported to work
@example @example
CC=cc CXX=CC CFLAGS='-O3 -n32 -TARG:platform=IP22 -I/usr/local/include \ CC=cc CXX=CC CFLAGS='-O3 -n32 -TARG:platform=IP22 -I/usr/local/include \
-L/usr/local/lib' CXXFLAGS='-O3 -n32 -TARG:platform=IP22 \ -L/usr/local/lib' CXXFLAGS='-O3 -n32 -TARG:platform=IP22 \
-I/usr/local/include -L/usr/local/lib' ./configure --prefix=/usr/local/mysql \ -I/usr/local/include -L/usr/local/lib' ./configure \
--with-innodb --with-berkeley-db \ --prefix=/usr/local/mysql --with-innodb --with-berkeley-db \
--with-libwrap=/usr/local --with-named-curses-libs=/usr/local/lib/libncurses.a --with-libwrap=/usr/local \
--with-named-curses-libs=/usr/local/lib/libncurses.a
@end example @end example
...@@ -10841,7 +10892,8 @@ GNU @code{as}. You can also use @code{egcs} 1.1.2 or newer ...@@ -10841,7 +10892,8 @@ GNU @code{as}. You can also use @code{egcs} 1.1.2 or newer
to execute the following command: to execute the following command:
@example @example
shell> cp -p /usr/include/pthread/stdtypes.h /usr/local/lib/gcc-lib/i386-pc-sco3.2v5.0.5/egcs-2.91.66/include/pthread/ shell> cp -p /usr/include/pthread/stdtypes.h \
/usr/local/lib/gcc-lib/i386-pc-sco3.2v5.0.5/egcs-2.91.66/include/pthread/
@end example @end example
@item @item
...@@ -11206,7 +11258,8 @@ ppm> install DBI ...@@ -11206,7 +11258,8 @@ ppm> install DBI
If this succeeds, run the following command: If this succeeds, run the following command:
@example @example
install ftp://ftp.de.uu.net/pub/CPAN/authors/id/JWIED/DBD-mysql-1.2212.x86.ppd install \
ftp://ftp.de.uu.net/pub/CPAN/authors/id/JWIED/DBD-mysql-1.2212.x86.ppd
@end example @end example
@end itemize @end itemize
...@@ -11304,7 +11357,10 @@ If you get the following error from @code{Msql-Mysql-modules} ...@@ -11304,7 +11357,10 @@ If you get the following error from @code{Msql-Mysql-modules}
when you run the tests: when you run the tests:
@example @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. 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 @end example
it means that you need to include the compression library, -lz, to the it means that you need to include the compression library, -lz, to the
...@@ -11334,9 +11390,12 @@ On SCO, you must have the following environment variables set: ...@@ -11334,9 +11390,12 @@ On SCO, you must have the following environment variables set:
@example @example
shell> LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib:/usr/progressive/lib shell> LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib:/usr/progressive/lib
or or
shell> LD_LIBRARY_PATH=/usr/lib:/lib:/usr/local/lib:/usr/ccs/lib:/usr/progressive/lib:/usr/skunk/lib shell> LD_LIBRARY_PATH=/usr/lib:/lib:/usr/local/lib:/usr/ccs/lib:\
shell> LIBPATH=/usr/lib:/lib:/usr/local/lib:/usr/ccs/lib:/usr/progressive/lib:/usr/skunk/lib /usr/progressive/lib:/usr/skunk/lib
shell> MANPATH=scohelp:/usr/man:/usr/local1/man:/usr/local/man:/usr/skunk/man: 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 @end example
First, create a Perl that includes a statically linked @code{DBI} by running First, create a Perl that includes a statically linked @code{DBI} by running
...@@ -13010,7 +13069,9 @@ calculate the age of the mother, you need her birth date. Because that is ...@@ -13010,7 +13069,9 @@ 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: stored in the @code{pet} table, you need both tables for the query:
@example @example
mysql> SELECT pet.name, (TO_DAYS(date) - TO_DAYS(birth))/365 AS age, remark mysql> SELECT pet.name,
-> (TO_DAYS(date) - TO_DAYS(birth))/365 AS age,
-> remark
-> FROM pet, event -> FROM pet, event
-> WHERE pet.name = event.name AND type = "litter"; -> WHERE pet.name = event.name AND type = "litter";
+--------+------+-----------------------------+ +--------+------+-----------------------------+
...@@ -13510,10 +13571,12 @@ The following shows an idea of how you can use the bit group functions ...@@ -13510,10 +13571,12 @@ 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. to calculate the number of days per month a user has visited a web page.
@example @example
CREATE TABLE t1 (year YEAR(4), month INT(2) UNSIGNED ZEROFILL, day INT(2) UNSIGNED ZEROFILL); CREATE TABLE t1 (year YEAR(4), month 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); day INT(2) UNSIGNED ZEROFILL);
INSERT INTO t1 VALUES(2000,1,1),(2000,1,20),(2000,1,30),(2000,2,2),
SELECT year,month,BIT_COUNT(BIT_OR(1<<day)) AS days FROM t1 GROUP BY year,month; (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: Which returns:
...@@ -13537,10 +13600,10 @@ The @code{AUTO_INCREMENT} attribute can be used to generate an unique ...@@ -13537,10 +13600,10 @@ The @code{AUTO_INCREMENT} attribute can be used to generate an unique
identity for new rows: identity for new rows:
@example @example
CREATE TABLE animals (id mediumint not null auto_increment, CREATE TABLE animals (id MEDIUMINT NOT NULL AUTO_INCREMENT,
name char(30) not null, name CHAR(30) NOT NULL, PRIMARY KEY (id));
primary key (id)); INSERT INTO animals (name) VALUES ("dog"),("cat"),("penguin"),
INSERT INTO animals (name) values ("dog"),("cat"),("penguin"),("lax"),("whale"); ("lax"),("whale");
SELECT * FROM animals; SELECT * FROM animals;
Which returns: Which returns:
...@@ -13563,12 +13626,12 @@ value for the autoincrement column is calculated as ...@@ -13563,12 +13626,12 @@ value for the autoincrement column is calculated as
useful when you want to put data into ordered groups. useful when you want to put data into ordered groups.
@example @example
CREATE TABLE animals (grp enum ('fish','mammal','bird') not null, CREATE TABLE animals (grp ENUM('fish','mammal','bird') NOT NULL,
id mediumint not null auto_increment, id MEDIUMINT NOT NULL AUTO_INCREMENT
name char(30) not null, PRIMARY KEY (grp,id));
primary key (grp,id)); INSERT INTO animals (grp,name) VALUES("mammal","dog"),("mammal","cat"),
INSERT INTO animals (grp,name) values ("mammal","dog"),("mammal","cat"),("bird","penguin"),("fish","lax"),("mammal","whale"); ("bird","penguin"),("fish","lax"),("mammal","whale");
SELECT * FROM animals order by grp,id; SELECT * FROM animals ORDER BY grp,id;
Which returns: Which returns:
...@@ -13761,15 +13824,23 @@ select ...@@ -13761,15 +13824,23 @@ select
from from
twin_project as tp twin_project as tp
/* For Twin 1 */ /* For Twin 1 */
left join twin_data as td on tp.id = td.id and tp.tvab = td.tvab left join twin_data as td on tp.id = td.id
left join informant_data as id on tp.id = id.id and tp.tvab = id.tvab and tp.tvab = td.tvab
left join harmony as h on tp.id = h.id and tp.tvab = h.tvab left join informant_data as id on tp.id = id.id
left join lentus as l on tp.id = l.id and tp.tvab = l.tvab 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 */ /* For Twin 2 */
left join twin_data as td2 on p2.id = td2.id and p2.tvab = td2.tvab left join twin_data as td2 on p2.id = td2.id
left join informant_data as id2 on p2.id = id2.id and p2.tvab = id2.tvab and p2.tvab = td2.tvab
left join harmony as h2 on p2.id = h2.id and p2.tvab = h2.tvab left join informant_data as id2 on p2.id = id2.id
left join lentus as l2 on p2.id = l2.id and p2.tvab = l2.tvab, 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 p1,
person_data as p2, person_data as p2,
postal_groups as pg postal_groups as pg
...@@ -13791,14 +13862,17 @@ where ...@@ -13791,14 +13862,17 @@ where
/* Twin is suspect */ /* Twin is suspect */
(td.future_contact = 'Yes' and td.suspect = 2) or (td.future_contact = 'Yes' and td.suspect = 2) or
/* Twin is suspect - Informant is Blessed */ /* Twin is suspect - Informant is Blessed */
(td.future_contact = 'Yes' and td.suspect = 1 and id.suspect = 1) or (td.future_contact = 'Yes' and td.suspect = 1
and id.suspect = 1) or
/* No twin - Informant is Blessed */ /* No twin - Informant is Blessed */
(ISNULL(td.suspect) and id.suspect = 1 and id.future_contact = 'Yes') or (ISNULL(td.suspect) and id.suspect = 1
and id.future_contact = 'Yes') or
/* Twin broken off - Informant is Blessed */ /* Twin broken off - Informant is Blessed */
(td.participation = 'Aborted' (td.participation = 'Aborted'
and id.suspect = 1 and id.future_contact = 'Yes') or and id.suspect = 1 and id.future_contact = 'Yes') or
/* Twin broken off - No inform - Have partner */ /* Twin broken off - No inform - Have partner */
(td.participation = 'Aborted' and ISNULL(id.suspect) and p2.dead = 0)) (td.participation = 'Aborted' and ISNULL(id.suspect)
and p2.dead = 0))
and and
l.event = 'Finished' l.event = 'Finished'
/* Get at area code */ /* Get at area code */
...@@ -14584,7 +14658,8 @@ If your are using the Perl @code{DBD::mysql} module you can read the options ...@@ -14584,7 +14658,8 @@ If your are using the Perl @code{DBD::mysql} module you can read the options
from the MySQL option files. @xref{Option files}. from the MySQL option files. @xref{Option files}.
@example @example
$dsn = "DBI:mysql:test;mysql_read_default_group=client;mysql_read_default_file=/usr/local/mysql/data/my.cnf" $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); $dbh = DBI->connect($dsn, $user, $password);
@end example @end example
...@@ -14862,7 +14937,8 @@ this: ...@@ -14862,7 +14937,8 @@ this:
@example @example
shell> mysql -u root mysql shell> mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('new_password') WHERE user='root'; mysql> UPDATE user SET Password=PASSWORD('new_password')
-> WHERE user='root';
mysql> FLUSH PRIVILEGES; mysql> FLUSH PRIVILEGES;
@end example @end example
...@@ -16667,7 +16743,7 @@ privilege tables: ...@@ -16667,7 +16743,7 @@ privilege tables:
@example @example
shell> mysql -u root mysql shell> mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('new_password') mysql> UPDATE user SET Password=PASSWORD('new_password')
WHERE user='root'; -> WHERE user='root';
mysql> FLUSH PRIVILEGES; mysql> FLUSH PRIVILEGES;
@end example @end example
...@@ -16748,9 +16824,9 @@ You can add new users by issuing @code{GRANT} statements: ...@@ -16748,9 +16824,9 @@ You can add new users by issuing @code{GRANT} statements:
@example @example
shell> mysql --user=root mysql shell> mysql --user=root mysql
mysql> GRANT ALL PRIVILEGES ON *.* TO monty@@localhost mysql> GRANT ALL PRIVILEGES ON *.* TO monty@@localhost
IDENTIFIED BY 'some_pass' WITH GRANT OPTION; -> IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
mysql> GRANT ALL PRIVILEGES ON *.* TO monty@@"%" mysql> GRANT ALL PRIVILEGES ON *.* TO monty@@"%"
IDENTIFIED BY 'some_pass' WITH GRANT OPTION; -> IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
mysql> GRANT RELOAD,PROCESS ON *.* TO admin@@localhost; mysql> GRANT RELOAD,PROCESS ON *.* TO admin@@localhost;
mysql> GRANT USAGE ON *.* TO dummy@@localhost; mysql> GRANT USAGE ON *.* TO dummy@@localhost;
@end example @end example
...@@ -16792,13 +16868,13 @@ tables: ...@@ -16792,13 +16868,13 @@ tables:
@example @example
shell> mysql --user=root mysql shell> mysql --user=root mysql
mysql> INSERT INTO user VALUES('localhost','monty',PASSWORD('some_pass'), mysql> INSERT INTO user VALUES('localhost','monty',PASSWORD('some_pass'),
'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'); -> 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
mysql> INSERT INTO user VALUES('%','monty',PASSWORD('some_pass'), mysql> INSERT INTO user VALUES('%','monty',PASSWORD('some_pass'),
'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'); -> 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
mysql> INSERT INTO user SET Host='localhost',User='admin', mysql> INSERT INTO user SET Host='localhost',User='admin',
Reload_priv='Y', Process_priv='Y'; -> Reload_priv='Y', Process_priv='Y';
mysql> INSERT INTO user (Host,User,Password) mysql> INSERT INTO user (Host,User,Password)
VALUES('localhost','dummy',''); -> VALUES('localhost','dummy','');
mysql> FLUSH PRIVILEGES; mysql> FLUSH PRIVILEGES;
@end example @end example
...@@ -16829,17 +16905,17 @@ commands: ...@@ -16829,17 +16905,17 @@ commands:
@example @example
shell> mysql --user=root mysql shell> mysql --user=root mysql
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
ON bankaccount.* -> ON bankaccount.*
TO custom@@localhost -> TO custom@@localhost
IDENTIFIED BY 'stupid'; -> IDENTIFIED BY 'stupid';
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
ON expenses.* -> ON expenses.*
TO custom@@whitehouse.gov -> TO custom@@whitehouse.gov
IDENTIFIED BY 'stupid'; -> IDENTIFIED BY 'stupid';
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
ON customer.* -> ON customer.*
TO custom@@'%' -> TO custom@@'%'
IDENTIFIED BY 'stupid'; -> IDENTIFIED BY 'stupid';
@end example @end example
The reason that we do to grant statements for the user 'custom' is that The reason that we do to grant statements for the user 'custom' is that
...@@ -16853,25 +16929,25 @@ run these commands (note the @code{FLUSH PRIVILEGES} at the end): ...@@ -16853,25 +16929,25 @@ run these commands (note the @code{FLUSH PRIVILEGES} at the end):
@example @example
shell> mysql --user=root mysql shell> mysql --user=root mysql
mysql> INSERT INTO user (Host,User,Password) mysql> INSERT INTO user (Host,User,Password)
VALUES('localhost','custom',PASSWORD('stupid')); -> VALUES('localhost','custom',PASSWORD('stupid'));
mysql> INSERT INTO user (Host,User,Password) mysql> INSERT INTO user (Host,User,Password)
VALUES('server.domain','custom',PASSWORD('stupid')); -> VALUES('server.domain','custom',PASSWORD('stupid'));
mysql> INSERT INTO user (Host,User,Password) mysql> INSERT INTO user (Host,User,Password)
VALUES('whitehouse.gov','custom',PASSWORD('stupid')); -> VALUES('whitehouse.gov','custom',PASSWORD('stupid'));
mysql> INSERT INTO db mysql> INSERT INTO db
(Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv, -> (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,
Create_priv,Drop_priv) -> Create_priv,Drop_priv)
VALUES -> VALUES
('localhost','bankaccount','custom','Y','Y','Y','Y','Y','Y'); -> ('localhost','bankaccount','custom','Y','Y','Y','Y','Y','Y');
mysql> INSERT INTO db mysql> INSERT INTO db
(Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv, -> (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,
Create_priv,Drop_priv) -> Create_priv,Drop_priv)
VALUES -> VALUES
('whitehouse.gov','expenses','custom','Y','Y','Y','Y','Y','Y'); -> ('whitehouse.gov','expenses','custom','Y','Y','Y','Y','Y','Y');
mysql> INSERT INTO db mysql> INSERT INTO db
(Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv, -> (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,
Create_priv,Drop_priv) -> Create_priv,Drop_priv)
VALUES('%','customer','custom','Y','Y','Y','Y','Y','Y'); -> VALUES('%','customer','custom','Y','Y','Y','Y','Y','Y');
mysql> FLUSH PRIVILEGES; mysql> FLUSH PRIVILEGES;
@end example @end example
...@@ -16890,16 +16966,16 @@ domain, you can issue a @code{GRANT} statement like the following: ...@@ -16890,16 +16966,16 @@ domain, you can issue a @code{GRANT} statement like the following:
@example @example
mysql> GRANT ... mysql> GRANT ...
ON *.* -> ON *.*
TO myusername@@"%.mydomainname.com" -> TO myusername@@"%.mydomainname.com"
IDENTIFIED BY 'mypassword'; -> IDENTIFIED BY 'mypassword';
@end example @end example
To do the same thing by modifying the grant tables directly, do this: To do the same thing by modifying the grant tables directly, do this:
@example @example
mysql> INSERT INTO user VALUES ('%.mydomainname.com', 'myusername', mysql> INSERT INTO user VALUES ('%.mydomainname.com', 'myusername',
PASSWORD('mypassword'),...); -> PASSWORD('mypassword'),...);
mysql> FLUSH PRIVILEGES; mysql> FLUSH PRIVILEGES;
@end example @end example
...@@ -16931,7 +17007,7 @@ passwords like this: ...@@ -16931,7 +17007,7 @@ passwords like this:
@example @example
shell> mysql -u root mysql shell> mysql -u root mysql
mysql> INSERT INTO user (Host,User,Password) mysql> INSERT INTO user (Host,User,Password)
VALUES('%','jeffrey','biscuit'); -> VALUES('%','jeffrey','biscuit');
mysql> FLUSH PRIVILEGES; mysql> FLUSH PRIVILEGES;
@end example @end example
...@@ -16958,7 +17034,7 @@ instead: ...@@ -16958,7 +17034,7 @@ instead:
@example @example
mysql> INSERT INTO user (Host,User,Password) mysql> INSERT INTO user (Host,User,Password)
VALUES('%','jeffrey',PASSWORD('biscuit')); -> VALUES('%','jeffrey',PASSWORD('biscuit'));
@end example @end example
You must also use the @code{PASSWORD()} function when you use @code{SET You must also use the @code{PASSWORD()} function when you use @code{SET
...@@ -17684,8 +17760,11 @@ If you want to check all tables and repair all tables that are corrupted, ...@@ -17684,8 +17760,11 @@ If you want to check all tables and repair all tables that are corrupted,
you can use the following line: you can use the following line:
@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 myisamchk --silent --force --fast --update-state -O key_buffer=64M \
isamchk --silent --force -O key_buffer=64M -O sort_buffer=64M -O read_buffer=1M -O write_buffer=1M /path/to/datadir/*/*.ISM -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 @end example
The above assumes that you have more than 64 M free. The above assumes that you have more than 64 M free.
...@@ -18456,8 +18535,10 @@ Key: 8: Keyblocks used: 99% Packed: 0% Max levels: 3 ...@@ -18456,8 +18535,10 @@ Key: 8: Keyblocks used: 99% Packed: 0% Max levels: 3
Key: 9: Keyblocks used: 98% Packed: 0% Max levels: 4 Key: 9: Keyblocks used: 98% Packed: 0% Max levels: 4
Total: Keyblocks used: 98% Packed: 17% Total: Keyblocks used: 98% Packed: 17%
Records: 1403698 M.recordlength: 226 Packed: 0% Records: 1403698 M.recordlength: 226
Recordspace used: 100% Empty space: 0% Blocks/Record: 1.00 Packed: 0%
Recordspace used: 100% Empty space: 0%
Blocks/Record: 1.00
Record blocks: 1403698 Delete blocks: 0 Record blocks: 1403698 Delete blocks: 0
Recorddata: 317235748 Deleted data: 0 Recorddata: 317235748 Deleted data: 0
Lost space: 0 Linkdata: 0 Lost space: 0 Linkdata: 0
...@@ -21764,21 +21845,27 @@ MySQL commands: ...@@ -21764,21 +21845,27 @@ MySQL commands:
help (\h) Display this text. help (\h) Display this text.
? (\h) Synonym for `help'. ? (\h) Synonym for `help'.
clear (\c) Clear command. clear (\c) Clear command.
connect (\r) Reconnect to the server. Optional arguments are db and host. connect (\r) Reconnect to the server.
Optional arguments are db and host.
edit (\e) Edit command with $EDITOR. edit (\e) Edit command with $EDITOR.
ego (\G) Send command to mysql server, display result vertically. ego (\G) Send command to mysql server,
display result vertically.
exit (\q) Exit mysql. Same as quit. exit (\q) Exit mysql. Same as quit.
go (\g) Send command to mysql server. go (\g) Send command to mysql server.
nopager (\n) Disable pager, print to stdout. nopager (\n) Disable pager, print to stdout.
notee (\t) Don't write into outfile. notee (\t) Don't write into outfile.
pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. pager (\P) Set PAGER [to_pager].
Print the query results via PAGER.
print (\p) Print current command. print (\p) Print current command.
quit (\q) Quit mysql. quit (\q) Quit mysql.
rehash (\#) Rebuild completion hash. rehash (\#) Rebuild completion hash.
source (\.) Execute a SQL script file. Takes a file name as an argument. source (\.) Execute a SQL script file.
Takes a file name as an argument.
status (\s) Get status information from the server. status (\s) Get status information from the server.
tee (\T) Set outfile [to_outfile]. Append everything into given outfile. tee (\T) Set outfile [to_outfile].
use (\u) Use another database. Takes database name as argument. Append everything into given outfile.
use (\u) Use another database.
Takes database name as argument.
@end example @end example
From the above, pager only works in Unix. From the above, pager only works in Unix.
...@@ -21909,7 +21996,8 @@ following would send the results to two files in two different ...@@ -21909,7 +21996,8 @@ following would send the results to two files in two different
directories, on two different hard-disks mounted on /dr1 and /dr2, yet directories, on two different hard-disks mounted on /dr1 and /dr2, yet
let the results still be seen on the screen via less: let the results still be seen on the screen via less:
@example @example
mysql> pager cat | tee /dr1/tmp/res.txt | tee /dr2/tmp/res2.txt | less -n -i -S mysql> pager cat | tee /dr1/tmp/res.txt | \
tee /dr2/tmp/res2.txt | less -n -i -S
@end example @end example
@item @item
...@@ -22013,7 +22101,9 @@ shell> mysqladmin proc stat ...@@ -22013,7 +22101,9 @@ shell> mysqladmin proc stat
+----+-------+-----------+----+-------------+------+-------+------+ +----+-------+-----------+----+-------------+------+-------+------+
| 6 | monty | localhost | | Processlist | 0 | | | | 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 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 @end example
@cindex status command, results @cindex status command, results
...@@ -22363,7 +22453,7 @@ mysqldump --opt database | mysql ---host=remote-host -C database ...@@ -22363,7 +22453,7 @@ mysqldump --opt database | mysql ---host=remote-host -C database
It is possible to dump several databases with one command: It is possible to dump several databases with one command:
@example @example
mysqldump --databases database1 [database2 database3...] > my_databases.sql mysqldump --databases database1 [database2 ...] > my_databases.sql
@end example @end example
If all the databases are wanted, one can use: If all the databases are wanted, one can use:
...@@ -24046,13 +24136,13 @@ able to take advantage of one-master/many slaves solution. The ...@@ -24046,13 +24136,13 @@ able to take advantage of one-master/many slaves solution. The
code will be a lot easier to maintain, and adding troubleshooting code will be a lot easier to maintain, and adding troubleshooting
options will be trivial. You will just need to modify one or two 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 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, query, among your many thousands, gave you an error. If you have
you may want to automate the conversion task by using Monty's written a lot of code already, you may want to automate the conversion
@code{replace} utility, which comes with the standard distribution of task by using Monty's @code{replace} utility, which comes with the
MySQL, or just write your own Perl script. Hopefully, your standard distribution of MySQL, or just write your own Perl script.
code follows some recognisable pattern. If not, then you are probably Hopefully, your code follows some recognisable pattern. If not, then
better off re-writing it anyway, or at least going through and manually you are probably better off re-writing it anyway, or at least going
beating it into a pattern. through and manually beating it into a pattern.
Note that, of course, you can use different names for the Note that, of course, you can use different names for the
functions. What is important is having unified interface for connecting functions. What is important is having unified interface for connecting
...@@ -25034,17 +25124,19 @@ do.CUSTNMBR} comparisons: ...@@ -25034,17 +25124,19 @@ do.CUSTNMBR} comparisons:
@example @example
mysql> ALTER TABLE tt MODIFY AssignedPC VARCHAR(15), mysql> ALTER TABLE tt MODIFY AssignedPC VARCHAR(15),
MODIFY ClientID VARCHAR(15); -> MODIFY ClientID VARCHAR(15);
@end example @end example
Now @code{EXPLAIN} produces the output shown below: Now @code{EXPLAIN} produces the output shown below:
@example @example
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
et ALL PRIMARY NULL NULL NULL 74 et ALL PRIMARY NULL NULL NULL 74
tt ref AssignedPC,ClientID,ActualPC ActualPC 15 et.EMPLOYID 52 where used tt ref AssignedPC, ActualPC 15 et.EMPLOYID 52 where used
et_1 eq_ref PRIMARY PRIMARY 15 tt.AssignedPC 1 ClientID,
do eq_ref PRIMARY PRIMARY 15 tt.ClientID 1 ActualPC
et_1 eq_ref PRIMARY PRIMARY 15 tt.AssignedPC 1
do eq_ref PRIMARY PRIMARY 15 tt.ClientID 1
@end example @end example
This is almost as good as it can get. This is almost as good as it can get.
...@@ -25062,11 +25154,13 @@ shell> mysqladmin refresh ...@@ -25062,11 +25154,13 @@ shell> mysqladmin refresh
Now the join is perfect, and @code{EXPLAIN} produces this result: Now the join is perfect, and @code{EXPLAIN} produces this result:
@example @example
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
tt ALL AssignedPC,ClientID,ActualPC NULL NULL NULL 3872 where used tt ALL AssignedPC NULL NULL NULL 3872 where used
et eq_ref PRIMARY PRIMARY 15 tt.ActualPC 1 ClientID,
et_1 eq_ref PRIMARY PRIMARY 15 tt.AssignedPC 1 ActualPC
do eq_ref PRIMARY PRIMARY 15 tt.ClientID 1 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 @end example
Note that the @code{rows} column in the output from @code{EXPLAIN} is an Note that the @code{rows} column in the output from @code{EXPLAIN} is an
...@@ -25219,7 +25313,7 @@ All the following tables are used as constant tables: ...@@ -25219,7 +25313,7 @@ All the following tables are used as constant tables:
@example @example
mysql> SELECT * FROM t WHERE primary_key=1; mysql> SELECT * FROM t WHERE primary_key=1;
mysql> SELECT * FROM t1,t2 mysql> SELECT * FROM t1,t2
WHERE t1.primary_key=1 AND t2.primary_key=t1.id; -> WHERE t1.primary_key=1 AND t2.primary_key=t1.id;
@end example @end example
@item @item
...@@ -25253,11 +25347,11 @@ Some examples of queries that are very fast: ...@@ -25253,11 +25347,11 @@ Some examples of queries that are very fast:
mysql> SELECT COUNT(*) FROM tbl_name; mysql> SELECT COUNT(*) FROM tbl_name;
mysql> SELECT MIN(key_part1),MAX(key_part1) FROM tbl_name; mysql> SELECT MIN(key_part1),MAX(key_part1) FROM tbl_name;
mysql> SELECT MAX(key_part2) FROM tbl_name mysql> SELECT MAX(key_part2) FROM tbl_name
WHERE key_part_1=constant; -> WHERE key_part_1=constant;
mysql> SELECT ... FROM tbl_name mysql> SELECT ... FROM tbl_name
ORDER BY key_part1,key_part2,... LIMIT 10; -> ORDER BY key_part1,key_part2,... LIMIT 10;
mysql> SELECT ... FROM tbl_name mysql> SELECT ... FROM tbl_name
ORDER BY key_part1 DESC,key_part2 DESC,... LIMIT 10; -> ORDER BY key_part1 DESC,key_part2 DESC,... LIMIT 10;
@end example @end example
The following queries are resolved using only the index tree (assuming The following queries are resolved using only the index tree (assuming
...@@ -25266,7 +25360,7 @@ the indexed columns are numeric): ...@@ -25266,7 +25360,7 @@ the indexed columns are numeric):
@example @example
mysql> SELECT key_part1,key_part2 FROM tbl_name WHERE key_part1=val; mysql> SELECT key_part1,key_part2 FROM tbl_name WHERE key_part1=val;
mysql> SELECT COUNT(*) FROM tbl_name mysql> SELECT COUNT(*) FROM tbl_name
WHERE key_part1=val1 AND key_part2=val2; -> WHERE key_part1=val1 AND key_part2=val2;
mysql> SELECT key_part2 FROM tbl_name GROUP BY key_part1; mysql> SELECT key_part2 FROM tbl_name GROUP BY key_part1;
@end example @end example
...@@ -25274,8 +25368,10 @@ The following queries use indexing to retrieve the rows in sorted ...@@ -25274,8 +25368,10 @@ The following queries use indexing to retrieve the rows in sorted
order without a separate sorting pass: order without a separate sorting pass:
@example @example
mysql> SELECT ... FROM tbl_name ORDER BY key_part1,key_part2,... ; mysql> SELECT ... FROM tbl_name
mysql> SELECT ... FROM tbl_name ORDER BY key_part1 DESC,key_part2 DESC,... ; -> ORDER BY key_part1,key_part2,... ;
mysql> SELECT ... FROM tbl_name
-> ORDER BY key_part1 DESC,key_part2 DESC,... ;
@end example @end example
...@@ -25358,7 +25454,8 @@ table permutations to check. ...@@ -25358,7 +25454,8 @@ table permutations to check.
Note that the above means that if you do a query of type: Note that the above means that if you do a query of type:
@example @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 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 @end example
MySQL will do a full scan on @code{b} as the @code{LEFT JOIN} will force MySQL will do a full scan on @code{b} as the @code{LEFT JOIN} will force
...@@ -25367,7 +25464,8 @@ it to be read before @code{d}. ...@@ -25367,7 +25464,8 @@ it to be read before @code{d}.
The fix in this case is to change the query to: The fix in this case is to change the query to:
@example @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 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 @end example
...@@ -26346,8 +26444,9 @@ The following @code{WHERE} clauses use indexes: ...@@ -26346,8 +26444,9 @@ The following @code{WHERE} clauses use indexes:
These @code{WHERE} clauses do @strong{NOT} use indexes: These @code{WHERE} clauses do @strong{NOT} use indexes:
@example @example
... WHERE index_part2=1 AND index_part3=2 /* index_part_1 is not used */ ... 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=1 OR A=10 /* Index is not used in
... WHERE index_part1=1 OR index_part2=10 /* No index spans all rows */ both AND parts */
... WHERE index_part1=1 OR index_part2=10 /* No index spans all rows */
@end example @end example
Note that in some cases MySQL will not use an index, even if one Note that in some cases MySQL will not use an index, even if one
...@@ -26392,8 +26491,8 @@ The example below creates an index for the first 10 characters of the ...@@ -26392,8 +26491,8 @@ The example below creates an index for the first 10 characters of the
@example @example
mysql> CREATE TABLE test ( mysql> CREATE TABLE test (
name CHAR(200) NOT NULL, -> name CHAR(200) NOT NULL,
KEY index_name (name(10))); -> KEY index_name (name(10)));
@end example @end example
For @code{BLOB} and @code{TEXT} columns, you must index a prefix of the For @code{BLOB} and @code{TEXT} columns, you must index a prefix of the
...@@ -26428,11 +26527,11 @@ Suppose a table is created using the following specification: ...@@ -26428,11 +26527,11 @@ Suppose a table is created using the following specification:
@example @example
mysql> CREATE TABLE test ( mysql> CREATE TABLE test (
id INT NOT NULL, -> id INT NOT NULL,
last_name CHAR(30) NOT NULL, -> last_name CHAR(30) NOT NULL,
first_name CHAR(30) NOT NULL, -> first_name CHAR(30) NOT NULL,
PRIMARY KEY (id), -> PRIMARY KEY (id),
INDEX name (last_name,first_name)); -> INDEX name (last_name,first_name));
@end example @end example
Then the index @code{name} is an index over @code{last_name} and Then the index @code{name} is an index over @code{last_name} and
...@@ -26445,13 +26544,13 @@ Therefore, the @code{name} index will be used in the following queries: ...@@ -26445,13 +26544,13 @@ Therefore, the @code{name} index will be used in the following queries:
mysql> SELECT * FROM test WHERE last_name="Widenius"; mysql> SELECT * FROM test WHERE last_name="Widenius";
mysql> SELECT * FROM test WHERE last_name="Widenius" mysql> SELECT * FROM test WHERE last_name="Widenius"
AND first_name="Michael"; -> AND first_name="Michael";
mysql> SELECT * FROM test WHERE last_name="Widenius" mysql> SELECT * FROM test WHERE last_name="Widenius"
AND (first_name="Michael" OR first_name="Monty"); -> AND (first_name="Michael" OR first_name="Monty");
mysql> SELECT * FROM test WHERE last_name="Widenius" mysql> SELECT * FROM test WHERE last_name="Widenius"
AND first_name >="M" AND first_name < "N"; -> AND first_name >="M" AND first_name < "N";
@end example @end example
However, the @code{name} index will NOT be used in the following queries: However, the @code{name} index will NOT be used in the following queries:
...@@ -26460,7 +26559,7 @@ However, the @code{name} index will NOT be used in the following queries: ...@@ -26460,7 +26559,7 @@ However, the @code{name} index will NOT be used in the following queries:
mysql> SELECT * FROM test WHERE first_name="Michael"; mysql> SELECT * FROM test WHERE first_name="Michael";
mysql> SELECT * FROM test WHERE last_name="Widenius" mysql> SELECT * FROM test WHERE last_name="Widenius"
OR first_name="Michael"; -> OR first_name="Michael";
@end example @end example
For more information on the manner in which MySQL uses indexes to For more information on the manner in which MySQL uses indexes to
...@@ -27099,7 +27198,8 @@ mysql> SET PASSWORD FOR bob@@"%.loc.gov" = PASSWORD("newpass"); ...@@ -27099,7 +27198,8 @@ mysql> SET PASSWORD FOR bob@@"%.loc.gov" = PASSWORD("newpass");
or or
mysql> UPDATE mysql.user SET password=PASSWORD("newpass") where user="bob' and host="%.loc.gov"; mysql> UPDATE mysql.user SET password=PASSWORD("newpass")
-> WHERE user="bob' AND host="%.loc.gov";
@end example @end example
@item SQL_AUTO_IS_NULL = 0 | 1 @item SQL_AUTO_IS_NULL = 0 | 1
...@@ -27714,11 +27814,11 @@ string where each pair of hex digits is converted to a character: ...@@ -27714,11 +27814,11 @@ string where each pair of hex digits is converted to a character:
@example @example
mysql> SELECT x'FF' mysql> SELECT x'FF'
-> 255 -> 255
mysql> SELECT 0xa+0; mysql> SELECT 0xa+0;
-> 10 -> 10
mysql> select 0x5061756c; mysql> select 0x5061756c;
-> Paul -> Paul
@end example @end example
The x'hexstring' syntax (new in 4.0) is based on ANSI SQL and the 0x The x'hexstring' syntax (new in 4.0) is based on ANSI SQL and the 0x
...@@ -27871,7 +27971,7 @@ because it refers to the alias both as @code{a} and as @code{A}: ...@@ -27871,7 +27971,7 @@ because it refers to the alias both as @code{a} and as @code{A}:
@example @example
mysql> SELECT col_name FROM tbl_name AS a mysql> SELECT col_name FROM tbl_name AS a
WHERE a.col_name = 1 OR A.col_name = 2; -> WHERE a.col_name = 1 OR A.col_name = 2;
@end example @end example
Aliases on columns are case insensitive. Aliases on columns are case insensitive.
...@@ -29274,8 +29374,8 @@ object. The standard way to do this is with the @code{SUBSTRING} ...@@ -29274,8 +29374,8 @@ object. The standard way to do this is with the @code{SUBSTRING}
function. For example: function. For example:
@example @example
mysql> select comment from tbl_name,substring(comment,20) as substr mysql> SELECT comment FROM tbl_name,substring(comment,20) AS substr
ORDER BY substr; -> ORDER BY substr;
@end example @end example
If you don't do this, only the first @code{max_sort_length} bytes of the If you don't do this, only the first @code{max_sort_length} bytes of the
...@@ -29285,10 +29385,8 @@ column are used when sorting. The default value of @code{max_sort_length} is ...@@ -29285,10 +29385,8 @@ column are used when sorting. The default value of @code{max_sort_length} is
@code{TEXT} values by specifying the column position or by using an alias: @code{TEXT} values by specifying the column position or by using an alias:
@example @example
mysql> select id,substring(blob_col,1,100) from tbl_name mysql> SELECT id,substring(blob_col,1,100) FROM tbl_name GROUP BY 2;
GROUP BY 2; mysql> SELECT id,substring(blob_col,1,100) AS b FROM tbl_name GROUP BY b;
mysql> select id,substring(blob_col,1,100) as b from tbl_name
GROUP BY b;
@end example @end example
@item @item
...@@ -29672,7 +29770,7 @@ For the sake of brevity, examples display the output from the @code{mysql} ...@@ -29672,7 +29770,7 @@ For the sake of brevity, examples display the output from the @code{mysql}
program in abbreviated form. So this: program in abbreviated form. So this:
@example @example
mysql> select MOD(29,9); mysql> SELECT MOD(29,9);
1 rows in set (0.00 sec) 1 rows in set (0.00 sec)
+-----------+ +-----------+
...@@ -29685,7 +29783,7 @@ mysql> select MOD(29,9); ...@@ -29685,7 +29783,7 @@ mysql> select MOD(29,9);
is displayed like this: is displayed like this:
@example @example
mysql> select MOD(29,9); mysql> SELECT MOD(29,9);
-> 2 -> 2
@end example @end example
...@@ -29728,9 +29826,9 @@ Use parenthesis to force the order of evaluation in an expression. For ...@@ -29728,9 +29826,9 @@ Use parenthesis to force the order of evaluation in an expression. For
example: example:
@example @example
mysql> select 1+2*3; mysql> SELECT 1+2*3;
-> 7 -> 7
mysql> select (1+2)*3; mysql> SELECT (1+2)*3;
-> 9 -> 9
@end example @end example
...@@ -31713,19 +31811,19 @@ mysql> SELECT INTERVAL 1 DAY + "1997-12-31"; ...@@ -31713,19 +31811,19 @@ mysql> SELECT INTERVAL 1 DAY + "1997-12-31";
mysql> SELECT "1998-01-01" - INTERVAL 1 SECOND; mysql> SELECT "1998-01-01" - INTERVAL 1 SECOND;
-> 1997-12-31 23:59:59 -> 1997-12-31 23:59:59
mysql> SELECT DATE_ADD("1997-12-31 23:59:59", mysql> SELECT DATE_ADD("1997-12-31 23:59:59",
INTERVAL 1 SECOND); -> INTERVAL 1 SECOND);
-> 1998-01-01 00:00:00 -> 1998-01-01 00:00:00
mysql> SELECT DATE_ADD("1997-12-31 23:59:59", mysql> SELECT DATE_ADD("1997-12-31 23:59:59",
INTERVAL 1 DAY); -> INTERVAL 1 DAY);
-> 1998-01-01 23:59:59 -> 1998-01-01 23:59:59
mysql> SELECT DATE_ADD("1997-12-31 23:59:59", mysql> SELECT DATE_ADD("1997-12-31 23:59:59",
INTERVAL "1:1" MINUTE_SECOND); -> INTERVAL "1:1" MINUTE_SECOND);
-> 1998-01-01 00:01:00 -> 1998-01-01 00:01:00
mysql> SELECT DATE_SUB("1998-01-01 00:00:00", mysql> SELECT DATE_SUB("1998-01-01 00:00:00",
INTERVAL "1 1:1:1" DAY_SECOND); -> INTERVAL "1 1:1:1" DAY_SECOND);
-> 1997-12-30 22:58:59 -> 1997-12-30 22:58:59
mysql> SELECT DATE_ADD("1998-01-01 00:00:00", mysql> SELECT DATE_ADD("1998-01-01 00:00:00",
INTERVAL "-1 10" DAY_HOUR); -> INTERVAL "-1 10" DAY_HOUR);
-> 1997-12-30 14:00:00 -> 1997-12-30 14:00:00
mysql> SELECT DATE_SUB("1998-01-02", INTERVAL 31 DAY); mysql> SELECT DATE_SUB("1998-01-02", INTERVAL 31 DAY);
-> 1997-12-02 -> 1997-12-02
...@@ -32590,10 +32688,10 @@ Returns a count of the number of non-@code{NULL} values in the rows ...@@ -32590,10 +32688,10 @@ Returns a count of the number of non-@code{NULL} values in the rows
retrieved by a @code{SELECT} statement: retrieved by a @code{SELECT} statement:
@example @example
mysql> select student.student_name,COUNT(*) mysql> SELECT student.student_name,COUNT(*)
from student,course -> FROM student,course
where student.student_id=course.student_id -> WHERE student.student_id=course.student_id
GROUP BY student_name; -> GROUP BY student_name;
@end example @end example
...@@ -32630,8 +32728,8 @@ Returns the average value of @code{expr}: ...@@ -32630,8 +32728,8 @@ Returns the average value of @code{expr}:
@example @example
mysql> select student_name, AVG(test_score) mysql> select student_name, AVG(test_score)
from student -> from student
GROUP BY student_name; -> GROUP BY student_name;
@end example @end example
@findex MIN() @findex MIN()
...@@ -32644,8 +32742,8 @@ minimum or maximum string value. @xref{MySQL indexes}. ...@@ -32644,8 +32742,8 @@ minimum or maximum string value. @xref{MySQL indexes}.
@example @example
mysql> select student_name, MIN(test_score), MAX(test_score) mysql> select student_name, MIN(test_score), MAX(test_score)
from student -> from student
GROUP BY student_name; -> GROUP BY student_name;
@end example @end example
@findex SUM() @findex SUM()
...@@ -32684,9 +32782,9 @@ grouping on unnecessary items. For example, you don't need to group on ...@@ -32684,9 +32782,9 @@ grouping on unnecessary items. For example, you don't need to group on
@example @example
mysql> select order.custid,customer.name,max(payments) mysql> select order.custid,customer.name,max(payments)
from order,customer -> from order,customer
where order.custid = customer.custid -> where order.custid = customer.custid
GROUP BY order.custid; -> GROUP BY order.custid;
@end example @end example
In ANSI SQL, you would have to add @code{customer.name} to the @code{GROUP In ANSI SQL, you would have to add @code{customer.name} to the @code{GROUP
...@@ -32721,7 +32819,7 @@ using an alias for the expression: ...@@ -32721,7 +32819,7 @@ using an alias for the expression:
@example @example
mysql> SELECT id,FLOOR(value/100) AS val FROM tbl_name mysql> SELECT id,FLOOR(value/100) AS val FROM tbl_name
GROUP BY id,val ORDER BY val; -> GROUP BY id,val ORDER BY val;
@end example @end example
In MySQL Version 3.23 you can do: In MySQL Version 3.23 you can do:
...@@ -32756,19 +32854,20 @@ mysql> SELECT id,FLOOR(value/100) FROM tbl_name ORDER BY RAND(); ...@@ -32756,19 +32854,20 @@ mysql> SELECT id,FLOOR(value/100) FROM tbl_name ORDER BY RAND();
@c help SELECT @c help SELECT
@example @example
SELECT [STRAIGHT_JOIN] [SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT] SELECT [STRAIGHT_JOIN]
[SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT]
[SQL_CACHE | SQL_NO_CACHE] [SQL_CALC_FOUND_ROWS] [HIGH_PRIORITY] [SQL_CACHE | SQL_NO_CACHE] [SQL_CALC_FOUND_ROWS] [HIGH_PRIORITY]
[DISTINCT | DISTINCTROW | ALL] [DISTINCT | DISTINCTROW | ALL]
select_expression,... select_expression,...
[INTO @{OUTFILE | DUMPFILE@} 'file_name' export_options] [INTO @{OUTFILE | DUMPFILE@} 'file_name' export_options]
[FROM table_references [FROM table_references
[WHERE where_definition] [WHERE where_definition]
[GROUP BY @{unsigned_integer | col_name | formula@} [ASC | DESC], ...] [GROUP BY @{unsigned_integer | col_name | formula@} [ASC | DESC], ...]
[HAVING where_definition] [HAVING where_definition]
[ORDER BY @{unsigned_integer | col_name | formula@} [ASC | DESC] ,...] [ORDER BY @{unsigned_integer | col_name | formula@} [ASC | DESC] ,...]
[LIMIT [offset,] rows] [LIMIT [offset,] rows]
[PROCEDURE procedure_name] [PROCEDURE procedure_name]
[FOR UPDATE | LOCK IN SHARE MODE]] [FOR UPDATE | LOCK IN SHARE MODE]]
@end example @end example
@c help end @c help end
...@@ -32844,9 +32943,9 @@ A table reference may be aliased using @code{tbl_name [AS] alias_name}: ...@@ -32844,9 +32943,9 @@ A table reference may be aliased using @code{tbl_name [AS] alias_name}:
@example @example
mysql> select t1.name, t2.salary from employee AS t1, info AS t2 mysql> select t1.name, t2.salary from employee AS t1, info AS t2
where t1.name = t2.name; -> where t1.name = t2.name;
mysql> select t1.name, t2.salary from employee t1, info t2 mysql> select t1.name, t2.salary from employee t1, info t2
where t1.name = t2.name; -> where t1.name = t2.name;
@end example @end example
@item @item
...@@ -32856,11 +32955,11 @@ positions. Column positions begin with 1: ...@@ -32856,11 +32955,11 @@ positions. Column positions begin with 1:
@example @example
mysql> select college, region, seed from tournament mysql> select college, region, seed from tournament
ORDER BY region, seed; -> ORDER BY region, seed;
mysql> select college, region AS r, seed AS s from tournament mysql> select college, region AS r, seed AS s from tournament
ORDER BY r, s; -> ORDER BY r, s;
mysql> select college, region, seed from tournament mysql> select college, region, seed from tournament
ORDER BY 2, 3; -> ORDER BY 2, 3;
@end example @end example
To sort in reverse order, add the @code{DESC} (descending) keyword to the To sort in reverse order, add the @code{DESC} (descending) keyword to the
...@@ -32892,14 +32991,14 @@ In MySQL Version 3.22.5 or later, you can also write queries like this: ...@@ -32892,14 +32991,14 @@ In MySQL Version 3.22.5 or later, you can also write queries like this:
@example @example
mysql> select user,max(salary) from users mysql> select user,max(salary) from users
group by user HAVING max(salary)>10; -> group by user HAVING max(salary)>10;
@end example @end example
In older MySQL versions, you can write this instead: In older MySQL versions, you can write this instead:
@example @example
mysql> select user,max(salary) AS sum from users mysql> select user,max(salary) AS sum from users
group by user HAVING sum>10; -> group by user HAVING sum>10;
@end example @end example
@item @item
...@@ -33149,7 +33248,7 @@ A table reference may be aliased using @code{tbl_name AS alias_name} or ...@@ -33149,7 +33248,7 @@ A table reference may be aliased using @code{tbl_name AS alias_name} or
@example @example
mysql> select t1.name, t2.salary from employee AS t1, info AS t2 mysql> select t1.name, t2.salary from employee AS t1, info AS t2
where t1.name = t2.name; -> where t1.name = t2.name;
@end example @end example
@item @item
...@@ -33164,8 +33263,8 @@ records in a table that have no counterpart in another table: ...@@ -33164,8 +33263,8 @@ records in a table that have no counterpart in another table:
@example @example
mysql> select table1.* from table1 mysql> select table1.* from table1
LEFT JOIN table2 ON table1.id=table2.id -> LEFT JOIN table2 ON table1.id=table2.id
where table2.id is NULL; -> where table2.id is NULL;
@end example @end example
This example finds all rows in @code{table1} with an @code{id} value that is This example finds all rows in @code{table1} with an @code{id} value that is
...@@ -33231,15 +33330,15 @@ particular index. ...@@ -33231,15 +33330,15 @@ particular index.
Some examples: Some examples:
@example @example
mysql> select * from table1,table2 where table1.id=table2.id; mysql> SELECT * FROM table1,table2 WHERE table1.id=table2.id;
mysql> select * from table1 LEFT JOIN table2 ON table1.id=table2.id; mysql> SELECT * FROM table1 LEFT JOIN table2 ON table1.id=table2.id;
mysql> select * from table1 LEFT JOIN table2 USING (id); mysql> SELECT * FROM table1 LEFT JOIN table2 USING (id);
mysql> select * from table1 LEFT JOIN table2 ON table1.id=table2.id mysql> SELECT * FROM table1 LEFT JOIN table2 ON table1.id=table2.id
LEFT JOIN table3 ON table2.id=table3.id; -> LEFT JOIN table3 ON table2.id=table3.id;
mysql> select * from table1 USE INDEX (key1,key2) WHERE key1=1 and key2=2 AND mysql> SELECT * FROM table1 USE INDEX (key1,key2)
key3=3; -> WHERE key1=1 AND key2=2 AND key3=3;
mysql> select * from table1 IGNORE INDEX (key3) WHERE key1=1 and key2=2 AND mysql> SELECT * FROM table1 IGNORE INDEX (key3)
key3=3; -> WHERE key1=1 AND key2=2 AND key3=3;
@end example @end example
@xref{LEFT JOIN optimisation, , @code{LEFT JOIN} optimisation}. @xref{LEFT JOIN optimisation, , @code{LEFT JOIN} optimisation}.
...@@ -33703,19 +33802,22 @@ only a given number of rows are changed. ...@@ -33703,19 +33802,22 @@ only a given number of rows are changed.
@example @example
DELETE [LOW_PRIORITY | QUICK] FROM table_name DELETE [LOW_PRIORITY | QUICK] FROM table_name
[WHERE where_definition] [WHERE where_definition]
[ORDER BY ...] [ORDER BY ...]
[LIMIT rows] [LIMIT rows]
or or
DELETE [LOW_PRIORITY | QUICK] table_name[.*] [,table_name[.*] ...] FROM DELETE [LOW_PRIORITY | QUICK] table_name[.*] [,table_name[.*] ...]
table-references [WHERE where_definition] FROM table-references
[WHERE where_definition]
or or
DELETE [LOW_PRIORITY | QUICK] FROM table_name[.*], [table_name[.*] ...] USING DELETE [LOW_PRIORITY | QUICK]
table-references [WHERE where_definition] FROM table_name[.*], [table_name[.*] ...]
USING table-references
[WHERE where_definition]
@end example @end example
@code{DELETE} deletes rows from @code{table_name} that satisfy the condition @code{DELETE} deletes rows from @code{table_name} that satisfy the condition
...@@ -34055,15 +34157,15 @@ fields delimited by commas: ...@@ -34055,15 +34157,15 @@ fields delimited by commas:
@example @example
mysql> SELECT * INTO OUTFILE 'data.txt' mysql> SELECT * INTO OUTFILE 'data.txt'
FIELDS TERMINATED BY ',' -> FIELDS TERMINATED BY ','
FROM ...; -> FROM ...;
@end example @end example
To read the comma-delimited file back in, the correct statement would be: To read the comma-delimited file back in, the correct statement would be:
@example @example
mysql> LOAD DATA INFILE 'data.txt' INTO TABLE table2 mysql> LOAD DATA INFILE 'data.txt' INTO TABLE table2
FIELDS TERMINATED BY ','; -> FIELDS TERMINATED BY ',';
@end example @end example
If instead you tried to read in the file with the statement shown below, it If instead you tried to read in the file with the statement shown below, it
...@@ -34072,7 +34174,7 @@ tabs between fields: ...@@ -34072,7 +34174,7 @@ tabs between fields:
@example @example
mysql> LOAD DATA INFILE 'data.txt' INTO TABLE table2 mysql> LOAD DATA INFILE 'data.txt' INTO TABLE table2
FIELDS TERMINATED BY '\t'; -> FIELDS TERMINATED BY '\t';
@end example @end example
The likely result is that each input line would be interpreted as The likely result is that each input line would be interpreted as
...@@ -34087,8 +34189,8 @@ the file: ...@@ -34087,8 +34189,8 @@ the file:
@example @example
mysql> LOAD DATA INFILE 'data.txt' INTO TABLE tbl_name mysql> LOAD DATA INFILE 'data.txt' INTO TABLE tbl_name
FIELDS TERMINATED BY ',' ENCLOSED BY '"' -> FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\n'; -> LINES TERMINATED BY '\n';
@end example @end example
Any of the field or line handling options may specify an empty string Any of the field or line handling options may specify an empty string
...@@ -34283,7 +34385,7 @@ If you wish to load only some of a table's columns, specify a field list: ...@@ -34283,7 +34385,7 @@ If you wish to load only some of a table's columns, specify a field list:
@example @example
mysql> LOAD DATA INFILE 'persondata.txt' mysql> LOAD DATA INFILE 'persondata.txt'
INTO TABLE persondata (col1,col2,...); -> INTO TABLE persondata (col1,col2,...);
@end example @end example
You must also specify a field list if the order of the fields in the input You must also specify a field list if the order of the fields in the input
...@@ -34839,8 +34941,8 @@ MySQL will create new fields for all elements in the ...@@ -34839,8 +34941,8 @@ MySQL will create new fields for all elements in the
@example @example
mysql> CREATE TABLE test (a int not null auto_increment, mysql> CREATE TABLE test (a int not null auto_increment,
primary key (a), key(b)) -> primary key (a), key(b))
TYPE=MyISAM SELECT b,c from test2; -> TYPE=MyISAM SELECT b,c from test2;
@end example @end example
This will create a @code{MyISAM} table with three columns, a, b, and c. This will create a @code{MyISAM} table with three columns, a, b, and c.
...@@ -35007,7 +35109,8 @@ alter_specification: ...@@ -35007,7 +35109,8 @@ alter_specification:
or ADD [CONSTRAINT symbol] FOREIGN KEY index_name (index_col_name,...) or ADD [CONSTRAINT symbol] FOREIGN KEY index_name (index_col_name,...)
[reference_definition] [reference_definition]
or ALTER [COLUMN] col_name @{SET DEFAULT literal | DROP DEFAULT@} or ALTER [COLUMN] col_name @{SET DEFAULT literal | DROP DEFAULT@}
or CHANGE [COLUMN] old_col_name create_definition [FIRST | AFTER column_name] or CHANGE [COLUMN] old_col_name create_definition
[FIRST | AFTER column_name]
or MODIFY [COLUMN] create_definition [FIRST | AFTER column_name] or MODIFY [COLUMN] create_definition [FIRST | AFTER column_name]
or DROP [COLUMN] col_name or DROP [COLUMN] col_name
or DROP PRIMARY KEY or DROP PRIMARY KEY
...@@ -35348,7 +35451,8 @@ automatically commit current active transaction. ...@@ -35348,7 +35451,8 @@ automatically commit current active transaction.
@cindex multi-part index @cindex multi-part index
@example @example
CREATE [UNIQUE|FULLTEXT] INDEX index_name ON tbl_name (col_name[(length)],... ) CREATE [UNIQUE|FULLTEXT] INDEX index_name
ON tbl_name (col_name[(length)],... )
@end example @end example
The @code{CREATE INDEX} statement doesn't do anything in MySQL prior The @code{CREATE INDEX} statement doesn't do anything in MySQL prior
...@@ -35449,7 +35553,7 @@ below accesses the @code{author} table from the @code{db1} database and the ...@@ -35449,7 +35553,7 @@ below accesses the @code{author} table from the @code{db1} database and the
@example @example
mysql> USE db1; mysql> USE db1;
mysql> SELECT author_name,editor_name FROM author,db2.editor mysql> SELECT author_name,editor_name FROM author,db2.editor
WHERE author.editor_id = db2.editor.editor_id; -> WHERE author.editor_id = db2.editor.editor_id;
@end example @end example
@cindex Sybase compatibility @cindex Sybase compatibility
...@@ -35664,7 +35768,7 @@ example shown below requires @code{LOCK TABLES} in order to execute safely: ...@@ -35664,7 +35768,7 @@ example shown below requires @code{LOCK TABLES} in order to execute safely:
mysql> LOCK TABLES trans READ, customer WRITE; mysql> LOCK TABLES trans READ, customer WRITE;
mysql> select sum(value) from trans where customer_id= some_id; mysql> select sum(value) from trans where customer_id= some_id;
mysql> update customer set total_value=sum_from_previous_statement mysql> update customer set total_value=sum_from_previous_statement
where customer_id=some_id; -> where customer_id=some_id;
mysql> UNLOCK TABLES; mysql> UNLOCK TABLES;
@end example @end example
...@@ -35748,22 +35852,23 @@ mysql> CREATE TABLE articles ( ...@@ -35748,22 +35852,23 @@ mysql> CREATE TABLE articles (
Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec)
mysql> INSERT INTO articles VALUES mysql> INSERT INTO articles VALUES
-> (0,'MySQL Tutorial', 'DBMS stands for DataBase Management ...'), -> (0,'MySQL Tutorial', 'DBMS stands for DataBase ...'),
-> (0,'How To Use MySQL Efficiently', 'After you went through a ...'), -> (0,'How To Use MySQL Efficiently', 'After you went through a ...'),
-> (0,'Optimising MySQL','In this tutorial we will show how to ...'), -> (0,'Optimising MySQL','In this tutorial we will show ...'),
-> (0,'1001 MySQL Trick','1. Never run mysqld as root. 2. Normalise ...'), -> (0,'1001 MySQL Trick','1. Never run mysqld as root. 2. ...'),
-> (0,'MySQL vs. YourSQL', 'In the following database comparison we ...'), -> (0,'MySQL vs. YourSQL', 'In the following database comparison ...'),
-> (0,'MySQL Security', 'When configured properly, MySQL could be ...'); -> (0,'MySQL Security', 'When configured properly, MySQL ...');
Query OK, 5 rows affected (0.00 sec) Query OK, 5 rows affected (0.00 sec)
Records: 5 Duplicates: 0 Warnings: 0 Records: 5 Duplicates: 0 Warnings: 0
mysql> SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('database'); mysql> SELECT * FROM articles
+----+-------------------+---------------------------------------------+ -> WHERE MATCH (title,body) AGAINST ('database');
| id | title | body | +----+-------------------+------------------------------------------+
+----+-------------------+---------------------------------------------+ | id | title | body |
| 5 | MySQL vs. YourSQL | In the following database comparison we ... | +----+-------------------+------------------------------------------+
| 1 | MySQL Tutorial | DBMS stands for DataBase Management ... | | 5 | MySQL vs. YourSQL | In the following database comparison ... |
+----+-------------------+---------------------------------------------+ | 1 | MySQL Tutorial | DBMS stands for DataBase ... |
+----+-------------------+------------------------------------------+
2 rows in set (0.00 sec) 2 rows in set (0.00 sec)
@end example @end example
...@@ -35806,12 +35911,12 @@ mysql> SELECT id, body, MATCH title,body AGAINST ( ...@@ -35806,12 +35911,12 @@ mysql> SELECT id, body, MATCH title,body AGAINST (
-> 'Security implications of running MySQL as root') AS score -> 'Security implications of running MySQL as root') AS score
-> FROM articles WHERE MATCH (title,body) AGAINST -> FROM articles WHERE MATCH (title,body) AGAINST
-> ('Security implications of running MySQL as root'); -> ('Security implications of running MySQL as root');
+----+-----------------------------------------------+-----------------+ +----+-------------------------------------+-----------------+
| id | body | score | | id | body | score |
+----+-----------------------------------------------+-----------------+ +----+-------------------------------------+-----------------+
| 4 | 1. Never run mysqld as root. 2. Normalise ... | 1.5055546709332 | | 4 | 1. Never run mysqld as root. 2. ... | 1.5055546709332 |
| 6 | When configured properly, MySQL could be ... | 1.31140957288 | | 6 | When configured properly, MySQL ... | 1.31140957288 |
+----+-----------------------------------------------+-----------------+ +----+-------------------------------------+-----------------+
2 rows in set (0.00 sec) 2 rows in set (0.00 sec)
@end example @end example
...@@ -35860,17 +35965,17 @@ Since version 4.0.1 MySQL can also perform boolean fulltext searches using ...@@ -35860,17 +35965,17 @@ Since version 4.0.1 MySQL can also perform boolean fulltext searches using
@code{IN BOOLEAN MODE} modifier. @code{IN BOOLEAN MODE} modifier.
@example @example
mysql> SELECT * FROM articles WHERE MATCH (title,body) AGAINST ( mysql> SELECT * FROM articles WHERE MATCH (title,body)
-> '+MySQL -YourSQL' IN BOOLEAN MODE); -> AGAINST ('+MySQL -YourSQL' IN BOOLEAN MODE);
+----+------------------------------+-----------------------------------------------+ +----+------------------------------+-------------------------------------+
| id | title | body | | id | title | body |
+----+------------------------------+-----------------------------------------------+ +----+------------------------------+-------------------------------------+
| 1 | MySQL Tutorial | DBMS stands for DataBase Management ... | | 1 | MySQL Tutorial | DBMS stands for DataBase ... |
| 2 | How To Use MySQL Efficiently | After you went through a ... | | 2 | How To Use MySQL Efficiently | After you went through a ... |
| 3 | Optimising MySQL | In this tutorial we will show how to ... | | 3 | Optimising MySQL | In this tutorial we will show ... |
| 4 | 1001 MySQL Trick | 1. Never run mysqld as root. 2. Normalise ... | | 4 | 1001 MySQL Trick | 1. Never run mysqld as root. 2. ... |
| 6 | MySQL Security | When configured properly, MySQL could be ... | | 6 | MySQL Security | When configured properly, MySQL ... |
+----+------------------------------+-----------------------------------------------+ +----+------------------------------+-------------------------------------+
@end example @end example
This query retrieved all the rows that contain the word @code{MySQL} This query retrieved all the rows that contain the word @code{MySQL}
...@@ -36951,7 +37056,8 @@ CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, message CHAR(20)); ...@@ -36951,7 +37056,8 @@ CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, message CHAR(20));
CREATE TABLE t2 (a INT AUTO_INCREMENT PRIMARY KEY, message CHAR(20)); CREATE TABLE t2 (a INT AUTO_INCREMENT PRIMARY KEY, message CHAR(20));
INSERT INTO t1 (message) VALUES ("Testing"),("table"),("t1"); INSERT INTO t1 (message) VALUES ("Testing"),("table"),("t1");
INSERT INTO t2 (message) VALUES ("Testing"),("table"),("t2"); INSERT INTO t2 (message) VALUES ("Testing"),("table"),("t2");
CREATE TABLE total (a INT NOT NULL, message CHAR(20), KEY(a)) TYPE=MERGE UNION=(t1,t2) INSERT_METHOD=LAST; CREATE TABLE total (a INT NOT NULL, message CHAR(20), KEY(a))
TYPE=MERGE UNION=(t1,t2) INSERT_METHOD=LAST;
@end example @end example
Note that we didn't create a @code{UNIQUE} or @code{PRIMARY KEY} in the Note that we didn't create a @code{UNIQUE} or @code{PRIMARY KEY} in the
...@@ -37104,7 +37210,7 @@ normally is common with hashed tables: ...@@ -37104,7 +37210,7 @@ normally is common with hashed tables:
@example @example
mysql> CREATE TABLE test TYPE=HEAP SELECT ip,SUM(downloads) as down mysql> CREATE TABLE test TYPE=HEAP SELECT ip,SUM(downloads) as down
FROM log_table GROUP BY ip; -> FROM log_table GROUP BY ip;
mysql> SELECT COUNT(ip),AVG(down) FROM test; mysql> SELECT COUNT(ip),AVG(down) FROM test;
mysql> DROP TABLE test; mysql> DROP TABLE test;
@end example @end example
...@@ -37304,26 +37410,26 @@ hard disk. Below is an example of possible configuration parameters in ...@@ -37304,26 +37410,26 @@ hard disk. Below is an example of possible configuration parameters in
# ... # ...
# #
innodb_data_home_dir = c:\ibdata innodb_data_home_dir = c:\ibdata
# Data files must be able to # Data files must be able to
# hold your data and indexes # hold your data and indexes
innodb_data_file_path = ibdata1:2000M;ibdata2:2000M innodb_data_file_path = ibdata1:2000M;ibdata2:2000M
# Set buffer pool size to 50 - 80 % # Set buffer pool size to 50 - 80 %
# of your computer's memory # of your computer's memory
set-variable = innodb_buffer_pool_size=70M set-variable = innodb_buffer_pool_size=70M
set-variable = innodb_additional_mem_pool_size=10M set-variable = innodb_additional_mem_pool_size=10M
innodb_log_group_home_dir = c:\iblogs innodb_log_group_home_dir = c:\iblogs
# .._log_arch_dir must be the same # .._log_arch_dir must be the same
# as .._log_group_home_dir # as .._log_group_home_dir
innodb_log_arch_dir = c:\iblogs innodb_log_arch_dir = c:\iblogs
innodb_log_archive=0 innodb_log_archive=0
set-variable = innodb_log_files_in_group=3 set-variable = innodb_log_files_in_group=3
# Set the log file size to about # Set the log file size to about
# 15 % of the buffer pool size # 15 % of the buffer pool size
set-variable = innodb_log_file_size=10M set-variable = innodb_log_file_size=10M
set-variable = innodb_log_buffer_size=8M set-variable = innodb_log_buffer_size=8M
# Set ..flush_log_at_trx_commit to # Set ..flush_log_at_trx_commit to
# 0 if you can afford losing # 0 if you can afford losing
# a few last transactions # a few last transactions
innodb_flush_log_at_trx_commit=1 innodb_flush_log_at_trx_commit=1
set-variable = innodb_file_io_threads=4 set-variable = innodb_file_io_threads=4
set-variable = innodb_lock_wait_timeout=50 set-variable = innodb_lock_wait_timeout=50
...@@ -37403,28 +37509,28 @@ InnoDB: ...@@ -37403,28 +37509,28 @@ InnoDB:
# ... # ...
# #
innodb_data_home_dir = / innodb_data_home_dir = /
# Data files must be able to # Data files must be able to
# hold your data and indexes # hold your data and indexes
innodb_data_file_path = ibdata/ibdata1:2000M;dr2/ibdata/ibdata2:2000M innodb_data_file_path = ibdata/ibdata1:2000M;dr2/ibdata/ibdata2:2000M
# Set buffer pool size to 50 - 80 % # Set buffer pool size to 50 - 80 %
# of your computer's memory, but # of your computer's memory, but
# make sure on Linux x86 the total # make sure on Linux x86 the total
# memory usage is < 2 GB # memory usage is < 2 GB
set-variable = innodb_buffer_pool_size=350M set-variable = innodb_buffer_pool_size=350M
set-variable = innodb_additional_mem_pool_size=20M set-variable = innodb_additional_mem_pool_size=20M
innodb_log_group_home_dir = /dr3/iblogs innodb_log_group_home_dir = /dr3/iblogs
# .._log_arch_dir must be the same # .._log_arch_dir must be the same
# as .._log_group_home_dir # as .._log_group_home_dir
innodb_log_arch_dir = /dr3/iblogs innodb_log_arch_dir = /dr3/iblogs
innodb_log_archive=0 innodb_log_archive=0
set-variable = innodb_log_files_in_group=3 set-variable = innodb_log_files_in_group=3
# Set the log file size to about # Set the log file size to about
# 15 % of the buffer pool size # 15 % of the buffer pool size
set-variable = innodb_log_file_size=50M set-variable = innodb_log_file_size=50M
set-variable = innodb_log_buffer_size=8M set-variable = innodb_log_buffer_size=8M
# Set ..flush_log_at_trx_commit to # Set ..flush_log_at_trx_commit to
# 0 if you can afford losing # 0 if you can afford losing
# a few last transactions # a few last transactions
innodb_flush_log_at_trx_commit=1 innodb_flush_log_at_trx_commit=1
set-variable = innodb_file_io_threads=4 set-variable = innodb_file_io_threads=4
set-variable = innodb_lock_wait_timeout=50 set-variable = innodb_lock_wait_timeout=50
...@@ -37560,21 +37666,23 @@ and log files. InnoDB will print something like the following: ...@@ -37560,21 +37666,23 @@ and log files. InnoDB will print something like the following:
@example @example
~/mysqlm/sql > mysqld ~/mysqlm/sql > mysqld
InnoDB: The first specified data file /home/heikki/data/ibdata1 did not exist: InnoDB: The first specified data file /home/heikki/data/ibdata1
did not exist:
InnoDB: a new database to be created! InnoDB: a new database to be created!
InnoDB: Setting file /home/heikki/data/ibdata1 size to 134217728 InnoDB: Setting file /home/heikki/data/ibdata1 size to 134217728
InnoDB: Database physically writes the file full: wait... InnoDB: Database physically writes the file full: wait...
InnoDB: Data file /home/heikki/data/ibdata2 did not exist: new to be created InnoDB: Data file /home/heikki/data/ibdata2 did not exist:
new to be created
InnoDB: Setting file /home/heikki/data/ibdata2 size to 262144000 InnoDB: Setting file /home/heikki/data/ibdata2 size to 262144000
InnoDB: Database physically writes the file full: wait... InnoDB: Database physically writes the file full: wait...
InnoDB: Log file /home/heikki/data/logs/ib_logfile0 did not exist: new to be c InnoDB: Log file /home/heikki/data/logs/ib_logfile0 did not exist:
reated new to be created
InnoDB: Setting log file /home/heikki/data/logs/ib_logfile0 size to 5242880 InnoDB: Setting log file /home/heikki/data/logs/ib_logfile0 size to 5242880
InnoDB: Log file /home/heikki/data/logs/ib_logfile1 did not exist: new to be c InnoDB: Log file /home/heikki/data/logs/ib_logfile1 did not exist:
reated new to be created
InnoDB: Setting log file /home/heikki/data/logs/ib_logfile1 size to 5242880 InnoDB: Setting log file /home/heikki/data/logs/ib_logfile1 size to 5242880
InnoDB: Log file /home/heikki/data/logs/ib_logfile2 did not exist: new to be c InnoDB: Log file /home/heikki/data/logs/ib_logfile2 did not exist:
reated new to be created
InnoDB: Setting log file /home/heikki/data/logs/ib_logfile2 size to 5242880 InnoDB: Setting log file /home/heikki/data/logs/ib_logfile2 size to 5242880
InnoDB: Started InnoDB: Started
mysqld: ready for connections mysqld: ready for connections
...@@ -37720,7 +37828,8 @@ constraints to guard the integrity of your data. ...@@ -37720,7 +37828,8 @@ constraints to guard the integrity of your data.
The syntax of a foreign key constraint definition in InnoDB: The syntax of a foreign key constraint definition in InnoDB:
@example @example
FOREIGN KEY (index_col_name, ...) REFERENCES table_name (index_col_name, ...) FOREIGN KEY (index_col_name, ...)
REFERENCES table_name (index_col_name, ...)
@end example @end example
An example: An example:
...@@ -38395,8 +38504,8 @@ RECORD LOCKS space id 0 page no 12758 n bits 104 table test/mytable index ...@@ -38395,8 +38504,8 @@ RECORD LOCKS space id 0 page no 12758 n bits 104 table test/mytable index
PRIMARY trx id 0 582333343 lock_mode X PRIMARY trx id 0 582333343 lock_mode X
Record lock, heap no 2 PHYSICAL RECORD: n_fields 74; 1-byte offs FALSE; Record lock, heap no 2 PHYSICAL RECORD: n_fields 74; 1-byte offs FALSE;
info bits 0 info bits 0
0: len 4; hex 0001a801; asc ;; 1: len 6; hex 000022b5b39f; asc ";; 2: len 7; 0: len 4; hex 0001a801; asc ;; 1: len 6; hex 000022b5b39f; asc ";;
hex 000002001e03ec; asc ;; 3: len 4; hex 00000001; 2: len 7; hex 000002001e03ec; asc ;; 3: len 4; hex 00000001;
... ...
----------------------------------------------- -----------------------------------------------
CURRENT SEMAPHORES RESERVED AND SEMAPHORE WAITS CURRENT SEMAPHORES RESERVED AND SEMAPHORE WAITS
...@@ -38407,7 +38516,8 @@ Sorry, cannot give rw-lock list info in non-debug version! ...@@ -38407,7 +38516,8 @@ Sorry, cannot give rw-lock list info in non-debug version!
----------------------------------------------------- -----------------------------------------------------
SYNC ARRAY INFO: reservation count 6041054, signal count 2913432 SYNC ARRAY INFO: reservation count 6041054, signal count 2913432
4a239430 waited for by thread 49627477 op. S-LOCK file NOT KNOWN line 0 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 Mut ex 0 sp 5530989 r 62038708 sys 2155035;
rws 0 8257574 8025336; rwx 0 1121090 1848344
----------------------------------------------------- -----------------------------------------------------
CURRENT PENDING FILE I/O'S CURRENT PENDING FILE I/O'S
-------------------------- --------------------------
...@@ -39271,7 +39381,8 @@ the MySQL error file: ...@@ -39271,7 +39381,8 @@ the MySQL error file:
@example @example
001119 23:43:56 bdb: Missing log fileid entry 001119 23:43:56 bdb: Missing log fileid entry
001119 23:43:56 bdb: txn_abort: Log undo failed for LSN: 1 3644744: Invalid 001119 23:43:56 bdb: txn_abort: Log undo failed for LSN:
1 3644744: Invalid
@end example @end example
This is not fatal but we don't recommend that you delete tables if you are This is not fatal but we don't recommend that you delete tables if you are
...@@ -42663,9 +42774,9 @@ An unknown error occurred. ...@@ -42663,9 +42774,9 @@ An unknown error occurred.
@findex @code{mysql_real_connect()} @findex @code{mysql_real_connect()}
@code{MYSQL *mysql_real_connect(MYSQL *mysql, const char *host, @code{MYSQL *mysql_real_connect(MYSQL *mysql, const char *host,
const char *user, const char *passwd, const char *db, const char *user, const char *passwd, const char *db,
unsigned int port, const char *unix_socket, unsigned int port, const char *unix_socket,
unsigned int client_flag)} unsigned int client_flag)}
@subsubheading Description @subsubheading Description
...@@ -45024,8 +45135,10 @@ mysql> CREATE FUNCTION metaphon RETURNS STRING SONAME "udf_example.so"; ...@@ -45024,8 +45135,10 @@ 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_double RETURNS REAL SONAME "udf_example.so";
mysql> CREATE FUNCTION myfunc_int RETURNS INTEGER 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 lookup RETURNS STRING SONAME "udf_example.so";
mysql> CREATE FUNCTION reverse_lookup RETURNS STRING SONAME "udf_example.so"; mysql> CREATE FUNCTION reverse_lookup
mysql> CREATE AGGREGATE FUNCTION avgcost RETURNS REAL SONAME "udf_example.so"; -> RETURNS STRING SONAME "udf_example.so";
mysql> CREATE AGGREGATE FUNCTION avgcost
-> RETURNS REAL SONAME "udf_example.so";
@end example @end example
Functions can be deleted using @code{DROP FUNCTION}: Functions can be deleted using @code{DROP FUNCTION}:
...@@ -45856,7 +45969,7 @@ function: ...@@ -45856,7 +45969,7 @@ function:
@example @example
mysql> update user set password=PASSWORD('your password') mysql> update user set password=PASSWORD('your password')
where user='XXX'; -> where user='XXX';
@end example @end example
@end itemize @end itemize
...@@ -46887,13 +47000,15 @@ Field types @code{FLOAT}, @code{DOUBLE} and @code{DECIMAL} are such. ...@@ -46887,13 +47000,15 @@ Field types @code{FLOAT}, @code{DOUBLE} and @code{DECIMAL} are such.
@example @example
CREATE TABLE t1 (i int, d1 decimal(9,2), d2 decimal(9,2)); CREATE TABLE t1 (i int, d1 decimal(9,2), d2 decimal(9,2));
INSERT INTO t1 values (1, 101.40, 21.40), (1, -80.00, 0.00), (2, 0.00, 0.00), INSERT INTO t1 values (1, 101.40, 21.40), (1, -80.00, 0.00),
(2, -13.20, 0.00), (2, 59.60, 46.40), (2, 30.40, 30.40), (3, 37.00, 7.40), (2, 0.00, 0.00), (2, -13.20, 0.00), (2, 59.60, 46.40),
(3, -29.60, 0.00), (4, 60.00, 15.40), (4, -10.60, 0.00), (4, -34.00, 0.00), (2, 30.40, 30.40), (3, 37.00, 7.40), (3, -29.60, 0.00),
(5, 33.00, 0.00), (5, -25.80, 0.00), (5, 0.00, 7.20), (6, 0.00, 0.00), (4, 60.00, 15.40), (4, -10.60, 0.00), (4, -34.00, 0.00),
(6, -51.40, 0.00); (5, 33.00, 0.00), (5, -25.80, 0.00), (5, 0.00, 7.20),
(6, 0.00, 0.00), (6, -51.40, 0.00);
mysql> SELECT i, SUM(d1) AS a, SUM(d2) AS b FROM t1 GROUP BY i HAVING a <> b;
mysql> SELECT i, SUM(d1) AS a, SUM(d2) AS b
-> FROM t1 GROUP BY i HAVING a <> b;
+------+--------+-------+ +------+--------+-------+
| i | a | b | | i | a | b |
+------+--------+-------+ +------+--------+-------+
...@@ -46915,7 +47030,8 @@ The problem cannot be solved by using ROUND() (or similar function), ...@@ -46915,7 +47030,8 @@ The problem cannot be solved by using ROUND() (or similar function),
because the result is still a floating point number. Example: because the result is still a floating point number. Example:
@example @example
mysql> SELECT i, ROUND(SUM(d1), 2) AS a, ROUND(SUM(d2), 2) AS b FROM t1 GROUP BY i HAVING a <> b; mysql> SELECT i, ROUND(SUM(d1), 2) AS a, ROUND(SUM(d2), 2) AS b
-> FROM t1 GROUP BY i HAVING a <> b;
+------+--------+-------+ +------+--------+-------+
| i | a | b | | i | a | b |
+------+--------+-------+ +------+--------+-------+
...@@ -46930,7 +47046,8 @@ mysql> SELECT i, ROUND(SUM(d1), 2) AS a, ROUND(SUM(d2), 2) AS b FROM t1 GROUP BY ...@@ -46930,7 +47046,8 @@ mysql> SELECT i, ROUND(SUM(d1), 2) AS a, ROUND(SUM(d2), 2) AS b FROM t1 GROUP BY
This is what the numbers in row 'a' look like: This is what the numbers in row 'a' look like:
@example @example
mysql> SELECT i, ROUND(SUM(d1), 2)*1.0000000000000000 AS a, ROUND(SUM(d2), 2) AS b FROM t1 GROUP BY i HAVING a <> b; mysql> SELECT i, ROUND(SUM(d1), 2)*1.0000000000000000 AS a,
-> ROUND(SUM(d2), 2) AS b FROM t1 GROUP BY i HAVING a <> b;
+------+----------------------+-------+ +------+----------------------+-------+
| i | a | b | | i | a | b |
+------+----------------------+-------+ +------+----------------------+-------+
...@@ -46952,8 +47069,8 @@ with 1, an example follows. ...@@ -46952,8 +47069,8 @@ with 1, an example follows.
AN EXAMPLE OF A WRONG METHOD!!!} AN EXAMPLE OF A WRONG METHOD!!!}
@example @example
mysql> SELECT i, ROUND(SUM(d1), 2)*1 AS a, ROUND(SUM(d2), 2)*1 AS b FROM t1 GROUP mysql> SELECT i, ROUND(SUM(d1), 2)*1 AS a, ROUND(SUM(d2), 2)*1 AS b
BY i HAVING a <> b; -> FROM t1 GROUP BY i HAVING a <> b;
+------+--------+------+ +------+--------+------+
| i | a | b | | i | a | b |
+------+--------+------+ +------+--------+------+
...@@ -46974,7 +47091,8 @@ same with precision of one of ten thousand (0.0001), the comparsion ...@@ -46974,7 +47091,8 @@ same with precision of one of ten thousand (0.0001), the comparsion
should be done like this: should be done like this:
@example @example
mysql> SELECT i, SUM(d1) AS a, SUM(d2) AS b FROM t1 GROUP BY i HAVING ABS(a - b) > 0.0001; mysql> SELECT i, SUM(d1) AS a, SUM(d2) AS b FROM t1
-> GROUP BY i HAVING ABS(a - b) > 0.0001;
+------+--------+------+ +------+--------+------+
| i | a | b | | i | a | b |
+------+--------+------+ +------+--------+------+
...@@ -46987,7 +47105,8 @@ And vice versa, if we wanted to get rows where the numbers are the same, ...@@ -46987,7 +47105,8 @@ And vice versa, if we wanted to get rows where the numbers are the same,
the test would be: the test would be:
@example @example
mysql> SELECT i, SUM(d1) AS a, SUM(d2) AS b FROM t1 GROUP BY i HAVING ABS(a - b) < 0.0001; mysql> SELECT i, SUM(d1) AS a, SUM(d2) AS b FROM t1
-> GROUP BY i HAVING ABS(a - b) < 0.0001;
+------+-------+-------+ +------+-------+-------+
| i | a | b | | i | a | b |
+------+-------+-------+ +------+-------+-------+
...@@ -53766,7 +53885,7 @@ Fixed bug that you couldn't use @code{tbl_name.field_name} in @code{UPDATE}. ...@@ -53766,7 +53885,7 @@ Fixed bug that you couldn't use @code{tbl_name.field_name} in @code{UPDATE}.
Fixed @code{SELECT DISTINCT} when using 'hidden group'. For example: Fixed @code{SELECT DISTINCT} when using 'hidden group'. For example:
@example @example
mysql> SELECT DISTINCT MOD(some_field,10) FROM test mysql> SELECT DISTINCT MOD(some_field,10) FROM test
GROUP BY some_field; -> GROUP BY some_field;
@end example @end example
Note: @code{some_field} is normally in the @code{SELECT} part. ANSI SQL should Note: @code{some_field} is normally in the @code{SELECT} part. ANSI SQL should
require it. require it.
...@@ -53840,8 +53959,8 @@ New range optimiser that can resolve ranges when some keypart prefix is ...@@ -53840,8 +53959,8 @@ New range optimiser that can resolve ranges when some keypart prefix is
constant. Example: constant. Example:
@example @example
mysql> SELECT * FROM tbl_name mysql> SELECT * FROM tbl_name
WHERE key_part_1="customer" -> WHERE key_part_1="customer"
AND key_part_2>=10 AND key_part_2<=10; -> AND key_part_2>=10 AND key_part_2<=10;
@end example @end example
@end itemize @end itemize
...@@ -54299,7 +54418,7 @@ lookups. The column that is used should be a constant for each group because ...@@ -54299,7 +54418,7 @@ lookups. The column that is used should be a constant for each group because
the value is calculated only once for the first row that is found for a group. the value is calculated only once for the first row that is found for a group.
@example @example
mysql> SELECT id,lookup.text,sum(*) FROM test,lookup mysql> SELECT id,lookup.text,sum(*) FROM test,lookup
WHERE test.id=lookup.id GROUP BY id; -> WHERE test.id=lookup.id GROUP BY id;
@end example @end example
@item @item
Fixed bug in @code{SUM(function)} (could cause a core dump). Fixed bug in @code{SUM(function)} (could cause a core dump).
...@@ -54664,7 +54783,9 @@ lists the @code{mysqld} version as @code{mysql ... --debug} in this case. ...@@ -54664,7 +54783,9 @@ lists the @code{mysqld} version as @code{mysql ... --debug} in this case.
If you are using gcc or egcs, the recommended configure line is: If you are using gcc or egcs, the recommended configure line is:
@example @example
CC=gcc CFLAGS="-O2" CXX=gcc CXXFLAGS="-O2 -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --with-debug --with-extra-charsets=complex CC=gcc CFLAGS="-O2" CXX=gcc CXXFLAGS="-O2 -felide-constructors \
-fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql \
--with-debug --with-extra-charsets=complex
@end example @end example
This will avoid problems with the @code{libstdc++} library and with C++ This will avoid problems with the @code{libstdc++} library and with C++
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment