mirror of
https://github.com/MariaDB/server.git
synced 2026-05-03 13:45:34 +02:00
merge
configure.in: Auto merged include/my_sys.h: Auto merged libmysql/libmysql.c: Auto merged sql/ha_berkeley.cc: Auto merged sql/handler.h: Auto merged sql/item_strfunc.cc: Auto merged sql/lex.h: Auto merged sql/mysqld.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_select.cc: Auto merged sql/sql_string.h: Auto merged BitKeeper/etc/logging_ok: Auto merged
This commit is contained in:
commit
c7d2c59ceb
56 changed files with 1942 additions and 1502 deletions
|
|
@ -26,7 +26,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c\
|
|||
mf_path.c mf_loadpath.c\
|
||||
my_open.c my_create.c my_seek.c my_read.c \
|
||||
my_pread.c my_write.c \
|
||||
mf_reccache.c mf_keycache.c \
|
||||
mf_keycache.c \
|
||||
mf_iocache.c mf_cache.c mf_tempfile.c \
|
||||
my_lock.c mf_brkhant.c my_alarm.c \
|
||||
my_malloc.c my_realloc.c my_once.c mulalloc.c \
|
||||
|
|
|
|||
|
|
@ -374,10 +374,11 @@ my_bool hash_delete(HASH *hash,byte *record)
|
|||
uint blength,pos2,pos_hashnr,lastpos_hashnr,idx,empty_index;
|
||||
HASH_LINK *data,*lastpos,*gpos,*pos,*pos3,*empty;
|
||||
DBUG_ENTER("hash_delete");
|
||||
if (!hash->records)
|
||||
DBUG_RETURN(1);
|
||||
|
||||
blength=hash->blength;
|
||||
data=dynamic_element(&hash->array,0,HASH_LINK*);
|
||||
|
||||
/* Search after record with key */
|
||||
pos=data+ hash_mask(rec_hashnr(hash,record),blength,hash->records);
|
||||
gpos = 0;
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ my_bool open_cached_file(IO_CACHE *cache, const char* dir, const char *prefix,
|
|||
}
|
||||
my_free(cache->dir, MYF(MY_ALLOW_ZERO_PTR));
|
||||
my_free(cache->prefix,MYF(MY_ALLOW_ZERO_PTR));
|
||||
DBUG_RETURN(0);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
/* Create the temporary file */
|
||||
|
|
@ -101,10 +101,12 @@ void close_cached_file(IO_CACHE *cache)
|
|||
DBUG_ENTER("close_cached_file");
|
||||
if (my_b_inited(cache))
|
||||
{
|
||||
File file=cache->file;
|
||||
cache->file= -1; /* Don't flush data */
|
||||
(void) end_io_cache(cache);
|
||||
if (cache->file >= 0)
|
||||
if (file >= 0)
|
||||
{
|
||||
(void) my_close(cache->file,MYF(0));
|
||||
(void) my_close(file,MYF(0));
|
||||
#ifdef CANT_DELETE_OPEN_FILES
|
||||
if (cache->file_name)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,10 +22,13 @@
|
|||
(and get a EOF-error).
|
||||
Possibly use of asyncronic io.
|
||||
macros for read and writes for faster io.
|
||||
Used instead of FILE when reading or writing hole files.
|
||||
This shall make mf_rec_cache obsolite.
|
||||
One can change info->pos_in_file to a higer value to skipp bytes in file if
|
||||
Used instead of FILE when reading or writing whole files.
|
||||
This will make mf_rec_cache obsolete.
|
||||
One can change info->pos_in_file to a higher value to skip bytes in file if
|
||||
also info->rc_pos is set to info->rc_end.
|
||||
If called through open_cached_file(), then the temporary file will
|
||||
only be created if a write exeeds the file buffer or if one calls
|
||||
flush_io_cache().
|
||||
*/
|
||||
|
||||
#define MAP_TO_USE_RAID
|
||||
|
|
@ -40,7 +43,7 @@ static void my_aiowait(my_aio_result *result);
|
|||
|
||||
/*
|
||||
** if cachesize == 0 then use default cachesize (from s-file)
|
||||
** if file == -1 then real_open_cached_file() will be called to
|
||||
** if file == -1 then real_open_cached_file() will be called.
|
||||
** returns 0 if ok
|
||||
*/
|
||||
|
||||
|
|
@ -59,17 +62,24 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize,
|
|||
min_cache=use_async_io ? IO_SIZE*4 : IO_SIZE*2;
|
||||
if (type == READ_CACHE)
|
||||
{ /* Assume file isn't growing */
|
||||
my_off_t file_pos,end_of_file;
|
||||
if ((file_pos=my_tell(file,MYF(0)) == MY_FILEPOS_ERROR))
|
||||
DBUG_RETURN(1);
|
||||
end_of_file=my_seek(file,0L,MY_SEEK_END,MYF(0));
|
||||
if (end_of_file < seek_offset)
|
||||
end_of_file=seek_offset;
|
||||
VOID(my_seek(file,file_pos,MY_SEEK_SET,MYF(0)));
|
||||
if ((my_off_t) cachesize > end_of_file-seek_offset+IO_SIZE*2-1)
|
||||
if (cache_myflags & MY_DONT_CHECK_FILESIZE)
|
||||
{
|
||||
cachesize=(uint) (end_of_file-seek_offset)+IO_SIZE*2-1;
|
||||
use_async_io=0; /* No nead to use async */
|
||||
cache_myflags &= ~MY_DONT_CHECK_FILESIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
my_off_t file_pos,end_of_file;
|
||||
if ((file_pos=my_tell(file,MYF(0)) == MY_FILEPOS_ERROR))
|
||||
DBUG_RETURN(1);
|
||||
end_of_file=my_seek(file,0L,MY_SEEK_END,MYF(0));
|
||||
if (end_of_file < seek_offset)
|
||||
end_of_file=seek_offset;
|
||||
VOID(my_seek(file,file_pos,MY_SEEK_SET,MYF(0)));
|
||||
if ((my_off_t) cachesize > end_of_file-seek_offset+IO_SIZE*2-1)
|
||||
{
|
||||
cachesize=(uint) (end_of_file-seek_offset)+IO_SIZE*2-1;
|
||||
use_async_io=0; /* No nead to use async */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -545,7 +555,6 @@ int my_block_write(register IO_CACHE *info, const byte *Buffer, uint Count,
|
|||
return error;
|
||||
}
|
||||
|
||||
|
||||
/* Flush write cache */
|
||||
|
||||
int flush_io_cache(IO_CACHE *info)
|
||||
|
|
@ -565,7 +574,9 @@ int flush_io_cache(IO_CACHE *info)
|
|||
length=(uint) (info->rc_pos - info->buffer);
|
||||
if (info->seek_not_done)
|
||||
{ /* File touched, do seek */
|
||||
VOID(my_seek(info->file,info->pos_in_file,MY_SEEK_SET,MYF(0)));
|
||||
if (my_seek(info->file,info->pos_in_file,MY_SEEK_SET,MYF(0)) ==
|
||||
MY_FILEPOS_ERROR)
|
||||
DBUG_RETURN((info->error= -1));
|
||||
info->seek_not_done=0;
|
||||
}
|
||||
info->rc_pos=info->buffer;
|
||||
|
|
|
|||
|
|
@ -21,74 +21,49 @@
|
|||
#include <stdarg.h>
|
||||
#include <m_ctype.h>
|
||||
|
||||
|
||||
|
||||
int my_vsnprintf(char* str, size_t n, const char* fmt, va_list ap)
|
||||
int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap)
|
||||
{
|
||||
uint olen = 0, plen;
|
||||
const char *tpos;
|
||||
reg1 char *endpos;
|
||||
reg2 char * par;
|
||||
char* ebuff = str;
|
||||
|
||||
endpos=ebuff;
|
||||
tpos = fmt;
|
||||
char *start=to, *end=to+n-1;
|
||||
|
||||
while (*tpos)
|
||||
for (; *fmt ; fmt++)
|
||||
{
|
||||
if (tpos[0] != '%')
|
||||
if (fmt[0] != '%')
|
||||
{
|
||||
if(olen + 1 >= n)
|
||||
if (to == end) /* End of buffer */
|
||||
break;
|
||||
|
||||
*endpos++= *tpos++; /* Copy ordinary char */
|
||||
olen++;
|
||||
*to++= *fmt; /* Copy ordinary char */
|
||||
continue;
|
||||
}
|
||||
if (*++tpos == '%') /* test if %% */
|
||||
/* Skipp if max size is used (to be compatible with printf) */
|
||||
while (isdigit(*fmt) || *fmt == '.' || *fmt == '-')
|
||||
fmt++;
|
||||
if (*fmt == 's') /* String parameter */
|
||||
{
|
||||
olen--;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Skipp if max size is used (to be compatible with printf) */
|
||||
while (isdigit(*tpos) || *tpos == '.' || *tpos == '-')
|
||||
tpos++;
|
||||
if (*tpos == 's') /* String parameter */
|
||||
reg2 char *par = va_arg(ap, char *);
|
||||
uint plen = (uint) strlen(par);
|
||||
if ((uint) (end-to) > plen) /* Replace if possible */
|
||||
{
|
||||
par = va_arg(ap, char *);
|
||||
plen = (uint) strlen(par);
|
||||
if (olen + plen < n) /* Replace if possible */
|
||||
{
|
||||
endpos=strmov(endpos,par);
|
||||
tpos++;
|
||||
olen+=plen;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (*tpos == 'd' || *tpos == 'u') /* Integer parameter */
|
||||
{
|
||||
register int iarg;
|
||||
iarg = va_arg(ap, int);
|
||||
if(olen + 16 >= n) break;
|
||||
|
||||
if (*tpos == 'd')
|
||||
plen= (uint) (int2str((long) iarg,endpos, -10) - endpos);
|
||||
else
|
||||
plen= (uint) (int2str((long) (uint) iarg,endpos,10)- endpos);
|
||||
if (olen + plen < n) /* Replace parameter if possible */
|
||||
{
|
||||
endpos+=plen;
|
||||
tpos++;
|
||||
olen+=plen;
|
||||
continue;
|
||||
}
|
||||
to=strmov(to,par);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
*endpos++='%'; /* % used as % or unknown code */
|
||||
else if (*fmt == 'd' || *fmt == 'u') /* Integer parameter */
|
||||
{
|
||||
register int iarg;
|
||||
if ((uint) (end-to) < 16)
|
||||
break;
|
||||
iarg = va_arg(ap, int);
|
||||
if (*fmt == 'd')
|
||||
to=int10_to_str((long) iarg,to, -10);
|
||||
else
|
||||
to=int10_to_str((long) (uint) iarg,to,10);
|
||||
continue;
|
||||
}
|
||||
/* We come here on '%%', unknown code or too long parameter */
|
||||
if (to == end)
|
||||
break;
|
||||
*to++='%'; /* % used as % or unknown code */
|
||||
}
|
||||
*endpos='\0';
|
||||
/* End of errmessage */
|
||||
return olen;
|
||||
*to='\0'; /* End of errmessage */
|
||||
return (uint) (to - start);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue