Commit 309d691e authored by monty@mysql.com's avatar monty@mysql.com

Changed %lx -> 0x%lx (for easier comparison of debug files)

Cosmetic cleanups
Don't call 'delete_elements' on copy_funcs as this causes elements to be freed twice
parent 84d9b862
......@@ -52,7 +52,7 @@ _hash_init(HASH *hash,CHARSET_INFO *charset,
void (*free_element)(void*),uint flags CALLER_INFO_PROTO)
{
DBUG_ENTER("hash_init");
DBUG_PRINT("enter",("hash: %lx size: %d",hash,size));
DBUG_PRINT("enter",("hash: 0x%lx size: %d",hash,size));
hash->records=0;
if (my_init_dynamic_array_ci(&hash->array,sizeof(HASH_LINK),size,0))
......@@ -565,7 +565,7 @@ my_bool hash_check(HASH *hash)
if ((rec_link=hash_rec_mask(hash,hash_info,blength,records)) != i)
{
DBUG_PRINT("error",
("Record in wrong link at %d: Start %d Record: %lx Record-link %d", idx,i,hash_info->data,rec_link));
("Record in wrong link at %d: Start %d Record: 0x%lx Record-link %d", idx,i,hash_info->data,rec_link));
error=1;
}
else
......
......@@ -28,7 +28,7 @@
LIST *list_add(LIST *root, LIST *element)
{
DBUG_ENTER("list_add");
DBUG_PRINT("enter",("root: %lx element: %lx", root, element));
DBUG_PRINT("enter",("root: 0x%lx element: %lx", root, element));
if (root)
{
if (root->prev) /* If add in mid of list */
......
......@@ -140,7 +140,7 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize,
uint min_cache;
my_off_t end_of_file= ~(my_off_t) 0;
DBUG_ENTER("init_io_cache");
DBUG_PRINT("enter",("cache: %lx type: %d pos: %ld",
DBUG_PRINT("enter",("cache: 0x%lx type: %d pos: %ld",
(ulong) info, (int) type, (ulong) seek_offset));
info->file= file;
......@@ -290,7 +290,7 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type,
pbool clear_cache)
{
DBUG_ENTER("reinit_io_cache");
DBUG_PRINT("enter",("cache: %lx type: %d seek_offset: %lu clear_cache: %d",
DBUG_PRINT("enter",("cache: 0x%lx type: %d seek_offset: %lu clear_cache: %d",
(ulong) info, type, (ulong) seek_offset,
(int) clear_cache));
......
......@@ -401,8 +401,8 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size,
keycache->waiting_for_hash_link.last_thread= NULL;
keycache->waiting_for_block.last_thread= NULL;
DBUG_PRINT("exit",
("disk_blocks: %d block_root: %lx hash_entries: %d\
hash_root: %lx hash_links: %d hash_link_root %lx",
("disk_blocks: %d block_root: 0x%lx hash_entries: %d\
hash_root: 0x%lx hash_links: %d hash_link_root: 0x%lx",
keycache->disk_blocks, keycache->block_root,
keycache->hash_entries, keycache->hash_root,
keycache->hash_links, keycache->hash_link_root));
......@@ -596,7 +596,7 @@ void change_key_cache_param(KEY_CACHE *keycache, uint division_limit,
void end_key_cache(KEY_CACHE *keycache, my_bool cleanup)
{
DBUG_ENTER("end_key_cache");
DBUG_PRINT("enter", ("key_cache: %lx", keycache));
DBUG_PRINT("enter", ("key_cache: 0x%lx", keycache));
if (!keycache->key_cache_inited)
DBUG_VOID_RETURN;
......@@ -1109,7 +1109,7 @@ static inline void link_hash(HASH_LINK **start, HASH_LINK *hash_link)
static void unlink_hash(KEY_CACHE *keycache, HASH_LINK *hash_link)
{
KEYCACHE_DBUG_PRINT("unlink_hash", ("file %u, filepos %lu #requests=%u",
KEYCACHE_DBUG_PRINT("unlink_hash", ("fd: %u pos_ %lu #requests=%u",
(uint) hash_link->file,(ulong) hash_link->diskpos, hash_link->requests));
KEYCACHE_DBUG_ASSERT(hash_link->requests == 0);
if ((*hash_link->prev= hash_link->next))
......@@ -1167,7 +1167,7 @@ static HASH_LINK *get_hash_link(KEY_CACHE *keycache,
int cnt;
#endif
KEYCACHE_DBUG_PRINT("get_hash_link", ("file %u, filepos %lu",
KEYCACHE_DBUG_PRINT("get_hash_link", ("fd: %u pos: %lu",
(uint) file,(ulong) filepos));
restart:
......@@ -1193,7 +1193,7 @@ static HASH_LINK *get_hash_link(KEY_CACHE *keycache,
for (i=0, hash_link= *start ;
i < cnt ; i++, hash_link= hash_link->next)
{
KEYCACHE_DBUG_PRINT("get_hash_link", ("file %u, filepos %lu",
KEYCACHE_DBUG_PRINT("get_hash_link", ("fd: %u pos: %lu",
(uint) hash_link->file,(ulong) hash_link->diskpos));
}
}
......@@ -1285,10 +1285,11 @@ static BLOCK_LINK *find_key_block(KEY_CACHE *keycache,
DBUG_ENTER("find_key_block");
KEYCACHE_THREAD_TRACE("find_key_block:begin");
DBUG_PRINT("enter", ("file %u, filepos %lu, wrmode %lu",
(uint) file, (ulong) filepos, (uint) wrmode));
KEYCACHE_DBUG_PRINT("find_key_block", ("file %u, filepos %lu, wrmode %lu",
(uint) file, (ulong) filepos, (uint) wrmode));
DBUG_PRINT("enter", ("fd: %u pos %lu wrmode: %lu",
(uint) file, (ulong) filepos, (uint) wrmode));
KEYCACHE_DBUG_PRINT("find_key_block", ("fd: %u pos: %lu wrmode: %lu",
(uint) file, (ulong) filepos,
(uint) wrmode));
#if !defined(DBUG_OFF) && defined(EXTRA_DEBUG)
DBUG_EXECUTE("check_keycache2",
test_key_cache(keycache, "start of find_key_block", 0););
......@@ -1542,7 +1543,7 @@ static BLOCK_LINK *find_key_block(KEY_CACHE *keycache,
KEYCACHE_DBUG_ASSERT(page_status != -1);
*page_st=page_status;
KEYCACHE_DBUG_PRINT("find_key_block",
("file %u, filepos %lu, page_status %lu",
("fd: %u pos %lu page_status %lu",
(uint) file,(ulong) filepos,(uint) page_status));
#if !defined(DBUG_OFF) && defined(EXTRA_DEBUG)
......@@ -1678,7 +1679,7 @@ byte *key_cache_read(KEY_CACHE *keycache,
uint offset= 0;
byte *start= buff;
DBUG_ENTER("key_cache_read");
DBUG_PRINT("enter", ("file %u, filepos %lu, length %u",
DBUG_PRINT("enter", ("fd: %u pos: %lu length: %u",
(uint) file, (ulong) filepos, length));
if (keycache->can_be_used)
......@@ -1814,7 +1815,7 @@ int key_cache_insert(KEY_CACHE *keycache,
byte *buff, uint length)
{
DBUG_ENTER("key_cache_insert");
DBUG_PRINT("enter", ("file %u, filepos %lu, length %u",
DBUG_PRINT("enter", ("fd: %u pos: %lu length: %u",
(uint) file,(ulong) filepos, length));
if (keycache->can_be_used)
......@@ -1926,7 +1927,7 @@ int key_cache_write(KEY_CACHE *keycache,
int error=0;
DBUG_ENTER("key_cache_write");
DBUG_PRINT("enter",
("file %u filepos %lu length %u block_length %u key_block_length: %u",
("fd: %u pos: %lu length: %u block_length: %u key_block_length: %u",
(uint) file, (ulong) filepos, length, block_length,
keycache ? keycache->key_cache_block_size : 0));
......@@ -2396,7 +2397,7 @@ int flush_key_blocks(KEY_CACHE *keycache,
{
int res;
DBUG_ENTER("flush_key_blocks");
DBUG_PRINT("enter", ("keycache: %lx", keycache));
DBUG_PRINT("enter", ("keycache: 0x%lx", keycache));
if (keycache->disk_blocks <= 0)
DBUG_RETURN(0);
......
......@@ -159,7 +159,7 @@ static byte *safe_hash_search(SAFE_HASH *hash, const byte *key, uint length)
result= hash->default_value;
else
result= ((SAFE_HASH_ENTRY*) result)->data;
DBUG_PRINT("exit",("data: %lx", result));
DBUG_PRINT("exit",("data: 0x%lx", result));
DBUG_RETURN(result);
}
......@@ -190,7 +190,7 @@ static my_bool safe_hash_set(SAFE_HASH *hash, const byte *key, uint length,
SAFE_HASH_ENTRY *entry;
my_bool error= 0;
DBUG_ENTER("safe_hash_set");
DBUG_PRINT("enter",("key: %.*s data: %lx", length, key, data));
DBUG_PRINT("enter",("key: %.*s data: 0x%lx", length, key, data));
rw_wrlock(&hash->mutex);
entry= (SAFE_HASH_ENTRY*) hash_search(&hash->hash, key, length);
......
......@@ -26,7 +26,7 @@ void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
uint pre_alloc_size __attribute__((unused)))
{
DBUG_ENTER("init_alloc_root");
DBUG_PRINT("enter",("root: %lx", mem_root));
DBUG_PRINT("enter",("root: 0x%lx", mem_root));
mem_root->free= mem_root->used= mem_root->pre_alloc= 0;
mem_root->min_malloc= 32;
mem_root->block_size= block_size-MALLOC_OVERHEAD-sizeof(USED_MEM)-8;
......@@ -121,7 +121,7 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
#if defined(HAVE_purify) && defined(EXTRA_DEBUG)
reg1 USED_MEM *next;
DBUG_ENTER("alloc_root");
DBUG_PRINT("enter",("root: %lx", mem_root));
DBUG_PRINT("enter",("root: 0x%lx", mem_root));
Size+=ALIGN_SIZE(sizeof(USED_MEM));
if (!(next = (USED_MEM*) my_malloc(Size,MYF(MY_WME))))
......@@ -222,7 +222,7 @@ void free_root(MEM_ROOT *root, myf MyFlags)
{
reg1 USED_MEM *next,*old;
DBUG_ENTER("free_root");
DBUG_PRINT("enter",("root: %lx flags: %u", root, (uint) MyFlags));
DBUG_PRINT("enter",("root: 0x%lx flags: %u", root, (uint) MyFlags));
if (!root) /* QQ: Should be deleted */
DBUG_VOID_RETURN; /* purecov: inspected */
......
......@@ -54,7 +54,7 @@ FILE *my_fopen(const char *FileName, int Flags, myf MyFlags)
my_stream_opened++;
my_file_info[fileno(fd)].type = STREAM_BY_FOPEN;
pthread_mutex_unlock(&THR_LOCK_open);
DBUG_PRINT("exit",("stream: %lx",fd));
DBUG_PRINT("exit",("stream: 0x%lx",fd));
DBUG_RETURN(fd);
}
pthread_mutex_unlock(&THR_LOCK_open);
......@@ -78,7 +78,7 @@ int my_fclose(FILE *fd, myf MyFlags)
{
int err,file;
DBUG_ENTER("my_fclose");
DBUG_PRINT("my",("stream: %lx MyFlags: %d",fd, MyFlags));
DBUG_PRINT("my",("stream: 0x%lx MyFlags: %d",fd, MyFlags));
pthread_mutex_lock(&THR_LOCK_open);
file=fileno(fd);
......@@ -138,7 +138,7 @@ FILE *my_fdopen(File Filedes, const char *name, int Flags, myf MyFlags)
pthread_mutex_unlock(&THR_LOCK_open);
}
DBUG_PRINT("exit",("stream: %lx",fd));
DBUG_PRINT("exit",("stream: 0x%lx",fd));
DBUG_RETURN(fd);
} /* my_fdopen */
......
......@@ -39,7 +39,7 @@ uint my_fread(FILE *stream, byte *Buffer, uint Count, myf MyFlags)
{
uint readbytes;
DBUG_ENTER("my_fread");
DBUG_PRINT("my",("stream: %lx Buffer: %lx Count: %u MyFlags: %d",
DBUG_PRINT("my",("stream: 0x%lx Buffer: 0x%lx Count: %u MyFlags: %d",
stream, Buffer, Count, MyFlags));
if ((readbytes = (uint) fread(Buffer,sizeof(char),(size_t) Count,stream))
......@@ -80,7 +80,7 @@ uint my_fwrite(FILE *stream, const byte *Buffer, uint Count, myf MyFlags)
uint errors;
#endif
DBUG_ENTER("my_fwrite");
DBUG_PRINT("my",("stream: %lx Buffer: %lx Count: %u MyFlags: %d",
DBUG_PRINT("my",("stream: 0x%lx Buffer: 0x%lx Count: %u MyFlags: %d",
stream, Buffer, Count, MyFlags));
#if !defined(NO_BACKGROUND) && defined(USE_MY_STREAM)
......@@ -150,7 +150,7 @@ my_off_t my_fseek(FILE *stream, my_off_t pos, int whence,
myf MyFlags __attribute__((unused)))
{
DBUG_ENTER("my_fseek");
DBUG_PRINT("my",("stream: %lx pos: %lu whence: %d MyFlags: %d",
DBUG_PRINT("my",("stream: 0x%lx pos: %lu whence: %d MyFlags: %d",
stream, pos, whence, MyFlags));
DBUG_RETURN(fseek(stream, (off_t) pos, whence) ?
MY_FILEPOS_ERROR : (my_off_t) ftell(stream));
......@@ -164,7 +164,7 @@ my_off_t my_ftell(FILE *stream, myf MyFlags __attribute__((unused)))
{
off_t pos;
DBUG_ENTER("my_ftell");
DBUG_PRINT("my",("stream: %lx MyFlags: %d",stream, MyFlags));
DBUG_PRINT("my",("stream: 0x%lx MyFlags: %d",stream, MyFlags));
pos=ftell(stream);
DBUG_PRINT("exit",("ftell: %lu",(ulong) pos));
DBUG_RETURN((my_off_t) pos);
......
......@@ -45,7 +45,7 @@ int my_getwd(my_string buf, uint size, myf MyFlags)
{
my_string pos;
DBUG_ENTER("my_getwd");
DBUG_PRINT("my",("buf: %lx size: %d MyFlags %d", buf,size,MyFlags));
DBUG_PRINT("my",("buf: 0x%lx size: %d MyFlags %d", buf,size,MyFlags));
#if ! defined(MSDOS)
if (curr_dir[0]) /* Current pos is saved here */
......
......@@ -624,7 +624,7 @@ MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags)
{
int m_used;
DBUG_ENTER("my_stat");
DBUG_PRINT("my", ("path: '%s', stat_area: %lx, MyFlags: %d", path,
DBUG_PRINT("my", ("path: '%s', stat_area: 0x%lx, MyFlags: %d", path,
(byte *) stat_area, my_flags));
if ((m_used= (stat_area == NULL)))
......
......@@ -23,7 +23,7 @@ uint32 my_lwrite(int Filedes, const byte *Buffer, uint32 Count, myf MyFlags)
{
uint32 writenbytes;
DBUG_ENTER("my_lwrite");
DBUG_PRINT("my",("Fd: %d Buffer: %lx Count: %ld MyFlags: %d",
DBUG_PRINT("my",("Fd: %d Buffer: 0x%lx Count: %ld MyFlags: %d",
Filedes, Buffer, Count, MyFlags));
/* Temp hack to get count to int32 while write wants int */
......
......@@ -44,7 +44,7 @@ gptr my_malloc(unsigned int size, myf my_flags)
}
else if (my_flags & MY_ZEROFILL)
bzero(point,size);
DBUG_PRINT("exit",("ptr: %lx",point));
DBUG_PRINT("exit",("ptr: 0x%lx",point));
DBUG_RETURN(point);
} /* my_malloc */
......@@ -55,7 +55,7 @@ gptr my_malloc(unsigned int size, myf my_flags)
void my_no_flags_free(gptr ptr)
{
DBUG_ENTER("my_free");
DBUG_PRINT("my",("ptr: %lx",ptr));
DBUG_PRINT("my",("ptr: 0x%lx",ptr));
if (ptr)
free(ptr);
DBUG_VOID_RETURN;
......
......@@ -29,7 +29,7 @@ uint my_pread(File Filedes, byte *Buffer, uint Count, my_off_t offset,
uint readbytes;
int error;
DBUG_ENTER("my_pread");
DBUG_PRINT("my",("Fd: %d Seek: %lu Buffer: %lx Count: %u MyFlags: %d",
DBUG_PRINT("my",("Fd: %d Seek: %lu Buffer: 0x%lx Count: %u MyFlags: %d",
Filedes, (ulong) offset, Buffer, Count, MyFlags));
for (;;)
......@@ -82,7 +82,7 @@ uint my_pwrite(int Filedes, const byte *Buffer, uint Count, my_off_t offset,
uint writenbytes,errors;
ulong written;
DBUG_ENTER("my_pwrite");
DBUG_PRINT("my",("Fd: %d Seek: %lu Buffer: %lx Count: %d MyFlags: %d",
DBUG_PRINT("my",("Fd: %d Seek: %lu Buffer: 0x%lx Count: %d MyFlags: %d",
Filedes, (ulong) offset,Buffer, Count, MyFlags));
errors=0; written=0L;
......
......@@ -38,7 +38,7 @@ uint my_read(File Filedes, byte *Buffer, uint Count, myf MyFlags)
{
uint readbytes,save_count;
DBUG_ENTER("my_read");
DBUG_PRINT("my",("Fd: %d Buffer: %lx Count: %u MyFlags: %d",
DBUG_PRINT("my",("Fd: %d Buffer: 0x%lx Count: %u MyFlags: %d",
Filedes, Buffer, Count, MyFlags));
save_count=Count;
......
......@@ -27,7 +27,7 @@ gptr my_realloc(gptr oldpoint, uint size, myf my_flags)
{
gptr point;
DBUG_ENTER("my_realloc");
DBUG_PRINT("my",("ptr: %lx size: %u my_flags: %d",oldpoint, size,
DBUG_PRINT("my",("ptr: 0x%lx size: %u my_flags: %d",oldpoint, size,
my_flags));
if (!oldpoint && (my_flags & MY_ALLOW_ZERO_PTR))
......@@ -60,6 +60,6 @@ gptr my_realloc(gptr oldpoint, uint size, myf my_flags)
my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG), size);
}
#endif
DBUG_PRINT("exit",("ptr: %lx",point));
DBUG_PRINT("exit",("ptr: 0x%lx",point));
DBUG_RETURN(point);
} /* my_realloc */
......@@ -26,7 +26,7 @@ uint my_write(int Filedes, const byte *Buffer, uint Count, myf MyFlags)
uint writenbytes,errors;
ulong written;
DBUG_ENTER("my_write");
DBUG_PRINT("my",("Fd: %d Buffer: %lx Count: %d MyFlags: %d",
DBUG_PRINT("my",("Fd: %d Buffer: 0x%lx Count: %d MyFlags: %d",
Filedes, Buffer, Count, MyFlags));
errors=0; written=0L;
......
......@@ -194,7 +194,7 @@ gptr _mymalloc(uint size, const char *filename, uint lineno, myf MyFlags)
if ((MyFlags & MY_ZEROFILL) || !sf_malloc_quick)
bfill(data, size, (char) (MyFlags & MY_ZEROFILL ? 0 : ALLOC_VAL));
/* Return a pointer to the real data */
DBUG_PRINT("exit",("ptr: %lx", data));
DBUG_PRINT("exit",("ptr: 0x%lx", data));
if (sf_min_adress > data)
sf_min_adress= data;
if (sf_max_adress < data)
......@@ -259,7 +259,7 @@ void _myfree(gptr ptr, const char *filename, uint lineno, myf myflags)
{
struct st_irem *irem;
DBUG_ENTER("_myfree");
DBUG_PRINT("enter",("ptr: %lx", ptr));
DBUG_PRINT("enter",("ptr: 0x%lx", ptr));
if (!sf_malloc_quick)
(void) _sanity (filename, lineno);
......@@ -446,7 +446,7 @@ static int _checkchunk(register struct st_irem *irem, const char *filename,
irem->filename, irem->linenum);
fprintf(stderr, " discovered at %s:%d\n", filename, lineno);
(void) fflush(stderr);
DBUG_PRINT("safe",("Underrun at %lx, allocated at %s:%d",
DBUG_PRINT("safe",("Underrun at 0x%lx, allocated at %s:%d",
data, irem->filename, irem->linenum));
flag=1;
}
......@@ -462,7 +462,7 @@ static int _checkchunk(register struct st_irem *irem, const char *filename,
irem->filename, irem->linenum);
fprintf(stderr, " discovered at '%s:%d'\n", filename, lineno);
(void) fflush(stderr);
DBUG_PRINT("safe",("Overrun at %lx, allocated at %s:%d",
DBUG_PRINT("safe",("Overrun at 0x%lx, allocated at %s:%d",
data,
irem->filename,
irem->linenum));
......
......@@ -257,9 +257,9 @@ void thr_end_alarm(thr_alarm_t *alarmed)
if (!found)
{
if (*alarmed)
fprintf(stderr,"Warning: Didn't find alarm %lx in queue of %d alarms\n",
fprintf(stderr,"Warning: Didn't find alarm 0x%lx in queue of %d alarms\n",
(long) *alarmed, alarm_queue.elements);
DBUG_PRINT("warning",("Didn't find alarm %lx in queue\n",
DBUG_PRINT("warning",("Didn't find alarm 0x%lx in queue\n",
(long) *alarmed));
}
pthread_mutex_unlock(&LOCK_alarm);
......
......@@ -435,7 +435,7 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type)
data->thread=pthread_self(); /* Must be reset ! */
data->thread_id=my_thread_id(); /* Must be reset ! */
VOID(pthread_mutex_lock(&lock->mutex));
DBUG_PRINT("lock",("data: %lx thread: %ld lock: %lx type: %d",
DBUG_PRINT("lock",("data: 0x%lx thread: %ld lock: 0x%lx type: %d",
data,data->thread_id,lock,(int) lock_type));
check_locks(lock,(uint) lock_type <= (uint) TL_READ_NO_INSERT ?
"enter read_lock" : "enter write_lock",0);
......@@ -656,7 +656,7 @@ void thr_unlock(THR_LOCK_DATA *data)
THR_LOCK *lock=data->lock;
enum thr_lock_type lock_type=data->type;
DBUG_ENTER("thr_unlock");
DBUG_PRINT("lock",("data: %lx thread: %ld lock: %lx",
DBUG_PRINT("lock",("data: 0x%lx thread: %ld lock: 0x%lx",
data,data->thread_id,lock));
pthread_mutex_lock(&lock->mutex);
check_locks(lock,"start of release lock",0);
......@@ -827,7 +827,7 @@ int thr_multi_lock(THR_LOCK_DATA **data,uint count)
{
THR_LOCK_DATA **pos,**end;
DBUG_ENTER("thr_multi_lock");
DBUG_PRINT("lock",("data: %lx count: %d",data,count));
DBUG_PRINT("lock",("data: 0x%lx count: %d",data,count));
if (count > 1)
sort_locks(data,count);
/* lock everything */
......@@ -839,7 +839,7 @@ int thr_multi_lock(THR_LOCK_DATA **data,uint count)
DBUG_RETURN(1);
}
#ifdef MAIN
printf("Thread: %s Got lock: %lx type: %d\n",my_thread_name(),
printf("Thread: %s Got lock: 0x%lx type: %d\n",my_thread_name(),
(long) pos[0]->lock, pos[0]->type); fflush(stdout);
#endif
}
......@@ -899,12 +899,12 @@ void thr_multi_unlock(THR_LOCK_DATA **data,uint count)
{
THR_LOCK_DATA **pos,**end;
DBUG_ENTER("thr_multi_unlock");
DBUG_PRINT("lock",("data: %lx count: %d",data,count));
DBUG_PRINT("lock",("data: 0x%lx count: %d",data,count));
for (pos=data,end=data+count; pos < end ; pos++)
{
#ifdef MAIN
printf("Thread: %s Rel lock: %lx type: %d\n",
printf("Thread: %s Rel lock: 0x%lx type: %d\n",
my_thread_name(), (long) pos[0]->lock, pos[0]->type);
fflush(stdout);
#endif
......@@ -912,7 +912,7 @@ void thr_multi_unlock(THR_LOCK_DATA **data,uint count)
thr_unlock(*pos);
else
{
DBUG_PRINT("lock",("Free lock: data: %lx thread: %ld lock: %lx",
DBUG_PRINT("lock",("Free lock: data: 0x%lx thread: %ld lock: 0x%lx",
*pos,(*pos)->thread_id,(*pos)->lock));
}
}
......@@ -1098,7 +1098,7 @@ static void thr_print_lock(const char* name,struct st_lock_list *list)
prev= &list->data;
for (data=list->data; data && count++ < MAX_LOCKS ; data=data->next)
{
printf("%lx (%lu:%d); ",(ulong) data,data->thread_id,(int) data->type);
printf("0x%lx (%lu:%d); ",(ulong) data,data->thread_id,(int) data->type);
if (data->prev != prev)
printf("\nWarning: prev didn't point at previous lock\n");
prev= &data->next;
......@@ -1120,7 +1120,7 @@ void thr_print_locks(void)
{
THR_LOCK *lock=(THR_LOCK*) list->data;
VOID(pthread_mutex_lock(&lock->mutex));
printf("lock: %lx:",(ulong) lock);
printf("lock: 0x%lx:",(ulong) lock);
if ((lock->write_wait.data || lock->read_wait.data) &&
(! lock->read.data && ! lock->write.data))
printf(" WARNING: ");
......
......@@ -210,7 +210,7 @@ int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp, const char *file,
if (mp->count++)
{
fprintf(stderr,
"safe_mutex: Count was %d in thread %lx when locking mutex at %s, line %d\n",
"safe_mutex: Count was %d in thread 0x%lx when locking mutex at %s, line %d\n",
mp->count-1, my_thread_id(), file, line);
fflush(stderr);
abort();
......@@ -248,7 +248,7 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
if (mp->count++)
{
fprintf(stderr,
"safe_mutex: Count was %d in thread %lx when locking mutex at %s, line %d (error: %d (%d))\n",
"safe_mutex: Count was %d in thread 0x%lx when locking mutex at %s, line %d (error: %d (%d))\n",
mp->count-1, my_thread_id(), file, line, error, error);
fflush(stderr);
abort();
......
......@@ -89,7 +89,7 @@ void init_tree(TREE *tree, uint default_alloc_size, uint memory_limit,
tree_element_free free_element, void *custom_arg)
{
DBUG_ENTER("init_tree");
DBUG_PRINT("enter",("tree: %lx size: %d",tree,size));
DBUG_PRINT("enter",("tree: 0x%lx size: %d",tree,size));
if (default_alloc_size < DEFAULT_ALLOC_SIZE)
default_alloc_size= DEFAULT_ALLOC_SIZE;
......@@ -137,7 +137,7 @@ void init_tree(TREE *tree, uint default_alloc_size, uint memory_limit,
static void free_tree(TREE *tree, myf free_flags)
{
DBUG_ENTER("free_tree");
DBUG_PRINT("enter",("tree: %lx",tree));
DBUG_PRINT("enter",("tree: 0x%lx",tree));
if (tree->root) /* If initialized */
{
......
......@@ -49,7 +49,7 @@ int find_type(my_string x, TYPELIB *typelib, uint full_name)
reg1 my_string i;
reg2 const char *j;
DBUG_ENTER("find_type");
DBUG_PRINT("enter",("x: '%s' lib: %lx",x,typelib));
DBUG_PRINT("enter",("x: '%s' lib: 0x%lx",x,typelib));
if (!typelib->count)
{
......
......@@ -192,7 +192,7 @@ static int free_share(ARCHIVE_SHARE *share)
thr_lock_delete(&share->lock);
pthread_mutex_destroy(&share->mutex);
if (gzclose(share->archive_write) == Z_ERRNO)
rc= -1;
rc= 1;
my_free((gptr) share, MYF(0));
}
pthread_mutex_unlock(&archive_mutex);
......@@ -226,7 +226,7 @@ int ha_archive::open(const char *name, int mode, uint test_if_locked)
if ((archive= gzopen(share->data_file_name, "rb")) == NULL)
{
(void)free_share(share); //We void since we already have an error
DBUG_RETURN(-1);
DBUG_RETURN(errno ? errno : -1);
}
DBUG_RETURN(0);
......@@ -234,56 +234,91 @@ int ha_archive::open(const char *name, int mode, uint test_if_locked)
/*
Closes the file. We first close this storage engines file handle to the
archive and then remove our reference count to the table (and possibly
free it as well).
*/
Closes the file.
SYNOPSIS
close();
IMPLEMENTATION:
We first close this storage engines file handle to the archive and
then remove our reference count to the table (and possibly free it
as well).
RETURN
0 ok
1 Error
*/
int ha_archive::close(void)
{
int rc= 0;
DBUG_ENTER("ha_archive::close");
DBUG_RETURN(((gzclose(archive) == Z_ERRNO || free_share(share)) ? -1 : 0));
/* First close stream */
if (gzclose(archive) == Z_ERRNO)
rc= 1;
/* then also close share */
rc|= free_share(share);
DBUG_RETURN(rc);
}
/*
We create our data file here. The format is pretty simple. The first bytes in
any file are the version number. Currently we do nothing with this, but in
the future this gives us the ability to figure out version if we change the
format at all. After the version we starting writing our rows. Unlike other
storage engines we do not "pack" our data. Since we are about to do a general
compression, packing would just be a waste of CPU time. If the table has blobs
they are written after the row in the order of creation.
We create our data file here. The format is pretty simple. The first
bytes in any file are the version number. Currently we do nothing
with this, but in the future this gives us the ability to figure out
version if we change the format at all. After the version we
starting writing our rows. Unlike other storage engines we do not
"pack" our data. Since we are about to do a general compression,
packing would just be a waste of CPU time. If the table has blobs
they are written after the row in the order of creation.
So to read a row we:
Read the version
Read the record and copy it into buf
Loop through any blobs and read them
*/
int ha_archive::create(const char *name, TABLE *table_arg, HA_CREATE_INFO *create_info)
*/
int ha_archive::create(const char *name, TABLE *table_arg,
HA_CREATE_INFO *create_info)
{
File create_file;
char name_buff[FN_REFLEN];
size_t written;
int error;
DBUG_ENTER("ha_archive::create");
if ((create_file= my_create(fn_format(name_buff,name,"",ARZ,MY_REPLACE_EXT|MY_UNPACK_FILENAME),0,
O_RDWR | O_TRUNC,MYF(MY_WME))) < 0)
DBUG_RETURN(-1);
if ((create_file= my_create(fn_format(name_buff,name,"",ARZ,
MY_REPLACE_EXT|MY_UNPACK_FILENAME),0,
O_RDWR | O_TRUNC,MYF(MY_WME))) < 0)
{
error= my_errno;
goto err;
}
if ((archive= gzdopen(create_file, "ab")) == NULL)
{
error= errno;
delete_table(name);
DBUG_RETURN(-1);
goto err;
}
version= ARCHIVE_VERSION;
written= gzwrite(archive, &version, sizeof(version));
if (written != sizeof(version) || gzclose(archive))
if (gzclose(archive) || written != sizeof(version))
{
error= errno;
delete_table(name);
DBUG_RETURN(-1);
goto err;
}
DBUG_RETURN(0);
err:
/* Return error number, if we got one */
DBUG_RETURN(error ? error : -1);
}
/*
Look at ha_archive::open() for an explanation of the row format.
Here we just write out the row.
......@@ -298,9 +333,9 @@ int ha_archive::write_row(byte * buf)
if (table->timestamp_default_now)
update_timestamp(buf+table->timestamp_default_now-1);
written= gzwrite(share->archive_write, buf, table->reclength);
share->dirty= true;
share->dirty= TRUE;
if (written != table->reclength)
DBUG_RETURN(-1);
DBUG_RETURN(errno ? errno : -1);
for (Field_blob **field=table->blob_field ; *field ; field++)
{
......@@ -310,7 +345,7 @@ int ha_archive::write_row(byte * buf)
(*field)->get_ptr(&ptr);
written= gzwrite(share->archive_write, ptr, (unsigned)size);
if (written != size)
DBUG_RETURN(-1);
DBUG_RETURN(errno ? errno : -1);
}
DBUG_RETURN(0);
......@@ -322,6 +357,7 @@ int ha_archive::write_row(byte * buf)
that it is a table scan we rewind the file to the beginning, otherwise
we assume the position will be set.
*/
int ha_archive::rnd_init(bool scan)
{
DBUG_ENTER("ha_archive::rnd_init");
......@@ -339,10 +375,10 @@ int ha_archive::rnd_init(bool scan)
If dirty, we lock, and then reset/flush the data.
I found that just calling gzflush() doesn't always work.
*/
if (share->dirty == true)
if (share->dirty == TRUE)
{
pthread_mutex_lock(&share->mutex);
if (share->dirty == true)
if (share->dirty == TRUE)
{
/* I was having problems with OSX, but it worked for 10.3 so I am wrapping this with and ifdef */
#ifdef BROKEN_GZFLUSH
......@@ -350,12 +386,12 @@ int ha_archive::rnd_init(bool scan)
if ((share->archive_write= gzopen(share->data_file_name, "ab")) == NULL)
{
pthread_mutex_unlock(&share->mutex);
DBUG_RETURN(-1);
DBUG_RETURN(errno ? errno : -1);
}
#else
gzflush(share->archive_write, Z_SYNC_FLUSH);
#endif
share->dirty= false;
share->dirty= FALSE;
}
pthread_mutex_unlock(&share->mutex);
}
......@@ -367,8 +403,8 @@ int ha_archive::rnd_init(bool scan)
if (scan)
{
read= gzread(archive, &version, sizeof(version));
if (read == 0 || read != sizeof(version))
DBUG_RETURN(-1);
if (read != sizeof(version))
DBUG_RETURN(errno ? errno : -1);
}
DBUG_RETURN(0);
......@@ -393,7 +429,7 @@ int ha_archive::get_row(byte *buf)
DBUG_RETURN(HA_ERR_END_OF_FILE);
/* If the record is the wrong size, the file is probably damaged */
if (read != table->reclength)
if ((ulong) read != table->reclength)
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
/* Calculate blob length, we use this for our buffer */
......@@ -409,7 +445,7 @@ int ha_archive::get_row(byte *buf)
{
size_t size= (*field)->get_length();
read= gzread(archive, last, size);
if (read == 0 || read != size)
if ((size_t) read != size)
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
(*field)->set_ptr(size, last);
last += size;
......@@ -417,19 +453,21 @@ int ha_archive::get_row(byte *buf)
DBUG_RETURN(0);
}
/*
Called during ORDER BY. Its position is either from being called sequentially
or by having had ha_archive::rnd_pos() called before it is called.
*/
int ha_archive::rnd_next(byte *buf)
{
DBUG_ENTER("ha_archive::rnd_next");
int rc;
DBUG_ENTER("ha_archive::rnd_next");
statistic_increment(ha_read_rnd_next_count,&LOCK_status);
current_position= gztell(archive);
rc= get_row(buf);
if (!(HA_ERR_END_OF_FILE == rc))
if (rc != HA_ERR_END_OF_FILE)
records++;
DBUG_RETURN(rc);
......@@ -450,10 +488,12 @@ void ha_archive::position(const byte *record)
/*
This is called after a table scan for each row if the results of the scan need
to be ordered. It will take *pos and use it to move the cursor in the file so
that the next row that is called is the correctly ordered row.
This is called after a table scan for each row if the results of the
scan need to be ordered. It will take *pos and use it to move the
cursor in the file so that the next row that is called is the
correctly ordered row.
*/
int ha_archive::rnd_pos(byte * buf, byte *pos)
{
DBUG_ENTER("ha_archive::rnd_pos");
......@@ -568,11 +608,8 @@ THR_LOCK_DATA **ha_archive::store_lock(THD *thd,
return to;
}
ha_rows ha_archive::records_in_range(int inx,
const byte *start_key,uint start_key_len,
enum ha_rkey_function start_search_flag,
const byte *end_key,uint end_key_len,
enum ha_rkey_function end_search_flag)
ha_rows ha_archive::records_in_range(uint inx, key_range *min_key,
key_range *max_key)
{
DBUG_ENTER("ha_archive::records_in_range ");
DBUG_RETURN(records); // HA_ERR_WRONG_COMMAND
......
......@@ -86,7 +86,8 @@ class ha_archive: public handler
*/
virtual double scan_time() { return (double) (records) / 20.0+10; }
/* The next method will never be called */
virtual double read_time(ha_rows rows) { return (double) rows / 20.0+1; }
virtual double read_time(uint index, uint ranges, ha_rows rows)
{ return (double) rows / 20.0+1; }
int open(const char *name, int mode, uint test_if_locked);
int close(void);
int write_row(byte * buf);
......@@ -109,10 +110,7 @@ class ha_archive: public handler
int extra(enum ha_extra_function operation);
int reset(void);
int external_lock(THD *thd, int lock_type);
ha_rows records_in_range(int inx, const byte *start_key,uint start_key_len,
enum ha_rkey_function start_search_flag,
const byte *end_key,uint end_key_len,
enum ha_rkey_function end_search_flag);
ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key);
int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info);
THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
......
......@@ -3911,7 +3911,11 @@ JOIN::join_free(bool full)
if (full)
{
group_fields.delete_elements();
tmp_table_param.copy_funcs.delete_elements();
/*
We can't call delete_elements() on copy_funcs as this will cause
problems in free_elements() as some of the elements are then deleted.
*/
tmp_table_param.copy_funcs.empty();
tmp_table_param.cleanup();
}
DBUG_VOID_RETURN;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment