Skip to content

Commit e69becf

Browse files
changed to use IO_CACHE instead of FILE
1 parent 7a01333 commit e69becf

24 files changed

+816
-821
lines changed

BitKeeper/etc/logging_ok

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
monty@tik.mysql.com
1+
monty@narttu.mysql.fi

Docs/manual.texi

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3610,10 +3610,13 @@ similar system. In the worst case, we may require access to your system
36103610
to be able to create a binary distribution.
36113611

36123612
@item
3613-
If you can provide accommodations and pay for traveler fares, you can even
3614-
get a @strong{MySQL} developer to visit you and offer you help with your
3615-
troubles. Extended login support entitles you to one personal
3616-
encounter per year, but we are always very flexible towards our customers!
3613+
If you can provide accommodations and pay for traveler fares, you can
3614+
even get a @strong{MySQL} developer to visit you and offer you help with
3615+
your troubles. Extended login support entitles you to one personal
3616+
encounter per year, but we are always very flexible towards our
3617+
customers! If the visit takes 16 hours or more, the first 8 hours is
3618+
without charge. For the hours above 8 hours, you will be charged with a
3619+
rate that is at least 20 % less than our standard rates.
36173620
@end itemize
36183621

36193622
@node Installing, Compatibility, Licensing and Support, Top
@@ -38367,6 +38370,9 @@ though, so 3.23 is not released as a stable version yet.
3836738370
@appendixsubsec Changes in release 3.23.28
3836838371
@itemize @bullet
3836938372
@item
38373+
Changed all log files to use our own IO_CACHE mechanism instead of
38374+
FILE:s to avoid OS problems when there is many files open.
38375+
@item
3837038376
Added options @code{--open-files} and @code{--timezone} to @code{safe_mysqld}.
3837138377
@item
3837238378
Fixed fatal bug in @code{CREATE TEMPORARY TABLE ...SELECT ...}.

client/mysqlimport.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
** * *
2626
** *************************
2727
*/
28-
#define IMPORT_VERSION "2.5"
28+
#define IMPORT_VERSION "2.6"
2929

3030
#include <global.h>
3131
#include <my_sys.h>
@@ -125,7 +125,7 @@ file. The SQL command 'LOAD DATA INFILE' is used to import the rows.\n");
125125
Give the column names in a comma separated list.\n\
126126
This is same as giving columns to LOAD DATA INFILE.\n\
127127
-C, --compress Use compression in server/client protocol\n\
128-
-d, --delete Deletes first all rows from table.\n\
128+
-d, --delete First delete all rows from table.\n\
129129
-f, --force Continue even if we get an sql-error.\n\
130130
-h, --host=... Connect to host.\n\
131131
-i, --ignore If duplicate unique key was found, keep old row.\n\

client/sql_string.cc

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,6 @@ bool String::realloc(uint32 alloc_length)
9595
return FALSE;
9696
}
9797

98-
99-
#ifdef NOT_NEEDED
100-
bool String::set(long num)
101-
{
102-
if (alloc(14))
103-
return TRUE;
104-
str_length=(uint32) (int10_to_str(num,Ptr,-10)-Ptr);
105-
return FALSE;
106-
}
107-
#endif
108-
10998
bool String::set(longlong num)
11099
{
111100
if (alloc(21))
@@ -274,6 +263,7 @@ bool String::append(const char *s,uint32 arg_length)
274263
return FALSE;
275264
}
276265

266+
#ifdef TO_BE_REMOVED
277267
bool String::append(FILE* file, uint32 arg_length, myf my_flags)
278268
{
279269
if (realloc(str_length+arg_length))
@@ -286,6 +276,20 @@ bool String::append(FILE* file, uint32 arg_length, myf my_flags)
286276
str_length+=arg_length;
287277
return FALSE;
288278
}
279+
#endif
280+
281+
bool String::append(IO_CACHE* file, uint32 arg_length)
282+
{
283+
if (realloc(str_length+arg_length))
284+
return TRUE;
285+
if (my_b_read(file, (byte*) Ptr + str_length, arg_length))
286+
{
287+
shrink(str_length);
288+
return TRUE;
289+
}
290+
str_length+=arg_length;
291+
return FALSE;
292+
}
289293

290294
uint32 String::numchars()
291295
{

client/sql_string.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,16 @@ class String
100100
bool set(ulonglong num);
101101
bool set(double num,uint decimals=2);
102102
inline void free()
103+
{
104+
if (alloced)
103105
{
104-
if (alloced)
105-
{
106-
alloced=0;
107-
Alloced_length=0;
108-
my_free(Ptr,MYF(0));
109-
Ptr=0;
110-
}
106+
alloced=0;
107+
Alloced_length=0;
108+
my_free(Ptr,MYF(0));
109+
Ptr=0;
110+
str_length=0; /* Safety */
111111
}
112-
112+
}
113113
inline bool alloc(uint32 arg_length)
114114
{
115115
if (arg_length < Alloced_length)
@@ -152,7 +152,7 @@ class String
152152
bool copy(const char *s,uint32 arg_length); // Allocate new string
153153
bool append(const String &s);
154154
bool append(const char *s,uint32 arg_length=0);
155-
bool append(FILE* file, uint32 arg_length, myf my_flags);
155+
bool append(IO_CACHE* file, uint32 arg_length);
156156
int strstr(const String &search,uint32 offset=0); // Returns offset to substring or -1
157157
int strrstr(const String &search,uint32 offset=0); // Returns offset to substring or -1
158158
bool replace(uint32 offset,uint32 arg_length,const String &to);

include/my_sys.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ extern int NEAR my_errno; /* Last error in mysys */
5959
#define MY_WME 16 /* Write message on error */
6060
#define MY_WAIT_IF_FULL 32 /* Wait and try again if disk full error */
6161
#define MY_RAID 64 /* Support for RAID (not the "Johnson&Johnson"-s one ;) */
62+
#define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */
6263
#define MY_LINK_WARNING 32 /* my_redel() gives warning if links */
6364
#define MY_COPYTIME 64 /* my_redel() copys time */
6465
#define MY_HOLD_ORIGINAL_MODES 128 /* my_copy() holds to file modes */
@@ -505,6 +506,10 @@ extern int my_block_write(IO_CACHE *info, const byte *Buffer,
505506
uint Count, my_off_t pos);
506507
extern int flush_io_cache(IO_CACHE *info);
507508
extern int end_io_cache(IO_CACHE *info);
509+
extern uint my_b_fill(IO_CACHE *info);
510+
extern void my_b_seek(IO_CACHE *info,my_off_t pos);
511+
extern uint my_b_gets(IO_CACHE *info, char *to, uint max_length);
512+
extern uint my_b_printf(IO_CACHE *info, const char* fmt, ...);
508513
extern my_bool open_cached_file(IO_CACHE *cache,const char *dir,
509514
const char *prefix, uint cache_size,
510515
myf cache_myflags);

mysql.proj

8 KB
Binary file not shown.

mysys/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c\
2626
mf_path.c mf_loadpath.c\
2727
my_open.c my_create.c my_seek.c my_read.c \
2828
my_pread.c my_write.c \
29-
mf_reccache.c mf_keycache.c \
29+
mf_keycache.c \
3030
mf_iocache.c mf_cache.c mf_tempfile.c \
3131
my_lock.c mf_brkhant.c my_alarm.c \
3232
my_malloc.c my_realloc.c my_once.c mulalloc.c \

mysys/mf_cache.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ my_bool open_cached_file(IO_CACHE *cache, const char* dir, const char *prefix,
7474
}
7575
my_free(cache->dir, MYF(MY_ALLOW_ZERO_PTR));
7676
my_free(cache->prefix,MYF(MY_ALLOW_ZERO_PTR));
77-
DBUG_RETURN(0);
77+
DBUG_RETURN(1);
7878
}
7979

8080
/* Create the temporary file */
@@ -101,10 +101,12 @@ void close_cached_file(IO_CACHE *cache)
101101
DBUG_ENTER("close_cached_file");
102102
if (my_b_inited(cache))
103103
{
104+
File file=cache->file;
105+
cache->file= -1; /* Don't flush data */
104106
(void) end_io_cache(cache);
105-
if (cache->file >= 0)
107+
if (file >= 0)
106108
{
107-
(void) my_close(cache->file,MYF(0));
109+
(void) my_close(file,MYF(0));
108110
#ifdef CANT_DELETE_OPEN_FILES
109111
if (cache->file_name)
110112
{

mysys/mf_iocache.c

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@
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

551560
int 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

Comments
 (0)