Implemented the server infrastructure for the fix:
1. Added a function LEX_STRING *thd_query_string(THD) to return
a LEX_STRING structure instead of char *.
This is the function that must be called in innodb instead of
thd_query()
2. Did some encapsulation in THD : aggregated thd_query and
thd_query_length into a LEX_STRING and made accessor and mutator
methods for easy code updating.
3. Updated the server code to use the new methods where applicable.
low myisam_sort_buffer_size
Repair by sort (default) or parallel repair of a MyISAM table
(doesn't matter partitioned or not) as well as bulk inserts
and enable indexes some times didn't failover to repair with
key cache.
The problem was that after unsuccessful attempt, data file was
closed. Whereas repair with key cache requires open data file.
Fixed by reopening data file.
Also fixed a valgrind warning, which may appear during repair
by sort or parallel repair with certain myisam_sort_buffer_size
number of rows and length of an index entry (very dependent).
mysql-test/r/myisam.result:
A test case for BUG#47073.
mysql-test/t/myisam.test:
A test case for BUG#47073.
storage/myisam/ha_myisam.cc:
Reverted fix for BUG25289. Not needed anymore.
storage/myisam/mi_check.c:
Reopen data file, when repair by sort or parallel repair
fails.
When repair by sort is requested to rebuild data file, data file
gets rebuilt while fixing first index. When rebuild is completed,
info->dfile is pointing to temporary data file, original data file
is closed.
It may happen that repair has successfully fixed first index and
rebuilt data file, but failed to fix second index. E.g.
myisam_sort_buffer_size was big enough to fix first shorter index,
but not enough to fix subsequent longer index.
In this case we end up with info->dfile pointing to temporary file,
which is removed and info->dfile is set to -1.
Though repair by sort failed, the upper layer may still want to
try repair with key cache. But it needs info->dfile pointing to
valid data file.
storage/myisam/sort.c:
When performing a copy of IO_CACHE structure, current_pos and
current_end must be updated separatly to point to memory we're
copying to (not to memory we're copying from).
As t_file2 is always WRITE cache, proper members are write_pos
and write_end accordingly.
2677 Vladislav Vaintroub 2008-11-04
CMakeLists.txt files cleanup
- remove SAFEMALLOC and SAFE_MUTEX definitions that were
present in *each* CMakeLists.txt. Instead, put them into top level
CMakeLists.txt, but disable on Windows, because
a) SAFEMALLOC does not add any functionality that is not already
present in Debug C runtime ( and 2 safe malloc one on top of the other
only unnecessarily slows down the server)
b)SAFE_MUTEX does not work on Windows and have been
explicitely disabled on Windows with #undef previously. Fortunately,
ntdll does pretty good job identifying l problems with
CRITICAL_SECTIONs.
DebugBreak()s on using uninited critical section, unlocking unowned
critical section)
-Also, remove occationally used -D_DEBUG (added by compiler
anyway)
sql/udf_example.c:
use unixish end of line
http://lists.mysql.com/commits/57725
Vladislav Vaintroub 2008-11-03
Cleanup CMakeLists.txt(s) - remove winsock2 (ws2_32) from
TARGET_LINK_LIBRARIES.
Every exe or dll linked with mysys needs ws2_32, because
mysys uses winsock function WSAStartup in my_init().
However, there is no need to explicitely add ws2_32 to
the list of TARGET_LINK_LIBRARIES multiple times.
Visual Studio comes with a handy pragma that tells linker
to add library. So patch replaces bunch of ws2_32 in
CMakeLists with single pragma comment(lib,"ws2_32")
in my_init.c
Additionally, reference to non-existing "debug" library
has been removed from TARGET_LINK_LIBRARIES. The correct
name of the library is "dbug".
Backport from 6.0 to 5.1.
Only those sync points are included, which are used in debug_sync.test.
The Debug Sync Facility allows to place synchronization points
in the code:
open_tables(...)
DEBUG_SYNC(thd, "after_open_tables");
lock_tables(...)
When activated, a sync point can
- Send a signal and/or
- Wait for a signal
Nomenclature:
- signal: A value of a global variable that persists
until overwritten by a new signal. The global
variable can also be seen as a "signal post"
or "flag mast". Then the signal is what is
attached to the "signal post" or "flag mast".
- send a signal: Assign the value (the signal) to the global
variable ("set a flag") and broadcast a
global condition to wake those waiting for
a signal.
- wait for a signal: Loop over waiting for the global condition until
the global value matches the wait-for signal.
Please find more information in the top comment in debug_sync.cc
or in the worklog entry.
.bzrignore:
WL#4259 - Debug Sync Facility
Added the symbolic link libmysqld/debug_sync.cc.
CMakeLists.txt:
WL#4259 - Debug Sync Facility
Added definition for ENABLED_DEBUG_SYNC.
configure.in:
WL#4259 - Debug Sync Facility
Added definition for ENABLED_DEBUG_SYNC.
include/my_sys.h:
WL#4259 - Debug Sync Facility
Added definition for the DEBUG_SYNC_C macro.
libmysqld/CMakeLists.txt:
WL#4259 - Debug Sync Facility
Added sql/debug_sync.cc.
libmysqld/Makefile.am:
WL#4259 - Debug Sync Facility
Added sql/debug_sync.cc.
mysql-test/include/have_debug_sync.inc:
WL#4259 - Debug Sync Facility
New include file.
mysql-test/mysql-test-run.pl:
WL#4259 - Debug Sync Facility
Added option --debug_sync_timeout.
mysql-test/r/debug_sync.result:
WL#4259 - Debug Sync Facility
New test result.
mysql-test/r/have_debug_sync.require:
WL#4259 - Debug Sync Facility
New require file.
mysql-test/t/debug_sync.test:
WL#4259 - Debug Sync Facility
New test file.
mysys/my_static.c:
WL#4259 - Debug Sync Facility
Added definition for debug_sync_C_callback_ptr.
mysys/thr_lock.c:
WL#4259 - Debug Sync Facility
Added sync point "wait_for_lock".
sql/CMakeLists.txt:
WL#4259 - Debug Sync Facility
Added debug_sync.cc and debug_sync.h.
sql/Makefile.am:
WL#4259 - Debug Sync Facility
Added debug_sync.cc and debug_sync.h.
sql/debug_sync.cc:
WL#4259 - Debug Sync Facility
New source file.
sql/debug_sync.h:
WL#4259 - Debug Sync Facility
New header file.
sql/mysqld.cc:
WL#4259 - Debug Sync Facility
Added opt_debug_sync_timeout.
Added calls to debug_sync_init() and debug_sync_end().
Fixed a purecov comment (unrelated).
sql/set_var.cc:
WL#4259 - Debug Sync Facility
Added server variable "debug_sync".
sql/set_var.h:
WL#4259 - Debug Sync Facility
Added declaration for server variable "debug_sync".
sql/share/errmsg.txt:
WL#4259 - Debug Sync Facility
Added error messages ER_DEBUG_SYNC_TIMEOUT and ER_DEBUG_SYNC_HIT_LIMIT.
sql/sql_base.cc:
WL#4259 - Debug Sync Facility
Added sync points "after_flush_unlock" and "before_lock_tables_takes_lock".
sql/sql_class.cc:
WL#4259 - Debug Sync Facility
Added initialization for debug_sync_control to THD::THD.
Added calls to debug_sync_init_thread() and debug_sync_end_thread().
sql/sql_class.h:
WL#4259 - Debug Sync Facility
Added element debug_sync_control to THD.
storage/myisam/myisamchk.c:
Fixed a typo in an error message string (unrelated).
Bug#24509 - 2048 file descriptor limit on windows needs increasing, also
WL#3049 - improved Windows I/O
The patch replaces the use of the POSIX I/O interfaces in mysys on Windows with
the Win32 API calls (CreateFile, WriteFile, etc). The Windows HANDLE for the open
file is stored in the my_file_info struct, along with a flag for append mode
because the Windows API does not support opening files in append mode in all cases)
The default max open files has been increased to 16384 and can be increased further
by setting --max-open-files=<value> during the server start.
Another major change in this patch that almost all Windows specific file IO code
has been moved to a new file my_winfile.c, greatly reducing the amount of code
in #ifdef blocks within mysys, thus improving readability.
Minor enhancements:
- my_(f)stat() is changed to use __stati64 structure with 64 file size
and timestamps. It will return correct file size now (C runtime implementation
used to report outdated information)
- my_lock on Windows is prepared to handle additional timeout parameter
- after review : changed __WIN__ to _WIN32 in the new and changed code.
client/mysqlbinlog.cc:
fileno -> my_fileno
client/readline.cc:
fileno -> my_fileno
include/config-win.h:
Increase OS_FILE_LIMIT for Windows.
Remove O_SHARE - Windows does not support it. Its definition conflicts with
O_SHORT_LIVED, that has different semantics.
include/my_dir.h:
Use stat64 for stat() family of functions on Windows, because of 64 bit file size.
include/my_global.h:
Increased default value for open file limit to 16K
include/my_sys.h:
- my_file_info got new structure members - file handle and open flags
- 2 new Windows-only mysys functions : my_get_osfhandle and my_osmaperr,
modelled after Windows C runtime functions _get_osfhandle and _dosmaperr
libmysql/CMakeLists.txt:
new files my_winfile.c and my_winerr.c
mysql-test/suite/large_tests/r/lock_tables_big.result:
test for more then 2048 open file descriptors on Windows
mysql-test/suite/large_tests/t/lock_tables_big.test:
test for more then 2048 open file descriptors on Windows
mysys/CMakeLists.txt:
new files my_winfile.c and my_winerr.c
mysys/Makefile.am:
new files my_winfile.c and my_winerr.c
mysys/default_modify.c:
fileno -> my_fileno
mysys/my_chsize.c:
implementation of chsize on Windows now moved to my_winfile.c
mysys/my_create.c:
- my_sopen->my_win_open
- close open file before removing (won't generally work on Windows otherwise)
mysys/my_file.c:
On Windows, files returned by my_open will not start with 0, but 2048
(making it simple to detect incompatible mix of CRT and mysys io functions)
mysys/my_fopen.c:
fileno->my_win_fileno , fclose->my_win_fclose, fdopen->my_win_fdopen
Check for legal filename is done by my_win_[f]open functions
mysys/my_fstream.c:
fileno->my_fileno
mysys/my_lib.c:
Windows stat() functions are moved to my_winfile.c
mysys/my_lock.c:
Move Windows code under #ifdef to a separate function win_lock().
Add a parameter for lock wait timeout
mysys/my_mmap.c:
_get_osfhandle->my_get_osfhandle
mysys/my_open.c:
my_sopen->my_win_open (simpler interface)
mysys/my_pread.c:
moved most windows specific code to my_win_file.c
Use my_win_pread
mysys/my_quick.c:
Use my_win_read/my_win_write
mysys/my_read.c:
Moved most of windows specific code to my_win_file.c
Use my_win_read()
mysys/my_seek.c:
On Windows, use my_win_lseek() in my_seek()/my_tell()
Removed dead code (synchronization of lseeks)
Improved DBUG tracing (file position is ulonglong, not ulong)
mysys/my_static.c:
Removed array initialization. my_file_info_default is global variable
thus it is initialized with all zeros anyway
mysys/my_sync.c:
_commit->my_win_fsync
mysys/my_winerr.c:
New file my_winerr.c
Exports my_osmaperr modelled after undocumented C runtime
function _dosmaperr(). The problem with _dosmaperr() used previously is that
1) it is nowhere documented and thus code relying on it is not guaranteed to work
in subsequent releases on the C runtime
2) it is present only in static C runtime (mysqld does not link if compiled with
/MD)
mysys/my_winfile.c:
New file my_winfile.c
Implements ANSI/Posix file IO routines, when possible using native Windows IO, without
C runtime (C runtime dropped because of the 2048 file descriptor limit).
mysys/my_write.c:
write->my_win_write
mysys/mysys_priv.h:
Declaration of Windows Posix functions (private to mysys, shall not be visible
outside)
storage/innobase/handler/ha_innodb.cc:
mysys native Windows IO : correct innodb tmp file handling
mysql_tmpfile does not return valid CRT file descriptor, thus
it is not possible to dup() it. Instead, the native file handle has
to be duplicated and then converted to CRT descriptor.
storage/myisam/mi_locking.c:
_commit->my_sync
client/mysql.cc:
Remove leading whitespace.
Remove extra text after #else directive.
client/mysqldump.c:
Function does not take a parameter.
mysys/array.c:
buffer is a uchar pointer.
sql/item.cc:
Assert if it should not happen.
storage/myisam/mi_check.c:
Cast to expected type. This is probably a bug, but it is
casted in a similar way in another part of the code.
storage/ndb/include/mgmapi/ndb_logevent.h:
Apply fix from cluster team.
tests/mysql_client_test.c:
Remove extraneous slash.
INSERT ... SELECT ...
Problem was that when bulk insert is used on an empty
table/partition, it disables the indexes for better
performance, but in this specific case it also tries
to read from that partition using an index, which is
not possible since it has been disabled.
Solution was to allow index reads on disabled indexes
if there are no records.
Also reverted the patch for bug#38005, since that was a workaround
in the partitioning engine instead of a fix in myisam.
mysql-test/r/partition.result:
Bug#46639: 1030 (HY000): Got error 124 from storage engine on
INSERT ... SELECT ...
updated result file
mysql-test/t/partition.test:
Bug#46639: 1030 (HY000): Got error 124 from storage engine on
INSERT ... SELECT ...
Added testcase
sql/ha_partition.cc:
Bug#46639: 1030 (HY000): Got error 124 from storage engine on
INSERT ... SELECT ...
reverted the patch for bug#38005, since that was a workaround
around this problem, not needed after fixing it in myisam.
storage/myisam/mi_search.c:
Bug#46639: 1030 (HY000): Got error 124 from storage engine on
INSERT ... SELECT ...
Return HA_ERR_END_OF_FILE instead of HA_ERR_WRONG_INDEX
when there are no rows.
bzr branch mysql-5.1-performance-version mysql-trunk # Summit
cd mysql-trunk
bzr merge mysql-5.1-innodb_plugin # which is 5.1 + Innodb plugin
bzr rm innobase # remove the builtin
Next step: build, test fixes.
the auto_increment value
This is an alternative patch that instead of allowing RECREATE TABLE
on TRUNCATE TABLE it implements reset_auto_increment that is called
after delete_all_rows.
Note: this bug was fixed by Mattias Jonsson:
Pusing this patch: http://lists.mysql.com/commits/70370
mysql-test/suite/parts/r/partition_auto_increment_memory.result:
Bug#35111: Truncate a MyISAM partitioned table does not reset
the auto_increment value
mysql-test/suite/parts/r/partition_auto_increment_myisam.result:
Bug#35111: Truncate a MyISAM partitioned table does not reset
the auto_increment value
sql/ha_partition.cc:
Bug#35111: Truncate a MyISAM partitioned table does not reset
the auto_increment value
Added reset_auto_increment, to be used after delete_all_rows
to simulate truncate.
storage/heap/ha_heap.cc:
Bug#35111: Truncate a MyISAM partitioned table does not reset
the auto_increment value
Added reset_auto_increment, to be used after delete_all_rows
to simulate truncate
storage/heap/ha_heap.h:
Bug#35111: Truncate a MyISAM partitioned table does not reset
the auto_increment value
Added reset_auto_increment, to be used after delete_all_rows
to simulate truncate
storage/myisam/ha_myisam.cc:
Bug#35111: Truncate a MyISAM partitioned table does not reset
the auto_increment value
Added reset_auto_increment, to be used after delete_all_rows
to simulate truncate.
storage/myisam/ha_myisam.h:
Bug#35111: Truncate a MyISAM partitioned table does not reset
the auto_increment value
Added reset_auto_increment, to be used after delete_all_rows
to simulate truncate.
Remove custom DLL loader code from innodb plugin code, use
symbols exported from mysqld.
storage/innodb_plugin/handler/ha_innodb.cc:
Remove a Win32 workaround for current_thd.
The original problem that innodb plugin used
value of TLS variable across DLL boundaries is
solved in MySQL server (current_thd is a function
not TLS variable now)
storage/innodb_plugin/handler/handler0alter.cc:
Remove custom delay loader
storage/innodb_plugin/handler/handler0vars.h:
Remove custom delay loader
storage/innodb_plugin/handler/i_s.cc:
Remove custom delay loader
storage/innodb_plugin/handler/win_delay_loader.cc:
Remove custom delay loader
storage/innodb_plugin/plug.in:
Remove commented out MYSQL_PLUGIN_STATIC,
CMake would not parse that correctly
The fix is to allow myisamchk to use >4G key_buffer_size on win64
include/myisam.h:
use ulonglong instead of ulong for use_buffers
storage/myisam/myisamchk.c:
use ulonglong instead of ulong for use_buffers
This patch fixes compilation warning, "conversion from 'time_t' to 'ulong',
possible loss of data".
The fix is to typecast time_t to ulong before assigning it to ulong.
Backported this from 6.0-bugteam tree.
storage/archive/ha_archive.cc:
type casting time_t to ulong before assigning.
storage/federated/ha_federated.cc:
type casting time_t to ulong before assigning.
storage/innobase/handler/ha_innodb.cc:
type casting time_t to ulong before assigning.
storage/myisam/ha_myisam.cc:
type casting time_t to ulong before assigning.
This patch adds corrections to the original patch
submitted 2009-04-08 (http://lists.mysql.com/commits/71607):
- fixed that the original patch didn't work because of an
incorrect condition;
- added a test case.
mysql-test/r/upgrade.result:
Bug#37631 Incorrect key file for table after upgrading from 5.0 to 5.1
Result file for test case
mysql-test/std_data/bug37631.MYD:
Bug#37631 Incorrect key file for table after upgrading from 5.0 to 5.1
table created in mysql 4.0
mysql-test/std_data/bug37631.MYI:
Bug#37631 Incorrect key file for table after upgrading from 5.0 to 5.1
table created in mysql 4.0
mysql-test/std_data/bug37631.frm:
Bug#37631 Incorrect key file for table after upgrading from 5.0 to 5.1
table created in mysql 4.0
mysql-test/t/upgrade.test:
Bug#37631 Incorrect key file for table after upgrading from 5.0 to 5.1
Adds test for checking that upgrade works
on a table which is created by a mysql
server version <= 4.0.
storage/myisam/ha_myisam.cc:
Bug#37631 Incorrect key file for table after upgrading from 5.0 to 5.1
Fix the conformance checker to relax checking
for the correct version of the tables (for tables
created by mysql server version <= 4.0)
Killing the insert-select statement corrupts the MyISAM table only
when the destination table is empty and when it has indexes. When
we bulk insert huge data and if the destination table is empty we
disable the indexes for fast inserts, data is then inserted and
indexes are re-enabled after bulk_insert operation
Killing the query, aborts the repair table operation during enable
indexes phase leading to table corruption.
We now truncate the table when we detect that enable indexes is
killed for bulk insert query.As we have an empty table before the
operation, we can fix by truncating the table.
mysql-test/r/myisam.result:
Result file for BUG#40827
mysql-test/t/myisam.test:
Testcase for BUG#40827
storage/myisam/ha_myisam.cc:
Fixed end_bulk_insert() method to truncate the table when we detect enable
index operation is killed.
A bug in the initialization of key segment information made it point
to the wrong bit, since a bit index was used when its int value
was needed. This lead to misinterpretation of bit columns
read from MyISAM record format when a NULL bit pushed them over
a byte boundary.
Fixed by using the int value of the bit instead.
mysql-test/r/myisam.result:
Bug#43737: Test result.
mysql-test/t/myisam.test:
Bug#43737: Test case.
storage/myisam/mi_open.c:
Bug#43737: fix.
single quote fails in 5.1.x
Performing fulltext prefix search (a word with truncation
operator) may cause a dead-loop.
The problem was in smarter index merge algorithm - it was writing
record reference to an incorrect memory area.
mysql-test/r/fulltext.result:
A test case for BUG#42907.
mysql-test/t/fulltext.test:
A test case for BUG#42907.
storage/myisam/ft_boolean_search.c:
Fixed incorrect memory update by _mi_dpointer() when performing
fulltext prefix search.
Killing insert-select statement on MyISAM corrupts the table.
Killing the insert-select statement corrupts the MyISAM table only
when the destination table is empty and when it has indexes. When
we bulk insert huge data and if the destination table is empty we
disable the indexes for fast inserts, data is then inserted and
indexes are re-enabled after bulk_insert operation
Killing the query, aborts the repair table operation during enable
indexes phase leading to table corruption.
We now truncate the table when we detect that enable indexes is
killed for bulk insert query.As we have an empty table before the
operation, we can fix by truncating the table.
mysql-test/r/myisam.result:
Result file for BUG#40827
mysql-test/t/myisam.test:
Testcase for BUG#40827
storage/myisam/ha_myisam.cc:
Fixed end_bulk_insert() method to truncate the table when we detect enable
index operation is killed.
Currently the memory map is being created
with a size that is greater than the size
of the underlying datafile. This can cause
varying behaviour,
e.g.
In windows the size of the datafile
is increased, while on linux it remains
the same.
This fix removes the increment margin to
the size that is used while creating the
memory map.
storage/myisam/mi_dynrec.c:
remove MEMMAP_EXTRA_MARGIN that is used as
the increment margin to the underlying
datafile size while creating the mmap.
storage/myisam/mi_packrec.c:
The size of the underlying datafile is
increased by MEMMAP_EXTRA_MARGIN when
using a packed record format. Hence in
this case the size of the memory map should
be incremented by the same factor.
The conformance checker was not taking into
account, and, making concessions for acceptable
incompatibilites in tables created by
versions earlier than 4.1.
The current patch relaxes the conformance
checker to ignore differences in key_alg
and language for tables created by versions
earlier than 4.1.
storage/myisam/ha_myisam.cc:
Modify check_definition to ignore differences
in key_alg and language for tables created
by versions earlier than 4.1.