diff options
author | unknown <tim@work.mysql.com> | 2001-01-29 20:14:29 +0100 |
---|---|---|
committer | unknown <tim@work.mysql.com> | 2001-01-29 20:14:29 +0100 |
commit | bf1f8fd3eb4b98dadd265f8ed10d92220dabe1bb (patch) | |
tree | c871edb91cbcc25e8dc02efd481e5c826480a715 | |
parent | ef2e14428542668c46d72fe8a4795df74ec4fedf (diff) | |
parent | 74e9d984e7404e559a0fc8c5636b113edfb3cd97 (diff) | |
download | mariadb-git-bf1f8fd3eb4b98dadd265f8ed10d92220dabe1bb.tar.gz |
Merge work.mysql.com:/home/bk/mysql
into work.mysql.com:/d1/users/tim/my/work
BitKeeper/etc/logging_ok:
auto-union
115 files changed, 1856 insertions, 647 deletions
diff --git a/.bzrignore b/.bzrignore index 8fac7c488a0..5983d500693 100644 --- a/.bzrignore +++ b/.bzrignore @@ -189,3 +189,4 @@ tmp/* extra/resolve_stack_dump sql/share/*.sys BitKeeper/tmp/bkr3sAHD +BitKeeper/tmp/* diff --git a/BitKeeper/etc/gone b/BitKeeper/etc/gone index 7ea90fa5f39..cd5d9f96635 100644 --- a/BitKeeper/etc/gone +++ b/BitKeeper/etc/gone @@ -317,3 +317,64 @@ serg@serg.mysql.com|mysql-test/r/3.23/mrg000001.dummy.result|20001206231604|0505 serg@serg.mysql.com|mysql-test/r/3.23/mrg000001.result|20001206231609|46662|db2ef2e717ab8332 mwagner@evoq.home.mwagner.org|mysql-test/chew_on_this/select.res|20001014084759|41327|1295456b9394876 mwagner@evoq.home.mwagner.org|mysql-test/chew_on_this/select.res|20001014084759|41327|1295456b93948768 +BK|sql-bench/Results-linux/ATIS-interbase-Linux_2.2.14_5.0_i686-cmp-interbase,mysql|19700101030959|02361|6a0a837742a861bb +BK|sql-bench/Results-linux/ATIS-interbase-Linux_2.2.14_5.0_i686|19700101030959|02348|e87091e2a6dce931 +BK|sql-bench/Results-linux/ATIS-mysql-Linux_2.0.33_i586-cmp-access,mysql|19700101030959|02326|70981cb1dd58d3fb +BK|sql-bench/Results-linux/ATIS-mysql-Linux_2.0.33_i586-cmp-ms-sql,mysql,sybase|19700101030959|02327|67957b2b80839c59 +BK|sql-bench/Results-linux/ATIS-mysql-Linux_2.2.14_5.0_i686-cmp-interbase,mysql|19700101030959|02362|20e8179c6f87930d +BK|sql-bench/Results-linux/RUN-interbase-Linux_2.2.14_5.0_i686-cmp-interbase,mysql|19700101030959|02365|5e446b99518aa0b1 +BK|sql-bench/Results-linux/RUN-interbase-Linux_2.2.14_5.0_i686|19700101030959|02351|9a0d8be7d641fae7 +BK|sql-bench/Results-linux/RUN-mysql-Linux_2.0.33_i586-cmp-access,mysql|19700101030959|02334|5f0504783180d906 +BK|sql-bench/Results-linux/RUN-mysql-Linux_2.0.33_i586-cmp-ms-sql,mysql,sybase|19700101030959|02335|6abba8bd8d9f8b7b +BK|sql-bench/Results-linux/RUN-mysql-Linux_2.2.14_5.0_i686-cmp-interbase,mysql|19700101030959|02366|730674f4ac333638 +BK|sql-bench/Results-linux/alter-table-interbase-Linux_2.2.14_5.0_i686-cmp-interbase,mysql|19700101030959|02367|e901749edf05bb58 +BK|sql-bench/Results-linux/alter-table-interbase-Linux_2.2.14_5.0_i686|19700101030959|02352|c4e27f25a15b6681 +BK|sql-bench/Results-linux/alter-table-mysql-Linux_2.2.14_5.0_i686-cmp-interbase,mysql|19700101030959|02368|19c95f9fc4ee458 +BK|sql-bench/Results-linux/big-tables-interbase-Linux_2.2.14_5.0_i686-cmp-interbase,mysql|19700101030959|02371|c0c1c5efea0661ad +BK|sql-bench/Results-linux/big-tables-interbase-Linux_2.2.14_5.0_i686|19700101030959|02353|beba3adfcfd472c0 +BK|sql-bench/Results-linux/big-tables-mysql-Linux_2.0.33_i586-cmp-access,mysql|19700101030959|02341|cabe523a8f103945 +BK|sql-bench/Results-linux/big-tables-mysql-Linux_2.0.33_i586-cmp-ms-sql,mysql,sybase|19700101030959|02342|c682fb7ee1fb3d8 +BK|sql-bench/Results-linux/big-tables-mysql-Linux_2.2.14_5.0_i686-cmp-interbase,mysql|19700101030959|02372|69d33d25eda85041 +BK|sql-bench/Results-linux/connect-interbase-Linux_2.2.14_5.0_i686-cmp-interbase,mysql|19700101030959|02373|744f1e38649d21d +BK|sql-bench/Results-linux/connect-interbase-Linux_2.2.14_5.0_i686|19700101030959|02354|c28534284b9f5657 +BK|sql-bench/Results-linux/connect-mysql-Linux_2.0.33_i586-cmp-access,mysql|19700101030959|02349|ebdc62367f5fcd43 +BK|sql-bench/Results-linux/connect-mysql-Linux_2.0.33_i586-cmp-ms-sql,mysql,sybase|19700101030959|02350|7ed494b7cc7081c9 +BK|sql-bench/Results-linux/connect-mysql-Linux_2.2.14_5.0_i686-cmp-interbase,mysql|19700101030959|02374|55d777517ce8091 +BK|sql-bench/Results-linux/create-interbase-Linux_2.2.14_5.0_i686-cmp-interbase,mysql|19700101030959|02377|d60ca06157cfc9b9 +BK|sql-bench/Results-linux/create-interbase-Linux_2.2.14_5.0_i686|19700101030959|02355|537da98f6c1bc6df +BK|sql-bench/Results-linux/create-mysql-Linux_2.0.33_i586-cmp-access,mysql|19700101030959|02356|612a182b889dd778 +BK|sql-bench/Results-linux/create-mysql-Linux_2.0.33_i586-cmp-ms-sql,mysql,sybase|19700101030959|02357|b501391eec112dd0 +BK|sql-bench/Results-linux/create-mysql-Linux_2.2.14_5.0_i686-cmp-interbase,mysql|19700101030959|02378|35bd48cfe30c16a3 +BK|sql-bench/Results-linux/insert-interbase-Linux_2.2.14_5.0_i686-cmp-interbase,mysql|19700101030959|02379|25161ee7c13036c1 +BK|sql-bench/Results-linux/insert-interbase-Linux_2.2.14_5.0_i686|19700101030959|02358|461a48df25628c0f +BK|sql-bench/Results-linux/insert-mysql-Linux_2.0.33_i586-cmp-access,mysql|19700101030959|02363|3260743076dbe95f +BK|sql-bench/Results-linux/insert-mysql-Linux_2.0.33_i586-cmp-ms-sql,mysql,sybase|19700101030959|02364|9de5538694cd87ea +BK|sql-bench/Results-linux/insert-mysql-Linux_2.2.14_5.0_i686-cmp-interbase,mysql|19700101030959|02380|7451b789c29b7dcd +BK|sql-bench/Results-linux/select-interbase-Linux_2.2.14_5.0_i686-cmp-interbase,mysql|19700101030959|02439|816ec12a9152b578 +BK|sql-bench/Results-linux/select-interbase-Linux_2.2.14_5.0_i686|19700101030959|02359|3535cd00c2a9cb5d +BK|sql-bench/Results-linux/select-mysql-Linux_2.0.33_i586-cmp-access,mysql|19700101030959|02369|de288cd8c11e1749 +BK|sql-bench/Results-linux/select-mysql-Linux_2.0.33_i586-cmp-ms-sql,mysql,sybase|19700101030959|02370|a82e759dbd5d66b +BK|sql-bench/Results-linux/select-mysql-Linux_2.2.14_5.0_i686-cmp-interbase,mysql|19700101030959|02440|862a7c0ef1b17f29 +BK|sql-bench/Results-linux/wisconsin-interbase-Linux_2.2.14_5.0_i686-cmp-interbase,mysql|19700101030959|02441|cb767c1f9abc2ebd +BK|sql-bench/Results-linux/wisconsin-interbase-Linux_2.2.14_5.0_i686|19700101030959|02360|9404247a2e483b34 +BK|sql-bench/Results-linux/wisconsin-mysql-Linux_2.0.33_i586-cmp-access,mysql|19700101030959|02375|8669562660b2c238 +BK|sql-bench/Results-linux/wisconsin-mysql-Linux_2.0.33_i586-cmp-ms-sql,mysql,sybase|19700101030959|02376|c7cbe3b167655f9c +BK|sql-bench/Results-linux/wisconsin-mysql-Linux_2.2.14_5.0_i686-cmp-interbase,mysql|19700101030959|02442|74b238eca114dbbe +monty@donna.mysql.com|sql-bench/Results-linux/ATIS-mysql_dbug-Linux_2.2.14_my_SMP_i686|20001218140918|34755|45d7837423db243f +monty@donna.mysql.com|sql-bench/Results-linux/ATIS-mysql_dbug_full-Linux_2.2.14_my_SMP_i686|20001218140918|37262|2274651e29d38b07 +monty@donna.mysql.com|sql-bench/Results-linux/RUN-mysql_dbug-Linux_2.2.14_my_SMP_i686|20001218140918|39831|a6ef8229d40b75d1 +monty@donna.mysql.com|sql-bench/Results-linux/RUN-mysql_dbug_full-Linux_2.2.14_my_SMP_i686|20001218140918|42374|65ccbcd7b1c4d7b5 +monty@donna.mysql.com|sql-bench/Results-linux/alter-table-mysql_dbug-Linux_2.2.14_my_SMP_i686|20001218140918|44909|de84e4a2fd07f53 +monty@donna.mysql.com|sql-bench/Results-linux/alter-table-mysql_dbug_full-Linux_2.2.14_my_SMP_i686|20001218140918|47422|ee162dd1474ba9d8 +monty@donna.mysql.com|sql-bench/Results-linux/big-tables-mysql_dbug-Linux_2.2.14_my_SMP_i686|20001218140918|49948|d11a751a268a4df3 +monty@donna.mysql.com|sql-bench/Results-linux/big-tables-mysql_dbug_full-Linux_2.2.14_my_SMP_i686|20001218140918|52469|c13eca5ec25cd6e1 +monty@donna.mysql.com|sql-bench/Results-linux/connect-mysql_dbug-Linux_2.2.14_my_SMP_i686|20001218140918|54998|dfaa50e67eb15556 +monty@donna.mysql.com|sql-bench/Results-linux/connect-mysql_dbug_full-Linux_2.2.14_my_SMP_i686|20001218140918|57532|4015a2bef627d8cd +monty@donna.mysql.com|sql-bench/Results-linux/create-mysql_dbug-Linux_2.2.14_my_SMP_i686|20001218140918|60103|fa19b9a2c7a3c3c +monty@donna.mysql.com|sql-bench/Results-linux/create-mysql_dbug_full-Linux_2.2.14_my_SMP_i686|20001218140918|62710|21ec8ba1ea3ca4c4 +monty@donna.mysql.com|sql-bench/Results-linux/insert-mysql_dbug-Linux_2.2.14_my_SMP_i686|20001218140918|65289|a02aceb3b30de493 +monty@donna.mysql.com|sql-bench/Results-linux/insert-mysql_dbug_full-Linux_2.2.14_my_SMP_i686|20001218140918|02393|7c9baa774fc324e1 +monty@donna.mysql.com|sql-bench/Results-linux/select-mysql_dbug-Linux_2.2.14_my_SMP_i686|20001218140918|05001|da73eefa16ca9383 +monty@donna.mysql.com|sql-bench/Results-linux/select-mysql_dbug_full-Linux_2.2.14_my_SMP_i686|20001218140918|07610|cffd7d282a90113a +monty@donna.mysql.com|sql-bench/Results-linux/wisconsin-mysql_dbug-Linux_2.2.14_my_SMP_i686|20001218140918|10615|8dcd7271a9137341 +monty@donna.mysql.com|sql-bench/Results-linux/wisconsin-mysql_dbug_full-Linux_2.2.14_my_SMP_i686|20001218140918|13213|4398328883aa75da diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 0de2e6a29f2..fd24496b265 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -6,5 +6,6 @@ paul@central.snake.net sasha@mysql.sashanet.com sasha@work.mysql.com serg@donna.mysql.com +serg@serg.mysql.com tim@cane.mysql.fi tim@work.mysql.com diff --git a/Docs/manual.texi b/Docs/manual.texi index ade214b3b3f..d4a4c2d0b17 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -130,6 +130,7 @@ version see the relevant distribution. * Common programs:: Using @strong{MySQL} with some common programs * Problems:: Problems * Common problems:: Solving some common problems with @strong{MySQL} +* Log files:: * Clients:: @strong{MySQL} client tools and APIs * Comparisons:: How does @strong{MySQL} compare with other databases? * MySQL internals:: @strong{MySQL} internals @@ -554,6 +555,7 @@ What Languages Are Supported by MySQL? * Character sets:: The character set used for data and sorting * Adding character set:: Adding a new character set +* Character arrays:: * String collating:: String collating support * Multi-byte characters:: Multi-byte character support @@ -566,7 +568,7 @@ Replication in MySQL * Replication Options:: Replication Options in my.cnf * Replication SQL:: SQL Commands related to replication * Replication FAQ:: Frequently Asked Questions about replication -* Troubleshooting Replication:: Troubleshooting Replication. Troubleshooting Replication +* Troubleshooting Replication:: Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication Getting Maximum Performance from MySQL @@ -631,7 +633,7 @@ Maintaining a MySQL Installation * Maintenance regimen:: Setting up a table maintenance regimen * Table-info:: Getting information about a table * Crash recovery:: Using @code{myisamchk} for crash recovery -* Log files:: Log file maintenance +* Log file maintenance:: Log file maintenance Using @code{myisamchk} for Table Maintenance and Crash Recovery @@ -726,11 +728,16 @@ Solving Some Common Problems with MySQL * Log Replication:: Database replication with update log * Backup:: Database backups -* Update log:: The update log -* Binary log:: The binary log -* Slow query log:: Log of slow queries * Multiple servers:: Running multiple @strong{MySQL} servers on the same machine +The MySQL log files + +* Error log:: +* Query log:: +* Update log:: +* Binary log:: +* Slow query log:: + MySQL Client Tools and APIs * C:: @strong{MySQL} C API @@ -857,6 +864,7 @@ Changes in release 4.0.x (Development; Alpha) Changes in release 3.23.x (Stable) +* News-3.23.33:: Changes in release 3.23.33 * News-3.23.32:: Changes in release 3.23.32 * News-3.23.31:: Changes in release 3.23.31 * News-3.23.30:: Changes in release 3.23.30 @@ -1007,6 +1015,14 @@ Comments on porting to other systems * RTS-threads:: Comments about RTS threads * Thread packages:: Differences between different thread packages +Debugging a MySQL server + +* Compiling for debugging:: +* Making trace files:: +* Using stack trace:: +* Using log files:: +* Reproducable test case:: + @end detailmenu @end menu @@ -1096,7 +1112,9 @@ The @code{mysqlbug} script should be used to generate bug reports. @c FIX! RPMs are also binary For source distributions, the @code{mysqlbug} script can be found in the @file{scripts} directory. For binary distributions, @code{mysqlbug} can -be found in the @file{bin} directory. +be found in the @file{bin} directory. If you have found a sensitive +security bug in @strong{MySQL}, you should send an email to +@email{security@@mysql.com}. @cindex errors, reporting @cindex reporting, errors @@ -2198,7 +2216,6 @@ Apart from the following links, you can find and download a lot of @uref{http://www.mysql.com/Downloads/Contrib/, Contrib directory}. @cindex @code{Contrib} directory - @cindex URLs to MySQL information @cindex related information URLs @strong{MySQL} @@ -2208,6 +2225,9 @@ Apart from the following links, you can find and download a lot of @item @uref{http://www.4t2.com/mysql}@* Information about the German MySQL mailing list. +@item @uref{http://www2.rent-a-database.de/mysql/} +@strong{MySQL} manual in German. + @item @uref{http://www.bitmover.com:8888//home/bk/mysql}@* Web access to the @strong{MySQL} BitKeeper repository. @@ -2246,8 +2266,10 @@ The Mac OS Xclave. Running @strong{MySQL} on Mac OS X MySQL for Mac OS X Server. @item @uref{http://www.latencyzero.com/macosx/mysql.html}@* Bulding MySQL for Mac OS X +@item @uref{http://www.essencesw.com/Software/mysqllib.html}@* +New Client libraries for the Mac OS Classic (Macintosh). @item @uref{http://www.lilback.com/macsql/}@* -Client libraries for the Macintosh. +Client libraries for Mac OS Classic (Macintosh). @end itemize @subheading Perl-related Links @@ -2336,6 +2358,9 @@ MySQL-Databases, creating of new DBs and tables, editing etc. @item @uref{http://www.scibit.com/Products/Software/Utils/Mascon.asp}@* Mascon is a powerful Win32 GUI for the administering MySQL server databases. + +@item @uref{http://www.rtlabs.com/}@* +MacSQL Monitor. GUI for MySQL, ODBC, and JDBC databases for the Mac OS. @end itemize @subheading Distributions that Include MySQL @@ -2514,7 +2539,7 @@ definitive standard for ODBC on the Linux platform. This is to include GUI support for KDE. @item @uref{http://www.sw-soft.com/products/BtrieveODBC/}@* -A @strong{MySQL}-based ODBC drivers for Btrieve. +A @strong{MySQL}-based ODBC drivers for Btrieve. From SWsoft. @end itemize @subheading @strong{API}-related Links @@ -2536,9 +2561,21 @@ any MTA to deliver to users in a @strong{MySQL} database. @item @uref{http://www.pbc.ottawa.on.ca}@* Visual Basic class generator for Active X. +@item @uref{http://www.essencesw.com/Software/mysqllib.html}@* +New Client libraries for the Mac OS Classic (Macintosh). + @item @uref{http://www.lilback.com/macsql/}@* Client libraries for the Macintosh. +@item @uref{http://www.essencesw.com/Plugins/mysqlplug.html}@* +Plugin for REALbasic (for Machintosh) + +@item @uref{http://www.iis.ee.ethz.ch/~neeri/macintosh/gusi-qa.html}@* +A library that emulates BSD sockets and pthreads on Macintosh. This can +be used if you want to compile the @strong{MySQL} client library on Mac. It +could probably even be sued to port @strong{MySQL} to Macintosh, but we +don't know of anyone that has tried that. + @c 404 not found @c @item @uref{http://tfdec1.fys.kuleuven.ac.be/~michael/fpc-linux/mysql}@* @c @strong{MySQL} binding to Free Pascal. @@ -3188,7 +3225,7 @@ try repairing your tables with @code{myisamchk} or @code{CHECK TABLE}/ If you often get corrupted tables you should try to find out when and why this happens! In this case, the @file{mysql-data-directory/'hostname'.err} file may contain some -information about what happened. Please include any relevant +information about what happened. @xref{Error log}. Please include any relevant information from this file in your bug report! Normally @code{mysqld} should @strong{NEVER} crash a table if nothing killed it in the middle of an update! If you can find the cause of @code{mysqld} dying, @@ -3598,7 +3635,7 @@ Payment should be made to: Postgirot Bank AB 105 06 STOCKHOLM, SWEDEN -TCX DataKonsult AB +MySQL AB BOX 6434 11382 STOCKHOLM, SWEDEN @@ -3615,7 +3652,7 @@ If you want to pay by check, make it payable to ``MySQL Finland AB'' and mail it to the address below: @example -TCX DataKonsult AB +MySQL AB BOX 6434, Torsgatan 21 11382 STOCKHOLM, SWEDEN @end example @@ -7565,8 +7602,15 @@ To compile on NetBSD you need GNU @code{make}. Otherwise the compile will crash when @code{make} tries to run @code{lint} on C++ files. @node OpenBSD, BSDI, NetBSD, Source install system issues -@subsection OpenBSD 2.5 Notes +@subsection OpenBSD Notes + +@menu +* OpenBSD 2.5:: OpenBSD 2.5 Notes +* OpenBSD 2.8:: OpenBSD 2.8 Notes +@end menu +@node OpenBSD 2.5 +@subsubsection OpenBSD 2.5 Notes On OpenBSD Version 2.5, you can compile @strong{MySQL} with native threads with the following options: @@ -7574,6 +7618,14 @@ with the following options: CFLAGS=-pthread CXXFLAGS=-pthread ./configure --with-mit-threads=no @end example +@node OpenBSD 2.8 +@subsubsection OpenBSD 2.8 Notes +Our users have reported that OpenBSD 2.8 has a threading bug which causes +problems with MySQL. The OpenBSD Developers have fixed the problem, but as +of January 25th, 2001, it's only available in the ``-current'' branch. The +symptoms of this threading bug are: slow response, high load, high cpu usage, +and crashes. + @node BSDI, SCO, OpenBSD, Source install system issues @subsection BSD/OS Notes @@ -8482,12 +8534,7 @@ utility in Win95. You must take it down with @code{mysqladmin shutdown}. Filenames are case insensitive on Windows, so database and table names are also case insensitive in @strong{MySQL} for Windows. The only restriction is that database and table names must be given in the same -case throughout a given statement. The following query would not work -because it refers to a table both as @code{my_table} and as -@code{MY_TABLE}: -@example -SELECT * FROM my_table WHERE MY_TABLE.col=1; -@end example +case throughout a given statement. @xref{Name case sensitivity}. @item The @samp{\} directory character Pathname components in Win95 are separated by the @samp{\} character, which is @@ -8536,6 +8583,13 @@ While you are doing an @code{ALTER TABLE} the table is locked from usage by other threads. This has to do with the fact that you on Windows can't delete a file that is in use by another threads. (We may in the future find some way to go around this problem). + +@item @code{DROP TABLE} on a table that is in use by a @code{MERGE} table will not work. +The @code{MERGE} handler does it table mapping hidden from @strong{MySQL}. +Because windows doesn't allow one to drop files that are open, you have +to first flush all @code{MERGE} tables (with @code{FLUSH TABLES}) or drop the +@code{MERGE} table before drooping the table. We will fix this at +the same time we introduce @code{VIEW}'s. @end table Here are some open issues for anyone who might want to help us with the Windows @@ -8894,17 +8948,19 @@ below: @example shell> BINDIR/mysqladmin version -mysqladmin Ver 6.3 Distrib 3.22.9-beta, for pc-linux-gnu on i686 -TCX Datakonsult AB, by Monty +mysqladmin Ver 8.14 Distrib 3.23.32, for linux on i586 +Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB +This software comes with ABSOLUTELY NO WARRANTY. This is free software, +and you are welcome to modify and redistribute it under the GPL license -Server version 3.22.9-beta +Server version 3.23.32-debug Protocol version 10 Connection Localhost via Unix socket TCP port 3306 UNIX socket /tmp/mysql.sock Uptime: 16 sec -Running threads: 1 Questions: 20 Reloads: 2 Open tables: 3 +Threads: 1 Questions: 9 Slow queries: 0 Opens: 7 Flush tables: 2 Open tables: 0 Queries per second avg: 0.000 Memory in use: 132K Max memory used: 16773K @end example To get a feeling for what else you can do with @code{BINDIR/mysqladmin}, @@ -9407,7 +9463,7 @@ Client error messages in given language. May be given as a full path. @xref{Languages}. @item -l, --log[=file] -Log connections and queries to file. +Log connections and queries to file. @xref{Query log}. @item --log-isam[=file] Log all ISAM/MyISAM changes to file (only used when debugging ISAM/MyISAM). @@ -10211,9 +10267,7 @@ This has a few implications: @item Database names and table names are case sensitive in @strong{MySQL} on operating systems that have case-sensitive filenames (like most Unix -systems). If you have a problem remembering table names, adopt a consistent -convention, such as always creating databases and tables using lowercase -names. +systems). @xref{Name case sensitivity}. @item Database, table, index, column, or alias names may begin with a digit @@ -13358,7 +13412,7 @@ In @strong{MySQL}, databases and tables correspond to directories and files within those directories. Consequently, the case sensitivity of the underlying operating system determines the case sensitivity of database and table names. This means database and table names are case sensitive in Unix -and case insensitive in Windows. +and case insensitive in Windows. @xref{Extensions to ANSI}. @strong{NOTE:} Although database and table names are case insensitive for Windows, you should not refer to a given database or table using different @@ -13381,6 +13435,17 @@ mysql> SELECT col_name FROM tbl_name AS a Aliases on columns are case insensitive. +If you have a problem remembering the used cases for a table names, +adopt a consistent convention, such as always creating databases and +tables using lowercase names. + +One way to avoid this problem is to start @code{mysqld} with @code{-O +lower_case_table_names=1}. + +In this case @strong{MySQL} will convert all table names to lower case on +storage and lookup. Not that you need to first convert your old table +names to lower case before starting @code{mysqld} with this option. + @cindex variables, user @cindex user variables @cindex names, variables @@ -15172,7 +15237,8 @@ mysql> select BIT_COUNT(29); @node Logical functions, Comparison functions, Bit functions, Functions @subsection Logical Operations -All logical functions return @code{1} (TRUE) or @code{0} (FALSE): +All logical functions return @code{1} (TRUE), @code{0} (FALSE) or +@code{NULL} (unknown, which is in most cases the same as FALSE): @table @code @findex NOT, logical @@ -18416,7 +18482,7 @@ swap two tables names, you have to: @example RENAME TABLE old_table TO backup_table, new_table TO old_table, - backup_table TO old_table; + backup_table TO new_table; @end example As long as two databases are on the same disk you can also rename @@ -18509,7 +18575,7 @@ CHECK TABLE tbl_name[,tbl_name...] [option [option...]] option = QUICK | FAST | MEDIUM | EXTEND | CHANGED @end example -@code{CHECK TABLE} only works on @code{MyISAM} and @code{BDB} tables. On +@code{CHECK TABLE} only works on @code{MyISAM} tables. On @code{MyISAM} tables it's the same thing as running @code{myisamchk -m table_name} on the table. @@ -18548,9 +18614,6 @@ For dynamic sized @code{MyISAM} tables a started check will always do a @code{MEDIUM} check. For static size rows we skip the row scan for @code{QUICK} and @code{FAST} as the rows are very seldom corrupted. -Note that for BDB tables the different check options doesn't affect the -check in any way! - You can combine check options as in: @example @@ -20264,59 +20327,64 @@ The following columns are returned: below, though the format and numbers probably differ: @example -+--------------------------+------------+ -| Variable_name | Value | -+--------------------------+------------+ -| Aborted_clients | 0 | -| Aborted_connects | 0 | -| Bytes_received | 142160923 | -| Bytes_sent | 1161910370 | -| Connections | 30022 | -| Created_tmp_disk_tables | 0 | -| Created_tmp_tables | 8988 | -| Delayed_insert_threads | 0 | -| Delayed_writes | 0 | -| Delayed_errors | 0 | -| Flush_commands | 1 | -| Handler_delete | 462604 | -| Handler_read_first | 95882 | -| Handler_read_key | 27681068 | -| Handler_read_next | 265008218 | -| Handler_read_prev | 3022500 | -| Handler_read_rnd | 36900998 | -| Handler_read_rnd_next | 252097176 | -| Handler_update | 16945404 | -| Handler_write | 66826676 | -| Key_blocks_used | 14955 | -| Key_read_requests | 90131960 | -| Key_reads | 163268 | -| Key_write_requests | 7573912 | -| Key_writes | 3780151 | -| Max_used_connections | 0 | -| Not_flushed_key_blocks | 0 | -| Not_flushed_delayed_rows | 0 | -| Open_tables | 0 | -| Open_files | 0 | -| Open_streams | 0 | -| Opened_tables | 44598 | -| Questions | 1866024 | -| Select_full_join | 0 | -| Select_full_range_join | 0 | -| Select_range | 68187 | -| Select_range_check | 0 | -| Select_scan | 31440 | -| Slave_running | OFF | -| Slow_launch_threads | 0 | -| Slow_queries | 0 | -| Sort_range | 0 | -| Sort_rows | 36650500 | -| Sort_scan | 5298 | -| Threads_cached | 0 | -| Threads_connected | 1 | -| Threads_created | 30022 | -| Threads_running | 1 | -| Uptime | 39613 | -+--------------------------+------------+ ++--------------------------+--------+ +| Variable_name | Value | ++--------------------------+--------+ +| Aborted_clients | 0 | +| Aborted_connects | 0 | +| Bytes_received | 629539 | +| Bytes_sent | 736394 | +| Connections | 62 | +| Created_tmp_disk_tables | 0 | +| Created_tmp_tables | 0 | +| Created_tmp_files | 0 | +| Delayed_insert_threads | 0 | +| Delayed_writes | 0 | +| Delayed_errors | 0 | +| Flush_commands | 1 | +| Handler_delete | 0 | +| Handler_read_first | 1 | +| Handler_read_key | 9201 | +| Handler_read_next | 0 | +| Handler_read_prev | 0 | +| Handler_read_rnd | 0 | +| Handler_read_rnd_next | 45 | +| Handler_update | 5998 | +| Handler_write | 0 | +| Key_blocks_used | 407 | +| Key_read_requests | 27683 | +| Key_reads | 407 | +| Key_write_requests | 0 | +| Key_writes | 0 | +| Max_used_connections | 60 | +| Not_flushed_key_blocks | 0 | +| Not_flushed_delayed_rows | 0 | +| Open_tables | 60 | +| Open_files | 66 | +| Open_streams | 0 | +| Opened_tables | 66 | +| Questions | 9308 | +| Select_full_join | 0 | +| Select_full_range_join | 0 | +| Select_range | 0 | +| Select_range_check | 0 | +| Select_scan | 0 | +| Slave_running | OFF | +| Slave_open_temp_tables | 0 | +| Slow_launch_threads | 0 | +| Slow_queries | 0 | +| Sort_merge_passes | 0 | +| Sort_range | 0 | +| Sort_rows | 0 | +| Sort_scan | 0 | +| Table_locks_immediate | 3183 | +| Table_locks_waited | 6030 | +| Threads_cached | 30 | +| Threads_created | 61 | +| Threads_connected | 31 | +| Threads_running | 31 | +| Uptime | 135 | ++--------------------------+--------+ @end example @cindex variables, status @@ -20379,6 +20447,12 @@ open by the slave thread @item @code{Sort_range} @tab Number of sorts that where done with ranges. @item @code{Sort_rows} @tab Number of sorted rows. @item @code{Sort_scan} @tab Number of sorts that where done by scanning the table. +@item @code{Table_locks_immediate} @tab Number of times a table lock was +acquired immediately. Available after 3.23.33. +@item @code{Table_locks_waited} @tab Number of times a table lock could not +be acquired immediately and a wait was needed. If this is high, and you +have performance problems, you should first optimize your queries, and then +either split your table(s) or use replication. Available after 3.23.33. @item @code{Threads_cached} @tab Number of threads in the thread cache. @item @code{Threads_connected} @tab Number of currently open connections. @item @code{Threads_created} @tab Number of threads created to handle connections. @@ -20710,13 +20784,9 @@ will be incremented. If you are using @code{--log-slow-queries}, the query will be logged to the slow query logfile. @xref{Slow query log}. @item @code{lower_case_table_names} -Is 1 if table names are stored in lowercase on disk. On @strong{MySQL} on Unix -tables are always case-sensitive; Is this a big problem for you can -start @code{mysqld} with @code{-O lower_case_table_names=1} - -In this case @strong{MySQL} will convert all table names to lower case on -storage and lookup. Not that you need to first convert your old table -names to lower case before starting @code{mysqld} with this option. +If set to 1 table names are stored in lowercase on disk. This will enable +you to access the table names case-insensitive also on Unix. +@xref{Name case sensitivity}. @item @code{max_allowed_packet} The maximum size of one packet. The message buffer is initialized to @@ -20731,6 +20801,11 @@ requires more than this amount of memory, one will get the error "Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage". +@item @code{max_binlog_size}. Available after 3.23.33. If a write to the +binary ( replication) log exceeds the given value, rotate the logs. You +cannot set it to less than 1024 bytes, or more than 1 GB. Default is +1 GB. + @item @code{max_connections} The number of simultaneous clients allowed. Increasing this value increases the number of file descriptors that @code{mysqld} requires. See below for @@ -22593,8 +22668,10 @@ that can be used as one. You can only @code{SELECT}, @code{DELETE}, and specification. With identical tables we mean that all tables are created with identical -column information. Some of the tables can be compressed with -@code{myisampack}. @xref{myisampack}. +column information. You can't put a MERGE over tables where the columns +are packed differently or doesn't have exactly the same columns. +Some of the tables can however be compressed with @code{myisampack}. +@xref{myisampack}. When you create a @code{MERGE} table, you will get a @code{.frm} table definition file and a @code{.MRG} table list file. The @code{.MRG} just @@ -22635,6 +22712,10 @@ batch, you should instead create a @code{MERGE} table on them on demand. This is much faster and will save a lot of disk space. @item Go around the file size limit for the operating system. +@item +You can create an alias/synonym for a table by just using MERGE over one +table. There shouldn't be any really notable performance impacts of doing this +(only a couple of indirect calls and memcpy's for each read). @end itemize The disadvantages with @code{MERGE} tables are: @@ -22683,6 +22764,7 @@ the outside of the @code{MySQL} server: @example shell> cd /mysql-data-directory/current-database shell> ls -1 t1.MYI t2.MYI > total.MRG +shell> mysqladmin flush-tables @end example Now you can do things like: @@ -22701,11 +22783,18 @@ mysql> select * from total; +---+---------+ @end example -To remap a @code{MERGE} table you must either @code{DROP} it and -re-create it, use @code{ALTER TABLE} with a new @code{UNION} -specification, or change the @code{.MRG} file and issue a @code{FLUSH -TABLE} on the @code{MERGE} table and all underlying tables to force the -handler to read the new definition file. +To remap a @code{MERGE} table you can do one of the following: + +@itemize @bullet +@item +@code{DROP} the table and re-create it +@item +Use @code{ALTER TABLE table_name UNION(...)} +@item +Change the @code{.MRG} file and issue a @code{FLUSH TABLE} on the +@code{MERGE} table and all underlying tables to force the handler to +read the new definition file. +@end itemize @cindex tables, ISAM @node ISAM, HEAP, MERGE, Table types @@ -22820,6 +22909,7 @@ SUM_OVER_ALL_KEYS(max_length_of_key + sizeof(char*) * 2) @code{sizeof(char*)} is 4 on 32-bit machines and 8 on 64-bit machines. @cindex tables, @code{BDB} +@cindex tables, @code{Berkeley DB} @node BDB, , HEAP, Table types @section BDB or Berkeley_db Tables @@ -23006,6 +23096,11 @@ unexpectedly. It should not be fatal even if this number is not 100 % correct. One can update the number of rows by executing @code{ANALYZE TABLE} or @code{OPTIMIZE TABLE}. @xref{ANALYZE TABLE} . @xref{OPTIMIZE TABLE}. +@item +If you get full disk with a @code{BDB} table, you will get an error +(probably error 28) and the transaction should roll back. This is in +contrast with @code{MyISAM} and @code{ISAM} tables where mysqld will +wait for enough free disk before continuing. @end itemize @node BDB TODO, BDB errors, BDB characteristic, BDB @@ -24566,7 +24661,8 @@ mysql> SELECT 1 IS NULL, 1 IS NOT NULL; +-----------+---------------+ @end example -In @strong{MySQL}, 0 means false and 1 means true. +In @strong{MySQL}, 0 or @code{NULL} means false and anything else means true. +The default trueth value from a boolean operation is 1. This special treatment of @code{NULL} is why, in the previous section, it was necessary to determine which animals are no longer alive using @@ -25420,6 +25516,7 @@ your changes with the new @file{errmsg.txt} file. @menu * Character sets:: The character set used for data and sorting * Adding character set:: Adding a new character set +* Character arrays:: * String collating:: String collating support * Multi-byte characters:: Multi-byte character support @end menu @@ -25478,28 +25575,52 @@ default-character-set=character-set-name but normally this is never needed. -To add another character set to @strong{MySQL}, use the following procedure. - @cindex character sets, adding @cindex adding, character sets -@node Adding character set, String collating, Character sets, Languages +@node Adding character set, Character arrays, Character sets, Languages @subsection Adding a New Character Set -@enumerate -@item -Choose a name for the character set, denoted @code{MYSET} below. +To add another character set to @strong{MySQL}, use the following procedure. -@item Decide if the set is simple or complex. If the character set does not need to use special string collating routines for -sorting and does not need mulit-byte character support, it is +sorting and does not need multi-byte character support, it is simple. If it needs either of those features, it is complex. +For example, @code{latin1} and @code{danish} are simple charactersets while +@code{big5} or @code{czech} are complex character sets. + +In the following section, we have assumed that you name your character +set @code{MYSET}. + +For a simple character set do the following: + +@enumerate @item -If the character set is simple, then create the file -@file{sql/share/charsets/MYSET.conf}, and add MYSET the -@file{sql/share/charsets/Index} file. Read the -@file{sql/share/charsets/README} for more instructions. +Add MYSET to the end of the @file{sql/share/charsets/Index} file +Assign an unique number to it. + +@item +Create the file @file{sql/share/charsets/MYSET.conf}. +(You can use @file{sql/share/charsets/latin1.conf} as a base for this). + +The syntax for the file very simple: + +@itemize @bullet +@item +Comments start with a '#' character and proceed to the end of the line. +@item +Words are separated by arbitrary amounts of whitespace. +@item +When defining the character set, every word must be a number in hexadecimal +format +@item +The @code{ctype} array takes up the first 257 words. The +@code{to_lower}, @code{to_upper} and @code{sort_order} arrays take up +256 words each after that. +@end itemize + +@xref{Character arrays}. @item Add the character set name to the @code{CHARSETS_AVAILABLE} and @@ -25508,20 +25629,28 @@ Add the character set name to the @code{CHARSETS_AVAILABLE} and @item Reconfigure, recompile, and test. +@end enumerate + +For a complex character set do the following: + +@enumerate @item -If the character set is complex, create the file -@file{strings/ctype-MYSET.c} in the @strong{MySQL} source distribution. +Create the file @file{strings/ctype-MYSET.c} in the @strong{MySQL} source +distribution. @item -Add MYSET to the end of the @file{sql/share/charsets/Index} file. Take -note of its position in the file - this is its character set number, -denoted @code{MYNUMBER} below. +Add MYSET to the end of the @file{sql/share/charsets/Index} file. +Assign an unique number to it. @item -Look at one of the existing @file{ctype-*.c} files to see what needs to be -defined. Note that the arrays in your file must have names like -@code{ctype_MYSET}, @code{to_lower_MYSET}, and so on. +Look at one of the existing @file{ctype-*.c} files to see what needs to +be defined, for example @file{strings/ctype-big5.c}. Note that the +arrays in your file must have names like @code{ctype_MYSET}, +@code{to_lower_MYSET}, and so on. This corresponds to the arrays +in the simple character set. @xref{Character arrays}. For a complex +character set +@item Near the top of the file, place a special comment like this: @example @@ -25543,6 +25672,34 @@ the following sections. Only include them if you the string collating functions or the multi-byte character set functions, respectively. +@item +You should then create some of the following functions: + +@itemize @bullet +@item @code{my_strncoll_MYSET()} +@item @code{my_strcoll_MYSET()} +@item @code{my_strxfrm_MYSET()} +@item @code{my_like_range_MYSET()} +@end itemize + +@xref{String collating}. + +@item +Add the character set name to the @code{CHARSETS_AVAILABLE} and +@code{COMPILED_CHARSETS} lists in @code{configure.in}. + +@item +Reconfigure, recompile, and test. +@end enumerate + +The file @file{sql/share/charsets/README} includes some more instructions. + +If you want to have the character set included in the @strong{MySQL} +distribution, mail a patch to @email{internals@@lists.mysql.com}. + +@node Character arrays, String collating, Adding character set, Languages +@subsection The character definition arrays + @code{to_lower[]} and @code{to_upper[]} are simple arrays that hold the lowercase and uppercase characters corresponding to each member of the character set. For example: @@ -25557,12 +25714,13 @@ comparison and sorting purposes. For many character sets, this is the same as @code{to_upper[]} (which means sorting will be case insensitive). @strong{MySQL} will sort characters based on the value of @code{sort_order[character]}. For more complicated sorting rules, see -the discussion of string collating below. +the discussion of string collating below. @xref{String collating}. @code{ctype[]} is an array of bit values, with one element for one character. (Note that @code{to_lower[]}, @code{to_upper[]}, and @code{sort_order[]} are indexed by character value, but @code{ctype[]} is indexed by character value + 1. This is an old legacy to be able to handle EOF.) + You can find the following bitmask definitions in @file{m_ctype.h}: @example @@ -25577,28 +25735,18 @@ You can find the following bitmask definitions in @file{m_ctype.h}: @end example The @code{ctype[]} entry for each character should be the union of the -applicable bitmask values that describe the character. -For example, @code{'A'} is an uppercase character (@code{_U}) as well as a -hexadecimal digit (@code{_X}), so @code{ctype['A'+1]} should contain the value: +applicable bitmask values that describe the character. For example, +@code{'A'} is an uppercase character (@code{_U}) as well as a +hexadecimal digit (@code{_X}), so @code{ctype['A'+1]} should contain the +value: + @example _U + _X = 01 + 0200 = 0201 @end example -@item -Add support for the string collating or multi-byte features needed, as -described in the following sections. - -@item -Add the character set name to the @code{CHARSETS_AVAILABLE} and -@code{COMPILED_CHARSETS} lists in @code{configure.in}. - -@item -Reconfigure, recompile, and test. -@end enumerate - @cindex collating, strings @cindex string collating -@node String collating, Multi-byte characters, Adding character set, Languages +@node String collating, Multi-byte characters, Character arrays, Languages @subsection String Collating Support If the sorting rules for your language are too complex to be handled @@ -25611,7 +25759,7 @@ character sets for examples. You must specify the @code{strxfrm_multiply_MYSET=N} value in the special comment at the top of the file. @code{N} should be set to -the maximum ratio the strings may grow during my_strxfrm_MYSET (it +the maximum ratio the strings may grow during @code{my_strxfrm_MYSET} (it must be a positive integer). @cindex characters, multi-byte @@ -25619,16 +25767,18 @@ must be a positive integer). @node Multi-byte characters, , String collating, Languages @subsection Multi-byte Character Support -If your character set includes multi-byte characters, you need to use -the multi-byte character functions. +If your want to add support for a new character set that includes +multi-byte characters, you need to use the multi-byte character +functions. Right now the best documentation on this is the character sets that are already implemented. Look at the euc_kr, gb2312, gbk, sjis and ujis -character sets for examples. +character sets for examples. These are implemented in the +@code{ctype-'charset'.c} files in the @file{strings} directory. -You must specify the @code{mbmaxlen_MYSET=N} value in the -special comment at the top of the file. @code{N} should be set to -the size in bytes of the largest character in the set. +You must specify the @code{mbmaxlen_MYSET=N} value in the special +comment at the top of the source file. @code{N} should be set to the +size in bytes of the largest character in the set. @cindex tables, maximum size @cindex size of tables @@ -25699,7 +25849,7 @@ tables}. * Replication Options:: Replication Options in my.cnf * Replication SQL:: SQL Commands related to replication * Replication FAQ:: Frequently Asked Questions about replication -* Troubleshooting Replication:: Troubleshooting Replication. Troubleshooting Replication +* Troubleshooting Replication:: Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication. Troubleshooting Replication @end menu @node Replication Intro, Replication Implementation, Replication, Replication @@ -25779,7 +25929,7 @@ below. @enumerate @item -Make you have a recent version of @strong{MySQL} installed on the master +Make sure you have a recent version of @strong{MySQL} installed on the master and slave(s). Use Version 3.23.29 or higher. Previous releases used a different binary @@ -26183,6 +26333,11 @@ summary of commands: @tab Re-enables update logging if the user has process privilege. Ignored otherwise. (Master) +@item @code{SET SQL_SLAVE_SKIP_COUNTER=n} + @tab Skip the next @code{n} events from the master. Only valid when +the slave thread is not running, otherwise, gives an error. Useful for +recovering from replication glitches. + @item @code{RESET MASTER} @tab Deletes all binary logs listed in the index file, resetting the binlog index file to be empty. In pre-3.23.26 versions, @code{FLUSH MASTER} (Master) @@ -26209,7 +26364,9 @@ CHANGE MASTER TO MASTER_HOST='master2.mycompany.com', MASTER_USER='replication', MASTER_PASSWORD='bigs3cret', - MASTER_PORT=3306; + MASTER_PORT=3306, + MASTER_LOG_FILE='master2-bin.001', + MASTER_LOG_POS=4; @end example @@ -26494,7 +26651,7 @@ the slaves of the master change in case of failure. Some suggestions: @item To tell a slave to change the master use the @code{CHANGE MASTER TO} command. @item -A good way to keep your applications informed where the master is is by +A good way to keep your applications informed where the master is by having a dynamic DNS entry for the master. With @strong{bind} you can use @code{nsupdate} to dynamically update your DNS. @item @@ -26538,12 +26695,36 @@ privileges for the replication user on the master, master host name, your DNS setup, whether the master is actually running, whether it is reachable from the slave, and if all that seems ok, read the error logs. @item -If the slave was running, but then stopped, check the error logs. It usually +If the slave was running, but then stopped, look at SHOW SLAVE STATUS +output andcheck the error logs. It usually happens when some query that succeeded on the master fails on the slave. This should never happen if you have taken a proper snapshot of the master, and never modify the data on the slave outside of the slave thread. If it does, it is a bug, read below on how to report it. @item +If a query on that succeeded on the master refuses to run on the slave, and +a full database resync ( the proper thing to do ) does not seem feasible, +try the following: +@itemize bullet +@item +First see if there is some stray record in the way. Understand how it got +there, then delete it and run @code{SLAVE START} +@item +If the above does not work or does not apply, try to understand if it would +be safe to make the update manually ( if needed) and then ignore the next +query from the master. +@item +If you have decided you can skip the next query, do +@code{SET SQL_SLAVE_SKIP_COUNTER=1; SLAVE START;} to skip a query that +does not use auto_increment, last_insert_id or timestamp, or +@code{SET SQL_SLAVE_SKIP_COUNTER=2; SLAVE START;} otherwise +@item +If you are sure the slave started out perfectly in sync with the master, +and no one has updated the tables involved outside of slave thread, +report the bug, so +you will not have to do the above tricks again. +@end itemize +@item Make sure you are not running into an old bug by upgrading to the most recent version. @item @@ -30420,7 +30601,7 @@ to start using the new table. * Maintenance regimen:: Setting up a table maintenance regimen * Table-info:: Getting information about a table * Crash recovery:: Using @code{myisamchk} for crash recovery -* Log files:: Log file maintenance +* Log file maintenance:: Log file maintenance @end menu @node Table maintenance, Maintenance regimen, Maintenance, Maintenance @@ -31170,7 +31351,7 @@ information and a description of what it means. @cindex crash, recovery @cindex recovery, from crash -@node Crash recovery, Log files, Table-info, Maintenance +@node Crash recovery, Log file maintenance, Table-info, Maintenance @section Using @code{myisamchk} for Crash Recovery If you run @code{mysqld} with @code{--skip-locking} (which is the default on @@ -31361,7 +31542,7 @@ If you are using @strong{MySQL} Version 3.23.16 and above, you can (and should) @code{CHECK} and @code{REPAIR} commands to check and repair @code{MyISAM} tables. @xref{CHECK TABLE}. @xref{REPAIR TABLE}. -The manual section about table maintenence includes the options to +The manual section about table maintenance includes the options to @code{isamchk}/@code{myisamchk}. @xref{Table maintenance}. The following section is for the cases where the above command fails or @@ -31510,17 +31691,23 @@ For a full description of the option, see @xref{myisamchk syntax}. @cindex files, log @cindex maintaining, log files @cindex log files, maintaining -@node Log files, , Crash recovery, Maintenance +@node Log file maintenance, , Crash recovery, Maintenance @section Log file Maintenance +@strong{MySQL} has a lot of log files which make it easy to see what is +going. @xref{Log files}. One must however from time to time clean up +after @code{MysQL} to ensure that the logs doesn't take up too much disk +space. + When using @strong{MySQL} with log files, you will, from time to time, want to remove/backup old log files and tell @strong{MySQL} to start -logging on new files. @xref{Update log}. +logging on new files. @xref{Backup}. On a Linux (@code{Redhat}) installation, you can use the @code{mysql-log-rotate} script for this. If you installed @strong{MySQL} from an RPM distribution, the script should have been installed -automatically. +automatically. Note that you should be careful with this if you are using +the log for replication! On other systems you must install a short script yourself that you start from @code{cron} to handle log files. @@ -32168,6 +32355,10 @@ program. @strong{MySQL}. @strong{MyODBC} works on Windows95, Windows98, NT, and on most Unix platforms. +If you have problem with @strong{MyODBC} and your program also works +with OLEDB, you should try the OLEDB driver that you can find in the +Contrib section. @xref{Contrib}. + Normally you only need to install @strong{MyODBC} on Windows machines. You only need @strong{MyODBC} for Unix if you have a program like ColdFusion that is running on the Unix machine and uses ODBC to connect @@ -32850,7 +33041,7 @@ First, you should try to find out whether the problem is that the client. You can check how long your @code{mysqld} server has been up by executing @code{mysqladmin version}. If @code{mysqld} has died, you may find the reason for this in the file -@file{mysql-data-directory/'hostname'.err}. +@file{mysql-data-directory/'hostname'.err}. @xref{Error log}. Many crashes of @strong{MySQL} are caused by corrupted index / data files. @strong{MySQL} will update the data on disk, with the @@ -32904,69 +33095,29 @@ state. @xref{Maintenance}. Use @code{mysqld --log} and try to determine from the information in the log whether or not some specific query kills the server. About 95% of all bugs are related to a particular query! Normally this is one of the last queries in -the log file just before @strong{MySQL} restarted. - -You may be able to verify this using the following procedure: - -@itemize @minus -@item -Take down the @strong{MySQL} daemon (with @code{mysqladmin shutdown}). -@item -Make a backup of files in the @strong{MySQL} database directory. -(As the server is stopped, you can just copy the files to some other -directory) -@item -Check the tables with @code{myisamchk -s */*.MYI} to verify that all -tables are correct. If any table is corrupted, repair it with -@code{myisamchk -r path-to-table.MYI}. You should take the backup -before checking the tables, as the problem could be related to corrupted -tables. -@item -Remove (or move away) any old log files from the @strong{MySQL} data directory. -@item -Start the server with @code{safe_mysqld --log-update} or -@code{safe_mysqld --log --log-update}. -@item -If @code{mysqld} now dies, you have two options: -@itemize @bullet -@item -First take a backup of your backup database. (Just copy the file(s) -somewhere again.) This is because we want to keep the original start -situation untouched. Start a mysqld process on the other backup database -(you can do this with option @code{--datadir=/path/to/backup/}). -@item -Just restore the backup on your original database and restart @code{mysqld}. -You will not any lose information, because you have the @code{log-update} file. -@end itemize +the log file just before @strong{MySQL} restarted. @xref{Query log}. +If you can repeatadly kill @strong{MySQL} with one of the queries, even +when you have checked all tables just before doing the query, then you +have been able to locate the bug and should do a bug report for this! +@xref{Bug reports}. @item -Now you can test if the problem is a specific update statement by executing -@code{mysql database_name < path-to-log-update-file}. - -You can also use the script @code{mysql_find_rows} to just execute some of the -update statements if you want to narrow down the problem. - -If mysqld now crashes, then you have something repeatable -available. Please send mail to @email{bugs@@lists.mysql.com} or -@email{developers@@mysql.com} or (if you are a support customer) to -@email{support@@mysql.com} about the problem and the @strong{MySQL} team -will fix it as soon as possible. -@end itemize +Try to make a test case that we can use to reproduce the problem. +@xref{Reproducable test case}. @item -Have you tried the benchmarks? They should test @strong{MySQL} rather well. -You can also add code that simulates your application! The benchmarks can be -found in the @file{bench} directory in the source distribution or, for a -binary distribution, in the @file{sql-bench} directory under your -@strong{MySQL} installation directory. +Try running the included mysql-test test and the @code{MySQL} +benchmarks. @xref{MySQL test suite}. They should test @strong{MySQL} +rather well. You can also add code that to the benchmarks to simulates +your application! The benchmarks can be found in the @file{bench} +directory in the source distribution or, for a binary distribution, in +the @file{sql-bench} directory under your @strong{MySQL} installation +directory. @item Try @code{fork_test.pl} and @code{fork2_test.pl}. @item -Check the file @file{mysql-data-directory/'hostname'.err} for any errors. - -@item If you configure @strong{MySQL} for debugging, it will be much easier to gather information about possible errors if something goes wrong. Reconfigure @strong{MySQL} with the @code{--with-debug} option to @@ -33073,8 +33224,9 @@ symbols that start with @code{mysql_}, like the following: you should be able to solve this by adding @code{-Lpath-to-the-mysql-library -lmysqlclient} @strong{LAST} on your link line. -If you get @code{undefined reference} errors for the @code{compress} function, -add @code{-lgz} @strong{LAST} on your link line and try again! +If you get @code{undefined reference} errors for the @code{uncompress} +or @code{compress} function, add @code{-lgz} @strong{LAST} on your link +line and try again! If you get @code{undefined reference} errors for functions that should exist on your system, like @code{connect}, check the man page for the @@ -33402,7 +33554,7 @@ The client program ended abruptly in the middle of the transfer. @end itemize When the above happens, the mysqld will write a note about an -@code{Aborted connection} in the @code{hostname.err} +@code{Aborted connection} in the @code{hostname.err} file. @xref{Error log}. The server variable @code{Aborted_connects} is incremented when: @@ -34261,16 +34413,13 @@ Drop or rename @code{old_table}. @cindex problems, solving @cindex solving, problems @cindex databases, replicating -@node Common problems, Clients, Problems, Top +@node Common problems, Log files, Problems, Top @chapter Solving Some Common Problems with MySQL @cindex replication @menu * Log Replication:: Database replication with update log * Backup:: Database backups -* Update log:: The update log -* Binary log:: The binary log -* Slow query log:: Log of slow queries * Multiple servers:: Running multiple @strong{MySQL} servers on the same machine @end menu @@ -34319,7 +34468,7 @@ mirror if needed. @code{LAST_INSERT_ID()} is also safe to use. @cindex databases, backups @cindex backups -@node Backup, Update log, Log Replication, Common problems +@node Backup, Multiple servers, Log Replication, Common problems @section Database Backups Because @strong{MySQL} tables are stored as files, it is easy to do a @@ -34400,9 +34549,190 @@ If you get performance problems in making backups on your system, you can solve this by setting up replication and do the backups on the slave instead of on the master. @xref{Replication Intro}. +@cindex multiple servers +@cindex servers, multiple +@cindex running, multiple servers +@node Multiple servers, , Backup, Common problems +@section Running Multiple MySQL Servers on the Same Machine + +There are circumstances when you might want to run multiple servers on the same +machine. For example, you might want to test a new @strong{MySQL} release +while leaving your existing production setup undisturbed. Or you might +be an Internet service provider that wants to provide independent +@strong{MySQL} installations for different customers. + +If you want to run multiple servers, the easiest way is to compile the servers +with different TCP/IP ports and socket files so they are not +both listening to the same TCP/IP port or socket file. @xref{mysqld_multi}. + +Assume an existing server is configured for the default port number and +socket file. Then configure the new server with a @code{configure} command +something like this: + +@example +shell> ./configure --with-tcp-port=port_number \ + --with-unix-socket-path=file_name \ + --prefix=/usr/local/mysql-3.22.9 +@end example + +Here @code{port_number} and @code{file_name} should be different than the +default port number and socket file pathname, and the @code{--prefix} value +should specify an installation directory different than the one under which +the existing @strong{MySQL} installation is located. + +You can check the socket and port used by any currently executing +@strong{MySQL} server with this command: + +@example +shell> mysqladmin -h hostname --port=port_number variables +@end example + +If you have a @strong{MySQL} server running on the port you used, you will +get a list of some of the most important configurable variables in +@strong{MySQL}, including the socket name. + +You don't have to recompile a new @strong{MySQL} server just to start with +a different port and socket. You can change the port and socket to be used +by specifying them at run time as options to @code{safe_mysqld}: + +@example +shell> /path/to/safe_mysqld --socket=file_name --port=port_number +@end example + +@code{mysqld_multi} can also take @code{safe_mysqld} (or @code{mysqld}) +as an argument and pass the options from a configuration file to +@code{safe_mysqld} and further to @code{mysqld}. + +If you run the new server on the same database directory as another +server with logging enabled, you should also specify the name of the log +files to @code{safe_mysqld} with @code{--log}, @code{--log-update}, or +@code{--log-slow-queries}. Otherwise, both servers may be trying to +write to the same log file. + +@strong{WARNING}: Normally you should never have two servers that update +data in the same database! If your OS doesn't support fault-free system +locking, this may lead to unpleasant surprises! + +If you want to use another database directory for the second server, you +can use the @code{--datadir=path} option to @code{safe_mysqld}. + +@strong{NOTE} also that starting several @strong{MySQL} servers +(@code{mysqlds}) in different machines and letting them access one data +directory over @code{NFS} is generally a @strong{BAD IDEA}! The problem +is that the @code{NFS} will become the bottleneck with the speed. It is +not meant for such use. And last but not least, you would still have to +come up with a solution how to make sure that two or more @code{mysqlds} +are not interfering with each other. At the moment there is no platform +that would 100% reliable do the file locking (@code{lockd} daemon +usually) in every situation. Yet there would be one more possible risk +with @code{NFS}; it would make the work even more complicated for +@code{lockd} daemon to handle. So make it easy for your self and forget +about the idea. The working solution is to have one computer with an +operating system that efficiently handles threads and have several CPUs +in it. + +When you want to connect to a @strong{MySQL} server that is running with +a different port than the port that is compiled into your client, you +can use one of the following methods: + +@itemize @bullet +@item +Start the client with @code{--host 'hostname' --port=port_numer} or +@code{[--host localhost] --socket=file_name}. + +@item +In your C or Perl programs, you can give the port and socket arguments +when connecting to the @strong{MySQL} server. + +@item +If your are using the @strong{MySQL} perl DBD module you can read the options +from the @strong{MySQL} option files. @xref{Option files}. + +@example +$dsn = "DBI:mysql:test;mysql_read_default_group=client;" +$dbh = DBI->connect($dsn, $user, $password); +@end example + +@item +@tindex MYSQL_UNIX_PORT environment variable +@tindex MYSQL_TCP_PORT environment variable +@tindex Environment variable, MYSQL_UNIX_PORT +@tindex Environment variable, MYSQL_TCP_PORT +Set the @code{MYSQL_UNIX_PORT} and @code{MYSQL_TCP_PORT} environment variables +to point to the Unix socket and TCP/IP port before you start your clients. +If you normally use a specific socket or port, you should place commands +to set these environment variables in your @file{.login} file. +@xref{Environment variables}. @xref{Programs}. + +@item +@tindex .my.cnf file +Specify the default socket and TCP/IP port in the @file{.my.cnf} file in your +home directory. @xref{Option files}. +@end itemize + +@cindex Log files +@node Log files, Clients, Common problems, Top +@chapter The MySQL log files + +@strong{MySQL} has a lot of different log files which can help you find +out what's going on inside @code{mysqld}: + +@multitable @columnfractions .3 .7 +@item The error log @tab Problems encountering starting, running or stopping mysqld. +@item The isam log @tab Logs all changes to the ISAM tables. Used only for debugging the isam code. +@item The query log @tab Established connections and executed queries. +@item The update log @tab Depricated: Stores all statements that changes data +@item The binary log @tab Stores all statements that changes something. Used also for replication +@item The slow log @tab Stores all queries that took more than @code{long_query_time} to execute or didn't use indexes. +@end multitable + +All logs can be found in the @code{mysqld} database directory. You can +tell force mysqld to switch to reopen the log files (or in some cases +switch to a new log) by executing @code{FLUSH LOGS}. @xref{FLUSH}. + +@cindex error log +@cindex files, error log +@menu +* Error log:: +* Query log:: +* Update log:: +* Binary log:: +* Slow query log:: +@end menu + +@node Error log, Query log, Log files, Log files +@section The Error Log + +@code{mysqld} writes all errors to the stderr, which the +@code{safe_mysqld} script redirects to a file called +@code{'hostname'.err}. (On windows @code{mysqld} writes this directly +to @file{mysql.err}). + +This contains information on when mysqld was started and stopped and +also any critical errors found when running. If @code{mysqld} dies +unexpectedly and @code{safe_mysqld} needs to restart @code{mysqld}, +@code{safe_mysqld} will write a @code{restarted mysqld} row in this +file. This log also holds a warning if @code{mysqld} notices a table +that needs to be automaticly checked or repaired. + +On some operating systems, the error log will contain a stack trace +for where mysqld died. This can be used to find out where mysqld died. +@xref{Using stack trace}. + +@cindex query log +@cindex files, query log +@node Query log, Update log, Error log, Log files +@section The Query Log + +If you want to know what happens within @code{mysqld}, you should start +it with @code{--log[=file]}. This will log all connections and queries +to the log file (by default named 'hostname.log'). This log can +be very useful when you suspect an error in a client and want to know +exactly what @code{mysqld} thought the client send to it. + @cindex update log @cindex files, update log -@node Update log, Binary log, Backup, Common problems +@node Update log, Binary log, Query log, Log files @section The Update Log @strong{NOTE}: The update log is replaced by the binary @@ -34462,7 +34792,7 @@ and the crash. @cindex binary log @cindex files, binary log -@node Binary log, Slow query log, Update log, Common problems +@node Binary log, Slow query log, Update log, Log files @section The Binary Log In the future the binary log will replace the update log, so we @@ -34528,7 +34858,7 @@ to cache a multi-transaction query. @cindex slow query log @cindex files, slow query log -@node Slow query log, Multiple servers, Binary log, Common problems +@node Slow query log, , Binary log, Log files @section The Slow Query Log When started with the @code{--log-slow-queries[=file_name]} option, @@ -34554,133 +34884,12 @@ You can also use the update logs when you have a mirrored database on another host and you want to replicate the changes that have been made to the master database. @xref{Log Replication}. -@cindex multiple servers -@cindex servers, multiple -@cindex running, multiple servers -@node Multiple servers, , Slow query log, Common problems -@section Running Multiple MySQL Servers on the Same Machine - -There are circumstances when you might want to run multiple servers on the same -machine. For example, you might want to test a new @strong{MySQL} release -while leaving your existing production setup undisturbed. Or you might -be an Internet service provider that wants to provide independent -@strong{MySQL} installations for different customers. - -If you want to run multiple servers, the easiest way is to compile the servers -with different TCP/IP ports and socket files so they are not -both listening to the same TCP/IP port or socket file. @xref{mysqld_multi}. - -Assume an existing server is configured for the default port number and -socket file. Then configure the new server with a @code{configure} command -something like this: - -@example -shell> ./configure --with-tcp-port=port_number \ - --with-unix-socket-path=file_name \ - --prefix=/usr/local/mysql-3.22.9 -@end example - -Here @code{port_number} and @code{file_name} should be different than the -default port number and socket file pathname, and the @code{--prefix} value -should specify an installation directory different than the one under which -the existing @strong{MySQL} installation is located. - -You can check the socket and port used by any currently executing -@strong{MySQL} server with this command: - -@example -shell> mysqladmin -h hostname --port=port_number variables -@end example - -If you have a @strong{MySQL} server running on the port you used, you will -get a list of some of the most important configurable variables in -@strong{MySQL}, including the socket name. - -You don't have to recompile a new @strong{MySQL} server just to start with -a different port and socket. You can change the port and socket to be used -by specifying them at run time as options to @code{safe_mysqld}: - -@example -shell> /path/to/safe_mysqld --socket=file_name --port=port_number -@end example - -@code{mysqld_multi} can also take @code{safe_mysqld} (or @code{mysqld}) -as an argument and pass the options from a configuration file to -@code{safe_mysqld} and further to @code{mysqld}. - -If you run the new server on the same database directory as another -server with logging enabled, you should also specify the name of the log -files to @code{safe_mysqld} with @code{--log}, @code{--log-update}, or -@code{--log-slow-queries}. Otherwise, both servers may be trying to -write to the same log file. - -@strong{WARNING}: Normally you should never have two servers that update -data in the same database! If your OS doesn't support fault-free system -locking, this may lead to unpleasant surprises! - -If you want to use another database directory for the second server, you -can use the @code{--datadir=path} option to @code{safe_mysqld}. - -@strong{NOTE} also that starting several @strong{MySQL} servers -(@code{mysqlds}) in different machines and letting them access one data -directory over @code{NFS} is generally a @strong{BAD IDEA}! The problem -is that the @code{NFS} will become the bottleneck with the speed. It is -not meant for such use. And last but not least, you would still have to -come up with a solution how to make sure that two or more @code{mysqlds} -are not interfering with each other. At the moment there is no platform -that would 100% reliable do the file locking (@code{lockd} daemon -usually) in every situation. Yet there would be one more possible risk -with @code{NFS}; it would make the work even more complicated for -@code{lockd} daemon to handle. So make it easy for your self and forget -about the idea. The working solution is to have one computer with an -operating system that efficiently handles threads and have several CPUs -in it. - -When you want to connect to a @strong{MySQL} server that is running with -a different port than the port that is compiled into your client, you -can use one of the following methods: - -@itemize @bullet -@item -Start the client with @code{--host 'hostname' --port=port_numer} or -@code{[--host localhost] --socket=file_name}. - -@item -In your C or Perl programs, you can give the port and socket arguments -when connecting to the @strong{MySQL} server. - -@item -If your are using the @strong{MySQL} perl DBD module you can read the options -from the @strong{MySQL} option files. @xref{Option files}. - -@example -$dsn = "DBI:mysql:test;mysql_read_default_group=client;" -$dbh = DBI->connect($dsn, $user, $password); -@end example - -@item -@tindex MYSQL_UNIX_PORT environment variable -@tindex MYSQL_TCP_PORT environment variable -@tindex Environment variable, MYSQL_UNIX_PORT -@tindex Environment variable, MYSQL_TCP_PORT -Set the @code{MYSQL_UNIX_PORT} and @code{MYSQL_TCP_PORT} environment variables -to point to the Unix socket and TCP/IP port before you start your clients. -If you normally use a specific socket or port, you should place commands -to set these environment variables in your @file{.login} file. -@xref{Environment variables}. @xref{Programs}. - -@item -@tindex .my.cnf file -Specify the default socket and TCP/IP port in the @file{.my.cnf} file in your -home directory. @xref{Option files}. -@end itemize - @cindex client tools @cindex APIs @cindex @code{mysqlclient} library @cindex buffer sizes, client @cindex library, @code{mysqlclient} -@node Clients, Comparisons, Common problems, Top +@node Clients, Comparisons, Log files, Top @chapter MySQL Client Tools and APIs @menu @@ -38082,6 +38291,10 @@ This means that your PHP version isn't compiled with @strong{MySQL} support. You can either compile a dynamic @strong{MySQL} module and load it into PHP or recompile PHP with built-in @strong{MySQL} support. This is described in detail in the PHP manual. +@item Error: "undefined reference to `uncompress'" +This means that the client library is compiled with support for a compressed +client/server protocol. The fix is to add @code{-lz} last when linking +with @code{-lmysqlclient}. @end itemize @cindex C++ APIs @@ -38829,7 +39042,7 @@ your @code{FULLTEXT} indexes. @end example line in @code{myisam/ftdefs.h} to @example -#define GWS_IN_USE GWS_IDF +#define GWS_IN_USE GWS_FREQ @end example and recompile @strong{MySQL}. There is no need to rebuild the indexes though. @@ -39560,6 +39773,17 @@ A @strong{MySQL} PMDA. Provides @strong{MySQL} server status and configuration variables. @end itemize +@cindex OLEDB +@item OLEDB +@itemize @bullet +@item @uref{http://www.mysql.com/Downloads/Win32/MyOLEDB.exe, MyOLEDB.exe} +OLEDB handler for @code{MySQL}. By SWsoft. +@item @uref{http://www.mysql.com/Downloads/Win32/MySamples.zip, MySamples.zip} +Examples and documentation for MyOLEDB. By SWsoft. +@item @uref{http://www.mysql.com/Downloads/Win32/Myoledb.zip, Myoledb.zip} +Source for MyOLEDB. By SWsoft. +@end itemize + @cindex C++ @item C++ @itemize @bullet @@ -39724,8 +39948,8 @@ Windows GUI (binary only) to administrate a database, by David B. Mansel, @item @uref{http://www.mysql.com/Downloads/Win32/netadmin.zip, netadmin.zip} An administrator tool for @strong{MySQL} on Windows 95/98 and Windows NT -4.0. Only tested with @strong{MySQL} Versions 3.23.5 - 3.23.7. Written using the -Tmysql components. +4.0. Only tested with @strong{MySQL} Versions 3.23.5 - 3.23.7. Written +using the Tmysql components. You can write queries and show tables, indexes, table syntax, and administrate user, host, and database and so on. This is beta and @@ -39738,6 +39962,12 @@ New version of netadmin. See above for details. @item @uref{http://www.mysql.com/Downloads/Win32/ARTADMIN203.EXE,Atronic's @strong{MySQL} client for Windows 2.0.3.0}. Home page for this can be found at: @uref{http://www.artronic.hr}. + +@item @uref{http://www.mysql.com/Downloads/Win32/mysqlfront.zip, mysqlfront} +Home page: @uref{http://my.anse.de/}. +Win32-Client for accessing and managing dbs, tables, table-data, indexes, +import-/export-files. (Freeware). By Ansgar Becker. + @item @uref{http://www.mysql.com/Downloads/Win32/W9xstop.zip,Utility from Artronic to stop MySQL on win9x}. @item @uref{http://dbtools.vila.bol.com.br/, Dbtools} @@ -39777,6 +40007,8 @@ colour coding, dump functionality and much more. @uref{http://www.scibit.com/Products/Software/Utils/Mascon.asp,Mascon home page}. @item @uref{http://www.virtualbeer.net/dbui/,DBUI} DBUI is a Gtk graphical database editor. +@item @uref{http://www.rtlabs.com/, MacSQL} +GUI for MySQL, ODBC, and JDBC databases for the Mac OS. @end itemize @cindex Web clients @@ -40639,6 +40871,10 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}. @itemize @bullet @item +Allow @code{SELECT expression LIMIT ...}. +@item +Added @code{IDENTITY} as a synonym for @code{AUTO_INCREMENT} (like SyBase). +@item Added @code{ORDER BY} syntax to @code{UPDATE} and @code{DELETE}. @item Added @code{SELECT .. WITH UPDATE} and @code{SELECT ... IN SHARE MODE} to @@ -40674,6 +40910,7 @@ users uses this code as the rest of the code and because of this we are not yet 100 % confident in this code. @menu +* News-3.23.33:: Changes in release 3.23.33 * News-3.23.32:: Changes in release 3.23.32 * News-3.23.31:: Changes in release 3.23.31 * News-3.23.30:: Changes in release 3.23.30 @@ -40709,7 +40946,65 @@ not yet 100 % confident in this code. * News-3.23.0:: Changes in release 3.23.0 @end menu -@node News-3.23.32, News-3.23.31, News-3.23.x, News-3.23.x +@node News-3.23.33, News-3.23.32, News-3.23.x, News-3.23.x +@appendixsubsec Changes in release 3.23.33 +@itemize bullet +@item +@code{myisamchk -S} and @code{OPTIMIZE TABLE} now works on Windows. +@item +Fixed bug when using @code{DISTINCT} on results from functions that refered to +a group function, like +@code{SELECT a,DISTINCT SEC_TO_TIME(sum(a)) from table_name GROUP BY a,b}. +@item +Fixed bug in handling @code{STOP} event after @code{ROTATE} event in +replication. +@item +Fixed another buffer overrun in @code{DROP DATABASE}. +@item +Added @code{Table_locks_immediate} and @code{Table_locks_waited} status +variables. +@item +Fixed bug in replication that broke slave server start with existing +@code{master.info}. This fixes a bug introduced in 3.23.32. +@item +Added @code{SET SQL_SLAVE_SKIP_COUNTER=n} command to recover from +replication glitches without a full database copy. +@item +Added @code{max_binlog_size} variable; the binary log will be rotated +automatically when the size crosses the limit. +@item +Added @code{Last_error}, @code{Last_errno}, and @code{Slave_skip_counter} to +@code{SHOW SLAVE STATUS}. +@item +Fixed bug in @code{MASTER_POS_WAIT()} function. +@item +Execute coredump handler on @code{SIGILL}, and @code{SIGBUS} in addition to +@code{SIGSEGV}. +@item +On x86 Linux, print the current query and thread (connection) id, if +available, in the coredump handler. +@item +Fixed several timing bugs in the test suite. +@item +Extended @code{mysqltest} to take care of the timing issues in the test +suite. +@item +@code{ALTER TABLE} can now be used to change the definition for a +@code{MERGE} table. +@item +Fixed creation of @code{MERGE} tables on Windows. +@item +Portability fixes for OpenBSD and OS2. +@item +Added --temp-pool option to mysqld. Using this option will cause most +temporary files created to use a small set of names, rather than a unique +name for each new file. This is to work around a problem in the Linux +kernel dealing with creating a bunch of new files with different names. +With the old behavior, Linux seems to "leak" memory, as it's being allocated +to the directory entry cache instead of the disk cache. +@end itemize + +@node News-3.23.32, News-3.23.31, News-3.23.33, News-3.23.x @appendixsubsec Changes in release 3.23.32 @itemize @bullet @item @@ -40717,8 +41012,8 @@ Changed code to get around compiler bug in Compaq C++ on OSF1, that broke @code{BACKUP}, @code{RESTORE}, @code{CHECK}, @code{REPAIR}, and @code{ANALYZE TABLE}. @item -Added option @code{FULL} to @code{SHOW COLUMNS}. Now we only show the -privilege list for the columns if this option is given. +Added option @code{FULL} to @code{SHOW COLUMNS}. Now we show the +privilege list for the columns only if this option is given. @item Fixed bug in @code{SHOW LOGS} when there weren't any BDB logs. @item @@ -45639,6 +45934,9 @@ New key cache When using @code{SET CHARACTER SET} we should translate the whole query at once and not only strings. This will enable users to use the translated characters in database, table and column names. +@item +Add a portable interface over @code{gethostbyaddr_r()} so that we can change +@code{ip_to_hostname()} to not block other threads while doing DNS lookups. @end itemize @node TODO future, TODO sometime, TODO MySQL 4.0, TODO @@ -46057,6 +46355,37 @@ any @code{my.cnf} files that interfere with your setup! You can check your @code{my.cnf} arguments with @code{mysqld --print-defaults} and avoid using them by starting with @code{mysqld --no-defaults ...}. +If @code{mysqld} starts to eat up CPU or memory or if it ``hangs'', you +can use @code{mysqladmin processlist status} to find out if someone is +executing a query that takes a long time. It may be a good idea to +run @code{mysqladmin -i10 processlist status} in some window if you are +experiencing performance problems or problems when new clients can't connect. + +The command @code{mysqladmin debug} will dump some information about +locks in use, used memory and query usage to the mysql log file. This +may help solve some problems. This command also provides some useful +information even if you haven't compiled @strong{MySQL} for debugging! + +If the problem is that some tables are getting slower and slower you +should try to optimize the table with @code{OPTIMIZE TABLE} or +@code{myisamchk}. @xref{Maintenance}. You should also check the slow +queries with @code{EXPLAIN}. + +You should also read the OS-specific section in this manual for +problems that may be unique to your environment. +@xref{Source install system issues}. + +@menu +* Compiling for debugging:: +* Making trace files:: +* Using stack trace:: +* Using log files:: +* Reproducable test case:: +@end menu + +@node Compiling for debugging, Making trace files, Debugging server, Debugging server +@appendixsubsec Compiling MYSQL for debugging. + If you have some very specific problem, you can always try to debug @strong{MySQL}. To do this you must configure @strong{MySQL} with the option @code{--with-debug}. You can check whether or not @@ -46075,6 +46404,11 @@ This will avoid problems with the @code{libstdc++} library and with C++ exceptions (many compilers have problems with C++ exceptions in threaded code) and compile a @strong{MySQL} version with support for all character sets. +If you suspect a memory overrun error, you can use @code{--with-debug=full}, +which will install a memory allocation checker. This is however quite slow +so this is not something one should do on a server in a heavy production +environment. + If @code{mysqld} stops crashing when you compile it with @code{--with-debug}, you have probably found a compiler bug or a timing bug within @strong{MySQL}. In this case you can try to add @code{-g} to @@ -46083,6 +46417,20 @@ the @code{CFLAGS} and @code{CXXFLAGS} variables above and not use to it with @code{gdb} or use @code{gdb} on the core file to find out what happened. +When you configure @strong{MySQL} for debugging you automatically enable a +lot of extra safety check functions that monitor the health of @code{mysqld}. +If they find something ``unexpected,'' an entry will be written to +@code{stderr}, which @code{safe_mysqld} directs to the error log! This also +means that if you are having some unexpected problems with @strong{MySQL} and +are using a source distribution, the first thing you should do is to +configure @strong{MySQL} for debugging! (The second thing, of course, is to +send mail to @email{mysql@@lists.mysql.com} and ask for help. Please use the +@code{mysqlbug} script for all bug reports or questions regarding the +@strong{MySQL} version you are using! + +@node Making trace files, Using stack trace, Compiling for debugging, Debugging server +@appendixsubsec Creating trace files and using gdb on mysqld + If you can cause the @code{mysqld} server to crash quickly, you can try to create a trace file of this: @@ -46097,17 +46445,6 @@ or you can start it with which only prints information with the most interesting tags. -When you configure @strong{MySQL} for debugging you automatically enable a -lot of extra safety check functions that monitor the health of @code{mysqld}. -If they find something ``unexpected,'' an entry will be written to -@code{stderr}, which @code{safe_mysqld} directs to the error log! This also -means that if you are having some unexpected problems with @strong{MySQL} and -are using a source distribution, the first thing you should do is to -configure @strong{MySQL} for debugging! (The second thing, of course, is to -send mail to @email{mysql@@lists.mysql.com} and ask for help. Please use the -@code{mysqlbug} script for all bug reports or questions regarding the -@strong{MySQL} version you are using! - On most system you can also start @code{mysqld} from @code{gdb} to get more information if @code{mysqld} crashes. @@ -46183,11 +46520,79 @@ If @code{mysqld} hangs you can try to use some system tools like strace /tmp/log libexec/mysqld @end example -If @code{mysqld} starts to eat up CPU or memory or if it ``hangs'', you -can use @code{mysqladmin processlist status} to find out if someone is -executing a query that takes a long time. It may be a good idea to -run @code{mysqladmin -i10 processlist status} in some window if you are -experiencing performance problems or problems when new clients can't connect. +@findex DBI->trace +@findex trace DBI method +@tindex DBI_TRACE environment variable +@tindex Environment variable, DBI_TRACE +If you are using the Perl @code{DBI} interface, you can turn on +debugging information by using the @code{trace} method or by +setting the @code{DBI_TRACE} environment variable. +@xref{Perl DBI Class, , Perl @code{DBI} Class}. + +@node Using stack trace, Using log files, Making trace files, Debugging server +@appendixsubsec Using a stack trace + +On some operating systems, the error log will contain a stack trace if +@code{mysqld} dies unexpectedly. You can use this to find out where (and +maybe why) @code{mysqld} died. @xref{Error log}. To get a stack trace, +you should NOT compile @code{mysqld} with the +@code{-fomit-frame-pointer} option to gcc. +@xref{Compiling for debugging}. + +If the error file contains something like the following: + +@example +mysqld got signal 11; +The manual section 'Debugging a MySQL server' tells you how to use a +stack trace and/or the core file to produce a readable backtrace that may +help in finding out why mysqld died +Attemping backtrace. You can use the following information to find out +where mysqld died. If you see no messages after this, something went +terribly wrong +stack range sanity check, ok, backtrace follows +0x40077552 +0x81281a0 +0x8128f47 +0x8127be0 +0x8127995 +0x8104947 +0x80ff28f +0x810131b +0x80ee4bc +0x80c3c91 +0x80c6b43 +0x80c1fd9 +0x80c1686 +@end example + +you can find where mysqld died by doing the following: + +@enumerate +@item +Copy the above numbers to a file, for example @file{mysqld.stack}. + +@item +Make a symbol file for the @code{mysqld} server: +@example +nm -n libexec/mysqld > /tmp/mysqld.sym +@end example + +Note that many MySQL binary distributions comes with the above file, +named @code{mysqld.sym.gz}. In this case you must unpack this by doing +@example +gunzip < bin/mysqld.sym.gz > /tmp/mysqld.sym +@end example + +@item +Execute @code{resolve_stack_dump -s /tmp/mysqld.sym -n mysqld.stack}. + +This will print out where @code{mysqld} died. If this doesn't help you +find out why @code{mysqld} died, you should make a bug report and include +the output from the above commend with the bug report. @xref{Bug reports}. +@end enumerate + +@node Using log files, Reproducable test case, Using stack trace, Debugging server +@appendixsubsec Using log files to find cause of errors in mysqld If @code{mysqld} dies or hangs, you should start @code{mysqld} with @code{--log}. When @code{mysqld} dies again, you can check in the log @@ -46218,18 +46623,45 @@ version. If this doesn't help and you can't find anything in the online at the @uref{http://www.mysql.com/documentation/, @strong{MySQL} documentation page}. +If you have started @code{mysqld} with @code{--with-myisam-recover}, +@strong{MySQL} will automaticly check and try to repair @code{MyISAM} +tables if they are marked as 'not closed properly' or 'crashed'. If +this happens, @strong{MySQL} will write an entry in the +@code{hostname.err} file @code{'Warning: Checking table ...'} which is +followed by @code{Warning: Repairing table} if the table needs to be +repaired. If you get a lot of these errors, without @code{mysqld} having +died unexpectedly just before, then something is wrong and needs to +be investigated further. @xref{Command-line options}. + +It's of course not a good sign if @code{mysqld} did died unexpectedly, +but in this case one shouldn't investigate the @code{Checking table...} +messages but instead try to find out why @code{mysqld} died. + +@node Reproducable test case, , Using log files, Debugging server +@appendixsubsec Makeing a test case when you get crashed tables + If you get corrupted tables or if @code{mysqld} always fails after some update commands, you can test if this bug is reproducible by doing the following: @itemize @bullet @item -Stop the mysqld daemon (with @code{mysqladmin shutdown}) +Take down the @strong{MySQL} daemon (with @code{mysqladmin shutdown}). +@item +Make a backup of the tables (to guard against the very unlikely case that +the repair will do something bad). @item Check all tables with @code{myisamchk -s database/*.MYI}. Repair any wrong tables with @code{myisamchk -r database/table.MYI}. @item +Make a second backup of the tables. +@item +Remove (or move away) any old log files from the @strong{MySQL} data +directory if you need more space. +@item Start @code{mysqld} with @code{--log-binary}. @xref{Binary log}. +If you want to find a query that crashes @code{mysqld}, you should use +@code{--log --log-binary}. @item When you have gotten a crashed table, stop the @code{mysqld server}. @item @@ -46241,34 +46673,17 @@ Re-execute the commands with @code{mysqlbinlog update-log-file | mysql}. The update log is saved in the @strong{MySQL} database directory with the name @code{hostname-bin.#}. @item -If the tables are corrupted again, you have found reproducible bug -in the @code{MyISAM} code! FTP the tables and the update log to -@uref{ftp://support.mysql.com/pub/mysql/secret} and we will fix this as soon as -possible! +If the tables are corrupted again or you can get @code{mysqld} to die with the +above command, you have found reproducible bug that should be easy to +fix! FTP the tables and the binary log to +@uref{ftp://support.mysql.com/pub/mysql/secret} and send a mail to +@email{bugs@@lists.mysql.com} or (if you are a support customer) to +@email{support@@mysql.com} about the problem and the @strong{MySQL} team +will fix it as soon as possible. @end itemize -The command @code{mysqladmin debug} will dump some information about -locks in use, used memory and query usage to the mysql log file. This -may help solve some problems. This command also provides some useful -information even if you haven't compiled @strong{MySQL} for debugging! - -If the problem is that some tables are getting slower and slower you -should try to optimize the table with @code{OPTIMIZE TABLE} or -@code{myisamchk}. @xref{Maintenance}. You should also check the slow -queries with @code{EXPLAIN}. - -You should also read the OS-specific section in this manual for -problems that may be unique to your environment. -@xref{Source install system issues}. - -@findex DBI->trace -@findex trace DBI method -@tindex DBI_TRACE environment variable -@tindex Environment variable, DBI_TRACE -If you are using the Perl @code{DBI} interface, you can turn on -debugging information by using the @code{trace} method or by -setting the @code{DBI_TRACE} environment variable. -@xref{Perl DBI Class, , Perl @code{DBI} Class}. +You can also use the script @code{mysql_find_rows} to just execute some of the +update statements if you want to narrow down the problem. @cindex debugging, client @cindex clients, debugging @@ -46382,10 +46797,15 @@ for @code{BDB} tables. @xref{Internal locking}. With @code{MyISAM} tables one can freely mix @code{INSERT} and @code{SELECT} without locks (@code{Versioning}). +Starting in version 3.23.33, you can analyze the table lock contention +on your system by checkining @code{Table_locks_waited} and +@code{Table_locks_immediate} environemt variables. + Some database users claim that @strong{MySQL} cannot support near the number of concurrent users because it lacks row-level locking. This is a may be true for some specific applications, but is' not generally -true. As always this depends totally on what the application does and what is the access/update pattern of the data. +true. As always this depends totally on what the application does and what +is the access/update pattern of the data. Pros for row locking: diff --git a/client/mysqltest.c b/client/mysqltest.c index 992583bb230..953f770240b 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -485,14 +485,19 @@ int do_echo(struct st_query* q) return 0; } -int do_sync_with_master() +int do_sync_with_master(struct st_query* q) { MYSQL_RES* res; MYSQL_ROW row; MYSQL* mysql = &cur_con->mysql; char query_buf[FN_REFLEN+128]; + int offset = 0; + char* p = q->first_argument; + if(*p) + offset = atoi(p); + sprintf(query_buf, "select master_pos_wait('%s', %ld)", master_pos.file, - master_pos.pos); + master_pos.pos + offset); if(mysql_query(mysql, query_buf)) die("At line %u: failed in %s: %d: %s", start_lineno, query_buf, mysql_errno(mysql), mysql_error(mysql)); @@ -1458,7 +1463,7 @@ int main(int argc, char** argv) q->require_file=require_file; save_file[0]=0; } - error |= run_query(&cur_con->mysql, q, QUERY_SEND|QUERY_REAP); + error |= run_query(&cur_con->mysql, q, flags); break; } case Q_SEND: diff --git a/configure.in b/configure.in index 25872825498..a55a1e95188 100644 --- a/configure.in +++ b/configure.in @@ -4,7 +4,7 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! -AM_INIT_AUTOMAKE(mysql, 3.23.32) +AM_INIT_AUTOMAKE(mysql, 3.23.33) AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10 @@ -129,6 +129,7 @@ fi # Still need ranlib for readline; local static use only so no libtool. AC_PROG_RANLIB # We use libtool +#AC_LIBTOOL_WIN32_DLL AM_PROG_LIBTOOL #AC_LIBTOOL_DLOPEN AC_LIBTOOL_WIN32_DLL AC_DISABLE_FAST_INSTALL AC_DISABLE_SHARED AC_DISABLE_STATIC diff --git a/include/my_bitmap.h b/include/my_bitmap.h new file mode 100644 index 00000000000..6c86a79fe45 --- /dev/null +++ b/include/my_bitmap.h @@ -0,0 +1,35 @@ +/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + MA 02111-1307, USA */ + +#ifndef _my_bitmap_h_ +#define _my_bitmap_h_ + +#define MY_BIT_NONE ~(uint)0 + +#ifdef __cplusplus +extern "C" { +#endif + + extern void bitmap_set_bit(uchar *bitmap, uint bitmap_size, uint bitmap_bit); + extern uint bitmap_set_next(uchar *bitmap, uint bitmap_size); + extern void bitmap_clear_bit(uchar *bitmap,uint bitmap_size,uint bitmap_bit); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/my_sys.h b/include/my_sys.h index 0f010fc71af..a3cb11fc515 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -41,13 +41,6 @@ extern int NEAR my_errno; /* Last error in mysys */ #include <stdarg.h> -#ifdef __EMX__ -/* record loging flags (F_GETLK, F_SETLK, F_SETLKW) */ -#define F_RDLCK 1 /* FreeBSD: shared or read lock */ -#define F_UNLCK 2 /* FreeBSD: unlock */ -#define F_WRLCK 3 /* FreeBSD: exclusive or write lock */ -#endif - #define MYSYS_PROGRAM_USES_CURSES() { error_handler_hook = my_message_curses; mysys_uses_curses=1; } #define MYSYS_PROGRAM_DONT_USE_CURSES() { error_handler_hook = my_message_no_curses; mysys_uses_curses=0;} #define MY_INIT(name); { my_progname= name; my_init(); } @@ -425,7 +418,7 @@ extern int my_printf_error _VARARGS((uint my_err, const char *format, __attribute__ ((format (printf, 2, 4)))); extern int my_vsnprintf( char *str, size_t n, const char *format, va_list ap ); - +extern int my_snprintf(char* to, size_t n, const char* fmt, ...); extern int my_message(uint my_err, const char *str,myf MyFlags); extern int my_message_no_curses(uint my_err, const char *str,myf MyFlags); extern int my_message_curses(uint my_err, const char *str,myf MyFlags); diff --git a/include/mysqld_error.h b/include/mysqld_error.h index 0391c3e6c4e..c84b0c08c77 100644 --- a/include/mysqld_error.h +++ b/include/mysqld_error.h @@ -198,4 +198,9 @@ #define ER_CRASHED_ON_REPAIR 1195 #define ER_WARNING_NOT_COMPLETE_ROLLBACK 1196 #define ER_TRANS_CACHE_FULL 1197 -#define ER_ERROR_MESSAGES 198 +#define ER_SLAVE_MUST_STOP 1198 +#define ER_SLAVE_NOT_RUNNING 1199 +#define ER_BAD_SLAVE 1200 +#define ER_MASTER_INFO 1201 +#define ER_SLAVE_THREAD 1202 +#define ER_ERROR_MESSAGES 203 diff --git a/include/thr_lock.h b/include/thr_lock.h index 569a09d7aa5..ffcad4a4d11 100644 --- a/include/thr_lock.h +++ b/include/thr_lock.h @@ -27,7 +27,8 @@ extern "C" { #include <my_list.h> struct st_thr_lock; - +extern ulong locks_immediate,locks_waited ; + enum thr_lock_type { TL_IGNORE=-1, TL_UNLOCK, /* UNLOCK ANY LOCK */ TL_READ, /* Read lock */ diff --git a/libmysql/errmsg.c b/libmysql/errmsg.c index 194542afd7f..00c8910a573 100644 --- a/libmysql/errmsg.c +++ b/libmysql/errmsg.c @@ -36,7 +36,7 @@ const char *client_errors[]= "MySQL client got out of memory", "Wrong host info", "Localhost via UNIX socket", - "%s via TCP/IP", + "%-.64s via TCP/IP", "Error in server handshake", "Lost connection to MySQL server during query", "Commands out of sync; You can't run this command now", @@ -62,11 +62,11 @@ const char *client_errors[]= "MySQL client run out of memory", "Wrong host info", "Localhost via UNIX socket", - "%s via TCP/IP", + "%-.64s via TCP/IP", "Error in server handshake", "Lost connection to MySQL server during query", "Commands out of sync; You can't run this command now", - "%s via named pipe", + "%-.64s via named pipe", "Can't wait for named pipe to host: %-.64s pipe: %-.32s (%lu)", "Can't open named pipe to host: %-.64s pipe: %-.32s (%lu)", "Can't set state of named pipe to host: %-.64s pipe: %-.32s (%lu)", @@ -1411,8 +1411,8 @@ else os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes - allow_undefined_flag=unsupported - archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $objdir/$libname.def~$echo DATA >> $objdir/$libname.def~$echo " SINGLE NONSHARED" >> $objdir/$libname.def~$echo EXPORTS >> $objdir/$libname.def~emxexp $libobjs >> $objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $linkopts $objdir/$libname.def' + allow_undefined_flag=" " + archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $objdir/$libname.def~$echo DATA >> $objdir/$libname.def~$echo " SINGLE NONSHARED" >> $objdir/$libname.def~$echo EXPORTS >> $objdir/$libname.def~emxexp $libobjs >> $objdir/$libname.def~$CC -Zdll $linkflags -o $lib $libobjs $deplibs $objdir/$libname.def' old_archive_from_new_cmds='emximp -o $objdir/$libname.a $objdir/$libname.def' ;; @@ -2036,6 +2036,7 @@ os2*) need_lib_prefix=no library_names_spec='$libname.dll $libname.a' dynamic_linker='OS/2 ld.exe' + deplibs_check_method=pass_all shlibpath_var=LIBPATH ;; diff --git a/ltmain.sh b/ltmain.sh index 12abf87a56a..a1c36109556 100644 --- a/ltmain.sh +++ b/ltmain.sh @@ -819,6 +819,7 @@ compiler." old_convenience= deplibs= linkopts= + linkflags= if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var @@ -1159,6 +1160,7 @@ compiler." # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + linkflags="$linkflags $arg" case "$arg" in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) arg="\"$arg\"" diff --git a/merge/open.c b/merge/open.c index 2a3d815cd27..35005e6e718 100644 --- a/merge/open.c +++ b/merge/open.c @@ -62,7 +62,7 @@ int handle_locking; { if ((end=buff+length)[-1] == '\n') end[-1]='\0'; - if (buff[0]) /* Skipp empty lines */ + if (buff[0] && buff[0] != '#') /* Skipp empty lines and comments */ { last_isam=isam; if (!test_if_hard_path(buff)) diff --git a/mit-pthreads/net/net_internal.h b/mit-pthreads/net/net_internal.h index 10ece181a94..0dc5c866e5d 100644 --- a/mit-pthreads/net/net_internal.h +++ b/mit-pthreads/net/net_internal.h @@ -44,6 +44,7 @@ static char *rcsid = "$Id$"; #include <resolv.h> #define NET_BUFSIZE 4096 +#undef ALIGN #define ALIGN(p, t) ((char *)(((((long)(p) - 1) / sizeof(t)) + 1) * sizeof(t))) #define SP(p, t, n) (ALIGN(p, t) + (n) * sizeof(t)) diff --git a/mit-pthreads/net/proto_internal.h b/mit-pthreads/net/proto_internal.h index d40f77b519e..4ed06883f25 100644 --- a/mit-pthreads/net/proto_internal.h +++ b/mit-pthreads/net/proto_internal.h @@ -44,6 +44,7 @@ static char *rcsid = "$Id$"; #include <resolv.h> #define PROTO_BUFSIZE 4096 +#undef ALIGN #define ALIGN(p, t) ((char *)(((((long)(p) - 1) / sizeof(t)) + 1) * sizeof(t))) #define SP(p, t, n) (ALIGN(p, t) + (n) * sizeof(t)) diff --git a/mit-pthreads/net/res_internal.h b/mit-pthreads/net/res_internal.h index 4a4691bab84..24e70278644 100644 --- a/mit-pthreads/net/res_internal.h +++ b/mit-pthreads/net/res_internal.h @@ -44,6 +44,7 @@ static char *rcsid = "$Id$"; #include <resolv.h> #define HOST_BUFSIZE 4096 +#undef ALIGN #define ALIGN(p, t) ((char *)(((((long)(p) - 1) / sizeof(t)) + 1) * sizeof(t))) #define SP(p, t, n) (ALIGN(p, t) + (n) * sizeof(t)) diff --git a/mit-pthreads/net/serv_internal.h b/mit-pthreads/net/serv_internal.h index 1d933826083..60a7c02c2ea 100644 --- a/mit-pthreads/net/serv_internal.h +++ b/mit-pthreads/net/serv_internal.h @@ -44,6 +44,7 @@ static char *rcsid = "$Id$"; #include <resolv.h> #define SERV_BUFSIZE 4096 +#undef ALIGN #define ALIGN(p, t) ((char *)(((((long)(p) - 1) / sizeof(t)) + 1) * sizeof(t))) #define SP(p, t, n) (ALIGN(p, t) + (n) * sizeof(t)) diff --git a/myisam/mi_check.c b/myisam/mi_check.c index ee9e3387119..467e9a9bcb4 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -376,7 +376,7 @@ int chk_key(MI_CHECK *param, register MI_INFO *info) if ((!(param->testflag & T_SILENT))) printf ("- check data record references index: %d\n",key+1); if (share->state.key_root[key] == HA_OFFSET_ERROR && - info->state->records == 0) + (info->state->records == 0 || keyinfo->flag & HA_FULLTEXT)) continue; if (!_mi_fetch_keypage(info,keyinfo,share->state.key_root[key],info->buff, 0)) @@ -1462,6 +1462,8 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, my_string name) reg1 MI_KEYDEF *keyinfo; File new_file; my_off_t index_pos[MI_MAX_POSSIBLE_KEY]; + uint r_locks,w_locks; + MYISAM_SHARE *share=info->s; DBUG_ENTER("sort_index"); if (!(param->testflag & T_SILENT)) @@ -1475,21 +1477,21 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, my_string name) param->temp_filename); DBUG_RETURN(-1); } - if (filecopy(param, new_file,info->s->kfile,0L, - (ulong) info->s->base.keystart, "headerblock")) + if (filecopy(param, new_file,share->kfile,0L, + (ulong) share->base.keystart, "headerblock")) goto err; - param->new_file_pos=info->s->base.keystart; - for (key= 0,keyinfo= &info->s->keyinfo[0]; key < info->s->base.keys ; + param->new_file_pos=share->base.keystart; + for (key= 0,keyinfo= &share->keyinfo[0]; key < share->base.keys ; key++,keyinfo++) { - if (!(((ulonglong) 1 << key) & info->s->state.key_map)) + if (!(((ulonglong) 1 << key) & share->state.key_map)) continue; - if (info->s->state.key_root[key] != HA_OFFSET_ERROR) + if (share->state.key_root[key] != HA_OFFSET_ERROR) { index_pos[key]=param->new_file_pos; /* Write first block here */ - if (sort_one_index(param,info,keyinfo,info->s->state.key_root[key], + if (sort_one_index(param,info,keyinfo,share->state.key_root[key], new_file)) goto err; } @@ -1498,19 +1500,24 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, my_string name) } /* Flush key cache for this file if we are calling this outside myisamchk */ - flush_key_blocks(info->s->kfile, FLUSH_IGNORE_CHANGED); + flush_key_blocks(share->kfile, FLUSH_IGNORE_CHANGED); /* Put same locks as old file */ - info->s->state.version=(ulong) time((time_t*) 0); - VOID(_mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE)); - VOID(my_close(info->s->kfile,MYF(MY_WME))); - info->s->kfile = -1; + share->state.version=(ulong) time((time_t*) 0); + r_locks=share->r_locks; w_locks=share->w_locks; + share->r_locks=share->w_locks=0; + (void) _mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE); + VOID(my_close(share->kfile,MYF(MY_WME))); + share->kfile = -1; VOID(my_close(new_file,MYF(MY_WME))); - if (change_to_newfile(info->s->filename,MI_NAME_IEXT,INDEX_TMP_EXT,0, + if (change_to_newfile(share->filename,MI_NAME_IEXT,INDEX_TMP_EXT,0, MYF(0)) || - mi_open_keyfile(info->s)) + mi_open_keyfile(share)) goto err2; - _mi_readinfo(info,F_WRLCK,0); + info->lock_type=F_UNLCK; /* Force mi_readinfo to lock */ + _mi_readinfo(info,F_WRLCK,0); /* Will lock the table */ + info->lock_type=F_WRLCK; + share->r_locks=r_locks; share->w_locks=w_locks; info->state->key_file_length=param->new_file_pos; info->update= (short) (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); diff --git a/myisammrg/myrg_info.c b/myisammrg/myrg_info.c index 304216a8276..8ca830339b9 100644 --- a/myisammrg/myrg_info.c +++ b/myisammrg/myrg_info.c @@ -52,8 +52,8 @@ int myrg_status(MYRG_INFO *info,register MYMERGE_INFO *x,int flag) info->data_file_length+=file->table->s->state.state.data_file_length; info->records+=file->table->s->state.state.records; info->del+=file->table->s->state.state.del; - DBUG_PRINT("info2",("table: %s, offset: 0x%08lx", - file->table->filename,(ulong)file->file_offset)); + DBUG_PRINT("info2",("table: %s, offset: %lu", + file->table->filename,(ulong) file->file_offset)); } x->records = info->records; x->deleted = info->del; diff --git a/myisammrg/myrg_open.c b/myisammrg/myrg_open.c index f0a2b4348f6..f73339f63c8 100644 --- a/myisammrg/myrg_open.c +++ b/myisammrg/myrg_open.c @@ -36,11 +36,12 @@ int mode; int handle_locking; { int save_errno,i,errpos; - uint files,dir_length; + uint files,dir_length,length; ulonglong file_offset; char name_buff[FN_REFLEN*2],buff[FN_REFLEN],*end; MYRG_INFO info,*m_info; - FILE *file; + File fd; + IO_CACHE file; MI_INFO *isam,*last_isam; DBUG_ENTER("myrg_open"); @@ -49,15 +50,18 @@ int handle_locking; isam=0; errpos=files=0; bzero((gptr) &info,sizeof(info)); - if (!(file=my_fopen(fn_format(name_buff,name,"",MYRG_NAME_EXT,4), - O_RDONLY | O_SHARE,MYF(0)))) + bzero((char*) &file,sizeof(file)); + if ((fd=my_open(fn_format(name_buff,name,"",MYRG_NAME_EXT,4), + O_RDONLY | O_SHARE,MYF(0))) < 0 || + init_io_cache(&file, fd, IO_SIZE, READ_CACHE, 0, 0, + MYF(MY_WME | MY_NABP))) goto err; errpos=1; dir_length=dirname_part(name_buff,name); info.reclength=0; - while (fgets(buff,FN_REFLEN-1,file)) + while ((length=my_b_gets(&file,buff,FN_REFLEN-1))) { - if ((end=strend(buff))[-1] == '\n') + if ((end=buff+length)[-1] == '\n') end[-1]='\0'; if (buff[0] && buff[0] != '#') /* Skipp empty lines and comments */ { @@ -118,7 +122,8 @@ int handle_locking; m_info->end_table=m_info->open_tables+files; m_info->last_used_table=m_info->open_tables; - VOID(my_fclose(file,MYF(0))); + VOID(my_close(fd,MYF(0))); + end_io_cache(&file); m_info->open_list.data=(void*) m_info; pthread_mutex_lock(&THR_LOCK_open); myrg_open_list=list_add(myrg_open_list,&m_info->open_list); @@ -132,7 +137,8 @@ err: my_free((char*) m_info,MYF(0)); /* Fall through */ case 1: - VOID(my_fclose(file,MYF(0))); + VOID(my_close(fd,MYF(0))); + end_io_cache(&file); for (i=files ; i-- > 0 ; ) { isam=last_isam; diff --git a/myisammrg/myrg_rrnd.c b/myisammrg/myrg_rrnd.c index 77fe00a1bb1..46bd3850bb5 100644 --- a/myisammrg/myrg_rrnd.c +++ b/myisammrg/myrg_rrnd.c @@ -36,7 +36,7 @@ int myrg_rrnd(MYRG_INFO *info,byte *buf,ulonglong filepos) int error; MI_INFO *isam_info; DBUG_ENTER("myrg_rrnd"); - DBUG_PRINT("info",("offset: 0x%016qx", (ulonglong)filepos)); + DBUG_PRINT("info",("offset: %lu", (ulong) filepos)); if (filepos == HA_OFFSET_ERROR) { @@ -109,7 +109,7 @@ static MYRG_TABLE *find_table(MYRG_TABLE *start, MYRG_TABLE *end, else start=mid; } - DBUG_PRINT("info",("offset: 0x%016qx, table: %s", - (ulonglong)pos, start->table->filename)); + DBUG_PRINT("info",("offset: %lu, table: %s", + (ulong) pos, start->table->filename)); DBUG_RETURN(start); } diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index a63e909d823..79fee8d493a 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -72,6 +72,7 @@ cd .. BASEDIR=`pwd` cd $CWD MYSQL_TEST_DIR=$BASEDIR/mysql-test +export MYSQL_TEST_DIR STD_DATA=$MYSQL_TEST_DIR/std_data hostname=`hostname` # Installed in the mysql privilege table @@ -336,6 +337,11 @@ gcov_collect () { start_master() { [ x$MASTER_RUNNING = 1 ] && return + #run master initialization shell script if one exists + if [ -f "$master_init_script" ] ; + then + /bin/sh $master_init_script + fi cd $BASEDIR # for gcov # Remove old berkeley db log files that can confuse the server $RM -f $MASTER_MYDDIR/log.* @@ -375,6 +381,13 @@ start_slave() { [ x$SKIP_SLAVE = x1 ] && return [ x$SLAVE_RUNNING = 1 ] && return + + #run slave initialization shell script if one exists + if [ -f "$slave_init_script" ] ; + then + /bin/sh $slave_init_script + fi + if [ -z "$SLAVE_MASTER_INFO" ] ; then master_info="--master-user=root \ --master-connect-retry=1 \ @@ -502,6 +515,8 @@ run_testcase () tname=`$BASENAME $tf .test` master_opt_file=$TESTDIR/$tname-master.opt slave_opt_file=$TESTDIR/$tname-slave.opt + master_init_script=$TESTDIR/$tname-master.sh + slave_init_script=$TESTDIR/$tname-slave.sh slave_master_info_file=$TESTDIR/$tname-slave-master-info.opt SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0` diff --git a/mysql-test/r/backup.result b/mysql-test/r/backup.result index a801e1cd28d..4b7b62f3ee8 100644 --- a/mysql-test/r/backup.result +++ b/mysql-test/r/backup.result @@ -37,3 +37,7 @@ k 223 245 267 +Table Op Msg_type Msg_text +test.t1 restore status OK +Table Op Msg_type Msg_text +test.t1 backup status OK diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result index 79c55e45342..1199cd07e2e 100644 --- a/mysql-test/r/distinct.result +++ b/mysql-test/r/distinct.result @@ -153,3 +153,17 @@ j_lj_t3 index id id 4 NULL 2 where used; Using index; Distinct t3_lj index id id 8 NULL 1 where used; Using index; Distinct id 2 +a sec_to_time(sum(time_to_sec(t))) +1 00:06:15 +1 00:36:30 +1 00:36:30 +a sec_to_time(sum(time_to_sec(t))) +1 00:06:15 +1 00:36:30 +a sec_to_time(sum(time_to_sec(t))) +1 00:06:15 +1 00:36:30 +1 00:36:30 +a sec_to_time(sum(time_to_sec(t))) +1 00:06:15 +1 00:36:30 diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result index 5ef58bcef3f..aa9ea098e0a 100644 --- a/mysql-test/r/merge.result +++ b/mysql-test/r/merge.result @@ -106,4 +106,10 @@ incr othr 2 24 4 33 3 53 +count(*) +10 +count(*) +20 +count(*) +20 a diff --git a/mysql-test/r/rpl000014.result b/mysql-test/r/rpl000014.result index 9e45b9c10a3..d2cb8ee5436 100644 --- a/mysql-test/r/rpl000014.result +++ b/mysql-test/r/rpl000014.result @@ -1,13 +1,13 @@ File Position Binlog_do_db Binlog_ignore_db master-bin.001 73 -Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db -127.0.0.1 root 9306 1 master-bin.001 73 Yes -Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db -127.0.0.1 root 9306 1 master-bin.001 73 No -Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db -127.0.0.1 root 9306 1 master-bin.001 73 Yes -Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db -127.0.0.1 root 9306 1 master-bin.001 173 Yes +Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter +127.0.0.1 root 9306 1 master-bin.001 73 Yes 0 0 +Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter +127.0.0.1 root 9306 1 master-bin.001 73 No 0 0 +Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter +127.0.0.1 root 9306 1 master-bin.001 73 Yes 0 0 +Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter +127.0.0.1 root 9306 1 master-bin.001 173 Yes 0 0 File Position Binlog_do_db Binlog_ignore_db master-bin.001 73 n diff --git a/mysql-test/r/rpl000015.result b/mysql-test/r/rpl000015.result index 59a1a21be17..5899d76c82f 100644 --- a/mysql-test/r/rpl000015.result +++ b/mysql-test/r/rpl000015.result @@ -1,13 +1,13 @@ File Position Binlog_do_db Binlog_ignore_db master-bin.001 73 -Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db - 0 0 0 No -Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db -127.0.0.1 test 3306 60 4 No -Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db -127.0.0.1 root 9306 60 4 No -Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db -127.0.0.1 root 9306 60 master-bin.001 73 Yes +Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter + 0 0 0 No 0 0 +Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter +127.0.0.1 test 3306 60 4 No 0 0 +Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter +127.0.0.1 root 9306 60 4 No 0 0 +Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter +127.0.0.1 root 9306 60 master-bin.001 73 Yes 0 0 n 10 45 diff --git a/mysql-test/r/rpl000016.result b/mysql-test/r/rpl000016.result index ae5b83a4a85..39ea7234e2a 100644 --- a/mysql-test/r/rpl000016.result +++ b/mysql-test/r/rpl000016.result @@ -1,5 +1,5 @@ -Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db -127.0.0.1 root 9306 60 master-bin.001 216 Yes +Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter +127.0.0.1 root 9306 60 master-bin.001 216 Yes 0 0 s Could not break slave Tried hard @@ -9,10 +9,17 @@ master-bin.002 master-bin.003 Log_name master-bin.003 -Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db -127.0.0.1 root 9306 60 master-bin.003 128 Yes +Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter +127.0.0.1 root 9306 60 master-bin.003 184 Yes 0 0 m 34 +65 67 123 -65 +1234 +Log_name +master-bin.003 +master-bin.004 +master-bin.005 +count(*) +100 diff --git a/mysql-test/r/rpl000017.result b/mysql-test/r/rpl000017.result new file mode 100644 index 00000000000..e4f324047f8 --- /dev/null +++ b/mysql-test/r/rpl000017.result @@ -0,0 +1,2 @@ +n +24 diff --git a/mysql-test/r/rpl000018.result b/mysql-test/r/rpl000018.result new file mode 100644 index 00000000000..7c89c2ef2b2 --- /dev/null +++ b/mysql-test/r/rpl000018.result @@ -0,0 +1,5 @@ +Log_name +master-bin.001 +master-bin.002 +n +3351 diff --git a/mysql-test/r/status.result b/mysql-test/r/status.result new file mode 100644 index 00000000000..8f3ad3e0d59 --- /dev/null +++ b/mysql-test/r/status.result @@ -0,0 +1,6 @@ +Variable_name Value +Table_locks_immediate 0 +Table_locks_waited 0 +Variable_name Value +Table_locks_immediate 3 +Table_locks_waited 1 diff --git a/mysql-test/std_data/master-bin.001 b/mysql-test/std_data/master-bin.001 Binary files differnew file mode 100644 index 00000000000..fa30d8e5302 --- /dev/null +++ b/mysql-test/std_data/master-bin.001 diff --git a/mysql-test/t/backup.test b/mysql-test/t/backup.test index 396576badb7..17b06d73814 100644 --- a/mysql-test/t/backup.test +++ b/mysql-test/t/backup.test @@ -26,6 +26,19 @@ select n from t1; select m from t2; select k from t3; drop table t1,t2,t3; -#restore table t1 from '../tmp'; -#connection con2; -#lock tables t1 write; +restore table t1 from '../tmp'; +connection con2; +send lock tables t1 write; +connection con1; +send backup table t1 to '../tmp'; +connection con2; +reap; +unlock tables; +connection con1; +reap; + + + + + + diff --git a/mysql-test/t/distinct.test b/mysql-test/t/distinct.test index 9ddc7ac4a9b..29b2fddbe5f 100644 --- a/mysql-test/t/distinct.test +++ b/mysql-test/t/distinct.test @@ -182,3 +182,19 @@ WHERE ((t1.id=j_lj_t2.id AND t2_lj.id IS NULL) OR (t1.id=t2.id AND t2.idx=2)) AND ((t1.id=j_lj_t3.id AND t3_lj.id IS NULL) OR (t1.id=t3.id AND t3.idx=2)); drop table t1,t2,t3; + +# +# Test using DISTINCT on a function that contains a group function +# This also test the case when one doesn't use all fields in GROUP BY. +# + +drop table if exists t1; +create table t1 (a int not null, b int not null, t time); +insert into t1 values (1,1,"00:06:15"),(1,2,"00:06:15"),(1,2,"00:30:15"),(1,3,"00:06:15"),(1,3,"00:30:15"); +select a,sec_to_time(sum(time_to_sec(t))) from t1 group by a,b; +select distinct a,sec_to_time(sum(time_to_sec(t))) from t1 group by a,b; +create table t2 (a int not null primary key, b int); +insert into t2 values (1,1),(2,2),(3,3); +select t1.a,sec_to_time(sum(time_to_sec(t))) from t1 left join t2 on (t1.b=t2.a) group by t1.a,t2.b; +select distinct t1.a,sec_to_time(sum(time_to_sec(t))) from t1 left join t2 on (t1.b=t2.a) group by t1.a,t2.b; +drop table t1,t2; diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test index a3b2c8a11de..2f4482d9723 100644 --- a/mysql-test/t/merge.test +++ b/mysql-test/t/merge.test @@ -35,7 +35,8 @@ select a from t3 order by a desc limit 300,10; # The following should give errors create table t4 (a int not null, b char(10), key(a)) type=MERGE UNION=(t1,t2); -drop table if exists t1,t2,t3,t4; +# Because of windows, it's important that we drop the merge tables first! +drop table if exists t4,t3,t1,t2; create table t1 (c char(10)) type=myisam; create table t2 (c char(10)) type=myisam; @@ -70,6 +71,12 @@ INSERT INTO t1 VALUES (11,20),(13,43),(15,11),(17,22),(19,37); INSERT INTO t2 VALUES (12,25),(14,31),(16,42),(18,27),(10,30); SELECT * from t3 where incr in (1,2,3,4) order by othr; +alter table t3 UNION=(t1); +select count(*) from t3; +alter table t3 UNION=(t1,t2); +select count(*) from t3; +alter table t3 TYPE=MYISAM; +select count(*) from t3; drop table t3,t2,t1; # diff --git a/mysql-test/t/overflow.test b/mysql-test/t/overflow.test new file mode 100644 index 00000000000..73554200dce --- /dev/null +++ b/mysql-test/t/overflow.test @@ -0,0 +1,4 @@ +connect (con1,localhost,boo,,test,0,mysql-master.sock); +connection con1; +-- error 1064; +drop database AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA; diff --git a/mysql-test/t/rpl000012.test b/mysql-test/t/rpl000012.test index 495cb81167e..eddd3ede1d7 100644 --- a/mysql-test/t/rpl000012.test +++ b/mysql-test/t/rpl000012.test @@ -10,20 +10,26 @@ connection master1; create temporary table t1 (n int); insert into t1 values (4),(5); insert into t2 select * from t1; +save_master_pos; disconnect master; +connection slave; + +#add 1 to the saved position, so we will catch drop table on disconnect +#for sure +sync_with_master 1; connection master1; insert into t2 values(6); -disconnect master1; -connect (master2,localhost,root,,test,0,mysql-master.sock); -connection master2; save_master_pos; +disconnect master1; connection slave; -sync_with_master; +#same trick - make sure we catch drop of temporary table on disconnect +sync_with_master 1; @r/rpl000012.result select * from t2; @r/rpl000012.status.result show status like 'Slave_open_temp_tables'; # # Clean up # +connect (master2,localhost,root,,test,0,mysql-master.sock); connection master2; drop table if exists t1,t2; save_master_pos; diff --git a/mysql-test/t/rpl000013.test b/mysql-test/t/rpl000013.test index f5056839791..f870d017fa3 100644 --- a/mysql-test/t/rpl000013.test +++ b/mysql-test/t/rpl000013.test @@ -13,20 +13,24 @@ connection master1; create temporary table t1 (n int); insert into t1 values (4),(5); insert into t2 select * from t1; +save_master_pos; disconnect master; +connection slave; +#add 1 to catch drop table +sync_with_master 1; connection master1; insert into t2 values(6); -disconnect master1; -connect (master2,localhost,root,,test,0,mysql-master.sock); -connection master2; save_master_pos; +disconnect master1; connection slave; -sync_with_master; +# same trick to go one more event +sync_with_master 1; @r/rpl000013.result select * from t2; @r/rpl000013.status.result show status like 'Slave_open_temp_tables'; # # Clean up # +connect (master2,localhost,root,,test,0,mysql-master.sock); connection master2; drop table if exists t1,t2; save_master_pos; diff --git a/mysql-test/t/rpl000016-master.opt b/mysql-test/t/rpl000016-master.opt new file mode 100644 index 00000000000..f27601e0d7d --- /dev/null +++ b/mysql-test/t/rpl000016-master.opt @@ -0,0 +1 @@ +-O max_binlog_size=2048 diff --git a/mysql-test/t/rpl000016.test b/mysql-test/t/rpl000016.test index f9ef99c62b6..fd30188ea89 100644 --- a/mysql-test/t/rpl000016.test +++ b/mysql-test/t/rpl000016.test @@ -26,10 +26,40 @@ select * from t1; connection master; flush logs; drop table if exists t2; -create table t2(m int); +create table t2(m int not null primary key); insert into t2 values (34),(67),(123); +save_master_pos; flush logs; show master logs; + +#now lets make some duplicate key mess and see if we can recover from it + +#first insert a value on the slave +connection slave; +sync_with_master; +insert into t2 values(1234); + +#same value on the master +connection master; +save_master_pos; +insert into t2 values(1234); +connection slave; +sync_with_master; + +#the slave may have already stopped, so we ignore the error +!slave stop; + +#restart slave skipping one event +set sql_slave_skip_counter=1; +slave start; + +connection master; +save_master_pos; + +#let slave catch up +connection slave; +sync_with_master; +connection master; purge master logs to 'master-bin.003'; show master logs; insert into t2 values (65); @@ -38,6 +68,25 @@ connection slave; sync_with_master; show slave status; select * from t2; -drop table if exists t1,t2; connection master; -drop table if exists t1,t2; +let $1=100; +drop table if exists t3; +create table t3 (n int); +while ($1) +{ + insert into t3 values(4); + dec $1; +} +show master logs; +save_master_pos; +connection slave; +slave stop; +slave start; +sync_with_master; +select count(*) from t3 where n = 4; +#clean up +connection master; +drop table if exists t1,t2,t3; +save_master_pos; +connection slave; +sync_with_master; diff --git a/mysql-test/t/rpl000017-slave.opt b/mysql-test/t/rpl000017-slave.opt new file mode 100644 index 00000000000..58a964c90d0 --- /dev/null +++ b/mysql-test/t/rpl000017-slave.opt @@ -0,0 +1 @@ +--skip-slave-start diff --git a/mysql-test/t/rpl000017-slave.sh b/mysql-test/t/rpl000017-slave.sh new file mode 100755 index 00000000000..fe875f1a778 --- /dev/null +++ b/mysql-test/t/rpl000017-slave.sh @@ -0,0 +1,9 @@ +cat > $MYSQL_TEST_DIR/var/slave-data/master.info <<EOF +master-bin.001 +4 +127.0.0.1 +root + +9306 +1 +EOF diff --git a/mysql-test/t/rpl000017.test b/mysql-test/t/rpl000017.test new file mode 100644 index 00000000000..c93d861bec8 --- /dev/null +++ b/mysql-test/t/rpl000017.test @@ -0,0 +1,19 @@ +connect (master,localhost,root,,test,0,mysql-master.sock); +connect (slave,localhost,root,,test,0,mysql-slave.sock); +connection master; +reset master; +connection slave; +slave start; +connection master; +drop table if exists t1; +create table t1(n int); +insert into t1 values(24); +save_master_pos; +connection slave; +sync_with_master; +select * from t1; +connection master; +drop table t1; +save_master_pos; +connection slave; +sync_with_master; diff --git a/mysql-test/t/rpl000018-master.opt b/mysql-test/t/rpl000018-master.opt new file mode 100644 index 00000000000..ad2c6a647b5 --- /dev/null +++ b/mysql-test/t/rpl000018-master.opt @@ -0,0 +1 @@ +-O max_binlog_size=4096 diff --git a/mysql-test/t/rpl000018-master.sh b/mysql-test/t/rpl000018-master.sh new file mode 100755 index 00000000000..71f0f12d0c5 --- /dev/null +++ b/mysql-test/t/rpl000018-master.sh @@ -0,0 +1,3 @@ +rm -f $MYSQL_TEST_DIR/var/lib/master-bin.* +cp $MYSQL_TEST_DIR/std_data/master-bin.001 $MYSQL_TEST_DIR/var/lib/ +echo ./master-bin.001 > $MYSQL_TEST_DIR/var/lib/master-bin.index diff --git a/mysql-test/t/rpl000018-slave.opt b/mysql-test/t/rpl000018-slave.opt new file mode 100644 index 00000000000..e854f0d0bb2 --- /dev/null +++ b/mysql-test/t/rpl000018-slave.opt @@ -0,0 +1 @@ +--skip-slave-start --abort-slave-event-count=1 diff --git a/mysql-test/t/rpl000018.test b/mysql-test/t/rpl000018.test new file mode 100644 index 00000000000..44236323d1d --- /dev/null +++ b/mysql-test/t/rpl000018.test @@ -0,0 +1,19 @@ +connect (master,localhost,root,,test,0,mysql-master.sock); +connect (slave,localhost,root,,test,0,mysql-slave.sock); +connection slave; +reset slave; +slave start; +connection master; +show master logs; +drop table if exists t1; +create table t1(n int); +insert into t1 values (3351); +save_master_pos; +connection slave; +sync_with_master; +select * from t1; +connection master; +drop table t1; +save_master_pos; +connection slave; +sync_with_master; diff --git a/mysql-test/t/status.test b/mysql-test/t/status.test new file mode 100644 index 00000000000..7c825469f09 --- /dev/null +++ b/mysql-test/t/status.test @@ -0,0 +1,23 @@ +connect (con1,localhost,root,,test,0,mysql-master.sock); +connect (con2,localhost,root,,test,0,mysql-master.sock); + +flush status; +show status like 'Table_lock%'; +connection con1; +SET SQL_LOG_BIN=0; +drop table if exists t1; +create table t1(n int); +insert into t1 values(1); +connection con2; +lock tables t1 read; +unlock tables; +lock tables t1 read; +connection con1; +send update t1 set n = 3; +connection con2; +sleep 0.5; +unlock tables; +connection con1; +reap; +show status like 'Table_lock%'; +drop table t1; diff --git a/mysys/Makefile.am b/mysys/Makefile.am index 7615b85fa29..6674132bdca 100644 --- a/mysys/Makefile.am +++ b/mysys/Makefile.am @@ -44,7 +44,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c\ my_quick.c my_lockmem.c my_static.c \ getopt.c getopt1.c getvar.c my_mkdir.c \ default.c my_compress.c checksum.c raid.cc my_net.c \ - my_vsnprintf.c charset.c + my_vsnprintf.c charset.c my_bitmap.c EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \ thr_mutex.c thr_rwlock.c libmysys_a_LIBADD = @THREAD_LOBJECTS@ diff --git a/mysys/hash.c b/mysys/hash.c index b366554272a..66fa91811b5 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -83,7 +83,7 @@ void hash_free(HASH *hash) /* some helper functions */ -static inline byte* +inline byte* hash_key(HASH *hash,const byte *record,uint *length,my_bool first) { if (hash->get_key) @@ -180,7 +180,7 @@ uint calc_hashnr_caseup(const byte *key, uint len) #endif -static inline uint rec_hashnr(HASH *hash,const byte *record) +inline uint rec_hashnr(HASH *hash,const byte *record) { uint length; byte *key=hash_key(hash,record,&length,0); diff --git a/mysys/mf_tempfile.c b/mysys/mf_tempfile.c index 6204c4d0407..b2c0e89b9e4 100644 --- a/mysys/mf_tempfile.c +++ b/mysys/mf_tempfile.c @@ -40,7 +40,7 @@ File create_temp_file(char *to, const char *dir, const char *prefix, myf MyFlags __attribute__((unused))) { File file= -1; - DBUG_ENTER("open_temp_file"); + DBUG_ENTER("create_temp_file"); #if defined(_MSC_VER) { char temp[FN_REFLEN],*end,*res,**old_env,*temp_env[1]; diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c new file mode 100644 index 00000000000..1434f472f98 --- /dev/null +++ b/mysys/my_bitmap.c @@ -0,0 +1,60 @@ +/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + MA 02111-1307, USA */ + +/* + Handling of uchar arrays as large bitmaps. +*/ + +#include "mysys_priv.h" +#include <my_bitmap.h> + +pthread_mutex_t LOCK_bitmap; + +void bitmap_set_bit(uchar *bitmap, uint bitmap_size, uint bitmap_bit) { + if((bitmap_bit != MY_BIT_NONE) && (bitmap_bit < bitmap_size*8)) { + pthread_mutex_lock(&LOCK_bitmap); + bitmap[bitmap_bit / 8] |= (1 << bitmap_bit % 8); + pthread_mutex_unlock(&LOCK_bitmap); + }; +}; + +uint bitmap_set_next(uchar *bitmap, uint bitmap_size) { + uint bit_found = MY_BIT_NONE; + int i, b; + + pthread_mutex_lock(&LOCK_bitmap); + for(i=0; (i<bitmap_size) && (bit_found==MY_BIT_NONE); i++) { + if(bitmap[i] == 0xff) continue; + for(b=0; (b<8) && (bit_found==MY_BIT_NONE); b++) + if((bitmap[i] & 1<<b) == 0) { + bit_found = (i*8)+b; + bitmap[i] |= 1<<b; + }; + }; + pthread_mutex_unlock(&LOCK_bitmap); + + return bit_found; +}; + +void bitmap_clear_bit(uchar *bitmap, uint bitmap_size, uint bitmap_bit) { + if((bitmap_bit != MY_BIT_NONE) && (bitmap_bit < bitmap_size*8)) { + pthread_mutex_lock(&LOCK_bitmap); + bitmap[bitmap_bit / 8] &= ~(1 << bitmap_bit % 8); + pthread_mutex_unlock(&LOCK_bitmap); + }; +}; + diff --git a/mysys/my_getwd.c b/mysys/my_getwd.c index 3d674276731..b49737b2a61 100644 --- a/mysys/my_getwd.c +++ b/mysys/my_getwd.c @@ -29,6 +29,10 @@ #include <direct.h> #endif +#ifdef __EMX__ +// chdir2 support also drive change +#define chdir _chdir2 +#endif /* Gets current working directory in buff. Directory is allways ended with FN_LIBCHAR */ diff --git a/mysys/my_init.c b/mysys/my_init.c index a9c8b49a257..384fab5d53c 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -48,6 +48,7 @@ static my_bool win32_init_tcp_ip(); static my_bool my_init_done=0; + static ulong atoi_octal(const char *str) { long int tmp; @@ -76,6 +77,7 @@ void my_init(void) #ifndef __WIN__ sigfillset(&my_signals); /* signals blocked by mf_brkhant */ #endif + pthread_mutex_init(&LOCK_bitmap, NULL); #endif { DBUG_ENTER("my_init"); @@ -127,7 +129,12 @@ void my_end(int infoflag) #ifdef HAVE_GETRUSAGE struct rusage rus; if (!getrusage(RUSAGE_SELF, &rus)) - fprintf(info_file,"\nUser time %.2f, System time %.2f\nMaximum resident set size %ld, Integral resident set size %ld\nNon physical pagefaults %ld, Physical pagefaults %ld, Swaps %ld\nBlocks in %ld out %ld, Messages in %ld out %ld, Signals %ld\nVouluntary context switches %ld, Invouluntary context switches %ld\n", + fprintf(info_file,"\n\ +User time %.2f, System time %.2f\n\ +Maximum resident set size %ld, Integral resident set size %ld\n\ +Non-physical pagefaults %ld, Physical pagefaults %ld, Swaps %ld\n\ +Blocks in %ld out %ld, Messages in %ld out %ld, Signals %ld\n\ +Voluntary context switches %ld, Involuntary context switches %ld\n", (rus.ru_utime.tv_sec * SCALE_SEC + rus.ru_utime.tv_usec / SCALE_USEC) / 100.0, (rus.ru_stime.tv_sec * SCALE_SEC + @@ -159,6 +166,7 @@ void my_end(int infoflag) pthread_mutex_destroy(&THR_LOCK_keycache); pthread_mutex_destroy(&THR_LOCK_malloc); pthread_mutex_destroy(&THR_LOCK_open); + pthread_mutex_destroy(&LOCK_bitmap); DBUG_POP(); /* Must be done before my_thread_end */ my_thread_end(); my_thread_global_end(); diff --git a/mysys/my_vsnprintf.c b/mysys/my_vsnprintf.c index 030846ea63b..669b8be61b1 100644 --- a/mysys/my_vsnprintf.c +++ b/mysys/my_vsnprintf.c @@ -21,6 +21,13 @@ #include <stdarg.h> #include <m_ctype.h> +int my_snprintf(char* to, size_t n, const char* fmt, ...) +{ + va_list args; + va_start(args,fmt); + return my_vsnprintf(to, n, fmt, args); +} + int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) { char *start=to, *end=to+n-1; diff --git a/mysys/mysys_priv.h b/mysys/mysys_priv.h index 86c32202e99..20fda270658 100644 --- a/mysys/mysys_priv.h +++ b/mysys/mysys_priv.h @@ -25,6 +25,7 @@ #ifdef THREAD extern pthread_mutex_t THR_LOCK_malloc,THR_LOCK_open,THR_LOCK_keycache, THR_LOCK_lock,THR_LOCK_isam,THR_LOCK_net,THR_LOCK_charset; +extern pthread_mutex_t LOCK_bitmap; #else /* THREAD */ #define pthread_mutex_lock(A) #define pthread_mutex_unlock(A) diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c index 5c48ad435a4..348c7bae74f 100644 --- a/mysys/thr_lock.c +++ b/mysys/thr_lock.c @@ -83,7 +83,7 @@ multiple read locks. #include <errno.h> my_bool thr_lock_inited=0; - +ulong locks_immediate = 0L, locks_waited = 0L; /* The following constants are only for debug output */ #define MAX_THREADS 100 @@ -387,6 +387,7 @@ static my_bool wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data, else { result=0; + statistic_increment(locks_waited, &THR_LOCK_lock); if (data->lock->get_status) (*data->lock->get_status)(data->status_param); check_locks(data->lock,"got wait_for_lock",0); @@ -447,6 +448,7 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type) check_locks(lock,"read lock with old write lock",0); if (lock->get_status) (*lock->get_status)(data->status_param); + ++locks_immediate; goto end; } if (lock->write.data->type == TL_WRITE_ONLY) @@ -470,6 +472,7 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type) if ((int) lock_type == (int) TL_READ_NO_INSERT) lock->read_no_write_count++; check_locks(lock,"read lock with no write locks",0); + ++locks_immediate; goto end; } /* Can't get lock yet; Wait for it */ @@ -501,6 +504,7 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type) data->cond=get_cond(); if (lock->get_status) (*lock->get_status)(data->status_param); + ++locks_immediate; goto end; } } @@ -535,6 +539,7 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type) check_locks(lock,"second write lock",0); if (data->lock->get_status) (*data->lock->get_status)(data->status_param); + ++locks_immediate; goto end; } DBUG_PRINT("lock",("write locked by thread: %ld", @@ -560,6 +565,7 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type) if (data->lock->get_status) (*data->lock->get_status)(data->status_param); check_locks(lock,"only write lock",0); + ++locks_immediate; goto end; } } diff --git a/sql-bench/crash-me.sh b/sql-bench/crash-me.sh index a62e042ffda..2ce5c73c9b2 100644 --- a/sql-bench/crash-me.sh +++ b/sql-bench/crash-me.sh @@ -38,7 +38,7 @@ # as such, and clarify ones such as "mediumint" with comments such as # "3-byte int" or "same as xxx". -$version="1.54"; +$version="1.55"; use DBI; use Getopt::Long; @@ -1315,7 +1315,7 @@ report("default value for column",'create_default', "drop table crash_q $drop_attr"); report("default value function for column",'create_default_func', - "create table crash_q (q integer not null,q1 integer default (1+1)", + "create table crash_q (q integer not null,q1 integer default (1+1))", "drop table crash_q $drop_attr"); report("temporary tables",'temporary_table', @@ -1696,7 +1696,7 @@ if (!report("drop table with cascade/restrict","drop_restrict", report("-- as comment (ANSI)","comment_--", "select * from crash_me -- Testing of comments"); -report("// as comment (ANSI)","comment_//", +report("// as comment","comment_//", "select * from crash_me // Testing of comments"); report("# as comment","comment_#", "select * from crash_me # Testing of comments"); diff --git a/sql/field.cc b/sql/field.cc index 225189a1098..55a98dde0ea 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4710,13 +4710,13 @@ create_field::create_field(Field *old_field,Field *orig_field) orig_field) { char buff[MAX_FIELD_WIDTH],*pos; - String tmp(buff,sizeof(buff)),*res; + String tmp(buff,sizeof(buff)); /* Get the value from record[2] (the default value row) */ my_ptrdiff_t diff= (my_ptrdiff_t) (orig_field->table->rec_buff_length*2); orig_field->move_field(diff); // Points now at record[2] bool is_null=orig_field->is_real_null(); - res=orig_field->val_str(&tmp,&tmp); + orig_field->val_str(&tmp,&tmp); orig_field->move_field(-diff); // Back to record[0] if (!is_null) { diff --git a/sql/field.h b/sql/field.h index 21fd9ebffd9..09ce80db615 100644 --- a/sql/field.h +++ b/sql/field.h @@ -28,6 +28,7 @@ class Send_field; struct st_cache_field; +void field_conv(Field *to,Field *from); class Field { Field(const Item &); /* Prevent use of theese */ diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index efaf7411c55..78ffb266366 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -472,8 +472,8 @@ int main(int argc,char **argv) int error; MY_INIT(argv[0]); - start_value=4424889L; best_t1=3207460L; best_t2=481534L; best_type=0; /* mode=4451 add=8 type: 0 */ - if (get_options(argc,(char **) argv)) + start_value=5315771L; best_t1=6916833L; best_t2=3813748L; best_type=3; /* mode=5839 add=5 type: 0 */ + if (get_options(argc,(char **) argv)) exit(1); make_max_length_table(); diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index 0c5f09c4b36..9f31064cc54 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -110,8 +110,6 @@ static void berkeley_noticecall(DB_ENV *db_env, db_notices notice); bool berkeley_init(void) { - char buff[1024],*config[10], **conf_pos, *str_pos; - conf_pos=config; str_pos=buff; DBUG_ENTER("berkeley_init"); if (!berkeley_tmpdir) @@ -247,9 +245,9 @@ int berkeley_show_logs(THD *thd) my_pthread_setspecific_ptr(THR_MALLOC,&show_logs_root); if ((error= log_archive(db_env, &all_logs, DB_ARCH_ABS | DB_ARCH_LOG, - (void* (*)(unsigned int)) sql_alloc)) || + (void* (*)(size_t)) sql_alloc)) || (error= log_archive(db_env, &free_logs, DB_ARCH_ABS, - (void* (*)(unsigned int)) sql_alloc))) + (void* (*)(size_t)) sql_alloc))) { DBUG_PRINT("error", ("log_archive failed (error %d)", error)); db_env->err(db_env, error, "log_archive: DB_ARCH_ABS"); @@ -387,6 +385,7 @@ berkeley_cmp_packed_key(DB *file, const DBT *new_key, const DBT *saved_key) /* The following is not yet used; Should be used for fixed length keys */ +#ifdef NOT_YET static int berkeley_cmp_fix_length_key(DB *file, const DBT *new_key, const DBT *saved_key) { @@ -407,7 +406,7 @@ berkeley_cmp_fix_length_key(DB *file, const DBT *new_key, const DBT *saved_key) } return key->handler.bdb_return_if_eq; } - +#endif /* Compare key against row */ @@ -1901,7 +1900,6 @@ longlong ha_berkeley::get_auto_increment() { DBT row,old_key; bzero((char*) &row,sizeof(row)); - uint key_len; KEY *key_info= &table->key_info[active_index]; /* Reading next available number for a sub key */ @@ -1947,6 +1945,7 @@ longlong ha_berkeley::get_auto_increment() Analyzing, checking, and optimizing tables ****************************************************************************/ +#ifdef NOT_YET static void print_msg(THD *thd, const char *table_name, const char *op_name, const char *msg_type, const char *fmt, ...) { @@ -1970,7 +1969,7 @@ static void print_msg(THD *thd, const char *table_name, const char *op_name, thd->packet.length())) thd->killed=1; } - +#endif int ha_berkeley::analyze(THD* thd, HA_CHECK_OPT* check_opt) { @@ -2025,14 +2024,14 @@ int ha_berkeley::optimize(THD* thd, HA_CHECK_OPT* check_opt) int ha_berkeley::check(THD* thd, HA_CHECK_OPT* check_opt) { - char name_buff[FN_REFLEN]; - int error; - DB *tmp_file; DBUG_ENTER("ha_berkeley::check"); DBUG_RETURN(HA_ADMIN_NOT_IMPLEMENTED); #ifdef NOT_YET + char name_buff[FN_REFLEN]; + int error; + DB *tmp_file; /* To get this to work we need to ensure that no running transaction is using the table. We also need to create a new environment without @@ -2242,7 +2241,6 @@ void ha_berkeley::get_status() static int write_status(DB *status_block, char *buff, uint length) { - DB_TXN *trans; DBT row,key; int error; const char *key_buff="status"; @@ -2285,7 +2283,6 @@ static void update_status(BDB_SHARE *share, TABLE *table) } { char rec_buff[4+MAX_KEY*4], *pos=rec_buff; - const char *key_buff="status"; int4store(pos,share->rows); pos+=4; for (uint i=0 ; i < table->keys ; i++) { diff --git a/sql/ha_berkeley.h b/sql/ha_berkeley.h index 12879383261..94d12dd2a56 100644 --- a/sql/ha_berkeley.h +++ b/sql/ha_berkeley.h @@ -64,7 +64,7 @@ class ha_berkeley: public handler ulong max_row_length(const byte *buf); int pack_row(DBT *row,const byte *record, bool new_row); void unpack_row(char *record, DBT *row); - void ha_berkeley::unpack_key(char *record, DBT *key, uint index); + void unpack_key(char *record, DBT *key, uint index); DBT *create_key(DBT *key, uint keynr, char *buff, const byte *record, int key_length = MAX_KEY_LENGTH); DBT *pack_key(DBT *key, uint keynr, char *buff, const byte *key_ptr, @@ -156,13 +156,12 @@ class ha_berkeley: public handler void get_status(); inline void get_auto_primary_key(byte *to) { - ulonglong tmp; pthread_mutex_lock(&share->mutex); share->auto_ident++; int5store(to,share->auto_ident); pthread_mutex_unlock(&share->mutex); } - longlong ha_berkeley::get_auto_increment(); + longlong get_auto_increment(); }; extern bool berkeley_skip, berkeley_shared_data; diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc index 863054b4837..4c562282090 100644 --- a/sql/ha_myisammrg.cc +++ b/sql/ha_myisammrg.cc @@ -177,6 +177,7 @@ void ha_myisammrg::info(uint flag) errkey = info.errkey; table->keys_in_use=(((key_map) 1) << table->keys)- (key_map) 1; table->db_options_in_use = info.options; + table->is_view=1; mean_rec_length=info.reclength; block_size=0; update_time=0; diff --git a/sql/hostname.cc b/sql/hostname.cc index fcf8d2753b8..90938c41ee9 100644 --- a/sql/hostname.cc +++ b/sql/hostname.cc @@ -48,6 +48,7 @@ public: }; static hash_filo *hostname_cache; +static pthread_mutex_t LOCK_hostname; void hostname_cache_refresh() { @@ -56,6 +57,7 @@ void hostname_cache_refresh() bool hostname_cache_init() { + (void) pthread_mutex_init(&LOCK_hostname,NULL); if (!(hostname_cache=new hash_filo(HOST_CACHE_SIZE,offsetof(host_entry,ip), sizeof(struct in_addr),NULL, (void (*)(void*)) free))) @@ -66,6 +68,7 @@ bool hostname_cache_init() void hostname_cache_free() { + (void) pthread_mutex_destroy(&LOCK_hostname); delete hostname_cache; } @@ -97,7 +100,7 @@ static void add_hostname(struct in_addr *in,const char *name) } -static inline void add_wrong_ip(struct in_addr *in) +inline void add_wrong_ip(struct in_addr *in) { add_hostname(in,NullS); } @@ -180,26 +183,26 @@ my_string ip_to_hostname(struct in_addr *in, uint *errors) DBUG_RETURN(0); // out of memory #else - VOID(pthread_mutex_lock(&hostname_cache->lock)); + VOID(pthread_mutex_lock(&LOCK_hostname)); if (!(hp=gethostbyaddr((char*) in,sizeof(*in), AF_INET))) { - VOID(pthread_mutex_unlock(&hostname_cache->lock)); + VOID(pthread_mutex_unlock(&LOCK_hostname)); DBUG_PRINT("error",("gethostbyaddr returned %d",errno)); goto err; } if (!hp->h_name[0]) // Don't allow empty hostnames { - VOID(pthread_mutex_unlock(&hostname_cache->lock)); + VOID(pthread_mutex_unlock(&LOCK_hostname)); DBUG_PRINT("error",("Got an empty hostname")); goto err; } if (!(name=my_strdup(hp->h_name,MYF(0)))) { - VOID(pthread_mutex_unlock(&hostname_cache->lock)); + VOID(pthread_mutex_unlock(&LOCK_hostname)); DBUG_RETURN(0); // out of memory } check=gethostbyname(name); - VOID(pthread_mutex_unlock(&hostname_cache->lock)); + VOID(pthread_mutex_unlock(&LOCK_hostname)); if (!check) { DBUG_PRINT("error",("gethostbyname returned %d",errno)); diff --git a/sql/item.cc b/sql/item.cc index db4ce792b27..10d1c6d0560 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -471,7 +471,7 @@ bool Item_real::save_in_field(Field *field) ** In number context this is a longlong value. ****************************************************************************/ -static inline uint char_val(char X) +inline uint char_val(char X) { return (uint) (X >= '0' && X <= '9' ? X-'0' : X >= 'A' && X <= 'Z' ? X-'A'+10 : diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 1c236e19bda..375ba081f80 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -811,7 +811,7 @@ bool Item_sum_count_distinct::setup(THD *thd) for (uint i=0; i < arg_count ; i++) if (list.push_back(args[i])) return 1; - count_field_types(tmp_table_param,list); + count_field_types(tmp_table_param,list,0); if (table) { free_tmp_table(thd, table); diff --git a/sql/item_sum.h b/sql/item_sum.h index 66231040747..8cb09c85623 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -166,6 +166,8 @@ class Item_sum_count_distinct :public Item_sum_int /* Item to get the value of a stored sum function */ +class Item_sum_avg; + class Item_avg_field :public Item_result_field { public: @@ -200,6 +202,7 @@ class Item_sum_avg :public Item_sum_num const char *func_name() const { return "avg"; } }; +class Item_sum_std; class Item_std_field :public Item_result_field { diff --git a/sql/lex.h b/sql/lex.h index 946cba49bce..6f030aa524d 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -283,6 +283,7 @@ static SYMBOL symbols[] = { { "SQL_QUOTE_SHOW_CREATE",SYM(SQL_QUOTE_SHOW_CREATE), 0, 0}, { "SQL_SAFE_UPDATES", SYM(SQL_SAFE_UPDATES),0,0}, { "SQL_SELECT_LIMIT", SYM(SQL_SELECT_LIMIT),0,0}, + { "SQL_SLAVE_SKIP_COUNTER", SYM(SQL_SLAVE_SKIP_COUNTER),0,0}, { "SQL_SMALL_RESULT", SYM(SQL_SMALL_RESULT),0,0}, { "SQL_WARNINGS", SYM(SQL_WARNINGS),0,0}, { "STRAIGHT_JOIN", SYM(STRAIGHT_JOIN),0,0}, diff --git a/sql/log.cc b/sql/log.cc index 5ce9a7a4deb..1ff86ed4b67 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -18,6 +18,10 @@ /* logging of commands */ /* TODO: Abort logging when we get an error in reading or writing log files */ +#ifdef __EMX__ +#include <io.h> +#endif + #include "mysql_priv.h" #include "sql_acl.h" #include "sql_repl.h" @@ -28,6 +32,7 @@ MYSQL_LOG mysql_log,mysql_update_log,mysql_slow_log,mysql_bin_log; extern I_List<i_string> binlog_do_db, binlog_ignore_db; +extern ulong max_binlog_size; static bool test_if_number(const char *str, long *res, bool allow_wildcards); @@ -609,6 +614,8 @@ bool MYSQL_LOG::write(Query_log_event* event_info) { /* In most cases this is only called if 'is_open()' is true */ bool error=0; + bool should_rotate = 0; + if (!inited) // Can't use mutex if not init return 0; VOID(pthread_mutex_lock(&LOCK_log)); @@ -655,7 +662,7 @@ bool MYSQL_LOG::write(Query_log_event* event_info) file == &log_file && flush_io_cache(file)) goto err; error=0; - + should_rotate = (file == &log_file && my_b_tell(file) >= max_binlog_size); err: if (error) { @@ -669,6 +676,8 @@ err: VOID(pthread_cond_broadcast(&COND_binlog_update)); } VOID(pthread_mutex_unlock(&LOCK_log)); + if(should_rotate) + new_file(); return error; } @@ -682,6 +691,7 @@ bool MYSQL_LOG::write(IO_CACHE *cache) { VOID(pthread_mutex_lock(&LOCK_log)); bool error=1; + if (is_open()) { uint length; @@ -722,7 +732,8 @@ err: else VOID(pthread_cond_broadcast(&COND_binlog_update)); - VOID(pthread_mutex_unlock(&LOCK_log)); + VOID(pthread_mutex_unlock(&LOCK_log)); + return error; } @@ -730,6 +741,8 @@ err: bool MYSQL_LOG::write(Load_log_event* event_info) { bool error=0; + bool should_rotate = 0; + if (inited) { VOID(pthread_mutex_lock(&LOCK_log)); @@ -745,11 +758,16 @@ bool MYSQL_LOG::write(Load_log_event* event_info) sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno); error=write_error=1; } + should_rotate = (my_b_tell(&log_file) >= max_binlog_size); VOID(pthread_cond_broadcast(&COND_binlog_update)); } } VOID(pthread_mutex_unlock(&LOCK_log)); } + + if(should_rotate) + new_file(); + return error; } diff --git a/sql/log_event.h b/sql/log_event.h index 3ee1776fde3..8a22048bba4 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -18,6 +18,10 @@ #ifndef _LOG_EVENT_H #define _LOG_EVENT_H +#ifdef __EMX__ +#undef write // remove pthread.h macro definition, conflict with write() class member +#endif + #if defined(__GNUC__) && !defined(MYSQL_CLIENT) #pragma interface /* gcc class implementation */ #endif diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index d3f208aa6de..4c83d70abf1 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -73,6 +73,7 @@ void kill_one_thread(THD *thd, ulong id); #ifndef MYSQLD_NET_RETRY_COUNT #define MYSQLD_NET_RETRY_COUNT 10 // Abort read after this many int. #endif +#define TEMP_POOL_SIZE 128 /* The following parameters is to decide when to use an extra cache to optimise seeks when reading a big table in sorted order */ #define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (16L*1024*1024) @@ -507,7 +508,8 @@ extern ulong ha_read_count, ha_write_count, ha_delete_count, ha_update_count, ha_read_key_count, ha_read_next_count, ha_read_prev_count, ha_read_first_count, ha_read_last_count, ha_read_rnd_count, ha_read_rnd_next_count; - +extern uchar temp_pool[TEMP_POOL_SIZE]; +extern bool use_temp_pool; extern char f_fyllchar; extern uchar *days_in_month; extern DATE_FORMAT dayord; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 62ee256b9da..07e0bd4131a 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -238,7 +238,7 @@ ulong keybuff_size,sortbuff_size,max_item_sort_length,table_cache_size, query_buff_size, lower_case_table_names, mysqld_net_retry_count, net_interactive_timeout, slow_launch_time = 2L, net_read_timeout,net_write_timeout,slave_open_temp_tables=0, - open_files_limit=0; + open_files_limit=0, max_binlog_size; ulong thread_cache_size=0, binlog_cache_size=0, max_binlog_cache_size=0; volatile ulong cached_thread_count=0; @@ -287,6 +287,9 @@ I_List<THD> threads,thread_cache; time_t start_time; +uchar temp_pool[TEMP_POOL_SIZE]; +bool use_temp_pool; + pthread_key(MEM_ROOT*,THR_MALLOC); pthread_key(THD*, THR_THD); pthread_key(NET*, THR_NET); @@ -1048,7 +1051,6 @@ static void init_signals(void) #elif defined(__EMX__) static void sig_reload(int signo) { - //reload_acl_and_cache(~0); // Flush everything reload_acl_and_cache((THD*) 0,~0, (TABLE_LIST*) 0); // Flush everything signal(signo, SIG_ACK); } @@ -1078,8 +1080,30 @@ static void init_signals(void) #ifdef HAVE_LINUXTHREADS static sig_handler write_core(int sig); + #ifdef __i386__ #define SIGRETURN_FRAME_COUNT 1 +#define PTR_SANE(p) ((char*)p >= heap_start && (char*)p <= heap_end) + +extern char* __bss_start; +static char* heap_start, *heap_end; + +inline static __volatile__ void print_str(const char* name, + const char* val, int max_len) +{ + fprintf(stderr, "%s at %p ", name, val); + if(!PTR_SANE(val)) + { + fprintf(stderr, " is invalid pointer\n"); + return; + } + + fprintf(stderr, "= "); + for(; max_len && PTR_SANE(val) && *val; --max_len) + fputc(*val++, stderr); + fputc('\n', stderr); +} + inline static __volatile__ void trace_stack() { uchar **stack_bottom; @@ -1136,7 +1160,18 @@ New value of ebp failed sanity check terminating backtrace\n"); ++frame_count; } - fprintf(stderr, "stack trace successful\n"); + fprintf(stderr, "stack trace successful, now will try to get some\n\ +variables. Some pointers may be invalid and cause dump abort\n"); + heap_start = __bss_start; + heap_end = (char*)sbrk(0); + print_str("thd->query", thd->query, 1024); + fprintf(stderr, "thd->thread_id = %ld\n", thd->thread_id); + fprintf(stderr, "successfully dumped variables, if you ran with --log\n \ +take a look at the details of what thread %ld did to cause the crash.\n\ +In some cases of really bad corruption, this value can be invalid \n", + thd->thread_id); + fprintf(stderr, "Please use the information above to create a repeatable\n\ +test case for the crash, and send it to bugs@lists.mysql.com\n"); } #endif #endif @@ -1195,6 +1230,8 @@ static void init_signals(void) sa.sa_handler=handle_segfault; #endif sigaction(SIGSEGV, &sa, NULL); + sigaction(SIGBUS, &sa, NULL); + sigaction(SIGILL, &sa, NULL); (void) sigemptyset(&set); #ifdef THREAD_SPECIFIC_SIGPIPE sigset(SIGPIPE,abort_thread); @@ -1498,6 +1535,9 @@ int main(int argc, char **argv) if (!mysql_tmpdir || !mysql_tmpdir[0]) mysql_tmpdir=(char*) P_tmpdir; /* purecov: inspected */ + bzero(temp_pool, TEMP_POOL_SIZE); + use_temp_pool = 0; + set_options(); #ifdef __WIN__ /* service parameters can be overwritten by options */ @@ -2370,7 +2410,8 @@ enum options { OPT_INNOBASE_LOG_GROUP_HOME_DIR, OPT_INNOBASE_LOG_ARCH_DIR, OPT_INNOBASE_LOG_ARCHIVE, OPT_INNOBASE_FLUSH_LOG_AT_TRX_COMMIT, OPT_SAFE_SHOW_DB, - OPT_GEMINI_SKIP + OPT_GEMINI_SKIP, + OPT_TEMP_POOL }; static struct option long_options[] = { @@ -2501,6 +2542,7 @@ static struct option long_options[] = { #ifdef __WIN__ {"standalone", no_argument, 0, (int) OPT_STANDALONE}, #endif + {"temp-pool", no_argument, 0, (int) OPT_TEMP_POOL}, {"tmpdir", required_argument, 0, 't'}, {"use-locking", no_argument, 0, (int) OPT_USE_LOCKING}, #ifdef USE_SYMDIR @@ -2571,6 +2613,8 @@ CHANGEABLE_VAR changeable_vars[] = { 1024*1024L, 80, 64*1024*1024L, MALLOC_OVERHEAD, 1024 }, { "max_binlog_cache_size", (long*) &max_binlog_cache_size, ~0L, IO_SIZE, ~0L, 0, IO_SIZE }, + { "max_binlog_size", (long*) &max_binlog_size, + 1024*1024L*1024L, 1024, 1024*1024L*1024L, 0, 1 }, { "max_connections", (long*) &max_connections, 100, 1, 16384, 0, 1 }, { "max_connect_errors", (long*) &max_connect_errors, @@ -2672,7 +2716,8 @@ struct show_var_st init_vars[]= { {"low_priority_updates", (char*) &low_priority_updates, SHOW_BOOL}, {"lower_case_table_names", (char*) &lower_case_table_names, SHOW_LONG}, {"max_allowed_packet", (char*) &max_allowed_packet, SHOW_LONG}, - {"max_binlog_cache_size", (char*) &max_binlog_cache_size, SHOW_LONG}, + {"max_binlog_cache_size", (char*) &max_binlog_cache_size, SHOW_LONG}, + {"max_binlog_size", (char*) &max_binlog_size, SHOW_LONG}, {"max_connections", (char*) &max_connections, SHOW_LONG}, {"max_connect_errors", (char*) &max_connect_errors, SHOW_LONG}, {"max_delayed_threads", (char*) &max_insert_delayed_threads, SHOW_LONG}, @@ -2766,6 +2811,8 @@ struct show_var_st status_vars[]= { {"Sort_range", (char*) &filesort_range_count, SHOW_LONG}, {"Sort_rows", (char*) &filesort_rows, SHOW_LONG}, {"Sort_scan", (char*) &filesort_scan_count, SHOW_LONG}, + {"Table_locks_immediate", (char*) &locks_immediate, SHOW_LONG}, + {"Table_locks_waited", (char*) &locks_waited, SHOW_LONG}, {"Threads_cached", (char*) &cached_thread_count, SHOW_LONG_CONST}, {"Threads_created", (char*) &thread_created, SHOW_LONG_CONST}, {"Threads_connected", (char*) &thread_count, SHOW_INT_CONST}, @@ -2874,6 +2921,7 @@ static void usage(void) Don't give threads different priorities.\n\ --socket=... Socket file to use for connection\n\ -t, --tmpdir=path Path for temporary files\n\ + --temp-pool Use a pool of temporary files\n\ -u, --user=user_name Run mysqld daemon as user\n\ -V, --version output version information and exit"); #ifdef __WIN__ @@ -3049,6 +3097,9 @@ static void get_options(int argc,char **argv) case 't': mysql_tmpdir=optarg; break; + case OPT_TEMP_POOL: + use_temp_pool=1; + break; case 'u': mysqld_user=optarg; break; diff --git a/sql/net_serv.cc b/sql/net_serv.cc index 34c2922da60..4c4642034e1 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -74,7 +74,7 @@ typedef my_bool ALARM; #define thr_alarm_in_use(A) (*(A)) #define thr_end_alarm(A) #define thr_alarm(A,B,C) local_thr_alarm((A),(B),(C)) -static inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)),ALARM *C __attribute__((unused))) +inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)),ALARM *C __attribute__((unused))) { *A=1; return 0; @@ -271,7 +271,7 @@ net_real_write(NET *net,const char *packet,ulong len) int length; char *pos,*end; thr_alarm_t alarmed; -#if !defined(__WIN__) && !defined(__EMX__) +#if !defined(__WIN__) ALARM alarm_buff; #endif uint retry_count=0; @@ -426,7 +426,7 @@ static void my_net_skip_rest(NET *net, ulong remain, thr_alarm_t *alarmed) if ((int) (length=vio_read(net->vio,(char*) net->buff,remain)) <= 0L) { my_bool interrupted = vio_should_retry(net->vio); - if (!thr_got_alarm(&alarmed) && interrupted) + if (!thr_got_alarm(alarmed) && interrupted) { /* Probably in MIT threads */ if (retry_count++ < RETRY_COUNT) continue; diff --git a/sql/password.c b/sql/password.c index 63ab9def651..1c88aabcce2 100644 --- a/sql/password.c +++ b/sql/password.c @@ -91,7 +91,7 @@ void make_scrambled_password(char *to,const char *password) sprintf(to,"%08lx%08lx",hash_res[0],hash_res[1]); } -static inline uint char_val(char X) +inline uint char_val(char X) { return (uint) (X >= '0' && X <= '9' ? X-'0' : X >= 'A' && X <= 'Z' ? X-'A'+10 : diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt index c10d59dc21c..319d8a88149 100644 --- a/sql/share/czech/errmsg.txt +++ b/sql/share/czech/errmsg.txt @@ -208,3 +208,8 @@ "Tabulka '%-.64s' je ozna-Bèena jako poru¹ená a poslední (automatická?) oprava se nezdaøila",-A "Warning: Some non-transactional changed tables couldn't be rolled back", "Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again', +"This operation cannot be performed with a running slave, run SLAVE STOP first", +"This operation requires a running slave, configure slave and do SLAVE START", +"The server is not configured as slave, fix in config file or with CHANGE MASTER TO", +"Could not initialize master info structure, check permisions on master.info", +"Could not create slave thread, check system resources", diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt index 79d7ae5efc4..43aad2f71e4 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -202,3 +202,8 @@ "Table '%-.64s' is marked as crashed and last (automatic?) repair failed", "Warning: Some non-transactional changed tables couldn't be rolled back", "Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again', +"This operation cannot be performed with a running slave, run SLAVE STOP first", +"This operation requires a running slave, configure slave and do SLAVE START", +"The server is not configured as slave, fix in config file or with CHANGE MASTER TO", +"Could not initialize master info structure, check permisions on master.info", +"Could not create slave thread, check system resources", diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt index 1cfdbee8d43..86d8e095d20 100644 --- a/sql/share/dutch/errmsg.txt +++ b/sql/share/dutch/errmsg.txt @@ -199,3 +199,8 @@ "Table '%-.64s' is marked as crashed and last (automatic?) repair failed", "Warning: Some non-transactional changed tables couldn't be rolled back", "Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again', +"This operation cannot be performed with a running slave, run SLAVE STOP first", +"This operation requires a running slave, configure slave and do SLAVE START", +"The server is not configured as slave, fix in config file or with CHANGE MASTER TO", +"Could not initialize master info structure, check permisions on master.info", +"Could not create slave thread, check system resources", diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index 4900e4bd7ad..e11a182c6b7 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -187,7 +187,7 @@ "Got error %d during CHECKPOINT", "Aborted connection %ld to db: '%-.64s' user: '%-.32s' host: `%-.64s' (%-.64s)", "The handler for the table does not support binary table dump", -"Binlog closed while trying to FLUSH MASTER", +"Binlog closed, cannot RESET MASTER", "Failed rebuilding the index of dumped table '%-.64s'", "Error from master: '%-.64s'", "Net error reading from master", @@ -199,3 +199,8 @@ "Table '%-.64s' is marked as crashed and last (automatic?) repair failed", "Warning: Some non-transactional changed tables couldn't be rolled back", "Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again', +"This operation cannot be performed with a running slave, run SLAVE STOP first", +"This operation requires a running slave, configure slave and do SLAVE START", +"The server is not configured as slave, fix in config file or with CHANGE MASTER TO", +"Could not initialize master info structure, check permisions on master.info", +"Could not create slave thread, check system resources", diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt index cb609f66432..227b6336562 100644 --- a/sql/share/estonian/errmsg.txt +++ b/sql/share/estonian/errmsg.txt @@ -203,3 +203,8 @@ "Table '%-.64s' is marked as crashed and last (automatic?) repair failed", "Warning: Some non-transactional changed tables couldn't be rolled back", "Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again', +"This operation cannot be performed with a running slave, run SLAVE STOP first", +"This operation requires a running slave, configure slave and do SLAVE START", +"The server is not configured as slave, fix in config file or with CHANGE MASTER TO", +"Could not initialize master info structure, check permisions on master.info", +"Could not create slave thread, check system resources", diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt index 0e1b9cf8e01..594da49c32e 100644 --- a/sql/share/french/errmsg.txt +++ b/sql/share/french/errmsg.txt @@ -199,3 +199,8 @@ "Table '%-.64s' is marked as crashed and last (automatic?) repair failed", "Warning: Some non-transactional changed tables couldn't be rolled back", "Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again', +"This operation cannot be performed with a running slave, run SLAVE STOP first", +"This operation requires a running slave, configure slave and do SLAVE START", +"The server is not configured as slave, fix in config file or with CHANGE MASTER TO", +"Could not initialize master info structure, check permisions on master.info", +"Could not create slave thread, check system resources", diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt index 4d36544fedc..621cef7affa 100644 --- a/sql/share/german/errmsg.txt +++ b/sql/share/german/errmsg.txt @@ -202,3 +202,8 @@ "Table '%-.64s' is marked as crashed and last (automatic?) repair failed", "Warning: Some non-transactional changed tables couldn't be rolled back", "Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again', +"This operation cannot be performed with a running slave, run SLAVE STOP first", +"This operation requires a running slave, configure slave and do SLAVE START", +"The server is not configured as slave, fix in config file or with CHANGE MASTER TO", +"Could not initialize master info structure, check permisions on master.info", +"Could not create slave thread, check system resources", diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt index eb43678ddcf..0be996a0e8a 100644 --- a/sql/share/greek/errmsg.txt +++ b/sql/share/greek/errmsg.txt @@ -199,3 +199,8 @@ "Table '%-.64s' is marked as crashed and last (automatic?) repair failed", "Warning: Some non-transactional changed tables couldn't be rolled back", "Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again', +"This operation cannot be performed with a running slave, run SLAVE STOP first", +"This operation requires a running slave, configure slave and do SLAVE START", +"The server is not configured as slave, fix in config file or with CHANGE MASTER TO", +"Could not initialize master info structure, check permisions on master.info", +"Could not create slave thread, check system resources", diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt index eacc8a967a9..20e1af723fa 100644 --- a/sql/share/hungarian/errmsg.txt +++ b/sql/share/hungarian/errmsg.txt @@ -201,3 +201,8 @@ "Table '%-.64s' is marked as crashed and last (automatic?) repair failed", "Warning: Some non-transactional changed tables couldn't be rolled back", "Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again', +"This operation cannot be performed with a running slave, run SLAVE STOP first", +"This operation requires a running slave, configure slave and do SLAVE START", +"The server is not configured as slave, fix in config file or with CHANGE MASTER TO", +"Could not initialize master info structure, check permisions on master.info", +"Could not create slave thread, check system resources", diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt index f5e333696cf..699ab815e2a 100644 --- a/sql/share/italian/errmsg.txt +++ b/sql/share/italian/errmsg.txt @@ -199,3 +199,8 @@ "La tabella '%-.64s' e' segnalata come rovinata e l'ultima ricostruzione (automatica?) e' fallita", "Warning: Some non-transactional changed tables couldn't be rolled back", "Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again', +"This operation cannot be performed with a running slave, run SLAVE STOP first", +"This operation requires a running slave, configure slave and do SLAVE START", +"The server is not configured as slave, fix in config file or with CHANGE MASTER TO", +"Could not initialize master info structure, check permisions on master.info", +"Could not create slave thread, check system resources", diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt index 4b7a3fd30e1..04b411239ae 100644 --- a/sql/share/japanese/errmsg.txt +++ b/sql/share/japanese/errmsg.txt @@ -201,3 +201,8 @@ "Table '%-.64s' is marked as crashed and last (automatic?) repair failed", "Warning: Some non-transactional changed tables couldn't be rolled back", "Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again', +"This operation cannot be performed with a running slave, run SLAVE STOP first", +"This operation requires a running slave, configure slave and do SLAVE START", +"The server is not configured as slave, fix in config file or with CHANGE MASTER TO", +"Could not initialize master info structure, check permisions on master.info", +"Could not create slave thread, check system resources", diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt index d772f8c46d5..e1efb0c15ae 100644 --- a/sql/share/korean/errmsg.txt +++ b/sql/share/korean/errmsg.txt @@ -199,3 +199,8 @@ "Table '%-.64s' is marked as crashed and last (automatic?) repair failed", "Warning: Some non-transactional changed tables couldn't be rolled back", "Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again', +"This operation cannot be performed with a running slave, run SLAVE STOP first", +"This operation requires a running slave, configure slave and do SLAVE START", +"The server is not configured as slave, fix in config file or with CHANGE MASTER TO", +"Could not initialize master info structure, check permisions on master.info", +"Could not create slave thread, check system resources", diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt index d6c29026c0b..5484b58425e 100644 --- a/sql/share/norwegian-ny/errmsg.txt +++ b/sql/share/norwegian-ny/errmsg.txt @@ -201,3 +201,8 @@ "Table '%-.64s' is marked as crashed and last (automatic?) repair failed", "Warning: Some non-transactional changed tables couldn't be rolled back", "Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again', +"This operation cannot be performed with a running slave, run SLAVE STOP first", +"This operation requires a running slave, configure slave and do SLAVE START", +"The server is not configured as slave, fix in config file or with CHANGE MASTER TO", +"Could not initialize master info structure, check permisions on master.info", +"Could not create slave thread, check system resources", diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt index 4d0c1ef87f0..4db4af5457f 100644 --- a/sql/share/norwegian/errmsg.txt +++ b/sql/share/norwegian/errmsg.txt @@ -201,3 +201,8 @@ "Table '%-.64s' is marked as crashed and last (automatic?) repair failed", "Warning: Some non-transactional changed tables couldn't be rolled back", "Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again', +"This operation cannot be performed with a running slave, run SLAVE STOP first", +"This operation requires a running slave, configure slave and do SLAVE START", +"The server is not configured as slave, fix in config file or with CHANGE MASTER TO", +"Could not initialize master info structure, check permisions on master.info", +"Could not create slave thread, check system resources", diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt index a77f64b8b37..5e90cf05b8e 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -203,3 +203,8 @@ "Table '%-.64s' is marked as crashed and last (automatic?) repair failed", "Warning: Some non-transactional changed tables couldn't be rolled back", "Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again', +"This operation cannot be performed with a running slave, run SLAVE STOP first", +"This operation requires a running slave, configure slave and do SLAVE START", +"The server is not configured as slave, fix in config file or with CHANGE MASTER TO", +"Could not initialize master info structure, check permisions on master.info", +"Could not create slave thread, check system resources", diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index 946a64df5d0..1cd257e9ab1 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -199,3 +199,8 @@ "Table '%-.64s' is marked as crashed and last (automatic?) repair failed", "Warning: Some non-transactional changed tables couldn't be rolled back", "Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again', +"This operation cannot be performed with a running slave, run SLAVE STOP first", +"This operation requires a running slave, configure slave and do SLAVE START", +"The server is not configured as slave, fix in config file or with CHANGE MASTER TO", +"Could not initialize master info structure, check permisions on master.info", +"Could not create slave thread, check system resources", diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt index 7c325b9c662..cc453ff4dfc 100644 --- a/sql/share/romanian/errmsg.txt +++ b/sql/share/romanian/errmsg.txt @@ -203,3 +203,8 @@ "Table '%-.64s' is marked as crashed and last (automatic?) repair failed", "Warning: Some non-transactional changed tables couldn't be rolled back", "Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again', +"This operation cannot be performed with a running slave, run SLAVE STOP first", +"This operation requires a running slave, configure slave and do SLAVE START", +"The server is not configured as slave, fix in config file or with CHANGE MASTER TO", +"Could not initialize master info structure, check permisions on master.info", +"Could not create slave thread, check system resources", diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt index 7a83573e0ff..d3564e5ef5b 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -179,7 +179,7 @@ "òÅÚÕÌØÔÁÔ ÓÏÄÅÒÖÉÔ ÂÏÌØÛÅ ÏÄÎÏÊ ÓÔÒÏËÉ", "ôÁÂÌÉÃÁ ÜÔÏÇÏ ÔÉÐÁ ÏÂÑÚÁÎÁ ÉÍÅÔØ PRIMARY KEY", "üÔÁ ËÏÐÉÑ MySQL ÓËÏÍÐÉÌÉÒÏ×ÁÎÁ ÂÅÚ ÐÏÄÄÅÒÖËÉ RAID", -"You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column", +"MySQL ÒÁÂÏÔÁÅÔ × ÒÅÖÉÍÅ ÚÁÝÉÔÙ ÏÔ ÄÕÒÁËÏ× (safe_mode) - ÎÅ ÍÏÇÕ UPDATE ÂÅÚ WHERE Ó ËÁËÉÍ-ÎÅÂÕÄØ KEY", "éÎÄÅËÓ '%-.64s' ÎÅ ÎÁÊÄÅÎ × ÔÁÂÌÉÃÅ '%-.64s'", "îÅ ÍÏÇÕ ÏÔËÒÙÔØ ÔÁÂÌÉÃÕ", "äÁÎÎÙÊ ÔÉÐ ÔÁÂÌÉà ÎÅ ÐÏÄÄÅÒÖÉ×ÁÅÔ check/repair", @@ -190,15 +190,20 @@ "ïÛÉÂËÁ %d ×Ï ×ÒÅÍÑ CHECKPOINT", "ðÒÅÒ×ÁÎÎÏÅ ÓÏÅÄÉÎÅÎÉÅ %ld Ë ÂÁÚÅ ÄÁÎÎÙÈ: '%-.64s' ÐÏÌØÚÏ×ÁÔÅÌØ: '%-.32s' ÈÏÓÔ: `%-.64s' (%-.64s)", "üÔÏÔ ÔÉÐ ÔÁÂÌÉà ÎÅ ÐÏÄÄÅÒÖÉ×ÁÅÔ binary table dump", -"Binlog closed while trying to FLUSH MASTER", -"Failed rebuilding the index of dumped table '%-.64s'", -"Error from master: '%-.64s'", -"Net error reading from master", -"Net error writing to master", +"òÅÐÌÉËÁÃÉÏÎÎÙÊ ÌÏÇ ÚÁËÒÙÔ, ÎÅ ÍÏÇÕ ÓÄÅÌÁÔØ RESET MASTER", +"ïÛÉÂËÁ ÐÒÉ ×ÏÓÓÔÁÎÏ×ÌÅÎÉÉ ÉÎÄÅËÓÁ ÐÅÒÅËÁÞÁÎÎÏÊ ÔÁÂÌÉÃÙ '%-.64s'", +"ïÛÉÂËÁ ÎÁ ÍÁÓÔÅÒÅ: '%-.64s'", +"óÅÔÅ×ÁÑ ÏÛÉÂËÁ ÐÒÉ ÞÔÅÎÉÉ Ó ÍÁÓÔÅÒÁ", +"óÅÔÅ×ÁÑ ÏÛÉÂËÁ ÐÒÉ ÐÉÓÁÎÉÉ ÍÁÓÔÅÒÕ", "FULLTEXT ÉÎÄÅËÓ, ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÉÊ ÚÁÄÁÎÎÏÍÕ ÓÐÉÓËÕ ÓÔÏÌÂÃÏ×, ÎÅ ÎÁÊÄÅÎ", -"Can't execute the given command because you have active locked tables or an active transaction", +"îÅ ÍÏÇÕ ×ÙÐÏÌÎÉÔØ ËÏÍÍÁÎÄÕ ÉÚ-ÚÁ ÁËÔÉ×ÎÙÈ locked ÔÁÂÌÉà ÉÌÉ ÁËÔÉ×ÎÏÊ ÔÒÁÎÚÁËÃÉÉ", "îÅÉÚ×ÅÓÔÎÁÑ ÓÉÓÔÅÍÎÁÑ ÐÅÒÅÍÅÎÎÁÑ '%-.64'", "ôÁÂÌÉÃÁ '%-.64s' ÐÏÍÅÞÅÎÁ ËÁË ÉÓÐÏÒÞÅÎÎÁÑ É ÄÏÌÖÎÁ ÂÙÔØ ÉÓÐÒÁ×ÌÅÎÁ", "ôÁÂÌÉÃÁ '%-.64s' ÐÏÍÅÞÅÎÁ ËÁË ÉÓÐÏÒÞÅÎÎÁÑ É ÐÏÓÌÅÄÎÑÑ ÐÏÐÙÔËÁ ÉÓÐÒÁ×ÌÅÎÉÑ (Á×ÔÏÍÁÔÉÞÅÓËÁÑ?) ÎÅ ÕÄÁÌÁÓØ", -"Warning: Some non-transactional changed tables couldn't be rolled back", -"Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again', +"ðÒÅÄÕÐÒÅÖÄÅÎÉÅ: ÎÅËÏÔÏÒÙÅ ÎÅÔÒÁÎÚÁËÃÉÏÎÎÙÅ ÔÁÂÌÉÃÙ ÎÅ ÐÏÄÞÉÎÑÀÔÓÑ ROLLBACK", +"íÎÏÇÏÚÁÐÒÏÓÎÁÑ ÔÒÁÎÚÁËÃÉÑ ÔÒÅÂÕÅÔ Õ×ÅÌÉÞÅÎÉÑ 'max_binlog_cache_size' - Õ×ÅÌÉÞÔÅ ÜÔÕ ÐÅÒÅÍÅÎÎÕÀ É ÐÏÐÒÏÂÕÊÔÅ ÅÝÅ ÒÁÚ", +"üÔÁ ÏÐÅÒÁÃÉÑ ÎÅ×ÏÚÍÏÖÎÁ Ó ÁËÔÉ×ÎÙÍ slave, ÎÁÄÏ SLAVE STOP", +"üÔÁ ÏÐÅÒÁÃÉÑ ÎÅ×ÏÚÍÏÖÎÁ Ó ÐÁÓÓÉ×ÎÙÍ slave, ÎÁÄÏ SLAVE START", +"üÔÏÔ ÓÅÒ×ÅÒ ÎÅ slave, ÉÓÐÒÁ×ØÔÅ × ËÏÎÆÉÇÕÒÁÃÉÏÎÎÏÍ ÆÁÊÌÅ ÉÌÉ ËÏÍÍÁÎÄÏÊ CHANGE MASTER TO", +"îÅ ÐÏÌÕÞÉÌÏÓØ ÉÎÉÃÉÁÌÉÚÉÒÏ×ÁÔØ ÓÔÒÕËÔÕÒÕ master info, ÐÒÏ×ÅÒÔÅ persmissions ÎÁ ÆÁÊÌÅ master.info", +"îÅ ÍÏÇÕ ÓÏÚÄÁÔØ ÐÒÏÃÅÓÓ SLAVE, ÐÒÏ×ÅÒØÔÅ ÓÉÓÔÅÍÎÙÅ ÒÅÓÕÒÓÙ", diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt index 774047be656..47d51506019 100644 --- a/sql/share/slovak/errmsg.txt +++ b/sql/share/slovak/errmsg.txt @@ -207,3 +207,8 @@ "Table '%-.64s' is marked as crashed and last (automatic?) repair failed", "Warning: Some non-transactional changed tables couldn't be rolled back", "Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again', +"This operation cannot be performed with a running slave, run SLAVE STOP first", +"This operation requires a running slave, configure slave and do SLAVE START", +"The server is not configured as slave, fix in config file or with CHANGE MASTER TO", +"Could not initialize master info structure, check permisions on master.info", +"Could not create slave thread, check system resources", diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index 0003e435183..6fc6451c0da 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -200,3 +200,8 @@ "Table '%-.64s' is marked as crashed and last (automatic?) repair failed", "Warning: Some non-transactional changed tables couldn't be rolled back", "Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again', +"This operation cannot be performed with a running slave, run SLAVE STOP first", +"This operation requires a running slave, configure slave and do SLAVE START", +"The server is not configured as slave, fix in config file or with CHANGE MASTER TO", +"Could not initialize master info structure, check permisions on master.info", +"Could not create slave thread, check system resources", diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt index ee3d913e51a..a47bdf7428e 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -199,3 +199,8 @@ "Tabell '%-.64s' är crashad och senast (automatiska?) reparation misslyckades", "Warning: Några icke transaktionella tabeller kunde inte återställas vid ROLLBACK", "Transaktionen krävde mera än 'max_binlog_cache_size' minne. Utöka denna mysqld variabel och försök på nytt", +"This operation cannot be performed with a running slave, run SLAVE STOP first", +"This operation requires a running slave, configure slave and do SLAVE START", +"The server is not configured as slave, fix in config file or with CHANGE MASTER TO", +"Could not initialize master info structure, check permisions on master.info", +"Could not create slave thread, check system resources", diff --git a/sql/slave.cc b/sql/slave.cc index 667440e4026..5a110b6921b 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -34,10 +34,13 @@ DYNAMIC_ARRAY replicate_wild_do_table, replicate_wild_ignore_table; bool do_table_inited = 0, ignore_table_inited = 0; bool wild_do_table_inited = 0, wild_ignore_table_inited = 0; bool table_rules_on = 0; - +uint32 slave_skip_counter = 0; +static TABLE* save_temporary_tables = 0; // when slave thread exits, we need to remember the temporary tables so we // can re-use them on slave start -static TABLE* save_temporary_tables = 0; + +static int last_slave_errno = 0; +static char last_slave_error[1024] = ""; #ifndef DBUG_OFF int disconnect_slave_event_count = 0, abort_slave_event_count = 0; static int events_till_disconnect = -1, events_till_abort = -1; @@ -45,8 +48,8 @@ static int stuck_count = 0; #endif -static inline void skip_load_data_infile(NET* net); -static inline bool slave_killed(THD* thd); +inline void skip_load_data_infile(NET* net); +inline bool slave_killed(THD* thd); static int init_slave_thread(THD* thd); static int safe_connect(THD* thd, MYSQL* mysql, MASTER_INFO* mi); static int safe_reconnect(THD* thd, MYSQL* mysql, MASTER_INFO* mi); @@ -54,7 +57,7 @@ static int safe_sleep(THD* thd, int sec); static int request_table_dump(MYSQL* mysql, char* db, char* table); static int create_table_from_dump(THD* thd, NET* net, const char* db, const char* table_name); -static inline char* rewrite_db(char* db); +inline char* rewrite_db(char* db); static void free_table_ent(TABLE_RULE_ENT* e) { my_free((gptr) e, MYF(0)); @@ -194,12 +197,12 @@ void end_slave() free_string_array(&replicate_wild_ignore_table); } -static inline bool slave_killed(THD* thd) +inline bool slave_killed(THD* thd) { return abort_slave || abort_loop || thd->killed; } -static inline void skip_load_data_infile(NET* net) +inline void skip_load_data_infile(NET* net) { (void)my_net_write(net, "\xfb/dev/null", 10); (void)net_flush(net); @@ -207,7 +210,7 @@ static inline void skip_load_data_infile(NET* net) send_ok(net); // the master expects it } -static inline char* rewrite_db(char* db) +inline char* rewrite_db(char* db) { if(replicate_rewrite_db.is_empty() || !db) return db; I_List_iterator<i_string_pair> it(replicate_rewrite_db); @@ -506,14 +509,14 @@ int init_master_info(MASTER_INFO* mi) return 1; } - if (!(length=my_b_gets(&mi->file, mi->log_file_name, - sizeof(mi->log_file_name)))) + if ((length=my_b_gets(&mi->file, mi->log_file_name, + sizeof(mi->log_file_name))) < 1) { msg="Error reading log file name from master info file "; goto error; } - mi->log_file_name[length]= 0; // kill \n + mi->log_file_name[length-1]= 0; // kill \n char buf[FN_REFLEN]; if(!my_b_gets(&mi->file, buf, sizeof(buf))) { @@ -570,6 +573,9 @@ int show_master_info(THD* thd) field_list.push_back(new Item_empty_string("Slave_Running", 3)); field_list.push_back(new Item_empty_string("Replicate_do_db", 20)); field_list.push_back(new Item_empty_string("Replicate_ignore_db", 20)); + field_list.push_back(new Item_empty_string("Last_errno", 4)); + field_list.push_back(new Item_empty_string("Last_error", 20)); + field_list.push_back(new Item_empty_string("Skip_counter", 12)); if(send_fields(thd, field_list, 1)) DBUG_RETURN(-1); @@ -589,6 +595,9 @@ int show_master_info(THD* thd) pthread_mutex_unlock(&LOCK_slave); net_store_data(packet, &replicate_do_db); net_store_data(packet, &replicate_ignore_db); + net_store_data(packet, (uint32)last_slave_errno); + net_store_data(packet, last_slave_error); + net_store_data(packet, slave_skip_counter); if (my_net_write(&thd->net, (char*)thd->packet.ptr(), packet->length())) DBUG_RETURN(-1); @@ -833,13 +842,14 @@ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len) if (ev) { int type_code = ev->get_type_code(); - if (ev->server_id == ::server_id) + if (ev->server_id == ::server_id || slave_skip_counter) { if(type_code == LOAD_EVENT) skip_load_data_infile(net); mi->inc_pos(event_len); flush_master_info(mi); + --slave_skip_counter; delete ev; return 0; // avoid infinite update loops } @@ -853,6 +863,7 @@ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len) { Query_log_event* qev = (Query_log_event*)ev; int q_len = qev->q_len; + int expected_error,actual_error = 0; init_sql_alloc(&thd->mem_root, 8192,0); thd->db = rewrite_db((char*)qev->db); if (db_ok(thd->db, replicate_do_db, replicate_ignore_db)) @@ -869,19 +880,22 @@ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len) thd->net.last_error[0] = 0; thd->slave_proxy_id = qev->thread_id; // for temp tables mysql_parse(thd, thd->query, q_len); - int expected_error,actual_error; if ((expected_error = qev->error_code) != (actual_error = thd->net.last_errno) && expected_error) { - sql_print_error("Slave: did not get the expected error\ - running query from master - expected: '%s', got '%s'", - ER(expected_error), - actual_error ? ER(actual_error):"no error" + const char* errmsg = "Slave: did not get the expected error\ + running query from master - expected: '%s', got '%s'"; + sql_print_error(errmsg, ER(expected_error), + actual_error ? thd->net.last_error:"no error" ); thd->query_error = 1; } else if (expected_error == actual_error) - thd->query_error = 0; + { + thd->query_error = 0; + *last_slave_error = 0; + last_slave_errno = 0; + } } thd->db = 0; // prevent db from being freed thd->query = 0; // just to be sure @@ -893,6 +907,13 @@ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len) { sql_print_error("Slave: error running query '%s' ", qev->query); + last_slave_errno = actual_error ? actual_error : -1; + my_snprintf(last_slave_error, sizeof(last_slave_error), + "error '%s' on query '%s'", + actual_error ? thd->net.last_error : + "unexpected success or fatal error", + qev->query + ); free_root(&thd->mem_root,0); delete ev; return 1; @@ -1034,9 +1055,12 @@ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len) break; case STOP_EVENT: - close_temporary_tables(thd); - mi->inc_pos(event_len); - flush_master_info(mi); + if(mi->pos > 4) // stop event should be ignored after rotate event + { + close_temporary_tables(thd); + mi->inc_pos(event_len); + flush_master_info(mi); + } delete ev; break; case ROTATE_EVENT: diff --git a/sql/slave.h b/sql/slave.h index b7e2d783749..11c01a9fa03 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -93,6 +93,11 @@ extern bool opt_log_slave_updates ; pthread_handler_decl(handle_slave,arg); extern bool volatile abort_loop, abort_slave; extern bool slave_running; +extern uint32 slave_skip_counter; +// needed for problems when slave stops and +// we want to restart it skipping one or more events in the master log that +// have caused errors, and have been manually applied by DBA already + extern pthread_t slave_real_id; extern MASTER_INFO glob_mi; extern HASH replicate_do_table, replicate_ignore_table; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 2317c896dfd..0f3ee483400 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1287,7 +1287,7 @@ static GRANT_TABLE *table_hash_search(const char *host,const char* ip, -static inline GRANT_COLUMN * +inline GRANT_COLUMN * column_hash_search(GRANT_TABLE *t, const char *cname, uint length) { diff --git a/sql/sql_analyse.h b/sql/sql_analyse.h index e1cab3d5949..ce5c0af6a96 100644 --- a/sql/sql_analyse.h +++ b/sql/sql_analyse.h @@ -88,6 +88,9 @@ public: }; +int collect_string(String *element, element_count count, + TREE_INFO *info); + class field_str :public field_info { String min_arg, max_arg; @@ -130,6 +133,9 @@ public: { return (String*) 0; } }; + +int collect_real(double *element, element_count count, TREE_INFO *info); + class field_real: public field_info { double min_arg, max_arg; @@ -174,6 +180,9 @@ public: { return (tree_walk_action) collect_real;} }; +int collect_longlong(longlong *element, element_count count, + TREE_INFO *info); + class field_longlong: public field_info { longlong min_arg, max_arg; @@ -216,6 +225,8 @@ public: { return (tree_walk_action) collect_longlong;} }; +int collect_ulonglong(ulonglong *element, element_count count, + TREE_INFO *info); class field_ulonglong: public field_info { @@ -261,6 +272,10 @@ public: }; +Procedure *proc_analyse_init(THD *thd, ORDER *param, + select_result *result, + List<Item> &field_list); + class analyse: public Procedure { protected: diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 28f509d3c81..d69bc905c31 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -187,7 +187,8 @@ query_table_status(THD *thd,const char *db,const char *table_name) ** Sum fields has table name empty and field_name. ** flag is a bit mask with the following functions: ** 1 send number of rows -** 2 send default values; Don't convert field names +** 2 send default values +** 4 Don't convert field names ******************************************************************************/ bool @@ -196,7 +197,7 @@ send_fields(THD *thd,List<Item> &list,uint flag) List_iterator<Item> it(list); Item *item; char buff[80]; - CONVERT *convert= (flag & 2) ? (CONVERT*) 0 : thd->convert_set; + CONVERT *convert= (flag & 4) ? (CONVERT*) 0 : thd->convert_set; String tmp((char*) buff,sizeof(buff)),*res,*packet= &thd->packet; @@ -1166,6 +1167,7 @@ bool wait_for_tables(THD *thd) /* Now we can open all tables without any interference */ thd->proc_info="Reopen tables"; result=reopen_tables(thd,0,0); + } pthread_mutex_unlock(&LOCK_open); thd->proc_info=0; diff --git a/sql/sql_class.h b/sql/sql_class.h index ef42eaf594c..cc5095397b6 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -102,6 +102,9 @@ public: /* character conversion tables */ +class CONVERT; +CONVERT *get_convert_set(const char *name_ptr); + class CONVERT { const uchar *from_map,*to_map; diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 89e7faa237c..25bbe75e944 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -35,7 +35,7 @@ void mysql_create_db(THD *thd, char *db, uint create_options) long result=1; DBUG_ENTER("mysql_create_db"); - if (!stripp_sp(db) || strlen(db) > NAME_LEN || check_db_name(db)) + if (!stripp_sp(db) || check_db_name(db)) { net_printf(&thd->net,ER_WRONG_DB_NAME, db); DBUG_VOID_RETURN; @@ -103,7 +103,7 @@ void mysql_rm_db(THD *thd,char *db,bool if_exists) MY_DIR *dirp; DBUG_ENTER("mysql_rm_db"); - if (!stripp_sp(db) || strlen(db) > NAME_LEN || check_db_name(db)) + if (!stripp_sp(db) || check_db_name(db)) { net_printf(&thd->net,ER_WRONG_DB_NAME, db); DBUG_VOID_RETURN; diff --git a/sql/sql_map.h b/sql/sql_map.h index e9093672fef..34f2f755b43 100644 --- a/sql/sql_map.h +++ b/sql/sql_map.h @@ -21,6 +21,10 @@ #pragma interface /* gcc class implementation */ #endif +class mapped_files; +mapped_files *map_file(const my_string name,byte *magic,uint magic_length); +void unmap_file(mapped_files *map); + class mapped_files :public ilink { byte *map; ha_rows size; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index a43b10e9ad0..2926f59547f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -71,7 +71,7 @@ static void init_signals(void) } #endif -static inline bool end_active_trans(THD *thd) +inline bool end_active_trans(THD *thd) { int error=0; if (thd->options & (OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN)) @@ -496,7 +496,7 @@ end: } -static inline void free_items(THD *thd) +inline void free_items(THD *thd) { /* This works because items are allocated with sql_alloc() */ for (Item *item=thd->free_list ; item ; item=item->next) @@ -1886,6 +1886,13 @@ check_access(THD *thd,uint want_access,const char *db, uint *save_priv, if (db == any_db) return FALSE; // Allow select on anything + + if (strlen(db) > NAME_LEN || check_db_name(db)) + { + net_printf(&thd->net,ER_WRONG_DB_NAME, db); + return TRUE; + } + if (db && (!thd->db || strcmp(db,thd->db))) db_access=acl_get(thd->host, thd->ip, (char*) &thd->remote.sin_addr, thd->priv_user, db); /* purecov: inspected */ diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index f4564c025e0..7730706f0d0 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -26,8 +26,7 @@ extern const char* any_db; extern pthread_handler_decl(handle_slave,arg); -static int fake_rotate_event(NET* net, String* packet, - const char* log_file_name); + static int fake_rotate_event(NET* net, String* packet, char* log_file_name, const char**errmsg) @@ -237,7 +236,7 @@ binlog purge"; break; break; case LOG_INFO_MEM: errmsg = "Out of memory"; break; case LOG_INFO_FATAL: errmsg = "Fatal error during purge"; break; - case LOG_INFO_IN_USE: errmsg = "A purgable log is in use, will not purge"; + case LOG_INFO_IN_USE: errmsg = "A purgeable log is in use, will not purge"; break; default: errmsg = "Unknown error during purge"; break; @@ -392,7 +391,7 @@ sweepstakes if you report the bug"; thd->mysys_var->current_mutex = log_lock; thd->mysys_var->current_cond = &COND_binlog_update; const char* proc_info = thd->proc_info; - thd->proc_info = "Waiting for update"; + thd->proc_info = "Slave connection: waiting for binlog update"; pthread_mutex_unlock(&thd->mysys_var->mutex); bool read_packet = 0, fatal_error = 0; @@ -519,34 +518,34 @@ int start_slave(THD* thd , bool net_report) { if(!thd) thd = current_thd; NET* net = &thd->net; - const char* err = 0; + int slave_errno = 0; if (check_access(thd, PROCESS_ACL, any_db)) return 1; pthread_mutex_lock(&LOCK_slave); if(!slave_running) { if(init_master_info(&glob_mi)) - err = "Could not initialize master info"; + slave_errno = ER_MASTER_INFO; else if(server_id_supplied && *glob_mi.host) { pthread_t hThread; if(pthread_create(&hThread, &connection_attrib, handle_slave, 0)) { - err = "cannot create slave thread"; + slave_errno = ER_SLAVE_THREAD; } while(!slave_running) // slave might already be running by now pthread_cond_wait(&COND_slave_start, &LOCK_slave); } else - err = "Master host not set, or server id not configured"; + slave_errno = ER_BAD_SLAVE; } else - err = "Slave already running"; + slave_errno = ER_SLAVE_MUST_STOP; pthread_mutex_unlock(&LOCK_slave); - if(err) + if(slave_errno) { - if(net_report) send_error(net, 0, err); + if(net_report) send_error(net, slave_errno); return 1; } else if(net_report) @@ -559,8 +558,8 @@ int stop_slave(THD* thd, bool net_report ) { if(!thd) thd = current_thd; NET* net = &thd->net; - const char* err = 0; - + int slave_errno = 0; + if (check_access(thd, PROCESS_ACL, any_db)) return 1; @@ -576,14 +575,14 @@ int stop_slave(THD* thd, bool net_report ) pthread_cond_wait(&COND_slave_stopped, &LOCK_slave); } else - err = "Slave is not running"; + slave_errno = ER_SLAVE_NOT_RUNNING; pthread_mutex_unlock(&LOCK_slave); thd->proc_info = 0; - if(err) + if(slave_errno) { - if(net_report) send_error(net, 0, err); + if(net_report) send_error(net, slave_errno); return 1; } else if(net_report) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 2d8373ec067..a3288540562 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -30,6 +30,7 @@ #include <hash.h> #include <ft_global.h> #include <assert.h> +#include <my_bitmap.h> const char *join_type_str[]={ "UNKNOWN","system","const","eq_ref","ref", "MAYBE_REF","ALL","range","index","fulltext" }; @@ -268,7 +269,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds, join.first_record=join.sort_and_group=0; join.select_options=select_options; join.result=result; - count_field_types(&join.tmp_table_param,all_fields); + count_field_types(&join.tmp_table_param,all_fields,0); join.const_tables=0; join.having=0; join.group= group != 0; @@ -632,9 +633,14 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds, /* ** If we have different sort & group then we must sort the data by group ** and copy it to another tmp table + ** This code is also used if we are using distinct something + ** we haven't been able to store in the temporary table yet + ** like SEC_TO_TIME(SUM(...)). */ - if (group && (!test_if_subpart(group,order) || select_distinct)) + if (group && (!test_if_subpart(group,order) || select_distinct) || + (select_distinct && + join.tmp_table_param.using_indirect_summary_function)) { /* Must copy to another table */ TABLE *tmp_table2; DBUG_PRINT("info",("Creating group table")); @@ -644,11 +650,16 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds, if (make_simple_join(&join,tmp_table)) goto err; calc_group_buffer(&join,group); - count_field_types(&join.tmp_table_param,all_fields); + count_field_types(&join.tmp_table_param,all_fields, + select_distinct && !group); + join.tmp_table_param.hidden_field_count=(all_fields.elements- + fields.elements); /* group data to new table */ if (!(tmp_table2 = create_tmp_table(thd,&join.tmp_table_param,all_fields, - (ORDER*) 0, 0 , 1, 0, + (ORDER*) 0, + select_distinct && !group, + 1, 0, join.select_options))) goto err; /* purecov: inspected */ if (group) @@ -657,7 +668,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds, if (create_sort_index(join.join_tab,group,HA_POS_ERROR) || alloc_group_fields(&join,group)) { - free_tmp_table(thd,tmp_table2); /* purecov: inspected */ + free_tmp_table(thd,tmp_table2); /* purecov: inspected */ goto err; /* purecov: inspected */ } group=0; @@ -696,14 +707,14 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds, if (make_simple_join(&join,tmp_table)) goto err; calc_group_buffer(&join,group); - count_field_types(&join.tmp_table_param,all_fields); + count_field_types(&join.tmp_table_param,all_fields,0); } if (procedure) { if (procedure->change_columns(fields) || result->prepare(fields)) goto err; - count_field_types(&join.tmp_table_param,all_fields); + count_field_types(&join.tmp_table_param,all_fields,0); } if (join.group || join.tmp_table_param.sum_func_count || (procedure && (procedure->flags & PROC_GROUP))) @@ -3265,6 +3276,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, { TABLE *table; uint i,field_count,reclength,null_count,null_pack_length, + hidden_null_count, hidden_null_pack_length, hidden_field_count, blob_count,group_null_items; bool using_unique_constraint=0; char *tmpname,path[FN_REFLEN]; @@ -3276,14 +3288,28 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, KEY_PART_INFO *key_part_info; Item_result_field **copy_func; MI_COLUMNDEF *recinfo; + uint temp_pool_slot; + DBUG_ENTER("create_tmp_table"); DBUG_PRINT("enter",("distinct: %d save_sum_fields: %d allow_distinct_limit: %d group: %d", (int) distinct, (int) save_sum_fields, (int) allow_distinct_limit,test(group))); statistic_increment(created_tmp_tables, &LOCK_status); - sprintf(path,"%s%s%lx_%lx_%x",mysql_tmpdir,tmp_file_prefix,current_pid, - thd->thread_id, thd->tmp_table++); + + if(use_temp_pool) { + temp_pool_slot = bitmap_set_next(temp_pool, TEMP_POOL_SIZE); + if(temp_pool_slot != MY_BIT_NONE) // we got a slot + sprintf(path, "%s%s_%lx_%i", mysql_tmpdir, tmp_file_prefix, + current_pid, temp_pool_slot); + else // if we run out of slots in the pool, fall back to old behavior + sprintf(path,"%s%s%lx_%lx_%x",mysql_tmpdir,tmp_file_prefix,current_pid, + thd->thread_id, thd->tmp_table++); + } else { + sprintf(path,"%s%s%lx_%lx_%x",mysql_tmpdir,tmp_file_prefix,current_pid, + thd->thread_id, thd->tmp_table++); + }; + if (group) { if (!param->quick_group) @@ -3292,9 +3318,12 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, (*tmp->item)->marker=4; // Store null in key if (param->group_length >= MAX_BLOB_WIDTH) using_unique_constraint=1; + if (group) + distinct=0; // Can't use distinct } field_count=param->field_count+param->func_count+param->sum_func_count; + hidden_field_count=param->hidden_field_count; if (!my_multi_malloc(MYF(MY_WME), &table,sizeof(*table), ®_field,sizeof(Field*)*(field_count+1), @@ -3310,10 +3339,12 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, param->group_length : 0, NullS)) { + bitmap_clear_bit(temp_pool, TEMP_POOL_SIZE, temp_pool_slot); DBUG_RETURN(NULL); /* purecov: inspected */ } if (!(param->copy_field=copy=new Copy_field[field_count])) { + bitmap_clear_bit(temp_pool, TEMP_POOL_SIZE, temp_pool_slot); my_free((gptr) table,MYF(0)); /* purecov: inspected */ DBUG_RETURN(NULL); /* purecov: inspected */ } @@ -3333,10 +3364,13 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, table->map=1; table->tmp_table=1; table->db_low_byte_first=1; // True for HEAP and MyISAM + table->temp_pool_slot = temp_pool_slot; + - /* Calculate with type of fields we will need in heap table */ + /* Calculate which type of fields we will store in the temporary table */ - reclength=blob_count=null_count=group_null_items=0; + reclength=blob_count=null_count=hidden_null_count=group_null_items=0; + param->using_indirect_summary_function=0; List_iterator<Item> li(fields); Item *item; @@ -3344,8 +3378,17 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, while ((item=li++)) { Item::Type type=item->type(); - if (item->with_sum_func && type != Item::SUM_FUNC_ITEM || - item->const_item()) + if (item->with_sum_func && type != Item::SUM_FUNC_ITEM) + { + /* + Mark that the we have ignored an item that refers to a summary + function. We need to know this if someone is going to use + DISTINCT on the result. + */ + param->using_indirect_summary_function=1; + continue; + } + if (item->const_item()) // We don't have to store this continue; if (type == Item::SUM_FUNC_ITEM && !group && !save_sum_fields) { /* Can't calc group yet */ @@ -3396,6 +3439,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, } *(reg_field++) =new_field; } + if (!--hidden_field_count) + hidden_null_count=null_count; } field_count= (uint) (reg_field - table->field); @@ -3420,8 +3465,16 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, table->blob_fields=blob_count; if (blob_count == 0) - null_count++; // For delete link - reclength+=(null_pack_length=(null_count+7)/8); + { + /* We need to ensure that first byte is not 0 for the delete link */ + if (hidden_null_count) + hidden_null_count++; + else + null_count++; + } + hidden_null_pack_length=(hidden_null_count+7)/8; + null_pack_length=hidden_null_count+(null_count+7)/8; + reclength+=null_pack_length; if (!reclength) reclength=1; // Dummy select @@ -3449,6 +3502,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, bfill(null_flags,null_pack_length,255); // Set null fields } null_count= (blob_count == 0) ? 1 : 0; + hidden_field_count=param->hidden_field_count; for (i=0,reg_field=table->field; i < field_count; i++,reg_field++,recinfo++) { Field *field= *reg_field; @@ -3496,6 +3550,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, recinfo->type=FIELD_SKIPP_ENDSPACE; else recinfo->type=FIELD_NORMAL; + if (!--hidden_field_count) + null_count=(null_count+7) & ~7; // move to next byte } param->copy_field_count=(uint) (copy - param->copy_field); @@ -3559,11 +3615,17 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, } } - if (distinct && !group) + if (distinct) { - /* Create an unique key or an unique constraint over all columns */ - keyinfo->key_parts=field_count+ test(null_count); - if (distinct && allow_distinct_limit) + /* + Create an unique key or an unique constraint over all columns + that should be in the result. In the temporary table, there are + 'param->hidden_field_count' extra columns, whose null bits are stored + in the first 'hidden_null_pack_length' bytes of the row. + */ + null_pack_length-=hidden_null_pack_length; + keyinfo->key_parts=field_count+ test(null_pack_length); + if (allow_distinct_limit) { set_if_smaller(table->max_rows,thd->select_limit); param->end_write_records=thd->select_limit; @@ -3585,11 +3647,11 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, keyinfo->flags=HA_NOSAME; keyinfo->key_length=(uint16) reclength; keyinfo->name=(char*) "tmp"; - if (null_count) + if (null_pack_length) { key_part_info->null_bit=0; - key_part_info->offset=0; - key_part_info->length=(null_count+7)/8; + key_part_info->offset=hidden_null_pack_length; + key_part_info->length=null_pack_length; key_part_info->field=new Field_string((char*) table->record[0], (uint32) key_part_info->length, (uchar*) 0, @@ -3600,7 +3662,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, key_part_info->type= HA_KEYTYPE_BINARY; key_part_info++; } - for (i=0,reg_field=table->field; i < field_count; + for (i=param->hidden_field_count, reg_field=table->field + i ; + i < field_count; i++, reg_field++, key_part_info++) { key_part_info->null_bit=0; @@ -3626,7 +3689,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, DBUG_RETURN(table); err: - free_tmp_table(thd,table); /* purecov: inspected */ + free_tmp_table(thd,table); /* purecov: inspected */ + bitmap_clear_bit(temp_pool, TEMP_POOL_SIZE, temp_pool_slot); DBUG_RETURN(NULL); /* purecov: inspected */ } @@ -3773,6 +3837,9 @@ free_tmp_table(THD *thd, TABLE *entry) delete *ptr; my_free((gptr) entry->record[0],MYF(0)); free_io_cache(entry); + + bitmap_clear_bit(temp_pool, TEMP_POOL_SIZE, entry->temp_pool_slot); + my_free((gptr) entry,MYF(0)); thd->proc_info=save_proc_info; @@ -5917,13 +5984,14 @@ create_distinct_group(ORDER *order_list,List<Item> &fields) *****************************************************************************/ void -count_field_types(TMP_TABLE_PARAM *param, List<Item> &fields) +count_field_types(TMP_TABLE_PARAM *param, List<Item> &fields, + bool reset_with_sum_func) { List_iterator<Item> li(fields); Item *field; - param->field_count=param->sum_func_count= - param->func_count=0; + param->field_count=param->sum_func_count=param->func_count= + param->hidden_field_count=0; param->quick_group=1; while ((field=li++)) { @@ -5949,7 +6017,11 @@ count_field_types(TMP_TABLE_PARAM *param, List<Item> &fields) } } else + { param->func_count++; + if (reset_with_sum_func) + field->with_sum_func=0; + } } } diff --git a/sql/sql_select.h b/sql/sql_select.h index 8ac00dde4c5..2f7454e4059 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -124,10 +124,13 @@ class TMP_TABLE_PARAM { KEY *keyinfo; ha_rows end_write_records; uint copy_field_count,field_count,sum_func_count,func_count; + uint hidden_field_count; uint group_parts,group_length; uint quick_group; + bool using_indirect_summary_function; - TMP_TABLE_PARAM() :copy_field(0), group_parts(0), group_length(0) {} + TMP_TABLE_PARAM() :copy_field(0), group_parts(0), group_length(0) + {} ~TMP_TABLE_PARAM() { cleanup(); @@ -178,7 +181,8 @@ TABLE *create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, ORDER *group, bool distinct, bool save_sum_fields, bool allow_distinct_limit, uint select_options); void free_tmp_table(THD *thd, TABLE *entry); -void count_field_types(TMP_TABLE_PARAM *param, List<Item> &fields); +void count_field_types(TMP_TABLE_PARAM *param, List<Item> &fields, + bool reset_with_sum_func); bool setup_copy_fields(TMP_TABLE_PARAM *param,List<Item> &fields); void copy_fields(TMP_TABLE_PARAM *param); void copy_funcs(Item_result_field **func_ptr); diff --git a/sql/sql_string.h b/sql/sql_string.h index f327618ffdd..31dea9991cc 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -25,6 +25,13 @@ #define NOT_FIXED_DEC 31 #endif +class String; +int sortcmp(const String *a,const String *b); +int stringcmp(const String *a,const String *b); +String *copy_if_not_alloced(String *a,String *b,uint32 arg_length); +int wild_case_compare(String &match,String &wild,char escape); +int wild_compare(String &match,String &wild,char escape); + class String { char *Ptr; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 3e1a0eb9fa1..9e720558456 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -798,7 +798,6 @@ static int send_check_errmsg(THD* thd, TABLE_LIST* table, static int prepare_for_restore(THD* thd, TABLE_LIST* table) { - String *packet = &thd->packet; DBUG_ENTER("prepare_for_restore"); if (table->table) // do not overwrite existing tables on restore @@ -1444,10 +1443,13 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, thd->cuted_fields=0L; thd->proc_info="copy to tmp table"; next_insert_id=thd->next_insert_id; // Remember for loggin - error=copy_data_between_tables(table,new_table,create_list,handle_duplicates, - order, &copied,&deleted); + copied=deleted=0; + if (!new_table->is_view) + error=copy_data_between_tables(table,new_table,create_list, + handle_duplicates, + order, &copied, &deleted); thd->last_insert_id=next_insert_id; // Needed for correct log - thd->count_cuted_fields=0; /* Don`t calc cuted fields */ + thd->count_cuted_fields=0; // Don`t calc cuted fields new_table->time_stamp=save_time_stamp; if (table->tmp_table) @@ -1690,6 +1692,7 @@ copy_data_between_tables(TABLE *from,TABLE *to, found_count++; } end_read_record(&info); + free_io_cache(from); delete [] copy; uint tmp_error; if ((tmp_error=to->file->extra(HA_EXTRA_NO_CACHE))) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index dd1fb916bad..fa4edf23a5f 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -22,6 +22,7 @@ #define YYMAXDEPTH 3200 /* Because of 64K stack */ #define Lex current_lex #include "mysql_priv.h" +#include "slave.h" #include "sql_acl.h" #include "lex_symbol.h" #include <myisam.h> @@ -408,6 +409,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); %token SQL_AUTO_IS_NULL %token SQL_SAFE_UPDATES %token SQL_QUOTE_SHOW_CREATE +%token SQL_SLAVE_SKIP_COUNTER %left SET_VAR %left OR_OR_CONCAT OR @@ -2662,6 +2664,15 @@ option_value: if (item->fix_fields(current_thd,0) || item->update()) YYABORT; } + | SQL_SLAVE_SKIP_COUNTER equal ULONG_NUM + { + pthread_mutex_lock(&LOCK_slave); + if(slave_running) + send_error(¤t_thd->net, ER_SLAVE_MUST_STOP); + else + slave_skip_counter = $3; + pthread_mutex_unlock(&LOCK_slave); + } text_or_password: TEXT_STRING { $$=$1.str;} diff --git a/sql/table.cc b/sql/table.cc index 762c28b0fbf..8ee6ee02d68 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1033,6 +1033,7 @@ char *get_field(MEM_ROOT *mem, TABLE *table, uint fieldnr) bool check_db_name(const char *name) { + const char *start=end; while (*name) { #if defined(USE_MB) && defined(USE_MB_IDENT) @@ -1050,7 +1051,7 @@ bool check_db_name(const char *name) return 1; name++; } - return 0; + return (uint) (name - start) > NAME_LEN; } diff --git a/sql/table.h b/sql/table.h index 8121271b479..a3b361742c5 100644 --- a/sql/table.h +++ b/sql/table.h @@ -93,6 +93,7 @@ struct st_table { my_bool locked_by_flush; my_bool locked_by_name; my_bool crashed; + my_bool is_view; Field *next_number_field, /* Set if next_number is activated */ *found_next_number_field, /* Set on open */ *rowid_field; @@ -119,6 +120,8 @@ struct st_table { key_part_map const_key_parts[MAX_KEY]; ulong query_id; + uint temp_pool_slot; + THD *in_use; /* Which thread uses this */ struct st_table *next,*prev; }; diff --git a/strings/longlong2str-x86.s b/strings/longlong2str-x86.s index 8ce711f812e..bafc485f759 100644 --- a/strings/longlong2str-x86.s +++ b/strings/longlong2str-x86.s @@ -14,8 +14,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Optimized longlong2str function for Intel 80x86 (gcc/gas syntax) */ -/* Some set sequences are optimized for pentuimpro II */ +# Optimized longlong2str function for Intel 80x86 (gcc/gas syntax) +# Some set sequences are optimized for pentuimpro II .file "longlong2str.s" .version "1.01" @@ -32,90 +32,90 @@ longlong2str: pushl %esi pushl %edi pushl %ebx - movl 100(%esp),%esi /* Lower part of val */ - movl 104(%esp),%ebp /* Higher part of val */ - movl 108(%esp),%edi /* get dst */ - movl 112(%esp),%ebx /* Radix */ + movl 100(%esp),%esi # Lower part of val + movl 104(%esp),%ebp # Higher part of val + movl 108(%esp),%edi # get dst + movl 112(%esp),%ebx # Radix movl %ebx,%eax testl %eax,%eax jge .L144 addl $36,%eax cmpl $34,%eax - ja .Lerror /* Wrong radix */ + ja .Lerror # Wrong radix testl %ebp,%ebp jge .L146 - movb $45,(%edi) /* Add sign */ - incl %edi /* Change sign of val */ + movb $45,(%edi) # Add sign + incl %edi # Change sign of val negl %esi adcl $0,%ebp negl %ebp .L146: - negl %ebx /* Change radix to positive */ + negl %ebx # Change radix to positive jmp .L148 - .p2align 4,,7 + .align 4 .L144: addl $-2,%eax cmpl $34,%eax - ja .Lerror /* Radix in range */ + ja .Lerror # Radix in range .L148: - movl %esi,%eax /* Test if zero (for easy loop) */ + movl %esi,%eax # Test if zero (for easy loop) orl %ebp,%eax jne .L150 movb $48,(%edi) incl %edi jmp .L164 - .p2align 4,,7 + .align 4 .L150: - leal 92(%esp),%ecx /* End of buffer */ + leal 92(%esp),%ecx # End of buffer jmp .L155 - .p2align 4,,7 + .align 4 .L153: - /* val is stored in in ebp:esi */ + # val is stored in in ebp:esi - movl %ebp,%eax /* High part of value */ + movl %ebp,%eax # High part of value xorl %edx,%edx divl %ebx movl %eax,%ebp movl %esi,%eax divl %ebx - movl %eax,%esi /* quotent in ebp:esi */ - movb _dig_vec(%edx),%al /* al is faster than dl */ + movl %eax,%esi # quotent in ebp:esi + movb _dig_vec(%edx),%al # al is faster than dl decl %ecx - movb %al,(%ecx) /* store value in buff */ - .p2align 4,,7 + movb %al,(%ecx) # store value in buff + .align 4 .L155: testl %ebp,%ebp ja .L153 - testl %esi,%esi /* rest value */ + testl %esi,%esi # rest value jl .L153 - je .L160 /* Ready */ + je .L160 # Ready movl %esi,%eax movl $_dig_vec,%ebp - .p2align 4,,7 + .align 4 -.L154: /* Do rest with integer precision */ +.L154: # Do rest with integer precision cltd divl %ebx decl %ecx - movb (%edx,%ebp),%dl /* bh is always zero as ebx=radix < 36 */ + movb (%edx,%ebp),%dl # bh is always zero as ebx=radix < 36 testl %eax,%eax movb %dl,(%ecx) jne .L154 .L160: movl %ecx,%esi - leal 92(%esp),%ecx /* End of buffer */ + leal 92(%esp),%ecx # End of buffer subl %esi,%ecx rep movsb .L164: - movl %edi,%eax /* Pointer to end null */ - movb $0,(%edi) /* Store the end null */ + movl %edi,%eax # Pointer to end null + movb $0,(%edi) # Store the end null .L165: popl %ebx @@ -126,7 +126,7 @@ longlong2str: ret .Lerror: - xorl %eax,%eax /* Wrong radix */ + xorl %eax,%eax # Wrong radix jmp .L165 .Lfe3: |