diff options
author | unknown <jcole@ham.spaceapes.com> | 2000-08-30 03:05:13 +0000 |
---|---|---|
committer | unknown <jcole@ham.spaceapes.com> | 2000-08-30 03:05:13 +0000 |
commit | 1f340779b08777e73876d5f790c304c8b959fb85 (patch) | |
tree | f620b529658627cc03b59079025ea123345055f5 | |
parent | 542e7e5707483fc8eb1b11bc0e189531c6c55e19 (diff) | |
parent | a6ec1f09b09f03652d6ab00b2a6632979825ffa3 (diff) | |
download | mariadb-git-1f340779b08777e73876d5f790c304c8b959fb85.tar.gz |
Merge jcole@work.mysql.com:/home/bk/mysql
into ham.spaceapes.com:/usr/home/jcole/bk/mysql
Docs/manual.texi:
Auto merged
45 files changed, 1312 insertions, 369 deletions
diff --git a/BUILD/compile-alpha-ccc b/BUILD/compile-alpha-ccc index 194ed099541..9a92de2590d 100755 --- a/BUILD/compile-alpha-ccc +++ b/BUILD/compile-alpha-ccc @@ -4,7 +4,7 @@ make -k clean /bin/rm -f config.cache mysql-*.tar.gz aclocal; autoheader; aclocal; automake; autoconf -CC=ccc CFLAGS="-fast -O3 -fomit-frame-pointer" CXX=gcc CXXFLAGS="-O6 -fomit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti -mcpu=ev6 -Wa,-mev6" CXXLDFLAGS='/usr/lib/compaq/libots-2.2.7/libots.so /usr/lib/compaq/cpml-5.0.0/libcpml_ev6.a' ./configure --prefix=/usr/local/mysql --disable-shared --with-extra-charsets=complex +CC=ccc CFLAGS="-fast -O3 -fomit-frame-pointer" CXX=gcc CXXFLAGS="-O6 -fomit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti -mcpu=ev6 -Wa,-mev6" CXXLDFLAGS='/usr/lib/compaq/libots-2.2.7/libots.so /usr/lib/compaq/cpml-5.0.0/libcpml_ev6.a' ./configure --prefix=/usr/local/mysql --disable-shared --with-extra-charsets=complex --enable-thread-safe-client make if [ $? = 0 ] then diff --git a/Docs/bk.txt b/Docs/bk.txt new file mode 100644 index 00000000000..17bab4453c3 --- /dev/null +++ b/Docs/bk.txt @@ -0,0 +1,64 @@ +Mail by sasha, should be rewritten as a HOWTO sometimes +----------- + +I have set up a repository with BitKeeper on work. There are still some things +about it that I would like to learn, but I have gotten far enough with it to +replace CVS functionality were are currently using, so let's just go ahead and +get started on it. Please follow the instructions below (make sure to save the +message for future reference): + +a) http://www.bitmover.com/download + user: beta + password: get bitkeeper + + get the version appropriate for your platform - download it to a temp +directory, chmod +x and then run it. You will have to tell it which directory +to install, for consistency, let's use /usr/local/bin + +b) we will take advantage of bk capablity of working with master/slave +repositories. The master will be on work.mysql.com, the slaves will be our +individual machines. The master repository has already been set up on work, so +you will need just to set up a slave repository on your machine: + + mkdir bk + cd bk + bk clone yourusername@work:/home/bk/mysql mysql + cd mysql + bk -r edit + +Now you have the entire source tree in the current directory. Let's compile it: + + BUILD/compile-pentium-debug + +After you edit a file, you need to check it in using bk citool or bk ci +filename. Note that ci is different than commit - you ci a file, but you commit +a change set. This is a very nice concept - instead of thinking of each +individual file as CVS does, bk groups the changes you are making and allows you +to document what you actually did between the commits as a whole, rather than +just commenting on every file. When you commit, bk will ask you to comment on +the change set. + +Commit is done just to your local repository. To make your changes global, you +will need to run bk push. Be careful with that - it is a good idea to run bk +push -l -n first too see what you are just about to push to the master +repository. + +When somebody does a push, you will be getting a email ( I will set this up to +day). You will then need to execute bk pull to update your sources. If there are +any conflicts, bk will force you to resolve them by asking you questions on what +to do with each conflict. + +To learn more about bk, use bk helptool - I will be doing this a lot in the next +couple of days :-) If you find bugs or have questions/feature +suggestions/comments for developers, feel free to e-mail dev@bitmover.com . +Their developers, and especially the president of the company Larry McCoy really +like MySQL and are very anxious to help us. Make sure it is obvious that you +work for MySQL, of course. And, of course, do not bug them with little things +that you can figure out on your own or with my help - they were nice to offer us +support, but we should not abuse it. + +If you are working on 3.23 MySQL source, please make sure to convert to bk ASAP +before you do any further developement - otherwise, things will get +exponentially worse as the code mass increases. I will work on mysql-4.0 next +and try to set it up so that when we update 3.23 source tree, the update makes +it to mysql-4.0. diff --git a/Docs/internals.texi b/Docs/internals.texi index 5676fcd2bb5..532a1ebe53d 100644 --- a/Docs/internals.texi +++ b/Docs/internals.texi @@ -143,6 +143,65 @@ same tables. and then we read the rows in the sorted order into a row buffer (record_buffer) . +@node Coding guidelines +@chapter Coding guidelines + +- We are using bitkeeper (www.bitkeeper.com) for source management. +- You should use the MySQL 3.23 or MySQL 4.0 source for all developments. +- If you have any questions about the MySQL source, you can post these + to developers@mysql.com and we will answer them. + Note that we will shortly change the name of this list to + internals@mysql.com, to more accurately reflect what should be + posted to this list. + +- Try to write code in a lot of black boxes that can be reused or at + least have a clean interface +- Reuse code; There is already in MySQL a lot of algorithms for list handling, + queues, dynamic and hashed arrays, sorting...) that can be reused. +- Try to always write optimized code, so that you don't have to + go back and rewrite it a couple of months later. It's better to + spend 3 times as much time designing and writing and optimal function than + having to do it all over again later on. +- Avoid CPU wasteful code, even where it does not matter, so that + you will not develop sloppy coding habits. +- If you can write it in fewer lines, do it (as long as the code will not + be slower or much harder to read) +- do not check the same pointer for NULL more than once. +- Use long function and variable names in English; This makes your + code easier to read. +- Think assembly - make it easier for the compiler to optimize your code. +- Comment your code when you do something that someone else may think + is 'not trivial'. +- Use the my_ functions like my_read/my_write/my_malloc() that you can + find in the mysys library instead of the direct system calls; This + will make your code easier to debug and more portable. +- use libstring functions instead of standard libc string functions + whenever possible +- Avoid using alloc (its REAL slow); For memory allocations that only + needs to live for the lifetime of one thread, on should use + sql_alloc() instead. +- Before doing big design decision, please first post a summary of + what you want to do, why you want to do it and how you plan to do + it. This way we can easily provide you with feedback and also + easily discuss is throughly if some other developer thinks there is better + way to do the same thing! + +- Use my_var as opposed to myVar or MyVar ( _ rather than dancing SHIFT + to spearate words in identifiers) +- class names start with a capital +- structure types are typedefed to all caps identifier +- #defines are capitalized +- matching { are in the same column + - functions return 0 on success , non-zero on error, so you can do + if(a() || b() || c()) { error("something went wrong");} +- goto is ok if not abused +- avoid default variable initalizations, use LINT_INIT() if the + compiler complains after making sure that there is really no way + the variable can be used uninitialized +- Do not instantiate a class if you do not have to +- Use pointers rather than array indexing when operating on strings + + @node Index @unnumbered Index diff --git a/Docs/manual.texi b/Docs/manual.texi index 33703ba763a..6a2c05654e7 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -178,9 +178,9 @@ Installing MySQL * MIT-pthreads:: MIT-pthreads notes * Perl support:: Perl installation comments * Source install system issues:: System-specific issues -* Win32:: Win32 notes +* Windows:: Windows notes * OS/2:: OS/2 notes -* MySQL binaries:: +* MySQL binaries:: * Post-installation:: Post-installation setup and testing * Upgrade:: Is there anything special to do when upgrading/downgrading @strong{MySQL}? @@ -204,8 +204,8 @@ Installing a MySQL source distribution Perl installation comments * Perl installation:: Installing Perl on Unix -* ActiveState Perl:: Installing ActiveState Perl on Win32 -* Win32 Perl:: Installing the @strong{MySQL} Perl distribution on Win32 +* ActiveState Perl:: Installing ActiveState Perl on Windows +* Windows Perl:: Installing the @strong{MySQL} Perl distribution on Windows * Perl support problems:: Problems using the Perl @code{DBI}/@code{DBD} interface System-specific issues @@ -238,7 +238,7 @@ Linux notes (all Linux versions) * Linux-Alpha:: Linux-Alpha notes * MKLinux:: MkLinux notes * Qube2:: Qube2 Linux notes -* Linux-Ia64:: +* Linux-Ia64:: BSD/OS notes @@ -246,16 +246,16 @@ BSD/OS notes * BSDI3:: BSD/OS 3.x notes * BSDI4:: BSD/OS 4.x notes -Win32 notes +Windows notes -* Win32 installation:: Installing @strong{MySQL} on Win32 +* Windows installation:: Installing @strong{MySQL} on Windows * Win95 start:: Starting @strong{MySQL} on Win95 / Win98 * NT start:: Starting @strong{MySQL} on NT / Win2000 -* Win32 running:: Running @strong{MySQL} on Win32 -* Win32 and SSH:: Connecting to a remote @strong{MySQL} from Win32 with SSH -* Win32 symbolic links:: Splitting data across different disks under Win32 -* Win32 compiling:: -* Win32 vs Unix:: @strong{MySQL}-Win32 compared to Unix @strong{MySQL} +* Windows running:: Running @strong{MySQL} on Windows +* Windows and SSH:: Connecting to a remote @strong{MySQL} from Windows with SSH +* Windows symbolic links:: Splitting data across different disks under Win32 +* Windows compiling:: Compiling MySQL clients on Windows. +* Windows vs Unix:: @strong{MySQL}-Windows compared to Unix @strong{MySQL} Post-installation setup and testing @@ -275,7 +275,7 @@ Is there anything special to do when upgrading/downgrading MySQL? How standards-compatible is MySQL? * Extensions to ANSI:: @strong{MySQL} extensions to ANSI SQL92 -* Ansi mode:: Running @strong{MySQL} in ANSI mode +* Ansi mode:: Runnning @strong{MySQL} in ANSI mode * Differences from ANSI:: @strong{MySQL} differences compared to ANSI SQL92 * Missing functions:: Functionality missing from @strong{MySQL} * Standards:: What standards does @strong{MySQL} follow? @@ -337,7 +337,7 @@ MySQL language reference * LOAD DATA:: @code{LOAD DATA INFILE} syntax * UPDATE:: @code{UPDATE} syntax * USE:: @code{USE} syntax -* FLUSH:: @code{FLUSH} syntax (clearing caches) +* FLUSH:: @code{Flush} syntax (clearing caches) * KILL:: @code{KILL} syntax * SHOW:: @code{SHOW} syntax (Get information about tables, columns, ...) * EXPLAIN:: @code{EXPLAIN} syntax (Get information about a @code{SELECT}) @@ -411,13 +411,13 @@ Functions for use in @code{SELECT} and @code{WHERE} clauses @code{SHOW} syntax (Get information about tables, columns,...) -* SHOW DATABASE INFO:: -* SHOW TABLE STATUS:: -* SHOW STATUS:: -* SHOW VARIABLES:: -* SHOW PROCESSLIST:: -* SHOW GRANTS:: -* SHOW CREATE TABLE:: +* SHOW DATABASE INFO:: +* SHOW TABLE STATUS:: +* SHOW STATUS:: +* SHOW VARIABLES:: +* SHOW PROCESSLIST:: +* SHOW GRANTS:: +* SHOW CREATE TABLE:: MySQL table types @@ -567,10 +567,10 @@ Using @code{myisamchk} for table maintenance and crash recovery @code{myisamchk} invocation syntax -* myisamchk general options:: -* myisamchk check options:: -* myisamchk repair options:: -* myisamchk other options:: +* myisamchk general options:: +* myisamchk check options:: +* myisamchk repair options:: +* myisamchk other options:: Using @code{myisamchk} for crash recovery @@ -641,17 +641,19 @@ Some common errors when using MySQL * Too many connections:: @code{Too many connections} error * Out of memory:: @code{Out of memory} error * Packet too large:: @code{Packet too large} error -* Communication errors:: +* Communication errors:: Communication errors / Aborted connection * Full table:: @code{The table is full} error +* Cannot create:: * Commands out of sync:: @code{Commands out of sync} error in client * Ignoring user:: @code{Ignoring user} error * Cannot find table:: @code{Table 'xxx' doesn't exist} error Solving some common problems with MySQL -* Log Replication:: Database replication with update log +* Log Replication:: Database replication with update log * Backup:: Database backups * Update log:: The update log +* Slow query log:: * Multiple servers:: Running multiple @strong{MySQL} servers on the same machine MySQL client tools and APIs @@ -752,6 +754,7 @@ How MySQL compares to @code{mSQL} MySQL internals * MySQL threads:: MySQL threads +* MySQL full-text search:: MySQL full-text search MySQL change history @@ -761,7 +764,7 @@ MySQL change history * News-3.20.x:: Changes in release 3.20.x * News-3.19.x:: Changes in release 3.19.x -Changes in release 3.23.x (Released as beta) +Changes in release 3.23.x (Recommended; beta) * News-3.23.23:: Changes in release 3.23.23 * News-3.23.22:: Changes in release 3.23.22 @@ -899,7 +902,7 @@ Comments on porting to other systems * Debugging server:: Debugging a @strong{MySQL} server * Debugging client:: Debugging a @strong{MySQL} client * The DBUG package:: The DBUG package -* Locking methods:: +* Locking methods:: * RTS-threads:: Comments about RTS threads * Thread packages:: Differences between different thread packages @@ -1464,7 +1467,7 @@ which allows host-based verification. Passwords are secure because all password traffic when connecting to a server is encrypted. @item -ODBC (Open-DataBase-Connectivity) support for Windows95 (with source). All +ODBC (Open-DataBase-Connectivity) support for Win32 (with source). All ODBC 2.5 functions and many others. For example, you can use MS Access to connect to your @strong{MySQL} server. @xref{ODBC}. @@ -1551,7 +1554,7 @@ languages. @xref{Languages}. @item Clients may connect to the @strong{MySQL} server using TCP/IP Sockets, -Unix Sockets (Unixes), or Named Pipes (Windows NT). +Unix Sockets (Unixes), or Named Pipes (NT). @item The @strong{MySQL}-specific @code{SHOW} command can be used to retrieve @@ -1923,8 +1926,8 @@ organization. @uref{http://www.penguinpowered.com/~kmysql, KMySQL} KMySQL is a database client for KDE that primarily supports @strong{MySQL}. @item -@uref{http://www.ecker-software.de, Win32 GUI client} -A Win32 GUI client by David Ecker. +@uref{http://www.ecker-software.de, Windows GUI client} +A Windows GUI client by David Ecker. @item @uref{http://www.icaap.org/software/kiosk/, Kiosk; a @strong{MySQL} client for database management}. Written in Perl. Will be a part of Bazaar. @@ -2381,7 +2384,7 @@ A digest version of the @code{java} list. @item win32 All things concerning @strong{MySQL} on Microsoft operating systems such as -Windows NT. +Win95, Win98, NT and Win2000. @item win32-digest A digest version of the @code{win32} list. @@ -3357,9 +3360,9 @@ encounter per year, but we are as always very flexible towards our customers! * MIT-pthreads:: MIT-pthreads notes * Perl support:: Perl installation comments * Source install system issues:: System-specific issues -* Win32:: Win32 notes +* Windows:: Windows notes * OS/2:: OS/2 notes -* MySQL binaries:: +* MySQL binaries:: * Post-installation:: Post-installation setup and testing * Upgrade:: Is there anything special to do when upgrading/downgrading @strong{MySQL}? @end menu @@ -4013,7 +4016,7 @@ SCO UnixWare 7.0.1. @xref{SCO Unixware}. @item Tru64 Unix @item -Win95, Win98, NT and Win2000. @xref{Win32}. +Win95, Win98, NT and Win2000. @xref{Windows}. @end itemize @cindex @strong{MySQL} binary distribution @@ -4583,6 +4586,25 @@ stable compiler available. @strong{MySQL} Perl support requires Perl 5.004_03 or newer. +On some Linux 2.2 versions, you may get the error @code{Resource +temporarily unavailable} when you do a lot of new connections to a +@code{mysqld} server over TCP/IP. + +The problem is that Linux has a delay between when you close a TCP/IP +socket and until this is actually freed by the system. As there is only +room for a finite number of TCP/IP slots you will get the above error if +you try to do too many new TCP/IP connections during a small time, like +when you run the @strong{MySQL} @file{test-connect} benchmark over +TCP/IP. + +We have mailed about this problem a couple of times to different Linux +mailing lists but have never been able to resolve this properly :( + +The only known 'fix' to this problem is to use persistent connections in +your clients or use sockets, if you are running the database server +and clients on the same machine. We hope that the @code{Linux 2.4} +kernel will fix this problem in the future. + @node Binary notes-HP-UX, , Binary notes-Linux, Binary install system issues @subsubsection HP-UX notes @@ -5333,8 +5355,8 @@ needed, but may be interesting for someone.) @menu * Perl installation:: Installing Perl on Unix -* ActiveState Perl:: Installing ActiveState Perl on Win32 -* Win32 Perl:: Installing the @strong{MySQL} Perl distribution on Win32 +* ActiveState Perl:: Installing ActiveState Perl on Windows +* Windows Perl:: Installing the @strong{MySQL} Perl distribution on Windows * Perl support problems:: Problems using the Perl @code{DBI}/@code{DBD} interface @end menu @@ -5408,11 +5430,11 @@ you: Look under the heading @code{Installing New Modules that Require Locally Installed Modules}. -@node ActiveState Perl, Win32 Perl, Perl installation, Perl support -@subsection Installing ActiveState Perl on Win32 +@node ActiveState Perl, Windows Perl, Perl installation, Perl support +@subsection Installing ActiveState Perl on Windows To install the @strong{MySQL} @code{DBD} module with ActiveState Perl on -Win32, you should do the following: +Windows, you should do the following: @itemize @bullet @item Open a DOS shell. @@ -5435,23 +5457,23 @@ $dbh= DBI->connect("DBI:ODBC:$dsn","$user","$password") || die "Got error $DBI::errstr when connecting to $dsn\n"; @end example -@node Win32 Perl, Perl support problems, ActiveState Perl, Perl support -@subsection Installing the MySQL Perl distribution on Win32 +@node Windows Perl, Perl support problems, ActiveState Perl, Perl support +@subsection Installing the MySQL Perl distribution on Windows The @strong{MySQL} Perl distribution contains @code{DBI}, @code{DBD:MySQL} and @code{DBD:ODBC}. @itemize @bullet -@item Get the Perl distribution for Win32 from +@item Get the Perl distribution for Windows from @uref{http://www.mysql.com/download.html}. @item Unzip the distribution in @code{C:} so that you get a @file{C:\PERL} directory. @item Add the directory @file{C:\PERL\BIN} to your path. -@item Add the directory @file{C:\PERL\BIN\MSWin32-x86-thread} or -@file{C:\PERL\BIN\MSWin32-x86} to your path. +@item Add the directory @file{C:\PERL\BIN\MSWIN32-x86-thread} or +@file{C:\PERL\BIN\MSWIN32-x86} to your path. @item Test that @code{perl} works by executing @code{perl -v} in a DOS shell. @end itemize -@node Perl support problems, , Win32 Perl, Perl support +@node Perl support problems, , Windows Perl, Perl support @subsection Problems using the Perl @code{DBI}/@code{DBD} interface If Perl reports that it can't find the @code{../mysql/mysql.so} module, @@ -5562,7 +5584,7 @@ shell> make perl Finally, you should install this new Perl. Again, the output of @code{make perl} indicates the command to use. -@node Source install system issues, Win32, Perl support, Installing +@node Source install system issues, Windows, Perl support, Installing @section System-specific issues The following sections indicate some of the issues that have been observed to @@ -5875,9 +5897,9 @@ of function} warnings. These may be ignored. @node Linux, Alpha-DEC-Unix, SunOS, Source install system issues @subsection Linux notes (all Linux versions) -@strong{MySQL} uses LinuxThreads on Linux. If you are using an old Linux -version that doesn't have @code{glibc2}, you must install LinuxThreads before -trying to compile +@strong{MySQL} uses LinuxThreads on Linux. If you are using an old +Linux version that doesn't have @code{glibc2}, you must install +LinuxThreads before trying to compile @strong{MySQL}. @uref{http://www.mysql.com/Downloads/Linux} Note that @code{glibc} versions before and including 2.1.1 has a fatal @@ -5948,6 +5970,11 @@ If you see a dead @code{mysqld} daemon process with @code{ps}, this usually means that you have found a bug in @strong{MySQL} or you have got a corrupted table. @xref{Crashing}. +If you want to get a core dump on Linux if mysqld dies with a SIGSEGV +signal, you can start mysqld with the @code{--core-file} option. Note +that you also probably need to raise the @code{core file size} with +@code{ulimit}! + If you are using LinuxThreads and @code{mysqladmin shutdown} doesn't work, you must upgrade to LinuxThreads 0.7.1 or newer. @@ -6007,7 +6034,7 @@ CC=fcc CFLAGS="-O -K fast -K lib -K omitfp -Kpreex -D_GNU_SOURCE -DCONST=const - * Linux-Alpha:: Linux-Alpha notes * MKLinux:: MkLinux notes * Qube2:: Qube2 Linux notes -* Linux-Ia64:: +* Linux-Ia64:: @end menu @node Linux-x86, Linux-RedHat50, Linux, Linux @@ -6144,6 +6171,10 @@ until you have installed @code{glibc} 2.0.7-19 from source! You can check which version of @code{glibc} you have with @code{rpm -q glibc}. +Another reason for the above error is if you try to use more threads +than your Linux kernel is configured for. In this case you should rise +the limits in @file{include/linux/tasks.h} and recompile your kernel! + @node Linux-SPARC, Linux-Alpha, Linux-RedHat51, Linux @subsubsection Linux-SPARC notes @@ -7025,26 +7056,26 @@ alias mysql '/usr/local/mysql/bin/mysql' alias mysqladmin '/usr/local/mysql/libexec/mysqladmin' @end example -@node Win32, OS/2, Source install system issues, Installing -@section Win32 notes +@node Windows, OS/2, Source install system issues, Installing +@section Windows notes -This section describes installation and use of @strong{MySQL} on Win32. This +This section describes installation and use of @strong{MySQL} on Windows. This is also described in the @file{README} file that comes with the -@strong{MySQL} Win32 distribution. +@strong{MySQL} Windows distribution. @menu -* Win32 installation:: Installing @strong{MySQL} on Win32 +* Windows installation:: Installing @strong{MySQL} on Windows * Win95 start:: Starting @strong{MySQL} on Win95 / Win98 * NT start:: Starting @strong{MySQL} on NT / Win2000 -* Win32 running:: Running @strong{MySQL} on Win32 -* Win32 and SSH:: Connecting to a remote @strong{MySQL} from Win32 with SSH -* Win32 symbolic links:: Splitting data across different disks under Win32 -* Win32 compiling:: -* Win32 vs Unix:: @strong{MySQL}-Win32 compared to Unix @strong{MySQL} +* Windows running:: Running @strong{MySQL} on Windows +* Windows and SSH:: Connecting to a remote @strong{MySQL} from Windows with SSH +* Windows symbolic links:: Splitting data across different disks under Win32 +* Windows compiling:: Compiling MySQL clients on Windows. +* Windows vs Unix:: @strong{MySQL}-Windows compared to Unix @strong{MySQL} @end menu -@node Win32 installation, Win95 start, Win32, Win32 -@subsection Installing MySQL on Win32 +@node Windows installation, Win95 start, Windows, Windows +@subsection Installing MySQL on Windows If you don't have a registered version of @strong{MySQL}, you should first download the shareware version from: @@ -7058,7 +7089,7 @@ probably also need the @strong{MyODBC} driver. You can find this at the To install either distribution, unzip it in some empty directory and run the @code{Setup.exe} program. -By default, @strong{MySQL}-Win32 is configured to be installed in +By default, @strong{MySQL}-Windows is configured to be installed in @file{C:\mysql}. If you want to install @strong{MySQL} elsewhere, install it in @file{C:\mysql}, then move the installation to where you want it. If you do move @strong{MySQL}, you must tell @code{mysqld} where everything is by @@ -7067,16 +7098,15 @@ display all options! For example, if you have moved the @strong{MySQL} distribution to @file{D:\programs\mysql}, you must start @code{mysqld} with: @code{D:\programs\mysql\bin\mysqld --basedir D:\programs\mysql} -With the registered version of @strong{MySQL}, you can also create a +With all newer @strong{MySQL} versions, you can also create a @file{C:\my.cnf} file that holds any default options for the @strong{MySQL} server. Copy the file @file{\mysql\my-xxxxx.cnf} to @file{C:\my.cnf} and edit this to suit your setup. Note that you should specify all paths with @code{/} instead of @code{\}. If you use @code{\}, you need to specify this twice, as @code{\} is the escape -character in @strong{MySQL}. -@xref{Option files}. +character in @strong{MySQL}. @xref{Option files}. -@node Win95 start, NT start, Win32 installation, Win32 +@node Win95 start, NT start, Windows installation, Windows @subsection Starting MySQL on Win95 / Win98 @strong{MySQL} uses TCP/IP to connect a client to a server. (This will @@ -7128,7 +7158,7 @@ that should contain the reason why @code{mysqld} doesn't start. If you make a bug report about this, please only send the lines where something seams to go wrong to the mailing list! -@node NT start, Win32 running, Win95 start, Win32 +@node NT start, Windows running, Win95 start, Windows @subsection Starting MySQL on NT / Win200 The Win95/Win98 section also applies to @strong{MySQL} on NT / Win2000, with @@ -7208,10 +7238,10 @@ C:\mysql\bin\mysqld --standalone --debug The last version gives you a debug trace in @file{C:\mysqld.trace}. -@node Win32 running, Win32 and SSH, NT start, Win32 -@subsection Running MySQL on Win32 +@node Windows running, Windows and SSH, NT start, Windows +@subsection Running MySQL on Windows -@strong{MySQL} supports TCP/IP on all Win32 platforms and named pipes on NT. +@strong{MySQL} supports TCP/IP on all Windows platforms and named pipes on NT. The default is to use named pipes for local connections on NT and TCP/IP for all other cases if the client has TCP/IP installed. The host name specifies which protocol is used: @@ -7248,7 +7278,7 @@ the @strong{MySQL} grant tables. You can also avoid DNS when connecting to a There are two versions of the @strong{MySQL} command line tool: @multitable @columnfractions .15 .85 -@item @code{mysql} @tab Compiled on native Win32, which offers very limited text +@item @code{mysql} @tab Compiled on native Windows, which offers very limited text editing capabilities. @item @code{mysqlc} @tab Compiled with the Cygnus GNU compiler and libraries, which offers @code{readline} editing. @end multitable @@ -7257,7 +7287,7 @@ If you want to use @code{mysqlc.exe}, you must copy @file{C:\mysql\lib\cygwinb19.dll} to @file{\windows\system} (or similar place). -The default privileges on Win32 give all local users full privileges +The default privileges on Windows give all local users full privileges to all databases. To make @strong{MySQL} more secure, you should set a password for all users and remove the row in the @code{mysql.user} table that has @code{Host='localhost'} and @@ -7293,8 +7323,8 @@ With the newer @strong{MySQL} versions you can easily add new users and change privileges with @code{GRANT} and @code{REVOKE} commands. @xref{GRANT}. -@node Win32 and SSH, Win32 symbolic links, Win32 running, Win32 -@subsection Connecting to a remote MySQL from Win32 with SSH +@node Windows and SSH, Windows symbolic links, Windows running, Windows +@subsection Connecting to a remote MySQL from Windows with SSH Here is a note about how to connect to get a secure connection to remote MySQL server with SSH (by David Carlson). @@ -7330,8 +7360,8 @@ usegroup! @findex Symbolic links @findex Using multiple disks to start data -@node Win32 symbolic links, Win32 compiling, Win32 and SSH, Win32 -@subsection Splitting data across different disks under Win32 +@node Windows symbolic links, Windows compiling, Windows and SSH, Windows +@subsection Splitting data across different disks under Windows On windows @strong{MySQL} 3.23.16 and above is compiled with the @code{-DUSE_SYMDIR} option. This allows you to put a database on @@ -7349,7 +7379,7 @@ should create the file @file{C:\mysql\data\foo.sym} that should contains the text @code{D:\data\foo}. After this, all tables created in the database @code{foo} will be created in @file{D:\data\foo}. -@node Win32 compiling, Win32 vs Unix, Win32 symbolic links, Win32 +@node Windows compiling, Windows vs Unix, Windows symbolic links, Windows @subsection Compiling MySQL clients on Windows. In your source files, you should include @file{windows.h} before you include @@ -7369,10 +7399,10 @@ with the static @file{mysqlclient.lib} library. Note that as the mysqlclient libraries are compiled as threaded libraries, you should also compile your code to be multi-threaded! -@node Win32 vs Unix, , Win32 compiling, Win32 -@subsection MySQL-Win32 compared to Unix MySQL +@node Windows vs Unix, , Windows compiling, Windows +@subsection MySQL-Windows compared to Unix MySQL -@strong{MySQL}-Win32 has by now proven itself to be very stable. This version +@strong{MySQL}-Windows has by now proven itself to be very stable. This version of @strong{MySQL} has the same features as the corresponding Unix version with the following exceptions: @@ -7414,21 +7444,23 @@ connections. We plan to fix this in the near future. @item UDF functions -For the moment, @strong{MySQL}-Win32 does not support user definable functions. +For the moment, @strong{MySQL}-Windows does not support user definable +functions. @item @code{DROP DATABASE} You can't drop a database that is in use by some thread. @item Killing @strong{MySQL} from the task manager You can't kill @strong{MySQL} from the task manager or with the shutdown -utility in Windows95. You must take it down with @code{mysqladmin shutdown}. +utility in Win95. You must take it down with @code{mysqladmin shutdown}. @item Case-insensitive names -Filenames are case insensitive on Win32, so database and table names -are also case insensitive in @strong{MySQL} for Win32. The only restriction is -that database and table names must be given in the same case throughout a -given statement. The following query would not work because it refers to -a table both as @code{my_table} and as @code{MY_TABLE}: +Filenames are case insensitive on Windows, so database and table names +are also case insensitive in @strong{MySQL} for Windows. The only +restriction is that database and table names must be given in the same +case throughout a given statement. The following query would not work +because it refers to a table both as @code{my_table} and as +@code{MY_TABLE}: @example SELECT * FROM my_table WHERE MY_TABLE.col=1; @end example @@ -7444,8 +7476,8 @@ SELECT * INTO OUTFILE 'C:/tmp/skr.txt' FROM skr; @end example @item @code{Can't open named pipe} error -If you use the shareware version of @strong{MySQL}-Win32 on NT with the -newest mysql-clients you will get the following error: +If you use an MySQL 3.22 version on NT with the newest mysql-clients you +will get the following error: @example error 2017: can't open named pipe to host: . pipe... @@ -7476,7 +7508,7 @@ following information: @end example @end table -Here are some open issues for anyone who might want to help us with the Win32 +Here are some open issues for anyone who might want to help us with the Windows release: @itemize @bullet @@ -7512,7 +7544,7 @@ It would be real nice to be able to kill @code{mysqld} from the task manager. For the moment, you must use @code{mysqladmin shutdown}. @item -Port @code{readline} to Win32 for use in the @code{mysql} command line tool. +Port @code{readline} to Windows for use in the @code{mysql} command line tool. @item GUI versions of the standard @strong{MySQL} clients (@code{mysql}, @@ -7521,18 +7553,18 @@ GUI versions of the standard @strong{MySQL} clients (@code{mysql}, @item It would be nice if the socket ``read'' and ``write'' functions in @file{net.c} were interruptible. This would make it possible to kill open -threads with @code{mysqladmin kill} on Win32. +threads with @code{mysqladmin kill} on Windows. @item Documentation of which Windows programs work with -@strong{MySQL}-Win32/@strong{MyODBC} and what must be done to get them working. +@strong{MySQL}-Windows/@strong{MyODBC} and what must be done to get them working. @item @code{mysqld} always starts in the "C" locale and not in the default locale. We would like to have @code{mysqld} use the current locale for the sort order. @item -Port @code{sqlclient} to Win32 (almost done) and add more features to it! +Port @code{sqlclient} to Windows (almost done) and add more features to it! @item Add more options to MysqlManager. @@ -7546,14 +7578,14 @@ Implement UDF functions with @code{.DLL}s. @item Add macros to use the faster thread-safe increment/decrement methods -provided by Win32. +provided by Windows. @end itemize -Other Win32-specific issues are described in the @file{README} file that comes -with the @strong{MySQL}-Win32 distribution. +Other Windows-specific issues are described in the @file{README} file that comes +with the @strong{MySQL}-Windows distribution. -@node OS/2, MySQL binaries, Win32, Installing +@node OS/2, MySQL binaries, Windows, Installing @section OS/2 notes @strong{MySQL} uses quite a few open files. Because of this, you @@ -8214,7 +8246,7 @@ C:\mysql\bin\mysqld --standalone --debug This will not run in the background and it should also write a trace in @file{\mysqld.trace}, which may help you determine the source of your -problems. @xref{Win32}. +problems. @xref{Windows}. @node Automatic start, Command-line options, Starting server, Post-installation @subsection Starting and stopping MySQL automatically @@ -8348,13 +8380,17 @@ Client error messages in given language. May be given as a full path. @item -l, --log[=file] Log connections and queries to file +@item --log-isam[=file] +Log all ISAM/MyISAM changes to file (only used when debugging ISAM/MyISAM). + +@item --log-slow-queries[=file] +Log all queries that has taken more than @code{long_query_time} to execute +to file. @xref{Slow query log}. + @item --log-update[=file] Log updates to @code{file.#} where @code{#} is a unique number if not given. @xref{Update log}. -@item --log-isam[=file] -Log all isam changes to file. - @item --log-long-format Log some extra information to update log. @@ -8488,7 +8524,7 @@ with @code{--datadir} when @code{mysqld} starts up! (@code{--datadir} has no effect on where the server looks for option files, because it looks for them before it processes any command-line arguments.) -@strong{MySQL} reads default options from the following files on Win32: +@strong{MySQL} reads default options from the following files on Windows: @multitable @columnfractions .3 .7 @item @strong{Filename} @tab @strong{Purpose} @@ -8497,7 +8533,7 @@ before it processes any command-line arguments.) @item @code{C:\mysql\data\my.cnf} @tab Server-specific options @end multitable -Note that you on Win32 should specify all paths with @code{/} instead of +Note that you on Windows should specify all paths with @code{/} instead of @code{\}. If you use @code{\}, you need to specify this twice, as @code{\} is the escape character in @strong{MySQL}. @@ -8665,9 +8701,14 @@ table to a @code{MyISAM} table with @code{ALTER TABLE} or the Perl script 3.22 and 3.21 clients will work without any problems with a 3.23 server. -The following lists what you have to watch out for when upgrading to 3.23: +The following lists tell what you have to watch out for when upgrading to 3.23: @itemize @bullet +@item @strong{MySQL} client 'mysql' now starts with option --no-named-commands +(-g) by default. This option can be disabled with --enable-named-commands +(-G). This may cause incompatibility problems in some cases, for example +in SQL scripts that use named commands without a semicolon, etc. ! +Long format commands still work from the first line. @item The default return type of @code{IF} will now depend on both arguments and not only the first argument. @item @code{AUTO_INCREMENT} will not work with negative numbers. @@ -11036,8 +11077,8 @@ Other privileges are denied. For example, normal users can't use @code{mysqladmin shutdown} or @code{mysqladmin processlist}. @end itemize -@strong{NOTE:} The default privileges are different for Win32. -@xref{Win32 running}. +@strong{NOTE:} The default privileges are different for Windows. +@xref{Windows running}. Because your installation is initially wide open, one of the first things you should do is specify a password for the @strong{MySQL} @@ -12001,10 +12042,10 @@ In @strong{MySQL}, databases and tables correspond to directories and files within those directories. Consequently, the case sensitivity of the underlying operating system determines the case sensitivity of database and table names. This means database and table names are case sensitive in Unix -and case insensitive in Win32. +and case insensitive in Windows. @strong{Note:} Although database and table names are case insensitive for -Win32, you should not refer to a given database or table using different +Windows, you should not refer to a given database or table using different cases within the same query. The following query would not work because it refers to a table both as @code{my_table} and as @code{MY_TABLE}: @@ -16848,7 +16889,7 @@ RENAME TABLE current_database.table_name TO other_database.table_name; @end example When you execute @code{RENAME}, you can't have any locked tables or -active transactions. You must also have the @code{ALTER TABLE} +active transactions. You must also have the @code{ALTER} and @code{DROP} privilege on the original table and @code{CREATE} and @code{INSERT} privilege on the new table. @@ -16893,6 +16934,10 @@ readable by other clients. Updates and writes to the table are stalled until the new table is ready. This is done in such a way that all updates are automatically redirected to the new table without any failed updates. +Currently @code{OPTIMIZE TABLE} is done by doing an @code{ALTER TABLE}, +but we will soon change this to use the @code{REPAIR} code, which will make +the repair much faster for @code{MyISAM} tables. + @findex CHECK TABLE @node CHECK TABLE, ANALYZE TABLE, OPTIMIZE TABLE, Reference @section @code{CHECK TABLE} syntax @@ -18325,13 +18370,13 @@ and @samp{_} wildcard characters. @findex SHOW INDEX @findex SHOW KEYS @menu -* SHOW DATABASE INFO:: -* SHOW TABLE STATUS:: -* SHOW STATUS:: -* SHOW VARIABLES:: -* SHOW PROCESSLIST:: -* SHOW GRANTS:: -* SHOW CREATE TABLE:: +* SHOW DATABASE INFO:: +* SHOW TABLE STATUS:: +* SHOW STATUS:: +* SHOW VARIABLES:: +* SHOW PROCESSLIST:: +* SHOW GRANTS:: +* SHOW CREATE TABLE:: @end menu @node SHOW DATABASE INFO, SHOW TABLE STATUS, SHOW, SHOW @@ -18515,7 +18560,7 @@ have.. @item @code{Opened_tables} @tab Number of tables that have been opened. @item @code{Questions} @tab Number of queries sent to the server. @item @code{Slow_launch_threads} @tab Number of threads that has taken more than @code{slow_launch_time} to connect. -@item @code{Slow_queries} @tab Number of queries that has taken more than @code{long_query_time} +@item @code{Slow_queries} @tab Number of queries that has taken more than @code{long_query_time}. @xref{Slow query log}. @item @code{Threads_cached} @tab Number of threads in the thread cache. @item @code{Threads_connected} @tab Number of currently open connections. @item @code{Threads_running} @tab Number of threads that are not sleeping. @@ -18745,7 +18790,8 @@ Change all table names to lower case on disk. @item @code{long_query_time} If a query takes longer than this (in seconds), the @code{Slow_queries} counter -will be incremented. +will be incremented. If you are using @code{--log-slow-queries}, the query +will be logged to the slow query logfile. @xref{Slow query log}. @item @code{max_allowed_packet} The maximum size of one packet. The message buffer is initialized to @@ -18901,7 +18947,7 @@ threads. Otherwise, you can see only your own threads. @xref{KILL, , @code{KILL}}. If you don't use the the @code{FULL} option, then only the first 100 characters of each query will be shown. -@node SHOW GRANTS,SHOW CREATE TABLE , SHOW PROCESSLIST, SHOW +@node SHOW GRANTS, SHOW CREATE TABLE, SHOW PROCESSLIST, SHOW @subsection SHOW GRANTS (privileges) for a user @code{SHOW GRANTS FOR user} lists the grant commands that must be issued to @@ -18916,7 +18962,7 @@ mysql> SHOW GRANTS FOR root@@localhost; +---------------------------------------------------------------------+ @end example -@node SHOW CREATE TABLE,,SHOW GRANTS, SHOW +@node SHOW CREATE TABLE, , SHOW GRANTS, SHOW @subsection SHOW CREATE TABLE Shows a @code{CREATE TABLE} statement that will create the given table @example @@ -23719,7 +23765,7 @@ if (1) On windows you can use internal symbolic links to directories by compiling @strong{MySQL} with @code{-DUSE_SYMDIR}. This allows you to put different -databases on different disks. @xref{Win32 symbolic links}. +databases on different disks. @xref{Windows symbolic links}. @cindex Startup parameters @node Server parameters, Table cache, Disk issues, System @@ -25516,19 +25562,33 @@ completion. This gives a quicker start of mysql. @item -B, --batch Print results with a tab as separator, each row on a new line. Doesn't use history file. +@item +--character-sets-dir=... +Directory where character sets are located. @item -C, --compress Use compression in server/client protocol. @item -#, --debug[=...] Debug log. Default is 'd:t:o,/tmp/mysql.trace' @item -D, --database=.. Database to use; This is mainly useful in the @code{my.cnf} file. +@item +--default-character-set=... Set the default character set. +@item +-G, --enable-named-commands +Named commands are enabled. Opposite to -g. @item -e, --execute=... Execute command and quit. (Output like with --batch) @item -E, --vertical Print the output of a query (rows) vertically. Without this option you can also force this output by ending your statements with @code{\G}. @item -f, --force -Continue even if we get a SQL error. +Continue even if we get an SQL error. +@item +-g, --no-named-commands +Named commands are disabled. Use \* form only, or use named commands +only in the beginning of a line ending with a semicolon (;) Since +version 10.9 the client now starts with this option ENABLED by default! +Disable with '-G'. Long format commands still work from the first line. @item -i, --ignore-space Ignore space after function names. @item -h, --host=... @@ -25566,9 +25626,8 @@ Be more silent. Socket file to use for connection. @item -t --table Output in table format. This is default in non-batch mode. -@item -T, --exit-info -Only used when debugging. --exit-info=0 will print some usage information -on exit. +@item -T, --debug-info +Print some debug info at exit. @item -u, --user=# User for login if not current user. @item -U, --safe-updates[=#], --i-am-a-dummy[=#] @@ -25696,7 +25755,7 @@ The @code{mysqladmin status} command result has the following columns: @item Uptime @tab Number of seconds the @strong{MySQL} server has been up. @item Threads @tab Number of active threads (clients). @item Questions @tab Number of questions from clients since @code{mysqld} was started. -@item Slow queries @tab Queries that have taken more than @code{long_query_time} seconds. +@item Slow queries @tab Queries that have taken more than @code{long_query_time} seconds. @xref{Slow query log}. @item Opens @tab How many tables @code{mysqld} has opened. @item Flush tables @tab Number of @code{flush ...}, @code{refresh} and @code{reload} commands. @item Open tables @tab Number of tables that are open now. @@ -26518,10 +26577,10 @@ shell> myisamchk /path/to/datadir/*/*.MYI @code{myisamchk} supports the following options: @menu -* myisamchk general options:: -* myisamchk check options:: -* myisamchk repair options:: -* myisamchk other options:: +* myisamchk general options:: +* myisamchk check options:: +* myisamchk repair options:: +* myisamchk other options:: @end menu @node myisamchk general options, myisamchk check options, myisamchk syntax, myisamchk syntax @@ -27442,8 +27501,9 @@ The above command does the following: @itemize @bullet @item -If standard logging (@code{--log}) is used, closes and reopens the log file. -(@file{mysql.log} as default). +If standard logging (@code{--log}) or slow query logging +@code{--log-slow-queries} is used, closes and reopens the log file. +(@file{mysql.log} and @file{mysql-slow.log} as default). @item If update logging (@code{--log-update}) is used, closes the update log and opens a new log file with a higher sequence number. @@ -28859,8 +28919,9 @@ sure that no other programs is using the dynamic libraries! * Too many connections:: @code{Too many connections} error * Out of memory:: @code{Out of memory} error * Packet too large:: @code{Packet too large} error -* Communication errors:: +* Communication errors:: Communication errors / Aborted connection * Full table:: @code{The table is full} error +* Cannot create:: * Commands out of sync:: @code{Commands out of sync} error in client * Ignoring user:: @code{Ignoring user} error * Cannot find table:: @code{Table 'xxx' doesn't exist} error @@ -29136,7 +29197,7 @@ properly only by replacing hardware @end itemize @cindex The table is full -@node Full table, Commands out of sync, Communication errors, Common errors +@node Full table, Cannot create, Communication errors, Common errors @subsection @code{The table is full} error This error occurs in older @strong{MySQL} versions when an in-memory temporary @@ -29153,8 +29214,31 @@ In @strong{MySQL} 3.23 in-memory temporary tables will automaticly be converted to a disk based @code{MyISAM} table after the table size gets bigger than @code{tmp_table_size}. +@cindex Can't create/write to file +@node Cannot create, Commands out of sync, Full table, Common errors +@subsection @code{Can't create/write to file} error. + +If you get an error for some queries of type: + +@example +Can't create/write to file '\\sqla3fe_0.ism'. +@end example + +this means that @strong{MySQL} can't create a temporary file for the +result set in the given temporary directory (the above error is a +typical error message on windows, the unix error message is similar) . +The fix is to start mysqld with @code{--tmpdir=path} or to add to your option +file: + +@example +[mysqld] +tmpdir=C:/temp +@end example + +assuming that the @file{c:\\temp} directory exists. @xref{Option files}. + @cindex Commands out of sync -@node Commands out of sync, Ignoring user, Full table, Common errors +@node Commands out of sync, Ignoring user, Cannot create, Common errors @subsection @code{Commands out of sync} error in client If you get @code{Commands out of sync; You can't run this command now} @@ -29215,7 +29299,7 @@ in the current database with the name @code{xxx}. Note that as @strong{MySQL} uses directories and files to store databases and tables, the database and table names are @strong{case sensitive}! -(On Win32 the databases and tables names are not case sensitive, but all +(On Windows the databases and tables names are not case sensitive, but all references to a given table within a query must use the same case!) You can check which tables you have in the current database with @@ -29881,6 +29965,7 @@ Drop or rename @code{old_table} * Log Replication:: Database replication with update log * Backup:: Database backups * Update log:: The update log +* Slow query log:: * Multiple servers:: Running multiple @strong{MySQL} servers on the same machine @end menu @@ -29986,7 +30071,7 @@ to be replaced with new ones when a new record duplicates an old record on a unique key value. @cindex Update log -@node Update log, Multiple servers, Backup, Common problems +@node Update log, Slow query log, Backup, Common problems @section The update log When started with the @code{--log-update[=file_name]} option, @@ -30040,6 +30125,20 @@ This can be useful if you have to revert to backup files after a crash and you want to redo the updates that occurred between the time of the backup and the crash. +@cindex Slow query log +@node Slow query log, Multiple servers, Update log, Common problems +@section The slow query log + +When started with the @code{--log-slow-queries[=file_name]} option, +@code{mysqld} writes a log file containing all SQL commands that took +more than @code{long_query_time} to execute. data. If no file name is +given, it defaults to the name of the host machine suffixed with +@code{-slow.log}. If file name is given, but it doesn't contain a path +the file is written in the data directory. + +The slow query log can be used to find queries that takes a long time to +execute and are thus candidates for optimization. + @cindex Database replication @cindex Replication, database @cindex Database mirroring @@ -30049,7 +30148,7 @@ another host and you want to replicate the changes that have been made to the master database. @xref{Log Replication}. @cindex Multiple servers -@node Multiple servers, , Update log, Common problems +@node Multiple servers, , Slow query log, Common problems @section Running multiple MySQL servers on the same machine There are circumstances when you might want to run multiple servers on the same @@ -30099,10 +30198,11 @@ by specifying them at runtime as options to @code{safe_mysqld}: shell> /path/to/safe_mysqld --socket=file_name --port=port_number @end example -If you run the new server on the same database directory as another server -with logging enabled, you should also specify the name of the log files -to @code{safe_mysqld} with @code{--log} and @code{--log-update}. Otherwise, -both servers may be trying to write to the same log file. +If you run the new server on the same database directory as another +server with logging enabled, you should also specify the name of the log +files to @code{safe_mysqld} with @code{--log}, @code{--log-update} or +@code{--log-slow-queries}. Otherwise, both servers may be trying to +write to the same log file. @strong{Warning}: Normally you should never have two servers that update data in the same database! If your OS doesn't support fault-free system @@ -30125,6 +30225,15 @@ In your C or Perl programs, you can give the port and socket arguments when connecting to the @strong{MySQL} server. @item +If your are using the @strong{MySQL} perl DBD module you can read the options +from the @strong{MySQL} option files. @xref{Option files}. + +@example +$dsn = "DBI:mysql:test;mysql_read_default_group=client;" +$dbh = DBI->connect($dsn, $user, $password); +@end example + +@item @tindex MYSQL_UNIX_PORT environment variable @tindex MYSQL_TCP_PORT environment variable @tindex Environment variable, MYSQL_UNIX_PORT @@ -32184,7 +32293,7 @@ example below. The value of @code{host} may be either a hostname or an IP address. If @code{host} is @code{NULL} or the string @code{"localhost"}, a connection to the local host is assumed. If the OS supports sockets (Unix) or named pipes -(Win32), they are used instead of TCP/IP to connect to the server. +(Windows), they are used instead of TCP/IP to connect to the server. @item The @code{user} parameter contains the user's @strong{MySQL} login ID. If @@ -32269,13 +32378,13 @@ use a very old client library to connect to a new server that wasn't started with the @code{--old-protocol} option. @item CR_NAMEDPIPEOPEN_ERROR; -Failed to create a named pipe on Win32. +Failed to create a named pipe on Windows. @item CR_NAMEDPIPEWAIT_ERROR; -Failed to wait for a named pipe on Win32. +Failed to wait for a named pipe on Windows. @item CR_NAMEDPIPESETSTATE_ERROR; -Failed to get a pipe handler on Win32. +Failed to get a pipe handler on Windows. @end table @subsubheading Example @@ -33464,10 +33573,12 @@ You can also find this at: @node Java, PHP, Eiffel, Clients @section MySQL Java connectivity (JDBC) -There are 2 supported JDBC drivers for @strong{MySQL} (the twz and mm driver). -You can find a copy of these at @uref{http://www.mysql.com/Downloads/Contrib/}. -For documentation consult any JDBC documentation and the -drivers own documentation for @strong{MySQL} specific features. +There are 2 supported JDBC drivers for @strong{MySQL} (the mm driver and +the Reisin JDBC driver). You can find a copy of the mm driver at +@uref{http://www.mysql.com/Downloads/Contrib/} and the Reisin driver at +@uref{http://www.caucho.com/projects/jdbc-mysql/index.xtp} For +documentation consult any JDBC documentation and the drivers own +documentation for @strong{MySQL} specific features. @node PHP, Cplusplus, Java, Clients @section MySQL PHP API @@ -33676,24 +33787,28 @@ of course.) some added features. @item JDBC (Java) -@strong{MySQL} currently has 4 JDBC drivers: +@strong{MySQL} currently has a lot of different JDBC drivers: @itemize @bullet @item +The mm driver: A type 4 JDBC driver by Mark Matthews +@email{mmatthew@@ecn.purdue.edu}. This is released under the LGPL. +@item +The Resin driver. This is a commercial JDBC driver released under open source. +@uref{http://www.caucho.com/projects/jdbc-mysql/index.xtp} +@item The gwe driver: A Java interface by GWE technologies (not supported anymore). @item The jms driver: An improved gwe driver by Xiaokun Kelvin ZHU -@email{X.Zhu@@brad.ac.uk}. +@email{X.Zhu@@brad.ac.uk} (not supported anymore). @item The twz driver: A type 4 JDBC driver by Terrence W. Zellers @email{zellert@@voicenet.com}. This is commercial but is free for private -and educational use. -@item -The mm driver: A type 4 JDBC driver by Mark Matthews -@email{mmatthew@@ecn.purdue.edu}. This is released under the GPL. +and educational use (not supported anymore). @end itemize -The recommended drivers are the twz or mm driver. Both are reported to work -excellently. +The recommended driver is the mm driver. The Resin driver may also be +good (at least the benchmarks looks good) but we haven't got that much +information about this yet. We know that @code{mSQL} has a JDBC driver, but we have too little experience with it to compare. @@ -34086,7 +34201,7 @@ started to read and apply updates from the master. @code{mysqladmin processlist} only shows the connection and @code{INSERT DELAYED} threads. -@node MySQL full-text search, , MySQL threads, MySQL internals +@node MySQL full-text search, , MySQL threads, MySQL internals @section MySQL full-text search Since version 3.23.23, @strong{MySQL} has support for full-text indexing @@ -34696,10 +34811,15 @@ The two drivers above have an LGPL license. Please check @uref{http://www.worldserver.com/mm.mysql/} for the latest drivers (and other JDBC information) because these drivers may be out of date. +@item @uref{http://www.caucho.com/projects/jdbc-mysql/index.xtp} +The Resin commercial JDBC driver which is released under open source. +It claims to be faster than the mm driver, but we haven't got that much +information about this yet. + @item @uref{http://www.mysql.com/Downloads/Contrib/twz1jdbcForMysql-1.0.4-GA.tar.gz, twz1jdbcForMysql-1.0.4-GA.tar.gz} The twz driver: A type 4 JDBC driver by Terrence W. Zellers @email{zellert@@voicenet.com}. This is commercial but is free for -private and educational use. +private and educational use. (not supported anymore) @c no answer from server 990830 @c You can always find the latest driver at @uref{http://www.voicenet.com/~zellert/tjFM/}. @item @@ -34824,7 +34944,7 @@ You can always find the latest version @uref{http://www.trash.net/~ffischer/admin/index.html, here}. @item @uref{http://www.mysql.com/Downloads/Contrib/mysqlwinadmn.zip, mysqlwinadmn.zip} -Win32 GUI (binary only) to administrate a database, by David B. Mansel, +Windows GUI (binary only) to administrate a database, by David B. Mansel, @email{david@@zhadum.org}. @item @uref{http://www.mysql.com/Downloads/Contrib/netadmin.zip, netadmin.zip} @@ -34838,12 +34958,12 @@ have still some bugs. you can test the program with all features. Please send bugs and hints to Marco Suess @email{ms@@it-netservice.de}. Original URL @url{http://www.it-netservice.de/pages/software/index.html}. -@item @uref{http://www.mysql.com/Downloads/Win32/ARTADMIN201.EXE,Atronic's @strong{MySQL} client for Win32 2.0.1.0}. +@item @uref{http://www.mysql.com/Downloads/Win32/ARTADMIN203.EXE,Atronic's @strong{MySQL} client for Windows 2.0.3.0}. Home page for this can be found at: @uref{http://www.artronic.hr}. @item @uref{http://www.mysql.com/Downloads/Win32/W9xstop.zip,Utility from Artronic to stop MySQL on win9x} @item @uref{http://dbtools.vila.bol.com.br/, Dbtools} -A tool to manage @strong{MySQL} databases. Currently only for Win32. +A tool to manage @strong{MySQL} databases. Currently only for Windows. Some features: @itemize @bullet @item manage servers, databases, tables, columns, indexes and users @@ -34913,7 +35033,12 @@ A PHP3 tool in the spirit of mysql-webadmin, by Tobias Ratschiller, tobias@@dnet @item @uref{http://www.mysql.com/Downloads/Contrib/useradm.tar.gz, useradm.tar.gz} @strong{MySQL} administrator in PHP. By Ofni Thomas @email{othomas@@vaidsystems.com}. + +@item @uref{http://gossamer-threads.com/perl/mysqlman/mysql.cgi, MySQLMan} +Similar functionality as phpmyadmin, but written with perl and using +html templates. By Alex Krohn. @end itemize + @item @uref{http://www.mysql.com/Downloads/Contrib/mysql-editor.tar.gz,mysql-editor.tar.gz} This cgi scripts in Perl enables you to edit content of Mysql database. By Tomas Zeman. @@ -34948,10 +35073,10 @@ programming! By Marc Beneteau, @email{marc@@odbsoft.com}. @item @uref{http://www.mysql.com/Downloads/Contrib/sqlhtml.tar.gz, sqlhtml.tar.gz} SQL/HTML is an HTML database manager for @strong{MySQL} using @code{DBI} 1.06. -@item @uref{http://www.mysql.com/Downloads/Contrib/udmsearch-2.2.1b.tar.gz, UdmSearch 2.2.1b (stable version)} -@item @uref{http://www.mysql.com/Downloads/Contrib/udmsearch-3.0.5.tar.gz, UdmSearch 3.0.5 (development version)} +@item @uref{http://www.mysql.com/Downloads/Contrib/udmsearch-3.0.21.tar.gz, UdmSearch 3.0.21 (stable version)} +@item @uref{http://www.mysql.com/Downloads/Contrib/udmsearch-3.1.3.tar.gz, UdmSearch 3.1.3 (development version)} @item @uref{http://mysearch.udm.net, UdmSearch home page} -A @strong{MySQL}- and PHP- based search engine over HTTP. By +A SQL-based search engine for Internet. By Alexander I. Barkov @email{bar@@izhcom.ru}. @item @uref{http://www.mysql.com/Downloads/Contrib/wmtcl.doc, wmtcl.doc} @@ -35057,7 +35182,7 @@ Boekhold, @email{boekhold@@cindy.et.tudelft.nl}, and Michael Widenius. This converter can't handle MEMO fields. @item @uref{http://www.mysql.com/Downloads/Contrib/dbf2mysql.zip, dbf2mysql.zip} -Convert between FoxPro @file{.dbf} files and @strong{MySQL} tables on Win32. +Convert between FoxPro @file{.dbf} files and @strong{MySQL} tables on Windows. By Alexander Eltsyn, @email{ae@@nica.ru} or @email{ae@@usa.net}. @item @uref{http://www.mysql.com/Downloads/Contrib/dump2h-1.20.gz, dump2h-1.20.gz} @@ -35576,6 +35701,31 @@ though, so 3.23 is not released as a stable version yet. @appendixsubsec Changes in release 3.23.23 @itemize @bullet @item +Added option @code{--core-file} to @code{mysqld} to get a core file on +Linux if mysqld dies on the SIGSEGV signal +@item +@strong{MySQL} client 'mysql' now starts with option --no-named-commands +(-g) by default. This option can be disabled with --enable-named-commands +(-G). This may cause incompatibility problems in some cases, for example +in SQL scripts that use named commands without a semicolon, etc. ! +Long format commands still work from the first line. +@item +Fixed a problem when using many pending @code{DROP TABLE} statement at +the same time. +@item +Optimizer didn't use keys properly when using @code{LEFT JOIN} on an +empty table. +@item +Added shorter help text when invoking @code{mysqld} with wrong options. +@item +Fixed not fatal @code{free()} bug in mysqlimport. +@item +Fixed bug in @code{MyISAM} index handling of +@code{DECIMAL}/@code{NUMERIC} keys. +@item +Fixed a bug in concurrent insert in @code{MyISAM} tables; In some context +usage of @code{MIN(key_part)} or @code{MAX(key_part)} returned an empty set. +@item Updated mysqlhotcopy to use the new @code{FLUSH TABLES table_list} syntax. Only tables which are being backed up are flushed now. @item @@ -35611,6 +35761,8 @@ that don't have the @code{pthread_rwlock_rdlock} code. When deleting rows with a non-unique key in a HEAP table, all rows weren't always deleted. @item +Fixed bug in range optimizer for HEAP tables when one did search on part index. +@item Fixed that @code{SELECT} on part keys works with BDB tables. @item Fixed that @code{INSERT INTO bdb_table ... SELECT} works with BDB tables. @@ -35825,7 +35977,7 @@ Fixed that @code{USE INDEX} works with @code{PRIMARY} keys. @item Added @code{BEGIN} statement to start a transaction in @code{AUTOCOMMIT} mode. @item -Added symbolic links support for Win32. +Added symbolic links support for Windows. @item Changed protocol to let client know if the server is in AUTOCOMMIT mode and if there is a pending transaction. If there is a pending transaction @@ -36570,7 +36722,8 @@ in scientific notation (1.0 E+10) when retrieved. @code{REPLACE} is now faster than before. @item Changed @code{LIKE} character comparison to behave as @code{=}; -This means that @code{'e' LIKE '@'e'} is now true. +This means that @code{'e' LIKE '@'e'} (if the line doesn't display +correctly, the latter 'e' means a French 'e' with a dot above) is now true. @item @code{SHOW TABLE STATUS} returns a lot of information about the tables. @item @@ -36799,7 +36952,7 @@ packed indexes. @itemize @bullet @item -A few small fixes for the Win32 version. +A few small fixes for the Windows version. @end itemize @@ -36873,7 +37026,7 @@ Some configure issues to fix problems with big file system detection. @item Fixed problem when sorting on big blob columns. @item -@code{ROUND()} will now work on Win32. +@code{ROUND()} will now work on Windows. @end itemize @node News-3.22.26, News-3.22.25, News-3.22.27, News-3.22.x @@ -36924,7 +37077,7 @@ Fixed bug when using @code{LOCK TABLES table_name READ; FLUSH TABLES;} @item Applied some patches for HP-UX. @item -@code{isamchk} should now work on Win32. +@code{isamchk} should now work on Windows. @item Changed @file{configure} to not use big file handling on Linux as this crashes some RedHat 6.0 systems @@ -36976,10 +37129,10 @@ Added patches for DEC 3.2 and SCO. @item Fixed path-bug when installing @strong{MySQL} as a service on NT. @item -The @strong{MySQL}-Win32 version is now compiled with VC++ 6.0 instead of +The @strong{MySQL}-Windows version is now compiled with VC++ 6.0 instead of with VC++ 5.0. @item -New installation setup for @strong{MySQL}-Win32. +New installation setup for @strong{MySQL}-Windows. @end itemize @node News-3.22.21, News-3.22.20, News-3.22.22, News-3.22.x @@ -37040,7 +37193,7 @@ Fixes a fatal problem in 3.22.17 on Linux; After @code{shutdown} all threads didn't die properly. @item Added option @code{-O flush_time=#} to @code{mysqld}. This is mostly -useful on Win32 and tells how often @strong{MySQL} should close all +useful on Windows and tells how often @strong{MySQL} should close all unused tables and flush all updated tables to disk. @item Fixed problem that a @code{VARCHAR} column compared with @code{CHAR} column @@ -37137,14 +37290,14 @@ value in the update log. Fixed lock handler bug when one did @code{INSERT INTO TABLE ... SELECT ... GROUP BY}. @item -Added a patch for @code{localtime_r()} on Win32 so that it will not crash +Added a patch for @code{localtime_r()} on Windows so that it will not crash anymore if your date is > 2039, but instead will return a time of all zero. @item Names for user-defined functions are no longer case sensitive. @item Added escape of @code{^Z} (ASCII 26) to @code{\Z} as @code{^Z} doesn't -work with pipes on Win32. +work with pipes on Windows. @item @code{mysql_fix_privileges} adds a new column to the @code{mysql.func} to support aggregate UDF functions in future @strong{MySQL} releases. @@ -37163,8 +37316,8 @@ column didn't work. Updated @file{config.guess} to allow @strong{MySQL} to configure on UnixWare 7.0.x. @item -Changed the implementation of @code{pthread_cond()} on the Win32 version. -@code{get_lock()} now correctly times out on Win32! +Changed the implementation of @code{pthread_cond()} on the Windows version. +@code{get_lock()} now correctly times out on Windows! @end itemize @node News-3.22.12, News-3.22.11, News-3.22.13, News-3.22.x @@ -37335,7 +37488,7 @@ Added @code{ESCAPE} option to @code{LIKE}. @item Added a lot more output to @code{mysqladmin debug}. @item -You can now start @code{mysqld} on Win32 with the @code{--flush} option. +You can now start @code{mysqld} on Windows with the @code{--flush} option. This will flush all tables to disk after each update. This makes things much safer on NT/Win98 but also @strong{MUCH} slower. @end itemize @@ -37366,7 +37519,7 @@ Fixed a big problem with @code{OPTIMIZE TABLE}. @strong{MySQL} clients on NT will now by default first try to connect with named pipes and after this with TCP/IP. @item -Fixed a problem with @code{DROP TABLE} and @code{mysqladmin shutdown} on Win32 +Fixed a problem with @code{DROP TABLE} and @code{mysqladmin shutdown} on Windows (a fatal bug from 3.22.6). @item Fixed problems with @code{TIME columns} and negative strings. @@ -37594,14 +37747,14 @@ delete rows from the table. Added optimization to remove const reference tables from @code{ORDER BY} and @code{GROUP BY}. @item -@code{mysqld} now automatically disables system locking on Linux and Win32, +@code{mysqld} now automatically disables system locking on Linux and Windows, and for systems that use MIT-pthreads. You can force the use of locking with the @code{--enable-locking} option. @item Added @code{--console} option to @code{mysqld}, to force a console window -(for error messages) when using Win32. +(for error messages) when using Windows. @item -Fixed table locks for Win32. +Fixed table locks for Windows. @item Allow @samp{$} in identifiers. @item @@ -38140,10 +38293,10 @@ A lot of small changes to the binary releases. @item Fixed a bug in the new protocol from @strong{MySQL} 3.21.20. @item -Changed @code{ALTER TABLE} to work with Win32 (Win32 can't rename open files). -Also fixed a couple of small bugs in the Win32 version. +Changed @code{ALTER TABLE} to work with Windows (Windows can't rename +open files). Also fixed a couple of small bugs in the Windows version. @item -All standard @strong{MySQL} clients are now ported to @strong{MySQL}-Win32. +All standard @strong{MySQL} clients are now ported to @strong{MySQL}-Windows. @item @strong{MySQL} can now be started as a service on NT. @end itemize @@ -39853,7 +40006,13 @@ should be implemented. @item Add support for UNICODE. @item -@code{NATURAL JOIN}. +@code{NATURAL JOIN} and @code{UNION JOIN} +@item +Allow @code{select a from crash_me left join crash_me2 using (a)}; In this +case a is assumed to come from the crash_me table. +@item +Fix that @code{ON} and @code{USING} works with the @code{JOIN} and +@code{INNER JOIN} join types. @item Oracle like @code{CONNECT BY PRIOR ...} to search hierarchy structures. @item @@ -39864,6 +40023,8 @@ added to @code{mysqld} @item Processlist should show number of queries/thread. @item +@code{SHOW HOSTS} for printing information about the hostname cache. +@item @code{DELETE} and @code{REPLACE} options to the @code{UPDATE} statement (this will delete rows when one gets a dupplicate key error while updating). @item @@ -39883,9 +40044,6 @@ one (The GNU library should be much faster than the old one). Change that @code{ALTER TABLE} doesn't abort clients that executes @code{INSERT DELAYED}. @item -Allow @code{select a from crash_me left join crash_me2 using (a)}; In this -case a is assumed to come from the crash_me table. -@item Fix that when columns referenced in an @code{UPDATE} clause contains the old values before the update started. @item @@ -39909,6 +40067,14 @@ Add @code{ANY()},@code{EVERY()} and @code{SOME()} group functions. In ANSI SQL these only works on boolean columns, but we can extend these to work on any columns/expressions by applying: value == 0 -> FALSE and value <> 0 -> TRUE. +@item +Fix that the type for @code{MAX(column)} is the same as the column type. +@example +create table t1 (a DATE); +insert into t1 values (now()); +create table t2 select max(a) from t1; +show columns from t2; +@end example @end itemize @node TODO sometime, TODO unplanned, TODO future, TODO @@ -40093,7 +40259,7 @@ will ensure that your thread installation has even a remote chance to work! * Debugging server:: Debugging a @strong{MySQL} server * Debugging client:: Debugging a @strong{MySQL} client * The DBUG package:: The DBUG package -* Locking methods:: +* Locking methods:: * RTS-threads:: Comments about RTS threads * Thread packages:: Differences between different thread packages @end menu @@ -40176,6 +40342,9 @@ old threads. You can avoid this problem by starting @code{mysqld} with @code{-O thread_cache_size= 'max_connections +1'}. In most cases just using @code{-O thread_cache_size= 5'} will help a lot! +If you want to get a core dump on Linux if mysqld dies with a SIGSEGV signal, +you can start mysqld with the @code{--core-file} option. + If you are using gdb 4.17.x or above on Linux, you should install a @file{.gdb} file, with the following information, in your current directory: @@ -40240,15 +40409,19 @@ mysqld are using indexes properly. @xref{EXPLAIN, , @code{EXPLAIN}}. You should also test complicated queries that didn't complete within the @code{mysql} command line tool. -If you find the text @code{mysqld restarted} in the error log file (normally -named @file{hostname.err}) you have probably found a query that causes -@code{mysqld} to fail. If this happens you should check all your tables with -@code{myisamchk} (@pxref{Maintenance}), and test the queries in the -@strong{MySQL} log files to see if one doesn't work. If you find such a query, -try first upgrading to the newest @strong{MySQL} version. If this doesn't -help and you can't find anything in the @code{mysql} mail archive, you should -report the bug to @email{mysql@@lists.mysql.com}. Links to mail archives are -available online at the @uref{http://www.mysql.com/documentation/, @strong{MySQL} +You can find the queries that takes a long time to run by starting +@code{mysqld} with @code{--log-slow-queries}. @xref{Slow query log}. + +If you find the text @code{mysqld restarted} in the error log file +(normally named @file{hostname.err}) you have probably found a query +that causes @code{mysqld} to fail. If this happens you should check all +your tables with @code{myisamchk} (@pxref{Maintenance}), and test the +queries in the @strong{MySQL} log files to see if one doesn't work. If +you find such a query, try first upgrading to the newest @strong{MySQL} +version. If this doesn't help and you can't find anything in the +@code{mysql} mail archive, you should report the bug to +@email{mysql@@lists.mysql.com}. Links to mail archives are available +online at the @uref{http://www.mysql.com/documentation/, @strong{MySQL} documentation page}. If you get corrupted tables or if @code{mysqld} always fails after some diff --git a/Makefile.am b/Makefile.am index f4240ac94f0..9f74861ce48 100644 --- a/Makefile.am +++ b/Makefile.am @@ -26,7 +26,7 @@ SUBDIRS = include @docs_dirs@ @readline_dir@ @sql_client_dirs@ \ @bench_dirs@ support-files # Relink after clean -CLEANFILES = linked_client_sources linked_server_sources +CLEANFILES = linked_client_sources linked_server_sources linked_libmysql_sources linked_libmysql_r_sources # This is just so that the linking is done early. config.h: linked_client_sources linked_server_sources @@ -36,9 +36,11 @@ linked_client_sources: @linked_client_targets@ linked_libmysql_sources: cd libmysql; $(MAKE) link_sources + echo timestamp > linked_libmysql_sources linked_libmysql_r_sources: linked_libmysql_sources cd libmysql_r; $(MAKE) link_sources + echo timestamp > linked_libmysql_r_sources #avoid recursive make calls in sql directory linked_server_sources: diff --git a/client/mysql.cc b/client/mysql.cc index 987f70dee5d..1353e0daeb8 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -114,7 +114,7 @@ static bool info_flag=0,ignore_errors=0,wait_flag=0,quick=0, no_rehash=0,skip_updates=0,safe_updates=0,one_database=0, opt_compress=0, vertical=0,skip_line_numbers=0,skip_column_names=0,opt_html=0, - no_named_cmds=0; + no_named_cmds=1; // we want this to be the default static uint verbose=0,opt_silent=0,opt_mysql_port=0; static my_string opt_mysql_unix_port=0; static int connect_flag=CLIENT_INTERACTIVE; @@ -160,7 +160,7 @@ typedef struct { static COMMANDS commands[] = { { "help", 'h', com_help, 0, "Display this text" }, - { "?", 'h', com_help, 0, "Synonym for `help'" }, + { "?", '?', com_help, 0, "Synonym for `help'" }, { "clear", 'c', com_clear, 0, "Clear command"}, { "connect",'r', com_connect,1, "Reconnect to the server. Optional arguments are db and host" }, @@ -300,7 +300,7 @@ int main(int argc,char *argv[]) } } #endif - sprintf(buff, "Type '%s' for help.\n", no_named_cmds ? "\\h" : "help"); + sprintf(buff, "Type 'help;' or '\\h' for help.\n"); put_info(buff,INFO_INFO); status.exit_status=read_lines(1); // read lines and execute them mysql_end(0); @@ -352,6 +352,7 @@ static struct option long_options[] = {"database", required_argument, 0, 'D'}, {"debug-info", no_argument, 0, 'T'}, {"default-character-set", required_argument, 0, OPT_DEFAULT_CHARSET}, + {"enable-named-commands", no_argument, 0, 'G'}, {"execute", required_argument, 0, 'e'}, {"force", no_argument, 0, 'f'}, {"help", no_argument, 0, '?'}, @@ -401,7 +402,7 @@ CHANGEABLE_VAR changeable_vars[] = { static void usage(int version) { - printf("%s Ver 10.8 Distrib %s, for %s (%s)\n", + printf("%s Ver 10.11 Distrib %s, for %s (%s)\n", my_progname, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE); if (version) return; @@ -426,11 +427,18 @@ static void usage(int version) -D, --database=.. Database to use.\n\ --default-character-set=...\n\ Set the default character set.\n\ + -G, --enable-named-commands\n\ + Named commands are enabled. Opposite to -g.\n\ -e, --execute=... Execute command and quit. (Output like with --batch)\n\ -E, --vertical Print the output of a query (rows) vertically.\n\ -f, --force Continue even if we get an sql error.\n\ -g, --no-named-commands\n\ - Named commands are disabled. Use \\* form only.\n\ + Named commands are disabled. Use \\* form only, or\n\ + use named commands only in the beginning of a line\n\ + ending with a semicolon (;) Since version 10.9 the\n\ + client now starts with this option ENABLED by\n\ + default! Disable with '-G'. Long format commands\n\ + still work from the first line.\n\ -i, --ignore-space Ignore space after function names.\n\ -h, --host=... Connect to host.\n\ -H, --html Produce HTML output.\n\ @@ -486,7 +494,7 @@ static int get_options(int argc, char **argv) bool tty_password=0; set_all_changeable_vars(changeable_vars); - while ((c=getopt_long(argc,argv,"?ABCD:LfgHinNoqrstTUvVwWEe:h:O:P:S:u:#::p::", + while ((c=getopt_long(argc,argv,"?ABCD:LfgGHinNoqrstTUvVwWEe:h:O:P:S:u:#::p::", long_options, &option_index)) != EOF) { switch(c) { @@ -565,6 +573,7 @@ static int get_options(int argc, char **argv) case 'E': vertical=1; break; case 'w': wait_flag=1; break; case 'A': no_rehash=1; break; + case 'G': no_named_cmds=0; break; case 'g': no_named_cmds=1; break; case 'H': opt_html=1; break; case 'i': connect_flag|= CLIENT_IGNORE_SPACE; break; @@ -682,12 +691,12 @@ static int read_lines(bool execute_commands) if (!in_string && (line[0] == '#' || (line[0] == '-' && line[1] == '-') || line[0] == 0)) - continue; // Skipp comment lines + continue; // Skip comment lines /* Check if line is a mysql command line */ /* (We want to allow help, print and clear anywhere at line start */ - if (execute_commands && !no_named_cmds && !in_string && - (com=find_command(line,0))) + if (execute_commands && (!no_named_cmds || glob_buffer.is_empty()) + && !in_string && (com=find_command(line,0))) { if ((*com->func)(&glob_buffer,line) > 0) break; @@ -1171,11 +1180,13 @@ com_help (String *buffer __attribute__((unused)), reg1 int i; put_info("\nMySQL commands:",INFO_INFO); + if (no_named_cmds) + put_info("Note that all text commands must be first on line and end with ';'",INFO_INFO); for (i = 0; commands[i].name; i++) { if (commands[i].func) - printf("%s\t(\\%c)\t%s\n", commands[i].name,commands[i].cmd_char, - commands[i].doc); + printf("%s\t(\\%c)\t%s\n", commands[i].name, + commands[i].cmd_char, commands[i].doc); } if (connected) printf("\nConnection id: %ld (Can be used with mysqladmin kill)\n\n", diff --git a/client/mysqlimport.c b/client/mysqlimport.c index 0a69f18c176..596b68591b7 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -25,7 +25,7 @@ ** * * ** ************************* */ -#define IMPORT_VERSION "2.3" +#define IMPORT_VERSION "2.4" #include <global.h> #include <my_sys.h> @@ -514,7 +514,6 @@ int main(int argc, char **argv) exitcode = error; db_disconnect(current_host, sock); my_free(password,MYF(MY_ALLOW_ZERO_PTR)); - my_free(current_user,MYF(MY_ALLOW_ZERO_PTR)); free_defaults(argv_to_free); my_end(0); return(exitcode); diff --git a/include/config-win.h b/include/config-win.h index dc54895a5d9..a0008675d49 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -250,6 +250,8 @@ inline double ulonglong2double(ulonglong value) #define HAVE_RINT /* defined in this file */ #define NO_FCNTL_NONBLOCK /* No FCNTL */ #define HAVE_ALLOCA +#define HAVE_STRPBRK +#define HAVE_STRSTR #define HAVE_COMPRESS #ifdef NOT_USED diff --git a/include/global.h b/include/global.h index 27a7c54ede0..6ad6b068b98 100644 --- a/include/global.h +++ b/include/global.h @@ -110,7 +110,7 @@ #endif /* In Linux-alpha we have atomic.h if we are using gcc */ -#if defined(HAVE_LINUXTHREADS) && defined(__GNUC__) && defined(__alpha__) && (__GNUC__ > 2 || ( __GNUC__ == 2 && __GNUC_MINOR__ >= 95)) +#if defined(HAVE_LINUXTHREADS) && defined(__GNUC__) && defined(__alpha__) && (__GNUC__ > 2 || ( __GNUC__ == 2 && __GNUC_MINOR__ >= 95)) && !defined(HAVE_ATOMIC_ADD) #define HAVE_ATOMIC_ADD #define HAVE_ATOMIC_SUB #endif diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 4049b1efa6d..8552d386e5e 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -112,7 +112,8 @@ static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to, * Base version coded by Steve Bernacki, Jr. <steve@navinet.net> *****************************************************************************/ -static int connect2(File s, const struct sockaddr *name, uint namelen, uint to) +static int connect2(my_socket s, const struct sockaddr *name, uint namelen, + uint to) { #if defined(__WIN__) return connect(s, (struct sockaddr*) name, namelen); @@ -1138,7 +1139,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, uint port, const char *unix_socket,uint client_flag) { char buff[100],charset_name_buff[16],*end,*host_info, *charset_name; - int sock; + my_socket sock; uint32 ip_addr; struct sockaddr_in sock_addr; uint pkt_length; @@ -1270,7 +1271,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, sprintf(host_info=buff,ER(CR_TCP_CONNECTION),host); DBUG_PRINT("info",("Server name: '%s'. TCP sock: %d", host,port)); /* _WIN64 ; Assume that the (int) range is enough for socket() */ - if ((sock = (int) socket(AF_INET,SOCK_STREAM,0)) == SOCKET_ERROR) + if ((sock = (my_socket) socket(AF_INET,SOCK_STREAM,0)) == SOCKET_ERROR) { net->last_errno=CR_IPSOCK_ERROR; sprintf(net->last_error,ER(net->last_errno),ERRNO); diff --git a/myisam/ChangeLog b/myisam/ChangeLog index e7950684f56..d212039fedf 100644 --- a/myisam/ChangeLog +++ b/myisam/ChangeLog @@ -1,3 +1,7 @@ +2000-08-23 Michael Widenius <monty@mysql.com> + +* Fixed bug when comparing DECIMAL/NUMERIC key parts. + 2000-08-17 Michael Widenius <monty@mysql.com> * Add a new flag in share.staus so that we can quickly check if a table diff --git a/myisam/Makefile.am b/myisam/Makefile.am index 6c5767640c8..70976a86b49 100644 --- a/myisam/Makefile.am +++ b/myisam/Makefile.am @@ -46,7 +46,7 @@ libmyisam_a_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \ mi_delete_table.c mi_rename.c mi_check.c \ ft_parser.c ft_search.c ft_stopwords.c ft_static.c \ ft_update.c sort.c -CLEANFILES = test?.IS? isam.log mi_test_all +CLEANFILES = test?.MY? FT?.MY? isam.log mi_test_all DEFS = -DMAP_TO_USE_RAID # Omit dependency for ../mit-pthreads/include/sys that only exits if # mit-pthreads are used diff --git a/myisam/ft_stopwords.c b/myisam/ft_stopwords.c index f8fddc9d4bb..4c13a845b42 100644 --- a/myisam/ft_stopwords.c +++ b/myisam/ft_stopwords.c @@ -48,7 +48,7 @@ int ft_init_stopwords(const char **sws) for(;*sws;sws++) { - if( (sw.len=strlen(sw.pos=*sws)) < MIN_WORD_LEN) continue; + if( (sw.len= (uint) strlen(sw.pos=*sws)) < MIN_WORD_LEN) continue; if(!tree_insert(stopwords3, &sw, 0)) { delete_tree(stopwords3); diff --git a/myisam/mi_check.c b/myisam/mi_check.c index 2b5a14f1e87..ab3d986980c 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -16,8 +16,7 @@ /* Descript, check and repair of ISAM tables */ -#include "myisamdef.h" - +#include "fulltext.h" #include <m_ctype.h> #include <stdarg.h> #include <getopt.h> diff --git a/myisam/mi_dbug.c b/myisam/mi_dbug.c index 62d6e039059..c424d65f7ec 100644 --- a/myisam/mi_dbug.c +++ b/myisam/mi_dbug.c @@ -147,3 +147,26 @@ void _mi_print_key(FILE *stream, register MI_KEYSEG *keyseg, VOID(fputs("\"\n",stream)); return; } /* print_key */ + + +#ifdef EXTRA_DEBUG + +my_bool check_table_is_closed(const char *name, const char *where) +{ + char filename[FN_REFLEN]; + LIST *pos; + + (void) fn_format(filename,name,"",MI_NAME_IEXT,4+16+32); + for (pos=myisam_open_list ; pos ; pos=pos->next) + { + MI_INFO *info=(MI_INFO*) pos->data; + MYISAM_SHARE *share=info->s; + if (!strcmp(share->filename,filename)) + { + fprintf(stderr,"Warning: Table: %s is open on %s\n", name,where); + return 1; + } + } + return 0; +} +#endif /* EXTRA_DEBUG */ diff --git a/myisam/mi_delete_table.c b/myisam/mi_delete_table.c index 916f5a8fc02..360956ad110 100644 --- a/myisam/mi_delete_table.c +++ b/myisam/mi_delete_table.c @@ -30,6 +30,10 @@ int mi_delete_table(const char *name) uint raid_type=0,raid_chunks=0; #endif DBUG_ENTER("mi_delete_table"); + +#ifdef EXTRA_DEBUG + check_table_is_closed(name,"delete"); +#endif #ifdef USE_RAID { MI_INFO *info; @@ -39,7 +43,10 @@ int mi_delete_table(const char *name) raid_chunks = info->s->base.raid_chunks; mi_close(info); } +#ifdef EXTRA_DEBUG + check_table_is_closed(name,"delete"); #endif +#endif /* USE_RAID */ fn_format(from,name,"",MI_NAME_IEXT,4); if (my_delete(from, MYF(MY_WME))) diff --git a/myisam/mi_rename.c b/myisam/mi_rename.c index 6849e1c3d26..5c92db3f7ce 100644 --- a/myisam/mi_rename.c +++ b/myisam/mi_rename.c @@ -30,6 +30,11 @@ int mi_rename(const char *old_name, const char *new_name) uint raid_type=0,raid_chunks=0; #endif DBUG_ENTER("mi_rename"); + +#ifdef EXTRA_DEBUG + check_table_is_closed(old_name,"rename old_table"); + check_table_is_closed(new_name,"rename new table2"); +#endif #ifdef USE_RAID { MI_INFO *info; @@ -39,7 +44,10 @@ int mi_rename(const char *old_name, const char *new_name) raid_chunks = info->s->base.raid_chunks; mi_close(info); } +#ifdef EXTRA_DEBUG + check_table_is_closed(old_name,"rename raidcheck"); #endif +#endif /* USE_RAID */ fn_format(from,old_name,"",MI_NAME_IEXT,4); fn_format(to,new_name,"",MI_NAME_IEXT,4); diff --git a/myisam/mi_rnext.c b/myisam/mi_rnext.c index 0dc40d0257f..f7e7b61d934 100644 --- a/myisam/mi_rnext.c +++ b/myisam/mi_rnext.c @@ -57,7 +57,7 @@ int mi_rnext(MI_INFO *info, byte *buf, int inx) /* Skip rows that are inserted by other threads since we got a lock */ if ((error=_mi_search_next(info,info->s->keyinfo+inx,info->lastkey, info->lastkey_length, - flag, + SEARCH_BIGGER, info->s->state.key_root[inx]))) break; } diff --git a/myisam/mi_rprev.c b/myisam/mi_rprev.c index 6a75cc0daa6..471eecc33f5 100644 --- a/myisam/mi_rprev.c +++ b/myisam/mi_rprev.c @@ -58,7 +58,7 @@ int mi_rprev(MI_INFO *info, byte *buf, int inx) /* Skip rows that are inserted by other threads since we got a lock */ if ((error=_mi_search_next(info,share->keyinfo+inx,info->lastkey, info->lastkey_length, - flag, + SEARCH_SMALLER, share->state.key_root[inx]))) break; } diff --git a/myisam/mi_search.c b/myisam/mi_search.c index 812982082af..8fb35f3af65 100644 --- a/myisam/mi_search.c +++ b/myisam/mi_search.c @@ -716,6 +716,7 @@ int _mi_key_cmp(register MI_KEYSEG *keyseg, register uchar *a, { alength= *a++; blength= *b++; end=a+alength; + next_key_length=key_length-blength-1; } else { diff --git a/myisam/myisamdef.h b/myisam/myisamdef.h index d0774feaa9d..cd1eaa76ce1 100644 --- a/myisam/myisamdef.h +++ b/myisam/myisamdef.h @@ -622,6 +622,8 @@ void mi_dectivate_non_unique_index(MI_INFO *info, ha_rows rows); int _mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, uint key_len, enum ha_rkey_function search_flag, bool raw_key); +my_bool check_table_is_closed(const char *name, const char *where); + /* Functions needed by mi_check */ #ifdef __cplusplus extern "C" { diff --git a/myisammrg/myrg_rkey.c b/myisammrg/myrg_rkey.c index 2f4cfb60068..c0123588a06 100644 --- a/myisammrg/myrg_rkey.c +++ b/myisammrg/myrg_rkey.c @@ -28,7 +28,7 @@ int myrg_rkey(MYRG_INFO *info,byte *record,int inx, const byte *key, uint key_len, enum ha_rkey_function search_flag) { - uchar *key_buff; + byte *key_buff; uint pack_key_length; MYRG_TABLE *table; MI_INFO *mi; @@ -45,7 +45,7 @@ int myrg_rkey(MYRG_INFO *info,byte *record,int inx, const byte *key, if (table == info->open_tables) { err=mi_rkey(mi,buf,inx,key,key_len,search_flag); - key_buff=mi->lastkey+mi->s->base.max_key_length; + key_buff=(byte*) mi->lastkey+mi->s->base.max_key_length; pack_key_length=mi->last_rkey_length; } else diff --git a/myisammrg/myrg_rnext.c b/myisammrg/myrg_rnext.c index 2bfa59be3ef..e714ce3b139 100644 --- a/myisammrg/myrg_rnext.c +++ b/myisammrg/myrg_rnext.c @@ -24,7 +24,7 @@ int myrg_rnext(MYRG_INFO *info, byte *buf, int inx) { MYRG_TABLE *table; MI_INFO *mi; - uchar *key_buff; + byte *key_buff; uint pack_key_length; int err; @@ -50,7 +50,7 @@ int myrg_rnext(MYRG_INFO *info, byte *buf, int inx) if (table < info->end_table) { mi=info->last_used_table->table; - key_buff=mi->lastkey+mi->s->base.max_key_length; + key_buff=(byte*) mi->lastkey+mi->s->base.max_key_length; pack_key_length=mi->last_rkey_length; for (; table < info->end_table ; table++) { diff --git a/myisammrg/myrg_rprev.c b/myisammrg/myrg_rprev.c index 3ee0894b42c..0523dc7f4e7 100644 --- a/myisammrg/myrg_rprev.c +++ b/myisammrg/myrg_rprev.c @@ -24,7 +24,7 @@ int myrg_rprev(MYRG_INFO *info, byte *buf, int inx) { MYRG_TABLE *table; MI_INFO *mi; - uchar *key_buff; + byte *key_buff; uint pack_key_length; int err; @@ -50,12 +50,13 @@ int myrg_rprev(MYRG_INFO *info, byte *buf, int inx) if (table < info->end_table) { mi=info->last_used_table->table; - key_buff=mi->lastkey+mi->s->base.max_key_length; + key_buff=(byte*) mi->lastkey+mi->s->base.max_key_length; pack_key_length=mi->last_rkey_length; for (; table < info->end_table ; table++) { mi=table->table; - err=_mi_rkey(mi,NULL,inx,key_buff,pack_key_length,HA_READ_KEY_OR_PREV,FALSE); + err=_mi_rkey(mi,NULL,inx,key_buff,pack_key_length, + HA_READ_KEY_OR_PREV,FALSE); info->last_used_table=table; if (err == HA_ERR_KEY_NOT_FOUND) diff --git a/mysys/charset.c b/mysys/charset.c index b989bf37c7b..82e84715213 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -193,7 +193,9 @@ static my_bool init_available_charsets(myf myflags) charset_initialized=1; pthread_mutex_unlock(&THR_LOCK_charset); } - return error || !available_charsets[0]; + if(!available_charsets || !available_charsets[0]) + error = TRUE; + return error; } @@ -467,6 +469,7 @@ char * list_charsets(myf want_flags) DYNAMIC_STRING s; char *p; + (void)init_available_charsets(MYF(0)); init_dynamic_string(&s, NullS, 256, 1024); if (want_flags & MY_COMPILED_SETS) @@ -485,16 +488,17 @@ char * list_charsets(myf want_flags) char buf[FN_REFLEN]; MY_STAT stat; - for (c = available_charsets; *c; ++c) - { - if (charset_in_string((*c)->name, &s)) - continue; - get_charset_conf_name((*c)->number, buf); - if (!my_stat(buf, &stat, MYF(0))) - continue; /* conf file doesn't exist */ - dynstr_append(&s, (*c)->name); - dynstr_append(&s, " "); - } + if((c=available_charsets)) + for (; *c; ++c) + { + if (charset_in_string((*c)->name, &s)) + continue; + get_charset_conf_name((*c)->number, buf); + if (!my_stat(buf, &stat, MYF(0))) + continue; /* conf file doesn't exist */ + dynstr_append(&s, (*c)->name); + dynstr_append(&s, " "); + } } if (want_flags & MY_INDEX_SETS) diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index 65d259a5307..a68df18c41a 100755 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -48,7 +48,7 @@ rm $BASE/include/Makefile*; rm $BASE/include/*.in cp -p tests/*.res tests/*.tst tests/*.pl $BASE/tests cp -p support-files/* $BASE/support-files -cp -p libmysql/.libs/libmysqlclient.a libmysql/.libs/libmysqlclient.so* libmysql/libmysqlclient.* mysys/libmysys.a strings/libmystrings.a dbug/libdbug.a $BASE/lib +cp -p libmysql/.libs/libmysqlclient.a libmysql/.libs/libmysqlclient.so* libmysql/libmysqlclient.* libmysql_r/.libs/libmysqlclient_a.a libmysql_r/.libs/libmysqlclient.so* libmysql_r/libmysqlclient.* mysys/libmysys.a strings/libmystrings.a dbug/libdbug.a $BASE/lib cp -r -p sql/share/* $BASE/share/mysql; rm -f $BASE/share/mysql/Makefile* $BASE/share/mysql/*/*.OLD $BASE/share/CVS $BASE/share/*/CVS cp -p scripts/* $BASE/bin diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc index 989497cee6e..591ca0bc813 100644 --- a/sql/ha_heap.cc +++ b/sql/ha_heap.cc @@ -251,6 +251,21 @@ int ha_heap::rename_table(const char * from, const char * to) } +ha_rows ha_heap::records_in_range(int inx, + const byte *start_key,uint start_key_len, + enum ha_rkey_function start_search_flag, + const byte *end_key,uint end_key_len, + enum ha_rkey_function end_search_flag) +{ + KEY *pos=table->key_info+inx; + if (start_key_len != end_key_len || + start_key_len != pos->key_length || + start_search_flag != HA_READ_KEY_EXACT || + end_search_flag != HA_READ_KEY_EXACT) + return HA_POS_ERROR; // Can't only use exact keys + return 10; // Good guess +} + /* We can just delete the heap on creation */ int ha_heap::create(const char *name, TABLE *form, HA_CREATE_INFO *create_info) diff --git a/sql/ha_heap.h b/sql/ha_heap.h index acbc0975f1e..b56ee84822f 100644 --- a/sql/ha_heap.h +++ b/sql/ha_heap.h @@ -65,7 +65,10 @@ class ha_heap: public handler int reset(void); int external_lock(THD *thd, int lock_type); int delete_all_rows(void); - + ha_rows records_in_range(int inx, const byte *start_key,uint start_key_len, + enum ha_rkey_function start_search_flag, + const byte *end_key,uint end_key_len, + enum ha_rkey_function end_search_flag); int delete_table(const char *from); int rename_table(const char * from, const char * to); int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info); diff --git a/sql/handler.cc b/sql/handler.cc index 592861e176b..437b11be5bb 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -317,8 +317,8 @@ int handler::ha_open(const char *name, int mode, int test_if_locked) } if (!error) { - - if (!(ref=(byte*) my_malloc(ALIGN_SIZE(ref_length)*2,MYF(0)))) + if (!(ref=(byte*) alloc_root(&table->mem_root, + ALIGN_SIZE(ref_length)*2))) { close(); error=HA_ERR_OUT_OF_MEM; diff --git a/sql/handler.h b/sql/handler.h index 67fd99c71d7..08bf355b60e 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -200,7 +200,7 @@ public: create_time(0), check_time(0), update_time(0), mean_rec_length(0), ft_handler(0) {} - virtual ~handler(void) { my_free((char*) ref,MYF(MY_ALLOW_ZERO_PTR)); } + virtual ~handler(void) {} int ha_open(const char *name, int mode, int test_if_locked); void update_timestamp(byte *record); void update_auto_increment(); diff --git a/sql/lock.cc b/sql/lock.cc index a2e4daa4590..eba1851bae0 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -407,15 +407,17 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list) TABLE *table; char key[MAX_DBKEY_LENGTH]; uint key_length; - key_length=(uint) (strmov(strmov(key,table_list->db)+1,table_list->name)-key)+ - 1; + DBUG_ENTER("lock_table_name"); + + key_length=(uint) (strmov(strmov(key,table_list->db)+1,table_list->name) + -key)+ 1; /* Only insert the table if we haven't insert it already */ for (table=(TABLE*) hash_search(&open_cache,(byte*) key,key_length) ; table ; table = (TABLE*) hash_next(&open_cache,(byte*) key,key_length)) if (table->in_use == thd) - return 0; + DBUG_RETURN(0); /* Create a table entry with the right key and with an old refresh version */ /* Note that we must use my_malloc() here as this is freed by the table @@ -423,17 +425,18 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list) if (!(table= (TABLE*) my_malloc(sizeof(*table)+key_length, MYF(MY_WME | MY_ZEROFILL)))) - return -1; + DBUG_RETURN(-1); memcpy((table->table_cache_key= (char*) (table+1)), key, key_length); table->key_length=key_length; table->in_use=thd; + table->locked_by_name=1; table_list->table=table; if (hash_insert(&open_cache, (byte*) table)) - return -1; + DBUG_RETURN(-1); if (remove_table_from_cache(thd, table_list->db, table_list->name)) - return 1; // Table is in use - return 0; + DBUG_RETURN(1); // Table is in use + DBUG_RETURN(0); } void unlock_table_name(THD *thd, TABLE_LIST *table_list) @@ -446,7 +449,7 @@ static bool locked_named_table(THD *thd, TABLE_LIST *table_list) { for ( ; table_list ; table_list=table_list->next) { - if (table_list->table && table_is_used(table_list->table)) + if (table_list->table && table_is_used(table_list->table,0)) return 1; } return 0; // All tables are locked @@ -456,6 +459,7 @@ static bool locked_named_table(THD *thd, TABLE_LIST *table_list) bool wait_for_locked_table_names(THD *thd, TABLE_LIST *table_list) { bool result=0; + DBUG_ENTER("wait_for_locked_table_names"); while (locked_named_table(thd,table_list)) { @@ -467,5 +471,5 @@ bool wait_for_locked_table_names(THD *thd, TABLE_LIST *table_list) wait_for_refresh(thd); pthread_mutex_lock(&LOCK_open); } - return result; + DBUG_RETURN(result); } diff --git a/sql/mini_client.cc b/sql/mini_client.cc index b9e66911475..5cd0fe2c680 100644 --- a/sql/mini_client.cc +++ b/sql/mini_client.cc @@ -225,13 +225,14 @@ static void mc_free_old_query(MYSQL *mysql) * Base version coded by Steve Bernacki, Jr. <steve@navinet.net> *****************************************************************************/ -static int mc_sock_connect(File s, const struct sockaddr *name, uint namelen, uint to) +static int mc_sock_connect(my_socket s, const struct sockaddr *name, + uint namelen, uint to) { #if defined(__WIN__) return connect(s, (struct sockaddr*) name, namelen); #else int flags, res, s_err; - socklen_t s_err_size = sizeof(uint); + size_socket s_err_size = sizeof(uint); fd_set sfds; struct timeval tv; @@ -451,7 +452,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, uint port, const char *unix_socket,uint client_flag) { char buff[100],*end,*host_info; - int sock; + my_socket sock; ulong ip_addr; struct sockaddr_in sock_addr; uint pkt_length; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index fa61102fb57..7e372a7ffd1 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -127,7 +127,7 @@ void sql_element_free(void *ptr); #define TEST_NO_THREADS 32 /* For debugging under Linux */ #define TEST_READCHECK 64 /* Force use of readcheck */ #define TEST_NO_EXTRA 128 -#define TEST_KILL_ON_DEBUG 256 /* Kill server */ +#define TEST_CORE_ON_SIGNAL 256 /* Give core if signal */ /* options for select set by the yacc parser */ #define SELECT_DISTINCT 1 @@ -319,10 +319,11 @@ TABLE *open_table(THD *thd,const char *db,const char *table,const char *alias, TABLE *find_locked_table(THD *thd, const char *db,const char *table_name); bool reopen_table(TABLE *table,bool locked=0); bool reopen_tables(THD *thd,bool get_locks,bool in_refresh); -void close_old_data_files(THD *thd, TABLE *table, bool abort_locks); +void close_old_data_files(THD *thd, TABLE *table, bool abort_locks, + bool send_refresh); bool close_data_tables(THD *thd,const char *db, const char *table_name); bool wait_for_tables(THD *thd); -bool table_is_used(TABLE *table); +bool table_is_used(TABLE *table, bool wait_for_name_lock); bool drop_locked_tables(THD *thd,const char *db, const char *table_name); void abort_locked_tables(THD *thd,const char *db, const char *table_name); Field *find_field_in_tables(THD *thd,Item_field *item,TABLE_LIST *tables); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index f8ce60b9681..8ea12f68da8 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1003,6 +1003,20 @@ static void init_signals(void) } #else +#ifdef HAVE_LINUXTHREADS + +/* Produce a core for the thread */ + +static sig_handler write_core(int sig) +{ + fprintf(stderr,"Got signal %s in thread %d\n",sys_siglist[sig],getpid()); + signal(sig, SIG_DFL); + if (fork() != 0) exit(1); // Abort main program + // Core will be written at exit +} +#endif + + static void init_signals(void) { sigset_t set; @@ -1012,6 +1026,16 @@ static void init_signals(void) sigset(THR_KILL_SIGNAL,end_thread_signal); sigset(THR_SERVER_ALARM,print_signal_warning); // Should never be called! +#ifdef HAVE_LINUXTHREADS + if (test_flags & TEST_CORE_ON_SIGNAL) + { + struct sigaction sa; sa.sa_flags = 0; + sigemptyset(&sa.sa_mask); + sigprocmask(SIG_SETMASK,&sa.sa_mask,NULL); + sa.sa_handler=write_core; + sigaction(SIGSEGV, &sa, NULL); + } +#endif (void) sigemptyset(&set); #ifdef THREAD_SPECIFIC_SIGPIPE sigset(SIGPIPE,abort_thread); @@ -2134,7 +2158,7 @@ enum options {OPT_ISAM_LOG=256,OPT_SKIP_NEW,OPT_SKIP_GRANT, OPT_MASTER_PORT, OPT_MASTER_INFO_FILE, OPT_MASTER_CONNECT_RETRY, OPT_SQL_BIN_UPDATE_SAME, OPT_REPLICATE_DO_DB, OPT_REPLICATE_IGNORE_DB, OPT_LOG_SLAVE_UPDATES, - OPT_BINLOG_DO_DB, OPT_BINLOG_IGNORE_DB}; + OPT_BINLOG_DO_DB, OPT_BINLOG_IGNORE_DB, OPT_WANT_CORE}; static struct option long_options[] = { @@ -2156,6 +2180,7 @@ static struct option long_options[] = #ifdef __WIN__ {"console", no_argument, 0, OPT_CONSOLE}, #endif + {"core-file", no_argument, 0, OPT_WANT_CORE}, {"chroot", required_argument,0, 'r'}, {"character-sets-dir",required_argument,0, OPT_CHARSETS_DIR}, {"datadir", required_argument, 0, 'h'}, @@ -2188,8 +2213,10 @@ static struct option long_options[] = {"master-connect-retry", required_argument, 0, (int) OPT_MASTER_CONNECT_RETRY}, {"master-info-file", required_argument, 0, (int) OPT_MASTER_INFO_FILE}, {"new", no_argument, 0, 'n'}, - {"old-protocol", no_argument, 0, 'o'}, + {"old-protocol", no_argument, 0, 'o'}, +#ifndef DBUG_OFF {"one-thread", no_argument, 0, OPT_ONE_THREAD}, +#endif {"pid-file", required_argument, 0, (int) OPT_PID_FILE}, {"port", required_argument, 0, 'P'}, {"replicate-do-db", required_argument, 0, OPT_REPLICATE_DO_DB}, @@ -2407,6 +2434,12 @@ static void print_version(void) server_version,SYSTEM_TYPE,MACHINE_TYPE); } +static void use_help(void) +{ + print_version(); + printf("Use %s --help for a list of available options\n",my_progname); +} + static void usage(void) { print_version(); @@ -2426,6 +2459,7 @@ static void usage(void) --character-sets-dir=...\n\ Directory where character sets are\n\ --chroot=path Chroot mysqld daemon during startup\n\ + --core-file Write core on errors\n\ -h, --datadir=path Path to the database root"); #ifndef DBUG_OFF printf("\ @@ -2454,11 +2488,17 @@ static void usage(void) --log-isam[=file] Log all isam changes to file\n\ --log-long-format Log some extra information to update log\n\ --low-priority-updates INSERT/DELETE/UPDATE has lower priority than selects\n\ + --log-slow-queries=[file]\n\ + Log slow queries to this log file\n\ --pid-file=path Pid file used by safe_mysqld\n\ -P, --port=... Port number to use for connection\n\ -n, --new Use very new possible 'unsafe' functions\n\ - -o, --old-protocol Use the old (3.20) protocol\n\ - --one-thread Only use one thread (for debugging under Linux)\n\ + -o, --old-protocol Use the old (3.20) protocol\n"); +#ifndef DBUG_OFF + puts("\ + --one-thread Only use one thread (for debugging under Linux)\n"); +#endif + puts("\ -O, --set-variable var=option\n\ Give a variable an value. --help lists variables\n\ -Sg, --skip-grant-tables\n\ @@ -2621,7 +2661,7 @@ static void get_options(int argc,char **argv) case 'O': if (set_changeable_var(optarg, changeable_vars)) { - usage(); + use_help(); exit(1); } break; @@ -2666,7 +2706,8 @@ static void get_options(int argc,char **argv) opt_noacl=1; else { - usage(); + fprintf(stderr,"%s: Unrecognized option: %s\n",my_progname,optarg); + use_help(); exit(1); } break; @@ -2718,8 +2759,6 @@ static void get_options(int argc,char **argv) binlog_do_db.push_back(db); break; } - - case (int) OPT_SQL_BIN_UPDATE_SAME: opt_sql_bin_update = 1; break; @@ -2774,6 +2813,9 @@ static void get_options(int argc,char **argv) case (int) OPT_ONE_THREAD: test_flags |= TEST_NO_THREADS; break; + case (int) OPT_WANT_CORE: + test_flags |= TEST_CORE_ON_SIGNAL; + break; case (int) OPT_BIND_ADDRESS: if (optarg && isdigit(optarg[0])) { @@ -2910,7 +2952,7 @@ static void get_options(int argc,char **argv) default: fprintf(stderr,"%s: Unrecognized option: %c\n",my_progname,c); - usage(); + use_help(); exit(1); } } @@ -2920,7 +2962,7 @@ static void get_options(int argc,char **argv) if (argc != optind) { fprintf(stderr,"%s: Too many parameters\n",my_progname); - usage(); + use_help(); exit(1); } fix_paths(); diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 4f1abf9b685..25ee26dbdbd 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -14,6 +14,16 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* + TODO: + Fix that MAYBE_KEY are stored in the tree so that we can detect use + of full hash keys for queries like: + + select s.id, kws.keyword_id from sites as s,kws where s.id=kws.site_id and kws.keyword_id in (204,205); + +*/ + + #ifdef __GNUC__ #pragma implementation // gcc: Class implementation @@ -557,7 +567,7 @@ SEL_ARG *SEL_ARG::clone_tree() ** Returns: ** -1 if impossible select ** 0 if can't use quick_select -** 1 if found usably range +** 1 if found usable range ** Updates the following in the select parameter: ** needed_reg ; Bits for keys with may be used if all prev regs are read ** quick ; Parameter to use when reading records. diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 6bf44f7d7d6..de689baaddb 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -582,9 +582,8 @@ bool close_cached_tables(THD *thd, bool if_wait_for_refresh, thd->mysys_var->current_cond= &COND_refresh; thd->proc_info="Flushing tables"; pthread_mutex_unlock(&thd->mysys_var->mutex); - VOID(pthread_cond_broadcast(&COND_refresh)); // If one flush is locked - close_old_data_files(thd,thd->open_tables,1); + close_old_data_files(thd,thd->open_tables,1,1); bool found=1; /* Wait until all threads has closed all the tables we had locked */ DBUG_PRINT("info", ("Waiting for others threads to close their open tables")); @@ -921,7 +920,7 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name, ** There is a refresh in progress for this table ** Wait until the table is freed or the thread is killed. */ - close_old_data_files(thd,thd->open_tables,0); + close_old_data_files(thd,thd->open_tables,0,0); if (table->in_use != thd) wait_for_refresh(thd); else @@ -1216,9 +1215,11 @@ bool reopen_tables(THD *thd,bool get_locks,bool in_refresh) abort_locks is set if called from flush_tables. */ -void close_old_data_files(THD *thd, TABLE *table, bool abort_locks) +void close_old_data_files(THD *thd, TABLE *table, bool abort_locks, + bool send_refresh) { - bool found=0; + DBUG_ENTER("close_old_data_files"); + bool found=send_refresh; for (; table ; table=table->next) { if (table->version != refresh_version) @@ -1241,6 +1242,7 @@ void close_old_data_files(THD *thd, TABLE *table, bool abort_locks) } if (found) VOID(pthread_cond_broadcast(&COND_refresh)); // Signal to refresh + DBUG_VOID_RETURN; } @@ -1250,17 +1252,19 @@ void close_old_data_files(THD *thd, TABLE *table, bool abort_locks) if the table is closed */ -bool table_is_used(TABLE *table) +bool table_is_used(TABLE *table, bool wait_for_name_lock) { do { char *key= table->table_cache_key; uint key_length=table->key_length; - for (TABLE *search=(TABLE*) hash_search(&open_cache,(byte*) key,key_length) ; + for (TABLE *search=(TABLE*) hash_search(&open_cache, + (byte*) key,key_length) ; search ; search = (TABLE*) hash_next(&open_cache,(byte*) key,key_length)) { if (search->locked_by_flush || + search->locked_by_name && wait_for_name_lock || search->db_stat && search->version < refresh_version) return 1; // Table is used } @@ -1278,19 +1282,14 @@ bool wait_for_tables(THD *thd) thd->proc_info="Waiting for tables"; pthread_mutex_lock(&LOCK_open); - thd->some_tables_deleted=0; - close_old_data_files(thd,thd->open_tables,0); - if (dropping_tables) - { - (void) pthread_cond_broadcast(&COND_refresh); // Signal to refresh/delete - (void) pthread_cond_wait(&COND_refresh,&LOCK_open); - } - - while (table_is_used(thd->open_tables) && ! thd->killed) + while (!thd->killed) { - (void) pthread_cond_wait(&COND_refresh,&LOCK_open); + thd->some_tables_deleted=0; + close_old_data_files(thd,thd->open_tables,0,dropping_tables != 0); + if (!table_is_used(thd->open_tables,1)) + break; + (void) pthread_cond_wait(&COND_refresh,&LOCK_open); } - if (thd->killed) result= 1; // aborted else diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 8b7e16709c0..3fb96857007 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1137,16 +1137,21 @@ mysql_execute_command(void) goto error; for (table=tables ; table ; table=table->next->next) { - if (check_access(thd, ALTER_ACL, table->db, &table->grant.privilege) || + if (check_access(thd, ALTER_ACL | DROP_ACL, table->db, + &table->grant.privilege) || check_access(thd, INSERT_ACL | CREATE_ACL, table->next->db, &table->next->grant.privilege)) goto error; if (grant_option) { - if (check_grant(thd,ALTER_ACL,table) || + TABLE_LIST old_list,new_list; + old_list=table[0]; + new_list=table->next[0]; + old_list.next=new_list.next=0; + if (check_grant(thd,ALTER_ACL,&old_list) || (!test_all_bits(table->next->grant.privilege, INSERT_ACL | CREATE_ACL) && - check_grant(thd,INSERT_ACL | CREATE_ACL, table->next))) + check_grant(thd,INSERT_ACL | CREATE_ACL, &new_list))) goto error; } } @@ -1170,9 +1175,8 @@ mysql_execute_command(void) #endif case SQLCOM_REPAIR: { - if (!tables->db) - tables->db=thd->db; - if (check_table_access(thd,SELECT_ACL | INSERT_ACL, tables)) + if (check_db_used(thd,tables) || + check_table_access(thd,SELECT_ACL | INSERT_ACL, tables)) goto error; /* purecov: inspected */ res = mysql_repair_table(thd, tables, &lex->check_opt); break; @@ -1695,6 +1699,10 @@ error: ** Get the user (global) and database privileges for all used tables ** Returns true (error) if we can't get the privileges and we don't use ** table/column grants. +** The idea of EXTRA_ACL is that one will be granted access to the table if +** one has the asked privilege on any column combination of the table; For +** example to be able to check a table one needs to have SELECT privilege on +** any column of the table. ****************************************************************************/ bool @@ -1760,7 +1768,8 @@ check_table_access(THD *thd,uint want_access,TABLE_LIST *tables) TABLE_LIST *org_tables=tables; for (; tables ; tables=tables->next) { - if ((thd->master_access & want_access) == want_access && thd->db) + if ((thd->master_access & want_access) == (want_access & ~EXTRA_ACL) && + thd->db) tables->grant.privilege= want_access; else if (tables->db && tables->db == thd->db) { diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 6578e3b717a..4ee0343274a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -29,7 +29,7 @@ #include <assert.h> const char *join_type_str[]={ "UNKNOWN","system","const","eq_ref","ref", - "MAYBE_REF","ALL","range","index" }; + "MAYBE_REF","ALL","range","index","fulltext" }; static bool make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds, DYNAMIC_ARRAY *keyuse,List<Item_func_match> &ftfuncs); @@ -800,6 +800,14 @@ make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds, if ((s->on_expr=tables->on_expr)) { // table->maybe_null=table->outer_join=1; // Mark for send fields + if (!table->file->records) + { // Empty table + s->key_dependent=s->dependent=0; + s->type=JT_SYSTEM; + const_table_map|=table->map; + set_position(join,const_count++,s,(KEYUSE*) 0); + continue; + } s->key_dependent=s->dependent= s->on_expr->used_tables() & ~(table->map); s->dependent|=stat_vector[i-1]->dependent | table_vector[i-1]->map; @@ -1272,15 +1280,54 @@ static void add_ft_keys(DYNAMIC_ARRAY *keyuse_array, JOIN_TAB *stat,COND *cond,table_map usable_tables) { - /* for now, handling only the simples WHERE MATCH (...) case */ - /* a bit more complex WHERE MATCH (...) > const, - AND's and (perhaps) OR's are on the way SerG */ + Item_func_match *cond_func=NULL; + + if (cond->type() == Item::FUNC_ITEM) + { + Item_func *func=(Item_func *)cond, + *arg0=(Item_func *)(func->arguments()[0]), + *arg1=(Item_func *)(func->arguments()[1]); + + if (func->functype() == Item_func::FT_FUNC) + cond_func=(Item_func_match *)cond; + else if (arg0->type() == Item::FUNC_ITEM && + arg0->functype() == Item_func::FT_FUNC && + (func->functype() == Item_func::GE_FUNC || + func->functype() == Item_func::GT_FUNC) && + arg1->const_item() && arg1->val()>=0) + cond_func=(Item_func_match *)arg0; + else if (arg1->type() == Item::FUNC_ITEM && + arg1->functype() == Item_func::FT_FUNC && + (func->functype() == Item_func::LE_FUNC || + func->functype() == Item_func::LT_FUNC) && + arg0->const_item() && arg0->val()>=0) + cond_func=(Item_func_match *)arg1; + } + else if (cond->type() == Item::COND_ITEM) + { + List_iterator<Item> li(*((Item_cond*) cond)->argument_list()); - if (cond->type() != Item::FUNC_ITEM || - ((Item_func*) cond)->functype() != Item_func::FT_FUNC) - return; + if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC) + { + Item *item; + /* I'm too lazy to implement proper recursive descent here, + and anyway, nobody will use such a stupid queries + that will require it :-) + May be later... + */ + while ((item=li++)) + if (item->type() == Item::FUNC_ITEM && + ((Item_func *)item)->functype() == Item_func::FT_FUNC) + { + cond_func=(Item_func_match *)item; + break; + } + } + } + + if(!cond_func) + return; - Item_func_match *cond_func= (Item_func_match *) cond; KEYUSE keyuse; keyuse.table= cond_func->table; @@ -1928,8 +1975,7 @@ get_best_combination(JOIN *join) if (ftkey) { j->ref.items[0]=((Item_func*)(keyuse->val))->key_item(); - if (!keyuse->used_tables && - !(join->select_options & SELECT_DESCRIBE)) + if (!keyuse->used_tables) { // AFAIK key_buff is zeroed... // We don't need to free ft_tmp as the buffer will be freed atom. diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 66141a8591c..b862ee60893 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1,15 +1,15 @@ /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ @@ -488,7 +488,7 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) if (send_fields(thd,field_list,1)) DBUG_RETURN(1); - + String *packet = &thd->packet; for(;table; table = table->next) { @@ -510,7 +510,7 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) // into fewer, so we cannot use net_store_data() anymore, // and do it ourselves char* p = (char*)packet->ptr() + store_len_offset; - *p++ = (char) 253; // The client the length is stored using 3-bytes + *p++ = (char) 253; // The client the length is stored using 3-bytes int3store(p, create_len); // now we are in business :-) @@ -649,10 +649,10 @@ mysqld_dump_create_info(THD *thd, TABLE *table, int fd) DBUG_PRINT("enter",("table: %s",table->real_name)); String* packet = &thd->packet; packet->length(0); - + if(store_create_info(thd,table,packet)) DBUG_RETURN(-1); - + if(fd < 0) { if(my_net_write(&thd->net, (char*)packet->ptr(), packet->length())) @@ -661,14 +661,14 @@ mysqld_dump_create_info(THD *thd, TABLE *table, int fd) } else { - if(my_write(fd, (const byte*) packet->ptr(), packet->length(), + if(my_write(fd, (const byte*) packet->ptr(), packet->length(), MYF(MY_WME))) DBUG_RETURN(-1); } DBUG_RETURN(0); } - + static int store_create_info(THD *thd, TABLE *table, String* packet) { @@ -676,37 +676,37 @@ store_create_info(THD *thd, TABLE *table, String* packet) DBUG_PRINT("enter",("table: %s",table->real_name)); restore_record(table,2); // Get empty record - + List<Item> field_list; char tmp[MAX_FIELD_WIDTH]; String type(tmp, sizeof(tmp)); packet->append("create table ", 13); packet->append(table->real_name); packet->append('('); - + Field **ptr,*field; for (ptr=table->field ; (field= *ptr); ptr++) { if(ptr != table->field) packet->append(','); - + uint flags = field->flags; packet->append(field->field_name); packet->append(' '); // check for surprises from the previous call to Field::sql_type() if(type.ptr() != tmp) type.set(tmp, sizeof(tmp)); - + field->sql_type(type); packet->append(type.ptr(),type.length()); - + bool null_default_value = (field->type() == FIELD_TYPE_TIMESTAMP || field->unireg_check == Field::NEXT_NUMBER); bool has_default = (field->type() != FIELD_TYPE_BLOB); - + if((flags & NOT_NULL_FLAG) && !null_default_value) packet->append(" not null", 9); - + if(has_default) { @@ -724,51 +724,54 @@ store_create_info(THD *thd, TABLE *table, String* packet) else packet->append(tmp,0); } - + if (field->unireg_check == Field::NEXT_NUMBER) packet->append(" auto_increment", 15 ); - + } KEY *key_info=table->key_info; table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK | HA_STATUS_TIME); uint primary_key = table->primary_key; - + for (uint i=0 ; i < table->keys ; i++,key_info++) { packet->append(','); - + KEY_PART_INFO *key_part= key_info->key_part; if(i == primary_key) packet->append("primary", 7); else if(key_info->flags & HA_NOSAME) packet->append("unique", 6); + else if(key_info->flags & HA_FULLTEXT) + packet->append("fulltext", 8); packet->append(" key ", 5); if(i != primary_key) packet->append(key_info->name); - + packet->append('('); - + for (uint j=0 ; j < key_info->key_parts ; j++,key_part++) { if(j) packet->append(','); - + if(key_part->field) packet->append(key_part->field->field_name); KEY *key=table->key_info+i; - + if (!key_part->field || - key_part->length != - table->field[key_part->fieldnr-1]->key_length()) + (key_part->length != + table->field[key_part->fieldnr-1]->key_length() && + !(key_info->flags & HA_FULLTEXT))) { char buff[64]; buff[0] = '('; char* end=int10_to_str((long) key_part->length, buff + 1,10); *end++ = ')'; - packet->append(buff,(uint) (end-buff)); + packet->append(buff,(uint) (end-buff)); } } @@ -776,13 +779,13 @@ store_create_info(THD *thd, TABLE *table, String* packet) } packet->append(')'); - + handler *file = table->file; packet->append(" type=", 6); packet->append(file->table_type()); char buff[128]; char* p; - + if(table->min_rows) { packet->append(" min_rows="); @@ -796,7 +799,7 @@ store_create_info(THD *thd, TABLE *table, String* packet) p = longlong10_to_str(table->max_rows, buff, 10); packet->append(buff, (uint) (p - buff)); } - + if (table->db_create_options & HA_OPTION_PACK_KEYS) packet->append(" pack_keys=1", 12); if (table->db_create_options & HA_OPTION_NO_PACK_KEYS) @@ -806,7 +809,7 @@ store_create_info(THD *thd, TABLE *table, String* packet) if (table->db_create_options & HA_OPTION_DELAY_KEY_WRITE) packet->append(" delay_key_write=1",18); - + DBUG_RETURN(0); } diff --git a/sql/table.h b/sql/table.h index 7fe3e5de601..198e0d6e801 100644 --- a/sql/table.h +++ b/sql/table.h @@ -91,6 +91,7 @@ struct st_table { my_bool crypted; my_bool db_low_byte_first; /* Portable row format */ my_bool locked_by_flush; + my_bool locked_by_name; Field *next_number_field, /* Set if next_number is activated */ *found_next_number_field, /* Set on open */ *rowid_field; diff --git a/tests/drop_test.pl b/tests/drop_test.pl new file mode 100755 index 00000000000..9dcadf45c2e --- /dev/null +++ b/tests/drop_test.pl @@ -0,0 +1,220 @@ +#!/usr/bin/perl -w +# +# This is a test with uses processes to insert, select and drop tables. +# + +$opt_loop_count=100000; # Change this to make test harder/easier + +##################### Standard benchmark inits ############################## + +use DBI; +use Getopt::Long; +use Benchmark; + +package main; + +$opt_skip_create=$opt_skip_in=$opt_verbose=$opt_fast_insert= + $opt_lock_tables=$opt_debug=$opt_skip_delete=$opt_fast=$opt_force=0; +$opt_host=""; $opt_db="test"; + +GetOptions("host=s","db=s","loop-count=i","skip-create","skip-in","skip-delete", +"verbose","fast-insert","lock-tables","debug","fast","force") || die "Aborted"; +$opt_verbose=$opt_debug=$opt_lock_tables=$opt_fast_insert=$opt_fast=$opt_skip_in=$opt_force=undef; # Ignore warnings from these + +print "Testing 5 multiple connections to a server with 1 insert, 2 drop/rename\n"; +print "1 select and 1 flush thread\n"; + +$firsttable = "bench_f1"; + +#### +#### Start timeing and start test +#### + +$start_time=new Benchmark; +if (!$opt_skip_create) +{ + $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host", + $opt_user, $opt_password, + { PrintError => 0}) || die $DBI::errstr; + $dbh->do("drop table if exists $firsttable, ${firsttable}_1, ${firsttable}_2"); + + print "Creating table $firsttable in database $opt_db\n"; + $dbh->do("create table $firsttable (id int(6) not null, info varchar(32), marker char(1), primary key(id))") || die $DBI::errstr; + $dbh->disconnect; $dbh=0; # Close handler +} +$|= 1; # Autoflush + +#### +#### Start the tests +#### + +test_insert() if (($pid=fork()) == 0); $work{$pid}="insert"; +test_drop(1) if (($pid=fork()) == 0); $work{$pid}="drop 1"; +test_drop(2) if (($pid=fork()) == 0); $work{$pid}="drop 2"; +test_select() if (($pid=fork()) == 0); $work{$pid}="select"; +test_flush() if (($pid=fork()) == 0); $work{$pid}="flush"; + +$errors=0; +while (($pid=wait()) != -1) +{ + $ret=$?/256; + print "thread '" . $work{$pid} . "' finished with exit code $ret\n"; + $errors++ if ($ret != 0); +} + +if (!$opt_skip_delete && !$errors) +{ + $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host", + $opt_user, $opt_password, + { PrintError => 0}) || die $DBI::errstr; + $dbh->do("drop table $firsttable"); + $dbh->disconnect; $dbh=0; # Close handler +} +print ($errors ? "Test failed\n" :"Test ok\n"); + +$end_time=new Benchmark; +print "Total time: " . + timestr(timediff($end_time, $start_time),"noc") . "\n"; + +exit(0); + +# +# Insert records in the table +# + +sub test_insert +{ + my ($dbh,$i); + + $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host", + $opt_user, $opt_password, + { PrintError => 0}) || die $DBI::errstr; + for ($i=0 ; $i < $opt_loop_count; $i++) + { + if (!$dbh->do("insert into $firsttable values ($i,'This is entry $i','')")) + { + print "Warning; Got error on insert: " . $dbh->errstr . "\n" if (! ($dbh->errstr =~ /doesn't exist/)); + } + } + $dbh->disconnect; $dbh=0; + print "Test_insert: Inserted $i rows\n"; + exit(0); +} + + +sub test_drop +{ + my ($id) = @_; + my ($dbh,$i,$sth,$error_counter,$sleep_time); + + $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host", + $opt_user, $opt_password, + { PrintError => 0}) || die $DBI::errstr; + $error_counter=0; + $sleep_time=2; + for ($i=0 ; $i < $opt_loop_count ; $i++) + { + sleep($sleep_time); + # Check if insert thread is ready + $sth=$dbh->prepare("select count(*) from $firsttable") || die "Got error on select from $firsttable: $dbh->errstr\n"; + if (!$sth->execute || !(@row = $sth->fetchrow_array()) || + !$row[0]) + { + $sth->finish; + $sleep_time=1; + last if ($error_counter++ == 5); + next; + } + $sleep_time=2; + $sth->finish; + + # Change to use a new table + $dbh->do("create table ${firsttable}_$id (id int(6) not null, info varchar(32), marker char(1), primary key(id))") || die $DBI::errstr; + $dbh->do("drop table if exists $firsttable") || die "Got error on drop table: $dbh->errstr\n"; + if (!$dbh->do("alter table ${firsttable}_$id rename to $firsttable")) + { + print "Warning; Got error from alter table: " . $dbh->errstr . "\n" if (! ($dbh->errstr =~ /already exist/)); + $dbh->do("drop table if exists ${firsttable}_$id") || die "Got error on drop table: $dbh->errstr\n"; + } + } + $dbh->do("drop table if exists $firsttable,${firsttable}_$id") || die "Got error on drop table: $dbh->errstr\n"; + $dbh->disconnect; $dbh=0; + print "Test_drop: Did a drop $i times\n"; + exit(0); +} + + +# +# select records +# + +sub test_select +{ + my ($dbh,$i,$sth,@row,$error_counter,$sleep_time); + + $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host", + $opt_user, $opt_password, + { PrintError => 0}) || die $DBI::errstr; + + $error_counter=0; + $sleep_time=3; + for ($i=0 ; $i < $opt_loop_count ; $i++) + { + sleep($sleep_time); + $sth=$dbh->prepare("select sum(t.id) from $firsttable as t,$firsttable as t2") || die "Got error on select: $dbh->errstr;\n"; + if ($sth->execute) + { + @row = $sth->fetchrow_array(); + $sth->finish; + $sleep_time=3; + } + else + { + print "Warning; Got error from select: " . $dbh->errstr . "\n" if (! ($dbh->errstr =~ /doesn't exist/)); + $sth->finish; + last if ($error_counter++ == 5); + $sleep_time=1; + } + } + $dbh->disconnect; $dbh=0; + print "Test_select: ok\n"; + exit(0); +} + +# +# flush records +# + +sub test_flush +{ + my ($dbh,$i,$sth,@row,$error_counter,$sleep_time); + + $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host", + $opt_user, $opt_password, + { PrintError => 0}) || die $DBI::errstr; + + $error_counter=0; + $sleep_time=5; + for ($i=0 ; $i < $opt_loop_count ; $i++) + { + sleep($sleep_time); + $sth=$dbh->prepare("select count(*) from $firsttable") || die "Got error on prepar: $dbh->errstr;\n"; + if ($sth->execute) + { + @row = $sth->fetchrow_array(); + $sth->finish; + $sleep_time=5; + $dbh->do("flush tables $firsttable") || die "Got error on flush table: " . $dbh->errstr . "\n"; + } + else + { + print "Warning; Got error from select: " . $dbh->errstr . "\n" if (! ($dbh->errstr =~ /doesn't exist/)); + $sth->finish; + last if ($error_counter++ == 5); + $sleep_time=1; + } + } + $dbh->disconnect; $dbh=0; + print "Test_select: ok\n"; + exit(0); +} diff --git a/tests/fork_test.pl b/tests/fork_test.pl index cd166b84555..26c614a364a 100755 --- a/tests/fork_test.pl +++ b/tests/fork_test.pl @@ -67,7 +67,7 @@ $errors=0; while (($pid=wait()) != -1) { $ret=$?/256; - print "thread '" . $work{$pid} . "' finnished with exit code $ret\n"; + print "thread '" . $work{$pid} . "' finished with exit code $ret\n"; $errors++ if ($ret != 0); } diff --git a/tests/grant.pl b/tests/grant.pl index a34a2909897..0219fdb71ee 100644 --- a/tests/grant.pl +++ b/tests/grant.pl @@ -40,9 +40,9 @@ $columns_cols="Host, Db, User, Table_name, Column_name, Column_priv"; # clear grant tables # -$dbh = DBI->connect("DBI:mysql:mysql:$opt_host;mysql_read_default_group=perl", +$dbh = DBI->connect("DBI:mysql:mysql:$opt_host", $opt_root_user,$opt_password, - { PrintError => 0}) || die "Can't connect to mysql server: $DBI::errstr\n"; + { PrintError => 0}) || die "Can't connect to mysql server with user '$opt_root_user': $DBI::errstr\n"; safe_query("delete from user where user='$opt_user' or user='${opt_user}2'"); safe_query("delete from db where user='$opt_user'"); @@ -171,8 +171,7 @@ user_query("create table $opt_database.test2 (a int not null)"); user_query("alter table $opt_database.test2 add b int"); user_query("create index dummy on $opt_database.test2 (a)"); user_query("drop table $opt_database.test2"); -user_query("show tables"); - +user_query("show tables from grant_test"); # These should fail user_query("insert into mysql.user (host,user) values ('error','$opt_user',0)",1); @@ -242,7 +241,22 @@ user_query("grant select on $opt_database.test2 to $user with grant option",1); safe_query("grant drop on $opt_database.test2 to $user with grant option"); user_query("grant drop on $opt_database.test2 to $user with grant option"); user_query("grant select on $opt_database.test2 to $user with grant option",1); -user_query("drop table $opt_database.test2"); + +# check rename privileges +user_query("rename table $opt_database.test2 to $opt_database.test3",1); +safe_query("grant CREATE,DROP on $opt_database.test3 to $user"); +user_query("rename table $opt_database.test2 to $opt_database.test3",1); +user_query("create table $opt_database.test3 (a int)"); +safe_query("grant INSERT on $opt_database.test3 to $user"); +user_query("drop table $opt_database.test3"); +user_query("rename table $opt_database.test2 to $opt_database.test3"); +user_query("rename table $opt_database.test3 to $opt_database.test2",1); +safe_query("grant ALTER on $opt_database.test3 to $user"); +user_query("rename table $opt_database.test3 to $opt_database.test2"); +safe_query("revoke DROP on $opt_database.test2 from $user"); +user_query("rename table $opt_database.test2 to $opt_database.test3"); +user_query("drop table if exists $opt_database.test2,$opt_database.test3",1); +safe_query("drop table if exists $opt_database.test2,$opt_database.test3"); # Check that the user doesn't have some user privileges user_query("create database $opt_database",1); @@ -253,9 +267,9 @@ safe_query("flush privileges"); safe_query("select $tables_cols from mysql.tables_priv"); safe_query("revoke ALL PRIVILEGES on $opt_database.test from $user"); safe_query("revoke ALL PRIVILEGES on $opt_database.test2 from $user"); +safe_query("revoke ALL PRIVILEGES on $opt_database.test3 from $user"); safe_query("revoke GRANT OPTION on $opt_database.test2 from $user"); safe_query("select $tables_cols from mysql.tables_priv"); - user_query("select count(a) from test",1); # @@ -435,7 +449,8 @@ sub print_info my $tmp; print <<EOF; This test will clear your table and column grant table and recreate the -$opt_database database ! All privileges for $user will be destroyed ! +$opt_database database ! +All privileges for $user will be destroyed ! Don\'t run this test if you have done any GRANT commands that you want to keep! EOF diff --git a/tests/grant.res b/tests/grant.res index 7cc08807fd1..37266facc61 100644 --- a/tests/grant.res +++ b/tests/grant.res @@ -119,7 +119,7 @@ Error in execute: Access denied for user: 'grant_user@localhost' to database 'gr drop table grant_test.test Error in execute: Access denied for user: 'grant_user@localhost' to database 'grant_test' grant ALL PRIVILEGES on grant_test.* to grant_user2@localhost -Error in execute: Access denied for user: 'grant_user@localhost' (Using password: NO) +Error in execute: Access denied for user: 'grant_user@localhost' to database 'grant_test' grant ALL PRIVILEGES on grant_test.* to grant_user@localhost WITH GRANT OPTION Connecting grant_user insert into grant_test.test values (5,0) @@ -145,7 +145,9 @@ create table grant_test.test2 (a int not null) alter table grant_test.test2 add b int create index dummy on grant_test.test2 (a) drop table grant_test.test2 -show tables +show tables from grant_test +test + insert into mysql.user (host,user) values ('error','grant_user',0) Error in execute: Access denied for user: 'grant_user@localhost' to database 'mysql' revoke ALL PRIVILEGES on grant_test.* from grant_user@localhost @@ -239,7 +241,24 @@ grant drop on grant_test.test2 to grant_user@localhost with grant option grant drop on grant_test.test2 to grant_user@localhost with grant option grant select on grant_test.test2 to grant_user@localhost with grant option Error in execute: select command denied to user: 'grant_user@localhost' for table 'test2' -drop table grant_test.test2 +rename table grant_test.test2 to grant_test.test3 +Error in execute: insert command denied to user: 'grant_user@localhost' for table 'test3' +grant CREATE,DROP on grant_test.test3 to grant_user@localhost +rename table grant_test.test2 to grant_test.test3 +Error in execute: insert command denied to user: 'grant_user@localhost' for table 'test3' +create table grant_test.test3 (a int) +grant INSERT on grant_test.test3 to grant_user@localhost +drop table grant_test.test3 +rename table grant_test.test2 to grant_test.test3 +rename table grant_test.test3 to grant_test.test2 +Error in execute: alter command denied to user: 'grant_user@localhost' for table 'test3' +grant ALTER on grant_test.test3 to grant_user@localhost +rename table grant_test.test3 to grant_test.test2 +revoke DROP on grant_test.test2 from grant_user@localhost +rename table grant_test.test2 to grant_test.test3 +drop table if exists grant_test.test2,grant_test.test3 +Error in execute: drop command denied to user: 'grant_user@localhost' for table 'test2' +drop table if exists grant_test.test2,grant_test.test3 create database grant_test Error in execute: Access denied for user: 'grant_user@localhost' to database 'grant_test' drop database grant_test @@ -248,15 +267,15 @@ flush tables Error in execute: Access denied for user: 'grant_user@localhost' (Using password: NO) flush privileges select Host, Db, User, Table_name, Grantor, Table_priv, Column_priv from mysql.tables_priv -localhost grant_test grant_user test2 grant_user@localhost Update,Delete,Create,Drop,Grant,Index,Alter Insert +localhost grant_test grant_user test2 root@localhost Update,Delete,Create,Grant,Index,Alter Insert localhost grant_test grant_user test root@localhost Select,Insert,Update,Delete +localhost grant_test grant_user test3 root@localhost Insert,Create,Drop,Alter revoke ALL PRIVILEGES on grant_test.test from grant_user@localhost revoke ALL PRIVILEGES on grant_test.test2 from grant_user@localhost +revoke ALL PRIVILEGES on grant_test.test3 from grant_user@localhost revoke GRANT OPTION on grant_test.test2 from grant_user@localhost select Host, Db, User, Table_name, Grantor, Table_priv, Column_priv from mysql.tables_priv -localhost grant_test grant_user test2 root@localhost Grant,Index,Alter - select count(a) from test Error in execute: select command denied to user: 'grant_user@localhost' for table 'test' delete from grant_test.test where a=2 @@ -284,13 +303,10 @@ select a,A from test 7 7 select Host, Db, User, Table_name, Grantor, Table_priv, Column_priv from mysql.tables_priv -localhost grant_test grant_user test2 root@localhost Grant,Index,Alter localhost grant_test grant_user test root@localhost Delete Select,Update revoke ALL PRIVILEGES on grant_test.test from grant_user@localhost select Host, Db, User, Table_name, Grantor, Table_priv, Column_priv from mysql.tables_priv -localhost grant_test grant_user test2 root@localhost Grant,Index,Alter - revoke GRANT OPTION on grant_test.test from grant_user@localhost Error in execute: There is no such grant defined for user 'grant_user' on host 'localhost' on table 'test' grant select(a) on grant_test.test to grant_user@localhost @@ -328,7 +344,6 @@ Error in execute: select command denied to user: 'grant_user@localhost' for colu update test set b=3 where b > 0 Error in execute: select command denied to user: 'grant_user@localhost' for column 'b' in table 'test' select Host, Db, User, Table_name, Grantor, Table_priv, Column_priv from mysql.tables_priv -localhost grant_test grant_user test2 root@localhost Grant,Index,Alter localhost grant_test grant_user test root@localhost Select,Insert,Update select Host, Db, User, Table_name, Column_name, Column_priv from mysql.columns_priv @@ -337,7 +352,6 @@ localhost grant_test grant_user test a Select revoke select(a), update (b) on grant_test.test from grant_user@localhost select Host, Db, User, Table_name, Grantor, Table_priv, Column_priv from mysql.tables_priv -localhost grant_test grant_user test2 root@localhost Grant,Index,Alter localhost grant_test grant_user test root@localhost Insert select Host, Db, User, Table_name, Column_name, Column_priv from mysql.columns_priv @@ -355,7 +369,6 @@ insert into test (b) values (9) update test set b=6 where b > 0 flush privileges select Host, Db, User, Table_name, Grantor, Table_priv, Column_priv from mysql.tables_priv -localhost grant_test grant_user test2 root@localhost Grant,Index,Alter localhost grant_test grant_user test root@localhost Select,Insert,Update select Host, Db, User, Table_name, Column_name, Column_priv from mysql.columns_priv @@ -402,7 +415,6 @@ select * from mysql.db where user = 'grant_user' localhost grant_test grant_user N Y N N N N N N N N select Host, Db, User, Table_name, Grantor, Table_priv, Column_priv from mysql.tables_priv where user = 'grant_user' -localhost grant_test grant_user test2 root@localhost Grant,Index,Alter localhost grant_test grant_user test root@localhost Select,Insert,Update select Host, Db, User, Table_name, Column_name, Column_priv from mysql.columns_priv where user = 'grant_user' @@ -418,8 +430,6 @@ select * from mysql.db where user = 'grant_user' localhost grant_test grant_user N Y N N N N N N N N select Host, Db, User, Table_name, Grantor, Table_priv, Column_priv from mysql.tables_priv where user = 'grant_user' -localhost grant_test grant_user test2 root@localhost Grant,Index,Alter - select Host, Db, User, Table_name, Column_name, Column_priv from mysql.columns_priv where user = 'grant_user' delete from user where user='grant_user' flush privileges diff --git a/tests/rename_test.pl b/tests/rename_test.pl new file mode 100755 index 00000000000..bdfb14be927 --- /dev/null +++ b/tests/rename_test.pl @@ -0,0 +1,204 @@ +#!/usr/bin/perl -w +# +# This is a test with uses processes to insert, select and drop tables. +# + +$opt_loop_count=100000; # Change this to make test harder/easier + +##################### Standard benchmark inits ############################## + +use DBI; +use Getopt::Long; +use Benchmark; + +package main; + +$opt_skip_create=$opt_skip_delete=$opt_skip_flush=0; +$opt_host=""; $opt_db="test"; + +GetOptions("host=s","db=s","loop-count=i","skip-create","skip-delete", +"skip-flush") || die "Aborted"; + +print "Testing 5 multiple connections to a server with 1 insert, 1 rename\n"; +print "1 select and 1 flush thread\n"; + +$firsttable = "bench_f1"; + +#### +#### Start timing and start test +#### + +$start_time=new Benchmark; +if (!$opt_skip_create) +{ + $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host", + $opt_user, $opt_password, + { PrintError => 0}) || die $DBI::errstr; + $dbh->do("drop table if exists $firsttable, ${firsttable}_1, ${firsttable}_2"); + + print "Creating table $firsttable in database $opt_db\n"; + $dbh->do("create table $firsttable (id int(6) not null, info varchar(32), marker char(1), primary key(id))") || die $DBI::errstr; + $dbh->disconnect; $dbh=0; # Close handler +} +$|= 1; # Autoflush + +#### +#### Start the tests +#### + +test_insert() if (($pid=fork()) == 0); $work{$pid}="insert"; +test_rename(1) if (($pid=fork()) == 0); $work{$pid}="rename 1"; +test_rename(2) if (($pid=fork()) == 0); $work{$pid}="rename 2"; +test_select() if (($pid=fork()) == 0); $work{$pid}="select"; +if (!$opt_skip_flush) +{ + test_flush() if (($pid=fork()) == 0); $work{$pid}="flush"; +} +$errors=0; +while (($pid=wait()) != -1) +{ + $ret=$?/256; + print "thread '" . $work{$pid} . "' finished with exit code $ret\n"; + $errors++ if ($ret != 0); +} + +if (!$opt_skip_delete && !$errors) +{ + $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host", + $opt_user, $opt_password, + { PrintError => 0}) || die $DBI::errstr; + $dbh->do("drop table $firsttable"); + $dbh->disconnect; $dbh=0; # Close handler +} +print ($errors ? "Test failed\n" :"Test ok\n"); + +$end_time=new Benchmark; +print "Total time: " . + timestr(timediff($end_time, $start_time),"noc") . "\n"; + +exit(0); + +# +# Insert records in the table. Delete table when test is finnished +# + +sub test_insert +{ + my ($dbh,$i,$error); + + $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host", + $opt_user, $opt_password, + { PrintError => 0}) || die $DBI::errstr; + for ($i=0 ; $i < $opt_loop_count; $i++) + { + if (!$dbh->do("insert into $firsttable values ($i,'This is entry $i','')")) + { + $error=$dbh->errstr; + $dbh->do("drop table ${firsttable}"); # End other threads + die "Warning; Got error on insert: " . $error . "\n"; + } + } + sleep(1); + $dbh->do("drop table ${firsttable}") || die "Got error on drop table: " . $dbh->errstr . "\n"; + $dbh->disconnect; $dbh=0; + print "Test_insert: Inserted $i rows\n"; + exit(0); +} + + +sub test_rename +{ + my ($id) = @_; + my ($dbh,$i,$error_counter,$sleep_time); + + $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host", + $opt_user, $opt_password, + { PrintError => 0}) || die $DBI::errstr; + $error_counter=0; + $sleep_time=2; + for ($i=0 ; $i < $opt_loop_count ; $i++) + { + sleep($sleep_time); + $dbh->do("create table ${firsttable}_$id (id int(6) not null, info varchar(32), marker char(1), primary key(id))") || die $DBI::errstr; + if (!$dbh->do("rename table $firsttable to ${firsttable}_${id}_1, ${firsttable}_$id to ${firsttable}")) + { + last if ($dbh->errstr =~ /^Can\'t find/); + die "Got error on rename: " . $dbh->errstr . "\n"; + } + $dbh->do("drop table ${firsttable}_${id}_1") || die "Got error on drop table: " . $dbh->errstr . "\n"; + } + $dbh->disconnect; $dbh=0; + print "Test_drop: Did a drop $i times\n"; + exit(0); +} + + +# +# select records +# + +sub test_select +{ + my ($dbh,$i,$sth,@row,$sleep_time); + + $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host", + $opt_user, $opt_password, + { PrintError => 0}) || die $DBI::errstr; + + $sleep_time=3; + for ($i=0 ; $i < $opt_loop_count ; $i++) + { + sleep($sleep_time); + $sth=$dbh->prepare("select sum(t.id) from $firsttable as t,$firsttable as t2") || die "Got error on select: $dbh->errstr;\n"; + if ($sth->execute) + { + @row = $sth->fetchrow_array(); + $sth->finish; + } + else + { + $sth->finish; + last if (! ($dbh->errstr =~ /doesn\'t exist/)); + die "Got error on select: " . $dbh->errstr . "\n"; + } + } + $dbh->disconnect; $dbh=0; + print "Test_select: ok\n"; + exit(0); +} + +# +# flush records +# + +sub test_flush +{ + my ($dbh,$i,$sth,@row,$error_counter,$sleep_time); + + $dbh = DBI->connect("DBI:mysql:$opt_db:$opt_host", + $opt_user, $opt_password, + { PrintError => 0}) || die $DBI::errstr; + + $error_counter=0; + $sleep_time=5; + for ($i=0 ; $i < $opt_loop_count ; $i++) + { + sleep($sleep_time); + $sth=$dbh->prepare("select count(*) from $firsttable") || die "Got error on prepar: $dbh->errstr;\n"; + if ($sth->execute) + { + @row = $sth->fetchrow_array(); + $sth->finish; + $sleep_time=5; + $dbh->do("flush tables $firsttable") || die "Got error on flush table: " . $dbh->errstr . "\n"; + } + else + { + last if (! ($dbh->errstr =~ /doesn\'t exist/)); + die "Got error on flush: " . $dbh->errstr . "\n"; + } + } + $dbh->disconnect; $dbh=0; + print "Test_select: ok\n"; + exit(0); +} |