Hello Sanja,
On Fri, Mar 07, 2008 at 11:32:09PM +0200, sanja@stripped wrote:
> ChangeSet@stripped, 2008-03-07 23:32:04+02:00, bell@stripped +1 -0
> Maria's usage of my_stat() is unreliable on Windows. (BUG#35036)
> %llu replaces with %s/llstr() as in other MySQL code.
>
> storage/maria/ma_loghandler.c@stripped, 2008-03-07 23:32:00+02:00,
> bell@stripped +58 -16
> my_stat is not reliable under windows for determinating file
> length so it is replaced with my_seek.
> %llu replaces with %s/llstr() as in other MySQL code.
>
> diff -Nrup a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c
> --- a/storage/maria/ma_loghandler.c 2008-02-29 13:11:24 +02:00
> +++ b/storage/maria/ma_loghandler.c 2008-03-07 23:32:00 +02:00
> @@ -2981,23 +2988,52 @@ static my_bool translog_get_last_page_ad
> my_bool *last_page_ok,
> my_bool no_errors)
> {
> - MY_STAT stat_buff, *local_stat;
> char path[FN_REFLEN];
> - uint32 rec_offset, file_size;
> + uint32 rec_offset;
> + my_off_t file_size;
> uint32 file_no= LSN_FILE_NO(*addr);
> + TRANSLOG_FILE *file;
> +#ifndef DBUG_OFF
> + char buff[21];
> +#endif
> DBUG_ENTER("translog_get_last_page_addr");
>
> - if (!(local_stat= my_stat(translog_filename_by_fileno(file_no, path),
> - &stat_buff,
> - (no_errors ? MYF(0) : MYF(MY_WME)))))
> - DBUG_RETURN(1);
> - DBUG_PRINT("info", ("File size: %lu", (ulong) local_stat->st_size));
> - file_size= (uint32)local_stat->st_size; /* st_size can be 'long' on Windows*/
> - if (file_size > TRANSLOG_PAGE_SIZE)
> + if (likely((file= get_logfile_by_number(file_no)) != NULL))
> {
> - rec_offset= (((file_size / TRANSLOG_PAGE_SIZE) - 1) *
> + /*
> + This function used only during initialization of loghandler or in
> + scanner (which mean we need read that part of the log), so the
> + requested log file have to be opened and can't be freed after
> + returning pointer on it (file_size).
> + */
> + file_size= my_seek(file->handler.file, 0, SEEK_END, MYF(0));
> + }
> + else
> + {
> + /*
> + This branch is used only during very early initialization
> + when files are not opened.
> + */
> + File fd;
> + if ((fd= my_open(translog_filename_by_fileno(file_no, path),
> + O_RDONLY, (no_errors ? MYF(0) : MYF(MY_WME)))) < 0)
> + {
> + my_errno= errno;
> + DBUG_PRINT("error", ("Error %d during opening file #%d",
> + errno, file_no));
> + DBUG_RETURN(1);
> + }
> + file_size= my_seek(fd, 0, SEEK_END, MYF(0));
> + my_close(fd, MYF(0));
> + }
> + DBUG_PRINT("info", ("File size: %s", llstr(file_size, buff)));
> + compile_time_assert(MY_FILEPOS_ERROR > ULL(0xffffffff));
> + DBUG_ASSERT(file_size < ULL(0xffffffff));
> + if (((uint32)file_size) > TRANSLOG_PAGE_SIZE)
> + {
if my_seek() failed, file_size is MY_FILEPOS_ERROR and, in non-debug
builds the assertion will not exist so we will enter this branch which
is not correct.
Please, add some "if MY_FILEPOS_ERROR then return an error" above and
then it's ok to push.
Thanks.
--
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Mr. Guilhem Bichot <guilhem@stripped>
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB, Lead Software Engineer
/_/ /_/\_, /___/\___\_\___/ Bordeaux, France
<___/ www.mysql.com