Commit 4a1763e4 authored by unknown's avatar unknown

Fix for Windows-specific bugs:

- one which led REDO_INSERT_ROW_BLOBS to fail to apply
- one excess close ("-1 file left open")
Don't need maria-path option / environment variable.
Fixes for ma_test_all-t to run under Windows.
Port of ma_test_recovery to Perl, written by Jani.


storage/maria/unittest/ma_test_recovery.expected:
  Rename: storage/maria/ma_test_recovery.expected -> storage/maria/unittest/ma_test_recovery.expected
mysys/my_pread.c:
  Fix for Windows-specific bug (maria_read_log -a failed during
  ma_test_all-t): Windows does not have pread() so the branch setting
  HA_ERR_FILE_TOO_SHORT was not compiled in, broke applying of
  REDO_INSERT_ROW_BLOBS. After fixing that, it appeared that in my
  Windows machine, errno is not changed in case of EOF; as we read it
  we have to reset it at start.
  The changed to readbytes!=-1 is to detect EOF
mysys/my_read.c:
  The change to readbytes!=-1 is to detect EOF
storage/maria/ma_loghandler.c:
  Fix for Windows-specific bug: as we don't open the directory
  we should not close it.
storage/maria/ma_page.c:
  This is C, cannot declare variable after instruction.
storage/maria/ma_test_recovery:
  ma_test_recovery.expected moved
storage/maria/unittest/ma_test_all-t:
  Can now safely guess maria_path so don't need the command-line option
  or environment variable. Port to Windows (.exe, different locations
  of executables); can guess suffix, don't need --suffix.
storage/maria/unittest/ma_test_recovery.pl:
  Perl version of ma_test_recovery, written by Jani. Will deprecate the
  shell version.
parent 16f92309
......@@ -47,7 +47,7 @@ size_t my_pread(File Filedes, uchar *Buffer, size_t Count, my_off_t offset,
myf MyFlags)
{
size_t readbytes;
int error= 0;
int error= 0, save_errno;
#ifndef DBUG_OFF
char llbuf[22];
DBUG_ENTER("my_pread");
......@@ -57,26 +57,25 @@ size_t my_pread(File Filedes, uchar *Buffer, size_t Count, my_off_t offset,
#endif
for (;;)
{
#ifndef __WIN__
errno=0; /* Linux doesn't reset this */
#endif
errno=0; /* Linux, Windows don't reset this on EOF/success */
#ifndef HAVE_PREAD
pthread_mutex_lock(&my_file_info[Filedes].mutex);
readbytes= (uint) -1;
error= (lseek(Filedes, offset, MY_SEEK_SET) == (my_off_t) -1 ||
(readbytes= read(Filedes, Buffer, Count)) != Count);
save_errno= errno;
pthread_mutex_unlock(&my_file_info[Filedes].mutex);
if (error)
{
errno= save_errno;
#else
if ((error= ((readbytes= pread(Filedes, Buffer, Count, offset)) != Count)))
{
#endif
my_errno= errno;
if (errno == 0 || (readbytes == (size_t) -1 &&
if (errno == 0 || (readbytes != (size_t) -1 &&
(MyFlags & (MY_NABP | MY_FNABP))))
my_errno= HA_ERR_FILE_TOO_SHORT;
}
#endif
if (error)
{
DBUG_PRINT("warning",("Read only %d bytes off %u from %d, errno: %d",
(int) readbytes, (uint) Count,Filedes,my_errno));
#ifdef THREAD
......
......@@ -43,11 +43,11 @@ size_t my_read(File Filedes, uchar *Buffer, size_t Count, myf MyFlags)
for (;;)
{
errno= 0; /* Linux doesn't reset this */
errno= 0; /* Linux, Windows don't reset this on EOF/success */
if ((readbytes= read(Filedes, Buffer, Count)) != Count)
{
my_errno= errno;
if (errno == 0 || (readbytes == (size_t) -1 &&
if (errno == 0 || (readbytes != (size_t) -1 &&
(MyFlags & (MY_NABP | MY_FNABP))))
my_errno= HA_ERR_FILE_TOO_SHORT;
DBUG_PRINT("warning",("Read only %d bytes off %lu from %d, errno: %d",
......
......@@ -3246,6 +3246,7 @@ my_bool translog_init_with_table(const char *directory,
DBUG_ENTER("translog_init_with_table");
id_to_share= NULL;
log_descriptor.directory_fd= -1;
(*init_table_func)();
......@@ -3914,7 +3915,8 @@ void translog_destroy()
delete_dynamic(&log_descriptor.open_files);
delete_dynamic(&log_descriptor.unfinished_files);
my_close(log_descriptor.directory_fd, MYF(MY_WME));
if (log_descriptor.directory_fd >= 0)
my_close(log_descriptor.directory_fd, MYF(MY_WME));
my_atomic_rwlock_destroy(&LOCK_id_to_share);
if (id_to_share != NULL)
my_free((uchar*)(id_to_share + 1), MYF(MY_WME));
......
......@@ -326,9 +326,12 @@ my_off_t _ma_new(register MARIA_HA *info, int level,
Next deleted page's number is in the header of the present page
(single linked list):
*/
#ifndef DBUG_OFF
my_off_t current_key_del;
#endif
share->current_key_del= mi_sizekorr(buff+share->keypage_header);
#ifndef DBUG_OFF
my_off_t current_key_del= share->current_key_del;
current_key_del= share->current_key_del;
DBUG_ASSERT(current_key_del != share->state.key_del &&
(current_key_del != 0) &&
((current_key_del == HA_OFFSET_ERROR) ||
......
......@@ -219,11 +219,11 @@ fi
# also note that maria_chk -dvv shows differences for ma_test2 in UNDO phase,
# this is normal: removing records does not shrink the data/key file,
# does not put back the "analyzed,optimized keys"(etc) index state.
diff $maria_path/ma_test_recovery.expected $tmp/ma_test_recovery.output > /dev/null || diff_failed=1
diff $maria_path/unittest/ma_test_recovery.expected $tmp/ma_test_recovery.output > /dev/null || diff_failed=1
if [ "$diff_failed" == "1" ]
then
echo "UNEXPECTED OUTPUT OF TESTS, FAILED"
echo "For more info, do diff $maria_path/ma_test_recovery.expected $tmp/ma_test_recovery.output"
echo "For more info, do diff $maria_path/unittest/ma_test_recovery.expected $tmp/ma_test_recovery.output"
exit 1
fi
echo "ALL RECOVERY TESTS OK"
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment