mirror of
https://github.com/MariaDB/server.git
synced 2025-02-02 20:11:42 +01:00
Merge mysql.com:/home/mydev/mysql-5.0-bug11527
into mysql.com:/home/mydev/mysql-5.1-bug11527
This commit is contained in:
commit
05b390b857
2 changed files with 79 additions and 32 deletions
|
@ -153,14 +153,14 @@ static struct my_option my_long_options[] =
|
||||||
#include <sslopt-longopts.h>
|
#include <sslopt-longopts.h>
|
||||||
{"tables", OPT_TABLES, "Overrides option --databases (-B).", 0, 0, 0,
|
{"tables", OPT_TABLES, "Overrides option --databases (-B).", 0, 0, 0,
|
||||||
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||||
#ifndef DONT_ALLOW_USER_CHANGE
|
|
||||||
{"user", 'u', "User for login if not current user.", (gptr*) ¤t_user,
|
|
||||||
(gptr*) ¤t_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
|
||||||
#endif
|
|
||||||
{"use-frm", OPT_FRM,
|
{"use-frm", OPT_FRM,
|
||||||
"When used with REPAIR, get table structure from .frm file, so the table can be repaired even if .MYI header is corrupted.",
|
"When used with REPAIR, get table structure from .frm file, so the table can be repaired even if .MYI header is corrupted.",
|
||||||
(gptr*) &opt_frm, (gptr*) &opt_frm, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
|
(gptr*) &opt_frm, (gptr*) &opt_frm, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
|
||||||
0},
|
0},
|
||||||
|
#ifndef DONT_ALLOW_USER_CHANGE
|
||||||
|
{"user", 'u', "User for login if not current user.", (gptr*) ¤t_user,
|
||||||
|
(gptr*) ¤t_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||||
|
#endif
|
||||||
{"verbose", 'v', "Print info about the various stages.", 0, 0, 0, GET_NO_ARG,
|
{"verbose", 'v', "Print info about the various stages.", 0, 0, 0, GET_NO_ARG,
|
||||||
NO_ARG, 0, 0, 0, 0, 0, 0},
|
NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||||
{"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG,
|
{"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG,
|
||||||
|
|
|
@ -399,11 +399,31 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type,
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Read buffered. Returns 1 if can't read requested characters
|
Read buffered.
|
||||||
This function is only called from the my_b_read() macro
|
|
||||||
when there isn't enough characters in the buffer to
|
SYNOPSIS
|
||||||
satisfy the request.
|
_my_b_read()
|
||||||
Returns 0 we succeeded in reading all data
|
info IO_CACHE pointer
|
||||||
|
Buffer Buffer to retrieve count bytes from file
|
||||||
|
Count Number of bytes to read into Buffer
|
||||||
|
|
||||||
|
NOTE
|
||||||
|
This function is only called from the my_b_read() macro when there
|
||||||
|
isn't enough characters in the buffer to satisfy the request.
|
||||||
|
|
||||||
|
WARNING
|
||||||
|
|
||||||
|
When changing this function, be careful with handling file offsets
|
||||||
|
(end-of_file, pos_in_file). Do not cast them to possibly smaller
|
||||||
|
types than my_off_t unless you can be sure that their value fits.
|
||||||
|
Same applies to differences of file offsets.
|
||||||
|
|
||||||
|
When changing this function, check _my_b_read_r(). It might need the
|
||||||
|
same change.
|
||||||
|
|
||||||
|
RETURN
|
||||||
|
0 we succeeded in reading all data
|
||||||
|
1 Error: can't read requested characters
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int _my_b_read(register IO_CACHE *info, byte *Buffer, uint Count)
|
int _my_b_read(register IO_CACHE *info, byte *Buffer, uint Count)
|
||||||
|
@ -431,7 +451,7 @@ int _my_b_read(register IO_CACHE *info, byte *Buffer, uint Count)
|
||||||
if (Count >= (uint) (IO_SIZE+(IO_SIZE-diff_length)))
|
if (Count >= (uint) (IO_SIZE+(IO_SIZE-diff_length)))
|
||||||
{ /* Fill first intern buffer */
|
{ /* Fill first intern buffer */
|
||||||
uint read_length;
|
uint read_length;
|
||||||
if (info->end_of_file == pos_in_file)
|
if (info->end_of_file <= pos_in_file)
|
||||||
{ /* End of file */
|
{ /* End of file */
|
||||||
info->error=(int) left_length;
|
info->error=(int) left_length;
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
|
@ -546,43 +566,70 @@ static void unlock_io_cache(IO_CACHE *info)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Read from IO_CACHE when it is shared between several threads.
|
Read from IO_CACHE when it is shared between several threads.
|
||||||
It works as follows: when a thread tries to read from a file
|
|
||||||
(that is, after using all the data from the (shared) buffer),
|
SYNOPSIS
|
||||||
it just hangs on lock_io_cache(), wating for other threads.
|
_my_b_read_r()
|
||||||
When the very last thread attempts a read, lock_io_cache()
|
info IO_CACHE pointer
|
||||||
returns 1, the thread does actual IO and unlock_io_cache(),
|
Buffer Buffer to retrieve count bytes from file
|
||||||
which signals all the waiting threads that data is in the buffer.
|
Count Number of bytes to read into Buffer
|
||||||
|
|
||||||
|
NOTE
|
||||||
|
This function is only called from the my_b_read() macro when there
|
||||||
|
isn't enough characters in the buffer to satisfy the request.
|
||||||
|
|
||||||
|
IMPLEMENTATION
|
||||||
|
|
||||||
|
It works as follows: when a thread tries to read from a file (that
|
||||||
|
is, after using all the data from the (shared) buffer), it just
|
||||||
|
hangs on lock_io_cache(), wating for other threads. When the very
|
||||||
|
last thread attempts a read, lock_io_cache() returns 1, the thread
|
||||||
|
does actual IO and unlock_io_cache(), which signals all the waiting
|
||||||
|
threads that data is in the buffer.
|
||||||
|
|
||||||
|
WARNING
|
||||||
|
|
||||||
|
When changing this function, be careful with handling file offsets
|
||||||
|
(end-of_file, pos_in_file). Do not cast them to possibly smaller
|
||||||
|
types than my_off_t unless you can be sure that their value fits.
|
||||||
|
Same applies to differences of file offsets. (Bug #11527)
|
||||||
|
|
||||||
|
When changing this function, check _my_b_read(). It might need the
|
||||||
|
same change.
|
||||||
|
|
||||||
|
RETURN
|
||||||
|
0 we succeeded in reading all data
|
||||||
|
1 Error: can't read requested characters
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int _my_b_read_r(register IO_CACHE *info, byte *Buffer, uint Count)
|
int _my_b_read_r(register IO_CACHE *info, byte *Buffer, uint Count)
|
||||||
{
|
{
|
||||||
my_off_t pos_in_file;
|
my_off_t pos_in_file;
|
||||||
uint length,diff_length,read_len;
|
uint length, diff_length, left_length;
|
||||||
DBUG_ENTER("_my_b_read_r");
|
DBUG_ENTER("_my_b_read_r");
|
||||||
|
|
||||||
if ((read_len=(uint) (info->read_end-info->read_pos)))
|
if ((left_length= (uint) (info->read_end - info->read_pos)))
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(Count >= read_len); /* User is not using my_b_read() */
|
DBUG_ASSERT(Count >= left_length); /* User is not using my_b_read() */
|
||||||
memcpy(Buffer,info->read_pos, (size_t) (read_len));
|
memcpy(Buffer, info->read_pos, (size_t) (left_length));
|
||||||
Buffer+=read_len;
|
Buffer+= left_length;
|
||||||
Count-=read_len;
|
Count-= left_length;
|
||||||
}
|
}
|
||||||
while (Count)
|
while (Count)
|
||||||
{
|
{
|
||||||
int cnt, len;
|
int cnt, len;
|
||||||
|
|
||||||
pos_in_file= info->pos_in_file + (uint)(info->read_end - info->buffer);
|
pos_in_file= info->pos_in_file + (info->read_end - info->buffer);
|
||||||
diff_length= (uint) (pos_in_file & (IO_SIZE-1));
|
diff_length= (uint) (pos_in_file & (IO_SIZE-1));
|
||||||
length=IO_ROUND_UP(Count+diff_length)-diff_length;
|
length=IO_ROUND_UP(Count+diff_length)-diff_length;
|
||||||
length=(length <= info->read_length) ?
|
length=(length <= info->read_length) ?
|
||||||
length + IO_ROUND_DN(info->read_length - length) :
|
length + IO_ROUND_DN(info->read_length - length) :
|
||||||
length - IO_ROUND_UP(length - info->read_length) ;
|
length - IO_ROUND_UP(length - info->read_length) ;
|
||||||
if (info->type != READ_FIFO &&
|
if (info->type != READ_FIFO &&
|
||||||
(length > (uint) (info->end_of_file - pos_in_file)))
|
(length > (info->end_of_file - pos_in_file)))
|
||||||
length= (uint) (info->end_of_file - pos_in_file);
|
length= (uint) (info->end_of_file - pos_in_file);
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
{
|
{
|
||||||
info->error=(int) read_len;
|
info->error= (int) left_length;
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
if (lock_io_cache(info, pos_in_file))
|
if (lock_io_cache(info, pos_in_file))
|
||||||
|
@ -607,15 +654,15 @@ int _my_b_read_r(register IO_CACHE *info, byte *Buffer, uint Count)
|
||||||
info->seek_not_done=0;
|
info->seek_not_done=0;
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
{
|
{
|
||||||
info->error=(int) read_len;
|
info->error= (int) left_length;
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
cnt=((uint) len > Count) ? (int) Count : len;
|
cnt= ((uint) len > Count) ? (int) Count : len;
|
||||||
memcpy(Buffer,info->read_pos, (size_t)cnt);
|
memcpy(Buffer, info->read_pos, (size_t) cnt);
|
||||||
Count -=cnt;
|
Count -= cnt;
|
||||||
Buffer+=cnt;
|
Buffer+= cnt;
|
||||||
read_len+=cnt;
|
left_length+= cnt;
|
||||||
info->read_pos+=cnt;
|
info->read_pos+= cnt;
|
||||||
}
|
}
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue