Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
5f2424ea
Commit
5f2424ea
authored
Nov 02, 2006
by
thek@kpdesk.mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge kpdesk.mysql.com:/home/thek/dev/mysql-5.0-maint
into kpdesk.mysql.com:/home/thek/dev/mysql-5.1-maint
parents
1532622b
35b833eb
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
244 additions
and
71 deletions
+244
-71
client/mysqltest.c
client/mysqltest.c
+18
-18
mysql-test/include/wait_for_query_to_suceed.inc
mysql-test/include/wait_for_query_to_suceed.inc
+25
-0
mysql-test/lib/mtr_io.pl
mysql-test/lib/mtr_io.pl
+5
-7
mysql-test/lib/mtr_process.pl
mysql-test/lib/mtr_process.pl
+25
-15
mysql-test/mysql-test-run.pl
mysql-test/mysql-test-run.pl
+10
-8
mysql-test/t/rename.test
mysql-test/t/rename.test
+8
-3
mysys/mf_iocache.c
mysys/mf_iocache.c
+90
-12
mysys/my_chsize.c
mysys/my_chsize.c
+5
-1
mysys/my_lock.c
mysys/my_lock.c
+34
-5
mysys/my_seek.c
mysys/my_seek.c
+24
-2
No files found.
client/mysqltest.c
View file @
5f2424ea
...
@@ -1409,7 +1409,7 @@ int open_file(const char *name)
...
@@ -1409,7 +1409,7 @@ int open_file(const char *name)
void
do_source
(
struct
st_command
*
command
)
void
do_source
(
struct
st_command
*
command
)
{
{
DYNAMIC_STRING
ds_filename
;
static
DYNAMIC_STRING
ds_filename
;
const
struct
command_arg
source_args
[]
=
{
const
struct
command_arg
source_args
[]
=
{
"filename"
,
ARG_STRING
,
TRUE
,
&
ds_filename
,
"File to source"
"filename"
,
ARG_STRING
,
TRUE
,
&
ds_filename
,
"File to source"
};
};
...
@@ -1697,7 +1697,7 @@ void do_system(struct st_command *command)
...
@@ -1697,7 +1697,7 @@ void do_system(struct st_command *command)
void
do_remove_file
(
struct
st_command
*
command
)
void
do_remove_file
(
struct
st_command
*
command
)
{
{
int
error
;
int
error
;
DYNAMIC_STRING
ds_filename
;
static
DYNAMIC_STRING
ds_filename
;
const
struct
command_arg
rm_args
[]
=
{
const
struct
command_arg
rm_args
[]
=
{
"filename"
,
ARG_STRING
,
TRUE
,
&
ds_filename
,
"File to delete"
"filename"
,
ARG_STRING
,
TRUE
,
&
ds_filename
,
"File to delete"
};
};
...
@@ -1730,8 +1730,8 @@ void do_remove_file(struct st_command *command)
...
@@ -1730,8 +1730,8 @@ void do_remove_file(struct st_command *command)
void
do_copy_file
(
struct
st_command
*
command
)
void
do_copy_file
(
struct
st_command
*
command
)
{
{
int
error
;
int
error
;
DYNAMIC_STRING
ds_from_file
;
static
DYNAMIC_STRING
ds_from_file
;
DYNAMIC_STRING
ds_to_file
;
static
DYNAMIC_STRING
ds_to_file
;
const
struct
command_arg
copy_file_args
[]
=
{
const
struct
command_arg
copy_file_args
[]
=
{
"from_file"
,
ARG_STRING
,
TRUE
,
&
ds_from_file
,
"Filename to copy from"
,
"from_file"
,
ARG_STRING
,
TRUE
,
&
ds_from_file
,
"Filename to copy from"
,
"to_file"
,
ARG_STRING
,
TRUE
,
&
ds_to_file
,
"Filename to copy to"
"to_file"
,
ARG_STRING
,
TRUE
,
&
ds_to_file
,
"Filename to copy to"
...
@@ -1766,7 +1766,7 @@ void do_copy_file(struct st_command *command)
...
@@ -1766,7 +1766,7 @@ void do_copy_file(struct st_command *command)
void
do_file_exist
(
struct
st_command
*
command
)
void
do_file_exist
(
struct
st_command
*
command
)
{
{
int
error
;
int
error
;
DYNAMIC_STRING
ds_filename
;
static
DYNAMIC_STRING
ds_filename
;
const
struct
command_arg
file_exist_args
[]
=
{
const
struct
command_arg
file_exist_args
[]
=
{
"filename"
,
ARG_STRING
,
TRUE
,
&
ds_filename
,
"File to check if it exist"
"filename"
,
ARG_STRING
,
TRUE
,
&
ds_filename
,
"File to check if it exist"
};
};
...
@@ -1873,9 +1873,9 @@ void read_until_delimiter(DYNAMIC_STRING *ds,
...
@@ -1873,9 +1873,9 @@ void read_until_delimiter(DYNAMIC_STRING *ds,
void
do_write_file
(
struct
st_command
*
command
)
void
do_write_file
(
struct
st_command
*
command
)
{
{
DYNAMIC_STRING
ds_content
;
static
DYNAMIC_STRING
ds_content
;
DYNAMIC_STRING
ds_filename
;
static
DYNAMIC_STRING
ds_filename
;
DYNAMIC_STRING
ds_delimiter
;
static
DYNAMIC_STRING
ds_delimiter
;
const
struct
command_arg
write_file_args
[]
=
{
const
struct
command_arg
write_file_args
[]
=
{
"filename"
,
ARG_STRING
,
TRUE
,
&
ds_filename
,
"File to write to"
,
"filename"
,
ARG_STRING
,
TRUE
,
&
ds_filename
,
"File to write to"
,
"delimiter"
,
ARG_STRING
,
FALSE
,
&
ds_delimiter
,
"Delimiter to read until"
"delimiter"
,
ARG_STRING
,
FALSE
,
&
ds_delimiter
,
"Delimiter to read until"
...
@@ -1927,8 +1927,8 @@ void do_perl(struct st_command *command)
...
@@ -1927,8 +1927,8 @@ void do_perl(struct st_command *command)
int
error
;
int
error
;
char
buf
[
FN_REFLEN
];
char
buf
[
FN_REFLEN
];
FILE
*
res_file
;
FILE
*
res_file
;
DYNAMIC_STRING
ds_script
;
static
DYNAMIC_STRING
ds_script
;
DYNAMIC_STRING
ds_delimiter
;
static
DYNAMIC_STRING
ds_delimiter
;
const
struct
command_arg
perl_args
[]
=
{
const
struct
command_arg
perl_args
[]
=
{
"delimiter"
,
ARG_STRING
,
FALSE
,
&
ds_delimiter
,
"Delimiter to read until"
"delimiter"
,
ARG_STRING
,
FALSE
,
&
ds_delimiter
,
"Delimiter to read until"
};
};
...
@@ -2985,14 +2985,14 @@ void do_connect(struct st_command *command)
...
@@ -2985,14 +2985,14 @@ void do_connect(struct st_command *command)
bool
con_ssl
=
0
,
con_compress
=
0
;
bool
con_ssl
=
0
,
con_compress
=
0
;
char
*
ptr
;
char
*
ptr
;
DYNAMIC_STRING
ds_connection_name
;
static
DYNAMIC_STRING
ds_connection_name
;
DYNAMIC_STRING
ds_host
;
static
DYNAMIC_STRING
ds_host
;
DYNAMIC_STRING
ds_user
;
static
DYNAMIC_STRING
ds_user
;
DYNAMIC_STRING
ds_password
;
static
DYNAMIC_STRING
ds_password
;
DYNAMIC_STRING
ds_database
;
static
DYNAMIC_STRING
ds_database
;
DYNAMIC_STRING
ds_port
;
static
DYNAMIC_STRING
ds_port
;
DYNAMIC_STRING
ds_sock
;
static
DYNAMIC_STRING
ds_sock
;
DYNAMIC_STRING
ds_options
;
static
DYNAMIC_STRING
ds_options
;
const
struct
command_arg
connect_args
[]
=
{
const
struct
command_arg
connect_args
[]
=
{
"connection name"
,
ARG_STRING
,
TRUE
,
&
ds_connection_name
,
"connection name"
,
ARG_STRING
,
TRUE
,
&
ds_connection_name
,
"Name of the connection"
,
"Name of the connection"
,
...
...
mysql-test/include/wait_for_query_to_suceed.inc
0 → 100644
View file @
5f2424ea
#
# Run a query over and over until it suceeds ot timeout occurs
#
let
$counter
=
100
;
disable_abort_on_error
;
disable_query_log
;
disable_result_log
;
eval
$query
;
while
(
$mysql_errno
)
{
eval
$query
;
sleep
0.1
;
dec
$counter
;
if
(
!
$counter
)
{
die
(
"Waited too long for query to suceed"
);
}
}
enable_abort_on_error
;
enable_query_log
;
enable_result_log
;
mysql-test/lib/mtr_io.pl
View file @
5f2424ea
...
@@ -37,18 +37,16 @@ sub mtr_get_pid_from_file ($) {
...
@@ -37,18 +37,16 @@ sub mtr_get_pid_from_file ($) {
open
(
FILE
,
'
<
',
$pid_file_path
)
open
(
FILE
,
'
<
',
$pid_file_path
)
or
mtr_error
("
can't open file
\"
$pid_file_path
\"
: $!
");
or
mtr_error
("
can't open file
\"
$pid_file_path
\"
: $!
");
# Read pid number from file
my
$pid
=
<
FILE
>
;
my
$pid
=
<
FILE
>
;
chomp
(
$pid
)
if
defined
$pid
;
close
FILE
;
close
FILE
;
return
$pid
if
defined
$pid
&&
$pid
ne
''
;
return
$pid
if
$pid
=~
/^(\d+)/
;
mtr_debug
("
Pid file '
$pid_file_path
'
is empty.
"
.
mtr_debug
("
Pid file '
$pid_file_path
'
does not yet contain pid number.
\n
"
.
"
Sleeping
$timeout
second(s)...
");
"
Sleeping
$timeout
second(s)
more
...
");
sleep
(
1
);
sleep
(
$timeout
);
}
}
mtr_error
("
Pid file '
$pid_file_path
' is corrupted.
"
.
mtr_error
("
Pid file '
$pid_file_path
' is corrupted.
"
.
...
...
mysql-test/lib/mtr_process.pl
View file @
5f2424ea
...
@@ -438,25 +438,35 @@ sub mtr_kill_leftovers () {
...
@@ -438,25 +438,35 @@ sub mtr_kill_leftovers () {
while
(
my
$elem
=
readdir
(
RUNDIR
)
)
while
(
my
$elem
=
readdir
(
RUNDIR
)
)
{
{
my
$pidfile
=
"
$rundir
/
$elem
";
# Only read pid from files that end with .pid
if
(
$elem
=~
/.*[.]pid$/
)
if
(
-
f
$pidfile
)
{
{
mtr_debug
("
Processing PID file: '
$pidfile
'...
");
my
$pid
=
mtr_get_pid_from_file
(
$pidfile
)
;
my
$pidfile
=
"
$rundir
/
$elem
"
;
mtr_debug
("
Got pid:
$pid
from file '
$pidfile
'
");
if
(
-
f
$pidfile
)
{
mtr_debug
("
Processing PID file: '
$pidfile
'...
");
if
(
$::glob_cygwin_perl
or
kill
(
0
,
$pid
)
)
my
$pid
=
mtr_get_pid_from_file
(
$pidfile
);
{
mtr_debug
("
There is process with pid
$pid
-- scheduling for kill.
");
mtr_debug
("
Got pid:
$pid
from file '
$pidfile
'
");
push
(
@pids
,
$pid
);
# We know (cygwin guess) it exists
}
if
(
$::glob_cygwin_perl
or
kill
(
0
,
$pid
)
)
else
{
{
mtr_debug
("
There is process with pid
$pid
-- scheduling for kill.
");
mtr_debug
("
There is no process with pid
$pid
-- skipping.
");
push
(
@pids
,
$pid
);
# We know (cygwin guess) it exists
}
}
else
{
mtr_debug
("
There is no process with pid
$pid
-- skipping.
");
}
}
}
else
{
mtr_warning
("
Found non pid file
$elem
in
$rundir
");
next
;
}
}
}
}
closedir
(
RUNDIR
);
closedir
(
RUNDIR
);
...
...
mysql-test/mysql-test-run.pl
View file @
5f2424ea
...
@@ -1801,14 +1801,16 @@ sub environment_setup () {
...
@@ -1801,14 +1801,16 @@ sub environment_setup () {
# ----------------------------------------------------
# ----------------------------------------------------
# Setup env so childs can execute mysql_fix_system_tables
# Setup env so childs can execute mysql_fix_system_tables
# ----------------------------------------------------
# ----------------------------------------------------
my
$cmdline_mysql_fix_system_tables
=
if
(
!
$glob_win32
)
"
$exe_mysql_fix_system_tables
--no-defaults --host=localhost
"
.
{
"
--user=root --password=
"
.
my
$cmdline_mysql_fix_system_tables
=
"
--basedir=
$glob_basedir
--bindir=
$path_client_bindir
--verbose
"
.
"
$exe_mysql_fix_system_tables
--no-defaults --host=localhost
"
.
"
--port=
$master
->[0]->{'port'}
"
.
"
--user=root --password=
"
.
"
--socket=
$master
->[0]->{'path_sock'}
";
"
--basedir=
$glob_basedir
--bindir=
$path_client_bindir
--verbose
"
.
"
--port=
$master
->[0]->{'port'}
"
.
$ENV
{'
MYSQL_FIX_SYSTEM_TABLES
'}
=
$cmdline_mysql_fix_system_tables
;
"
--socket=
$master
->[0]->{'path_sock'}
";
$ENV
{'
MYSQL_FIX_SYSTEM_TABLES
'}
=
$cmdline_mysql_fix_system_tables
;
}
# ----------------------------------------------------
# ----------------------------------------------------
# Setup env so childs can execute my_print_defaults
# Setup env so childs can execute my_print_defaults
...
...
mysql-test/t/rename.test
View file @
5f2424ea
...
@@ -43,8 +43,8 @@ select * from t3;
...
@@ -43,8 +43,8 @@ select * from t3;
drop
table
if
exists
t1
,
t2
,
t3
,
t4
;
drop
table
if
exists
t1
,
t2
,
t3
,
t4
;
#
#
#
Test-case for Bug #2397 RENAME TABLES is not blocked by
#
Bug #2397 RENAME TABLES is not blocked by
#
FLUSH TABLES WITH READ LOCK
# FLUSH TABLES WITH READ LOCK
#
#
connect
(
con1
,
localhost
,
root
,,);
connect
(
con1
,
localhost
,
root
,,);
...
@@ -58,12 +58,17 @@ FLUSH TABLES WITH READ LOCK;
...
@@ -58,12 +58,17 @@ FLUSH TABLES WITH READ LOCK;
connection
con1
;
connection
con1
;
send
RENAME
TABLE
t1
TO
t2
,
t3
to
t4
;
send
RENAME
TABLE
t1
TO
t2
,
t3
to
t4
;
connection
con2
;
connection
con2
;
sleep
1
;
show
tables
;
show
tables
;
UNLOCK
TABLES
;
UNLOCK
TABLES
;
connection
con1
;
connection
con1
;
reap
;
reap
;
connection
con2
;
connection
con2
;
# Wait for the the tables to be renamed
# i.e the query below succeds
let
$query
=
select
*
from
t2
,
t4
;
source
include
/
wait_for_query_to_suceed
.
inc
;
show
tables
;
show
tables
;
drop
table
t2
,
t4
;
drop
table
t2
,
t4
;
...
...
mysys/mf_iocache.c
View file @
5f2424ea
...
@@ -445,11 +445,24 @@ int _my_b_read(register IO_CACHE *info, byte *Buffer, uint Count)
...
@@ -445,11 +445,24 @@ int _my_b_read(register IO_CACHE *info, byte *Buffer, uint Count)
/* pos_in_file always point on where info->buffer was read */
/* pos_in_file always point on where info->buffer was read */
pos_in_file
=
info
->
pos_in_file
+
(
uint
)
(
info
->
read_end
-
info
->
buffer
);
pos_in_file
=
info
->
pos_in_file
+
(
uint
)
(
info
->
read_end
-
info
->
buffer
);
/*
Whenever a function which operates on IO_CACHE flushes/writes
some part of the IO_CACHE to disk it will set the property
"seek_not_done" to indicate this to other functions operating
on the IO_CACHE.
*/
if
(
info
->
seek_not_done
)
if
(
info
->
seek_not_done
)
{
/* File touched, do seek */
{
VOID
(
my_seek
(
info
->
file
,
pos_in_file
,
MY_SEEK_SET
,
MYF
(
0
)));
if
(
my_seek
(
info
->
file
,
pos_in_file
,
MY_SEEK_SET
,
MYF
(
0
))
==
MY_FILEPOS_ERROR
)
{
info
->
error
=
-
1
;
DBUG_RETURN
(
1
);
}
info
->
seek_not_done
=
0
;
info
->
seek_not_done
=
0
;
}
}
diff_length
=
(
uint
)
(
pos_in_file
&
(
IO_SIZE
-
1
));
diff_length
=
(
uint
)
(
pos_in_file
&
(
IO_SIZE
-
1
));
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 */
...
@@ -950,8 +963,22 @@ int _my_b_read_r(register IO_CACHE *cache, byte *Buffer, uint Count)
...
@@ -950,8 +963,22 @@ int _my_b_read_r(register IO_CACHE *cache, byte *Buffer, uint Count)
len
=
0
;
len
=
0
;
else
else
{
{
if
(
cache
->
seek_not_done
)
/* File touched, do seek */
/*
VOID
(
my_seek
(
cache
->
file
,
pos_in_file
,
MY_SEEK_SET
,
MYF
(
0
)));
Whenever a function which operates on IO_CACHE flushes/writes
some part of the IO_CACHE to disk it will set the property
"seek_not_done" to indicate this to other functions operating
on the IO_CACHE.
*/
if
(
cache
->
seek_not_done
)
{
if
(
my_seek
(
cache
->
file
,
pos_in_file
,
MY_SEEK_SET
,
MYF
(
0
))
==
MY_FILEPOS_ERROR
)
{
cache
->
error
=
-
1
;
unlock_io_cache
(
cache
);
DBUG_RETURN
(
1
);
}
}
len
=
(
int
)
my_read
(
cache
->
file
,
cache
->
buffer
,
length
,
cache
->
myflags
);
len
=
(
int
)
my_read
(
cache
->
file
,
cache
->
buffer
,
length
,
cache
->
myflags
);
}
}
DBUG_PRINT
(
"io_cache_share"
,
(
"read %d bytes"
,
len
));
DBUG_PRINT
(
"io_cache_share"
,
(
"read %d bytes"
,
len
));
...
@@ -1053,11 +1080,16 @@ static void copy_to_read_buffer(IO_CACHE *write_cache,
...
@@ -1053,11 +1080,16 @@ static void copy_to_read_buffer(IO_CACHE *write_cache,
/*
/*
Do sequential read from the SEQ_READ_APPEND cache
Do sequential read from the SEQ_READ_APPEND cache.
we do this in three stages:
We do this in three stages:
- first read from info->buffer
- first read from info->buffer
- then if there are still data to read, try the file descriptor
- then if there are still data to read, try the file descriptor
- afterwards, if there are still data to read, try append buffer
- afterwards, if there are still data to read, try append buffer
RETURNS
0 Success
1 Failed to read
*/
*/
int
_my_b_seq_read
(
register
IO_CACHE
*
info
,
byte
*
Buffer
,
uint
Count
)
int
_my_b_seq_read
(
register
IO_CACHE
*
info
,
byte
*
Buffer
,
uint
Count
)
...
@@ -1085,7 +1117,13 @@ int _my_b_seq_read(register IO_CACHE *info, byte *Buffer, uint Count)
...
@@ -1085,7 +1117,13 @@ int _my_b_seq_read(register IO_CACHE *info, byte *Buffer, uint Count)
With read-append cache we must always do a seek before we read,
With read-append cache we must always do a seek before we read,
because the write could have moved the file pointer astray
because the write could have moved the file pointer astray
*/
*/
VOID
(
my_seek
(
info
->
file
,
pos_in_file
,
MY_SEEK_SET
,
MYF
(
0
)));
if
(
my_seek
(
info
->
file
,
pos_in_file
,
MY_SEEK_SET
,
MYF
(
0
))
==
MY_FILEPOS_ERROR
)
{
info
->
error
=
-
1
;
unlock_append_buffer
(
info
);
return
(
1
);
}
info
->
seek_not_done
=
0
;
info
->
seek_not_done
=
0
;
diff_length
=
(
uint
)
(
pos_in_file
&
(
IO_SIZE
-
1
));
diff_length
=
(
uint
)
(
pos_in_file
&
(
IO_SIZE
-
1
));
...
@@ -1201,6 +1239,21 @@ read_append_buffer:
...
@@ -1201,6 +1239,21 @@ read_append_buffer:
#ifdef HAVE_AIOWAIT
#ifdef HAVE_AIOWAIT
/*
Read from the IO_CACHE into a buffer and feed asynchronously
from disk when needed.
SYNOPSIS
_my_b_async_read()
info IO_CACHE pointer
Buffer Buffer to retrieve count bytes from file
Count Number of bytes to read into Buffer
RETURN VALUE
-1 An error has occurred; my_errno is set.
0 Success
1 An error has occurred; IO_CACHE to error state.
*/
int
_my_b_async_read
(
register
IO_CACHE
*
info
,
byte
*
Buffer
,
uint
Count
)
int
_my_b_async_read
(
register
IO_CACHE
*
info
,
byte
*
Buffer
,
uint
Count
)
{
{
uint
length
,
read_length
,
diff_length
,
left_length
,
use_length
,
org_Count
;
uint
length
,
read_length
,
diff_length
,
left_length
,
use_length
,
org_Count
;
...
@@ -1291,13 +1344,20 @@ int _my_b_async_read(register IO_CACHE *info, byte *Buffer, uint Count)
...
@@ -1291,13 +1344,20 @@ int _my_b_async_read(register IO_CACHE *info, byte *Buffer, uint Count)
info
->
error
=
(
int
)
(
read_length
+
left_length
);
info
->
error
=
(
int
)
(
read_length
+
left_length
);
return
1
;
return
1
;
}
}
VOID
(
my_seek
(
info
->
file
,
next_pos_in_file
,
MY_SEEK_SET
,
MYF
(
0
)));
if
(
my_seek
(
info
->
file
,
next_pos_in_file
,
MY_SEEK_SET
,
MYF
(
0
))
==
MY_FILEPOS_ERROR
)
{
info
->
error
=
-
1
;
return
(
1
);
}
read_length
=
IO_SIZE
*
2
-
(
uint
)
(
next_pos_in_file
&
(
IO_SIZE
-
1
));
read_length
=
IO_SIZE
*
2
-
(
uint
)
(
next_pos_in_file
&
(
IO_SIZE
-
1
));
if
(
Count
<
read_length
)
if
(
Count
<
read_length
)
{
/* Small block, read to cache */
{
/* Small block, read to cache */
if
((
read_length
=
my_read
(
info
->
file
,
info
->
request_pos
,
if
((
read_length
=
my_read
(
info
->
file
,
info
->
request_pos
,
read_length
,
info
->
myflags
))
==
(
uint
)
-
1
)
read_length
,
info
->
myflags
))
==
(
uint
)
-
1
)
return
info
->
error
=
-
1
;
return
info
->
error
=
-
1
;
use_length
=
min
(
Count
,
read_length
);
use_length
=
min
(
Count
,
read_length
);
memcpy
(
Buffer
,
info
->
request_pos
,(
size_t
)
use_length
);
memcpy
(
Buffer
,
info
->
request_pos
,(
size_t
)
use_length
);
info
->
read_pos
=
info
->
request_pos
+
Count
;
info
->
read_pos
=
info
->
request_pos
+
Count
;
...
@@ -1384,7 +1444,15 @@ int _my_b_get(IO_CACHE *info)
...
@@ -1384,7 +1444,15 @@ int _my_b_get(IO_CACHE *info)
return
(
int
)
(
uchar
)
buff
;
return
(
int
)
(
uchar
)
buff
;
}
}
/* Returns != 0 if error on write */
/*
Write a byte buffer to IO_CACHE and flush to disk
if IO_CACHE is full.
RETURN VALUE
1 On error on write
0 On success
-1 On error; my_errno contains error code.
*/
int
_my_b_write
(
register
IO_CACHE
*
info
,
const
byte
*
Buffer
,
uint
Count
)
int
_my_b_write
(
register
IO_CACHE
*
info
,
const
byte
*
Buffer
,
uint
Count
)
{
{
...
@@ -1408,8 +1476,18 @@ int _my_b_write(register IO_CACHE *info, const byte *Buffer, uint Count)
...
@@ -1408,8 +1476,18 @@ int _my_b_write(register IO_CACHE *info, const byte *Buffer, uint Count)
{
/* Fill first intern buffer */
{
/* Fill first intern buffer */
length
=
Count
&
(
uint
)
~
(
IO_SIZE
-
1
);
length
=
Count
&
(
uint
)
~
(
IO_SIZE
-
1
);
if
(
info
->
seek_not_done
)
if
(
info
->
seek_not_done
)
{
/* File touched, do seek */
{
VOID
(
my_seek
(
info
->
file
,
info
->
pos_in_file
,
MY_SEEK_SET
,
MYF
(
0
)));
/*
Whenever a function which operates on IO_CACHE flushes/writes
some part of the IO_CACHE to disk it will set the property
"seek_not_done" to indicate this to other functions operating
on the IO_CACHE.
*/
if
(
my_seek
(
info
->
file
,
info
->
pos_in_file
,
MY_SEEK_SET
,
MYF
(
0
)))
{
info
->
error
=
-
1
;
return
(
1
);
}
info
->
seek_not_done
=
0
;
info
->
seek_not_done
=
0
;
}
}
if
(
my_write
(
info
->
file
,
Buffer
,(
uint
)
length
,
info
->
myflags
|
MY_NABP
))
if
(
my_write
(
info
->
file
,
Buffer
,(
uint
)
length
,
info
->
myflags
|
MY_NABP
))
...
...
mysys/my_chsize.c
View file @
5f2424ea
...
@@ -86,7 +86,11 @@ int my_chsize(File fd, my_off_t newlength, int filler, myf MyFlags)
...
@@ -86,7 +86,11 @@ int my_chsize(File fd, my_off_t newlength, int filler, myf MyFlags)
Fill space between requested length and true length with 'filler'
Fill space between requested length and true length with 'filler'
We should never come here on any modern machine
We should never come here on any modern machine
*/
*/
VOID
(
my_seek
(
fd
,
newlength
,
MY_SEEK_SET
,
MYF
(
MY_WME
+
MY_FAE
)));
if
(
my_seek
(
fd
,
newlength
,
MY_SEEK_SET
,
MYF
(
MY_WME
+
MY_FAE
))
==
MY_FILEPOS_ERROR
)
{
goto
err
;
}
swap_variables
(
my_off_t
,
newlength
,
oldsize
);
swap_variables
(
my_off_t
,
newlength
,
oldsize
);
#endif
#endif
}
}
...
...
mysys/my_lock.c
View file @
5f2424ea
...
@@ -30,7 +30,14 @@
...
@@ -30,7 +30,14 @@
#include <nks/fsio.h>
#include <nks/fsio.h>
#endif
#endif
/* Lock a part of a file */
/*
Lock a part of a file
RETURN VALUE
0 Success
-1 An error has occured and 'my_errno' is set
to indicate the actual error code.
*/
int
my_lock
(
File
fd
,
int
locktype
,
my_off_t
start
,
my_off_t
length
,
int
my_lock
(
File
fd
,
int
locktype
,
my_off_t
start
,
my_off_t
length
,
myf
MyFlags
)
myf
MyFlags
)
...
@@ -94,10 +101,22 @@ int my_lock(File fd, int locktype, my_off_t start, my_off_t length,
...
@@ -94,10 +101,22 @@ int my_lock(File fd, int locktype, my_off_t start, my_off_t length,
#elif defined(HAVE_LOCKING)
#elif defined(HAVE_LOCKING)
/* Windows */
/* Windows */
{
{
my_bool
error
;
my_bool
error
=
false
;
pthread_mutex_lock
(
&
my_file_info
[
fd
].
mutex
);
pthread_mutex_lock
(
&
my_file_info
[
fd
].
mutex
);
if
(
MyFlags
&
MY_SEEK_NOT_DONE
)
if
(
MyFlags
&
MY_SEEK_NOT_DONE
)
VOID
(
my_seek
(
fd
,
start
,
MY_SEEK_SET
,
MYF
(
MyFlags
&
~
MY_SEEK_NOT_DONE
)));
{
if
(
my_seek
(
fd
,
start
,
MY_SEEK_SET
,
MYF
(
MyFlags
&
~
MY_SEEK_NOT_DONE
))
==
MY_FILEPOS_ERROR
)
{
/*
If my_seek fails my_errno will already contain an error code;
just unlock and return error code.
*/
DBUG_PRINT
(
"error"
,(
"my_errno: %d (%d)"
,
my_errno
,
errno
));
pthread_mutex_unlock
(
&
my_file_info
[
fd
].
mutex
);
DBUG_RETURN
(
-
1
);
}
}
error
=
locking
(
fd
,
locktype
,(
ulong
)
length
)
&&
errno
!=
EINVAL
;
error
=
locking
(
fd
,
locktype
,(
ulong
)
length
)
&&
errno
!=
EINVAL
;
pthread_mutex_unlock
(
&
my_file_info
[
fd
].
mutex
);
pthread_mutex_unlock
(
&
my_file_info
[
fd
].
mutex
);
if
(
!
error
)
if
(
!
error
)
...
@@ -135,7 +154,17 @@ int my_lock(File fd, int locktype, my_off_t start, my_off_t length,
...
@@ -135,7 +154,17 @@ int my_lock(File fd, int locktype, my_off_t start, my_off_t length,
}
}
#else
#else
if
(
MyFlags
&
MY_SEEK_NOT_DONE
)
if
(
MyFlags
&
MY_SEEK_NOT_DONE
)
VOID
(
my_seek
(
fd
,
start
,
MY_SEEK_SET
,
MYF
(
MyFlags
&
~
MY_SEEK_NOT_DONE
)));
{
if
(
my_seek
(
fd
,
start
,
MY_SEEK_SET
,
MYF
(
MyFlags
&
~
MY_SEEK_NOT_DONE
))
==
MY_FILEPOS_ERROR
)
{
/*
If an error has occured in my_seek then we will already
have an error code in my_errno; Just return error code.
*/
DBUG_RETURN
(
-
1
);
}
}
if
(
lockf
(
fd
,
locktype
,
length
)
!=
-
1
)
if
(
lockf
(
fd
,
locktype
,
length
)
!=
-
1
)
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
#endif
/* HAVE_FCNTL */
#endif
/* HAVE_FCNTL */
...
...
mysys/my_seek.c
View file @
5f2424ea
...
@@ -16,8 +16,30 @@
...
@@ -16,8 +16,30 @@
#include "mysys_priv.h"
#include "mysys_priv.h"
/* Seek to position in file */
/*
/*ARGSUSED*/
Seek to a position in a file.
ARGUMENTS
File fd The file descriptor
my_off_t pos The expected position (absolute or relative)
int whence A direction parameter and one of
{SEEK_SET, SEEK_CUR, SEEK_END}
myf MyFlags Not used.
DESCRIPTION
The my_seek function is a wrapper around the system call lseek and
repositions the offset of the file descriptor fd to the argument
offset according to the directive whence as follows:
SEEK_SET The offset is set to offset bytes.
SEEK_CUR The offset is set to its current location plus offset bytes
SEEK_END The offset is set to the size of the file plus offset bytes
RETURN VALUE
my_off_t newpos The new position in the file.
MY_FILEPOS_ERROR An error was encountered while performing
the seek. my_errno is set to indicate the
actual error.
*/
my_off_t
my_seek
(
File
fd
,
my_off_t
pos
,
int
whence
,
my_off_t
my_seek
(
File
fd
,
my_off_t
pos
,
int
whence
,
myf
MyFlags
__attribute__
((
unused
)))
myf
MyFlags
__attribute__
((
unused
)))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment