2222 (and get a EOF-error).
2323 Possibly use of asyncronic io.
2424 macros for read and writes for faster io.
25- Used instead of FILE when reading or writing hole files.
26- This shall make mf_rec_cache obsolite .
27- One can change info->pos_in_file to a higer value to skipp bytes in file if
25+ Used instead of FILE when reading or writing whole files.
26+ This will make mf_rec_cache obsolete .
27+ One can change info->pos_in_file to a higher value to skip bytes in file if
2828 also info->rc_pos is set to info->rc_end.
29+ If called through open_cached_file(), then the temporary file will
30+ only be created if a write exeeds the file buffer or if one calls
31+ flush_io_cache().
2932*/
3033
3134#define MAP_TO_USE_RAID
@@ -40,7 +43,7 @@ static void my_aiowait(my_aio_result *result);
4043
4144 /*
4245 ** if cachesize == 0 then use default cachesize (from s-file)
43- ** if file == -1 then real_open_cached_file() will be called to
46+ ** if file == -1 then real_open_cached_file() will be called.
4447 ** returns 0 if ok
4548 */
4649
@@ -59,17 +62,24 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize,
5962 min_cache = use_async_io ? IO_SIZE * 4 : IO_SIZE * 2 ;
6063 if (type == READ_CACHE )
6164 { /* Assume file isn't growing */
62- my_off_t file_pos ,end_of_file ;
63- if ((file_pos = my_tell (file ,MYF (0 )) == MY_FILEPOS_ERROR ))
64- DBUG_RETURN (1 );
65- end_of_file = my_seek (file ,0L ,MY_SEEK_END ,MYF (0 ));
66- if (end_of_file < seek_offset )
67- end_of_file = seek_offset ;
68- VOID (my_seek (file ,file_pos ,MY_SEEK_SET ,MYF (0 )));
69- if ((my_off_t ) cachesize > end_of_file - seek_offset + IO_SIZE * 2 - 1 )
65+ if (cache_myflags & MY_DONT_CHECK_FILESIZE )
7066 {
71- cachesize = (uint ) (end_of_file - seek_offset )+ IO_SIZE * 2 - 1 ;
72- use_async_io = 0 ; /* No nead to use async */
67+ cache_myflags &= ~MY_DONT_CHECK_FILESIZE ;
68+ }
69+ else
70+ {
71+ my_off_t file_pos ,end_of_file ;
72+ if ((file_pos = my_tell (file ,MYF (0 )) == MY_FILEPOS_ERROR ))
73+ DBUG_RETURN (1 );
74+ end_of_file = my_seek (file ,0L ,MY_SEEK_END ,MYF (0 ));
75+ if (end_of_file < seek_offset )
76+ end_of_file = seek_offset ;
77+ VOID (my_seek (file ,file_pos ,MY_SEEK_SET ,MYF (0 )));
78+ if ((my_off_t ) cachesize > end_of_file - seek_offset + IO_SIZE * 2 - 1 )
79+ {
80+ cachesize = (uint ) (end_of_file - seek_offset )+ IO_SIZE * 2 - 1 ;
81+ use_async_io = 0 ; /* No nead to use async */
82+ }
7383 }
7484 }
7585
@@ -545,7 +555,6 @@ int my_block_write(register IO_CACHE *info, const byte *Buffer, uint Count,
545555 return error ;
546556}
547557
548-
549558 /* Flush write cache */
550559
551560int flush_io_cache (IO_CACHE * info )
@@ -565,7 +574,9 @@ int flush_io_cache(IO_CACHE *info)
565574 length = (uint ) (info -> rc_pos - info -> buffer );
566575 if (info -> seek_not_done )
567576 { /* File touched, do seek */
568- VOID (my_seek (info -> file ,info -> pos_in_file ,MY_SEEK_SET ,MYF (0 )));
577+ if (my_seek (info -> file ,info -> pos_in_file ,MY_SEEK_SET ,MYF (0 )) ==
578+ MY_FILEPOS_ERROR )
579+ DBUG_RETURN ((info -> error = -1 ));
569580 info -> seek_not_done = 0 ;
570581 }
571582 info -> rc_pos = info -> buffer ;
0 commit comments