summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2004-10-29 19:26:52 +0300
committerunknown <monty@mysql.com>2004-10-29 19:26:52 +0300
commit952c09b308f9f70c2b6c3c2c07ae510527b09656 (patch)
tree23bcc9a71fe7237887a111b158e30f5a6bb665d3 /mysys
parented61d47efe31765b0e6bce85266574b5e07c4fef (diff)
parente27f6a502eebce1a0ddef4436d6615dfc0a64503 (diff)
downloadmariadb-git-952c09b308f9f70c2b6c3c2c07ae510527b09656.tar.gz
merge with 4.1
BitKeeper/etc/ignore: auto-union BitKeeper/etc/logging_ok: auto-union BitKeeper/triggers/post-commit: Auto merged Docs/Support/texi2html: Auto merged Makefile.am: Auto merged client/Makefile.am: Auto merged client/mysql.cc: Auto merged client/mysqldump.c: Auto merged include/my_base.h: Auto merged include/my_global.h: Auto merged include/my_pthread.h: Auto merged include/my_sys.h: Auto merged include/my_time.h: Auto merged include/mysql.h: Auto merged include/mysql_com.h: Auto merged innobase/buf/buf0buf.c: Auto merged innobase/include/row0mysql.h: Auto merged innobase/row/row0sel.c: Auto merged libmysql/libmysql.c: Auto merged libmysqld/examples/Makefile.am: Auto merged myisam/mi_check.c: Auto merged mysql-test/include/ps_modify.inc: Auto merged mysql-test/install_test_db.sh: Auto merged mysql-test/r/alter_table.result: Auto merged mysql-test/r/auto_increment.result: Auto merged mysql-test/r/bdb.result: Auto merged mysql-test/r/ctype_latin1_de.result: Auto merged mysql-test/r/ctype_recoding.result: Auto merged mysql-test/r/fulltext.result: Auto merged mysql-test/r/func_gconcat.result: Auto merged mysql-test/r/func_group.result: Auto merged mysql-test/r/func_if.result: Auto merged mysql-test/t/derived.test: Auto merged mysql-test/t/insert.test: merge with 4.1 Fixed test case to not use 'if exists' when it shouldn't mysql-test/t/range.test: merge with 4.1 Added missing drop table sql/ha_ndbcluster.cc: merge with 4.1 Simple optimization: use max() instead of ? : sql/item_func.cc: merge with 4.1 (Added back old variable names for easier merges) sql/opt_range.cc: merge with 4.1 Removed argument 'parent_alloc' from QUICK_RANGE_SELECT as this was not used Added assert if using QUICK_GROUP_MIN_MAX_SELECT with parent_alloc as the init() function can't handle this Changed back get_quick_select_for_ref() to use it's own alloc root becasue this function may be called several times for one query sql/sql_handler.cc: merge with 4.1 change variable 'err' to 'error' as same function had a label named 'err' sql/sql_update.cc: Use multi-update code from 5.0 instead of 4.1 We will fix the locking code shortly in 5.0 to be faster than in 4.1
Diffstat (limited to 'mysys')
-rw-r--r--mysys/charset-def.c4
-rw-r--r--mysys/errors.c2
-rw-r--r--mysys/hash.c66
-rw-r--r--mysys/mf_format.c2
-rw-r--r--mysys/my_alloc.c40
-rw-r--r--mysys/my_bitmap.c4
-rw-r--r--mysys/my_fstream.c14
-rw-r--r--mysys/my_gethwaddr.c2
-rw-r--r--mysys/my_handler.c10
-rw-r--r--mysys/my_pread.c9
-rw-r--r--mysys/my_thr_init.c5
-rw-r--r--mysys/my_write.c5
-rw-r--r--mysys/mysys_priv.h7
-rw-r--r--mysys/thr_lock.c12
14 files changed, 150 insertions, 32 deletions
diff --git a/mysys/charset-def.c b/mysys/charset-def.c
index 420a13a592d..3dcd2a2d116 100644
--- a/mysys/charset-def.c
+++ b/mysys/charset-def.c
@@ -39,6 +39,7 @@ extern CHARSET_INFO my_charset_ucs2_lithuanian_uca_ci;
extern CHARSET_INFO my_charset_ucs2_slovak_uca_ci;
extern CHARSET_INFO my_charset_ucs2_spanish2_uca_ci;
extern CHARSET_INFO my_charset_ucs2_roman_uca_ci;
+extern CHARSET_INFO my_charset_ucs2_persian_uca_ci;
#endif
#ifdef HAVE_CHARSET_utf8
@@ -58,6 +59,7 @@ extern CHARSET_INFO my_charset_utf8_lithuanian_uca_ci;
extern CHARSET_INFO my_charset_utf8_slovak_uca_ci;
extern CHARSET_INFO my_charset_utf8_spanish2_uca_ci;
extern CHARSET_INFO my_charset_utf8_roman_uca_ci;
+extern CHARSET_INFO my_charset_utf8_persian_uca_ci;
#endif
my_bool init_compiled_charsets(myf flags __attribute__((unused)))
@@ -127,6 +129,7 @@ my_bool init_compiled_charsets(myf flags __attribute__((unused)))
add_compiled_collation(&my_charset_ucs2_slovak_uca_ci);
add_compiled_collation(&my_charset_ucs2_spanish2_uca_ci);
add_compiled_collation(&my_charset_ucs2_roman_uca_ci);
+ add_compiled_collation(&my_charset_ucs2_persian_uca_ci);
#endif
#ifdef HAVE_CHARSET_ujis
@@ -153,6 +156,7 @@ my_bool init_compiled_charsets(myf flags __attribute__((unused)))
add_compiled_collation(&my_charset_utf8_slovak_uca_ci);
add_compiled_collation(&my_charset_utf8_spanish2_uca_ci);
add_compiled_collation(&my_charset_utf8_roman_uca_ci);
+ add_compiled_collation(&my_charset_utf8_persian_uca_ci);
#endif
/* Copy compiled charsets */
diff --git a/mysys/errors.c b/mysys/errors.c
index 255b6893c73..5401c2b3cc6 100644
--- a/mysys/errors.c
+++ b/mysys/errors.c
@@ -41,7 +41,7 @@ const char * NEAR globerrs[GLOBERRS]=
"Can't change dir to '%s' (Errcode: %d)",
"Warning: '%s' had %d links",
"%d files and %d streams is left open\n",
- "Disk is full writing '%s'. Waiting for someone to free space...",
+ "Disk is full writing '%s' (Errcode: %d). Waiting for someone to free space... Retry in %d secs",
"Can't create directory '%s' (Errcode: %d)",
"Character set '%s' is not a compiled character set and is not specified in the '%s' file",
"Out of resources when opening file '%s' (Errcode: %d)",
diff --git a/mysys/hash.c b/mysys/hash.c
index ce25ae89b63..d068299d44e 100644
--- a/mysys/hash.c
+++ b/mysys/hash.c
@@ -72,19 +72,70 @@ _hash_init(HASH *hash,CHARSET_INFO *charset,
}
-void hash_free(HASH *hash)
+/*
+ Call hash->free on all elements in hash.
+
+ SYNOPSIS
+ hash_free_elements()
+ hash hash table
+
+ NOTES:
+ Sets records to 0
+*/
+
+static inline void hash_free_elements(HASH *hash)
{
- DBUG_ENTER("hash_free");
if (hash->free)
{
- uint i,records;
HASH_LINK *data=dynamic_element(&hash->array,0,HASH_LINK*);
- for (i=0,records=hash->records ; i < records ; i++)
- (*hash->free)(data[i].data);
- hash->free=0;
+ HASH_LINK *end= data + hash->records;
+ while (data < end)
+ (*hash->free)((data++)->data);
}
- delete_dynamic(&hash->array);
hash->records=0;
+}
+
+
+/*
+ Free memory used by hash.
+
+ SYNOPSIS
+ hash_free()
+ hash the hash to delete elements of
+
+ NOTES: Hash can't be reused wuthing calling hash_init again.
+*/
+
+void hash_free(HASH *hash)
+{
+ DBUG_ENTER("hash_free");
+ DBUG_PRINT("enter",("hash: 0x%lxd",hash));
+
+ hash_free_elements(hash);
+ hash->free= 0;
+ delete_dynamic(&hash->array);
+ DBUG_VOID_RETURN;
+}
+
+
+/*
+ Delete all elements from the hash (the hash itself is to be reused).
+
+ SYNOPSIS
+ hash_reset()
+ hash the hash to delete elements of
+*/
+
+void hash_reset(HASH *hash)
+{
+ DBUG_ENTER("hash_reset");
+ DBUG_PRINT("enter",("hash: 0x%lxd",hash));
+
+ hash_free_elements(hash);
+ reset_dynamic(&hash->array);
+ /* Set row pointers so that the hash can be reused at once */
+ hash->blength= 1;
+ hash->current_record= NO_RECORD;
DBUG_VOID_RETURN;
}
@@ -123,6 +174,7 @@ static uint hash_rec_mask(HASH *hash,HASH_LINK *pos,uint buffmax,
/* for compilers which can not handle inline */
+static
#if !defined(__SUNPRO_C) && !defined(__USLC__) && !defined(__sgi)
inline
#endif
diff --git a/mysys/mf_format.c b/mysys/mf_format.c
index 114e19759c8..d1ca1108d02 100644
--- a/mysys/mf_format.c
+++ b/mysys/mf_format.c
@@ -42,7 +42,7 @@ my_string fn_format(my_string to, const char *name, const char *dir,
/* Use given directory */
convert_dirname(dev,dir,NullS); /* Fix to this OS */
}
- else if ((flag & MY_RELATIVE_PATH) && !test_if_hard_path(name))
+ else if ((flag & MY_RELATIVE_PATH) && !test_if_hard_path(dev))
{
/* Put 'dir' before the given path */
strmake(buff,dev,sizeof(buff)-1);
diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c
index 7b4287fc7a6..d8c19d86e5c 100644
--- a/mysys/my_alloc.c
+++ b/mysys/my_alloc.c
@@ -22,6 +22,27 @@
#undef EXTRA_DEBUG
#define EXTRA_DEBUG
+
+/*
+ Initialize memory root
+
+ SYNOPSIS
+ init_alloc_root()
+ mem_root - memory root to initialize
+ block_size - size of chunks (blocks) used for memory allocation
+ (It is external size of chunk i.e. it should include
+ memory required for internal structures, thus it
+ should be no less than ALLOC_ROOT_MIN_BLOCK_SIZE)
+ pre_alloc_size - if non-0, then size of block that should be
+ pre-allocated during memory root initialization.
+
+ DESCRIPTION
+ This function prepares memory root for further use, sets initial size of
+ chunk for memory allocation and pre-allocates first block if specified.
+ Altough error can happen during execution of this function if pre_alloc_size
+ is non-0 it won't be reported. Instead it will be reported as error in first
+ alloc_root() on this memory root.
+*/
void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
uint pre_alloc_size __attribute__((unused)))
{
@@ -29,7 +50,7 @@ void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
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;
+ mem_root->block_size= block_size - ALLOC_ROOT_MIN_BLOCK_SIZE;
mem_root->error_handler= 0;
mem_root->block_num= 4; /* We shift this with >>2 */
mem_root->first_block_usage= 0;
@@ -54,9 +75,9 @@ void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
SYNOPSIS
reset_root_defaults()
mem_root memory root to change defaults of
- block_size new value of block size. Must be
- greater than ~68 bytes (the exact value depends on
- platform and compilation flags)
+ block_size new value of block size. Must be greater or equal
+ than ALLOC_ROOT_MIN_BLOCK_SIZE (this value is about
+ 68 bytes and depends on platform and compilation flags)
pre_alloc_size new size of preallocated block. If not zero,
must be equal to or greater than block size,
otherwise means 'no prealloc'.
@@ -70,7 +91,9 @@ void init_alloc_root(MEM_ROOT *mem_root, uint block_size,
void reset_root_defaults(MEM_ROOT *mem_root, uint block_size,
uint pre_alloc_size __attribute__((unused)))
{
- mem_root->block_size= block_size-MALLOC_OVERHEAD-sizeof(USED_MEM)-8;
+ DBUG_ASSERT(alloc_root_inited(mem_root));
+
+ mem_root->block_size= block_size - ALLOC_ROOT_MIN_BLOCK_SIZE;
#if !(defined(HAVE_purify) && defined(EXTRA_DEBUG))
if (pre_alloc_size)
{
@@ -123,6 +146,8 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
DBUG_ENTER("alloc_root");
DBUG_PRINT("enter",("root: 0x%lx", mem_root));
+ DBUG_ASSERT(alloc_root_inited(mem_root));
+
Size+=ALIGN_SIZE(sizeof(USED_MEM));
if (!(next = (USED_MEM*) my_malloc(Size,MYF(MY_WME))))
{
@@ -133,7 +158,8 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
next->next= mem_root->used;
next->size= Size;
mem_root->used= next;
- DBUG_PRINT("exit",("ptr: 0x%lx", (((char*) next)+ALIGN_SIZE(sizeof(USED_MEM)))));
+ DBUG_PRINT("exit",("ptr: 0x%lx", (((char*) next)+
+ ALIGN_SIZE(sizeof(USED_MEM)))));
DBUG_RETURN((gptr) (((char*) next)+ALIGN_SIZE(sizeof(USED_MEM))));
#else
uint get_size, block_size;
@@ -141,6 +167,8 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
reg1 USED_MEM *next= 0;
reg2 USED_MEM **prev;
+ DBUG_ASSERT(alloc_root_inited(mem_root));
+
Size= ALIGN_SIZE(Size);
if ((*(prev= &mem_root->free)) != NULL)
{
diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c
index a596fcb6fd9..1d98204ff8e 100644
--- a/mysys/my_bitmap.c
+++ b/mysys/my_bitmap.c
@@ -41,7 +41,7 @@
#include <m_string.h>
-inline void bitmap_lock(MY_BITMAP *map)
+static inline void bitmap_lock(MY_BITMAP *map)
{
#ifdef THREAD
if (map->mutex)
@@ -50,7 +50,7 @@ inline void bitmap_lock(MY_BITMAP *map)
}
-inline void bitmap_unlock(MY_BITMAP *map)
+static inline void bitmap_unlock(MY_BITMAP *map)
{
#ifdef THREAD
if (map->mutex)
diff --git a/mysys/my_fstream.c b/mysys/my_fstream.c
index 00fe5c7a009..5b17e3ff51c 100644
--- a/mysys/my_fstream.c
+++ b/mysys/my_fstream.c
@@ -114,13 +114,15 @@ uint my_fwrite(FILE *stream, const byte *Buffer, uint Count, myf MyFlags)
if (my_thread_var->abort)
MyFlags&= ~ MY_WAIT_IF_FULL; /* End if aborted by user */
#endif
- if (errno == ENOSPC && (MyFlags & MY_WAIT_IF_FULL))
+ if ((errno == ENOSPC || errno == EDQUOT) &&
+ (MyFlags & MY_WAIT_IF_FULL))
{
- if (!(errors++ % MY_WAIT_GIVE_USER_A_MESSAGE))
- my_error(EE_DISK_FULL,MYF(ME_BELL | ME_NOREFRESH));
- sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC);
- VOID(my_fseek(stream,seekptr,MY_SEEK_SET,MYF(0)));
- continue;
+ if (!(errors++ % MY_WAIT_GIVE_USER_A_MESSAGE))
+ my_error(EE_DISK_FULL,MYF(ME_BELL | ME_NOREFRESH),
+ "[stream]",my_errno,MY_WAIT_FOR_USER_TO_FIX_PANIC);
+ VOID(sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC));
+ VOID(my_fseek(stream,seekptr,MY_SEEK_SET,MYF(0)));
+ continue;
}
#endif
if (ferror(stream) || (MyFlags & (MY_NABP | MY_FNABP)))
diff --git a/mysys/my_gethwaddr.c b/mysys/my_gethwaddr.c
index 72f1cb975c4..222abe81933 100644
--- a/mysys/my_gethwaddr.c
+++ b/mysys/my_gethwaddr.c
@@ -107,7 +107,7 @@ my_bool my_gethwaddr(uchar *to __attribute__((unused)))
}
#endif
-#else MAIN
+#else /* MAIN */
int main(int argc __attribute__((unused)),char **argv)
{
uchar mac[6];
diff --git a/mysys/my_handler.c b/mysys/my_handler.c
index 360a7666e94..00f25924e69 100644
--- a/mysys/my_handler.c
+++ b/mysys/my_handler.c
@@ -309,6 +309,11 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
case HA_KEYTYPE_FLOAT:
mi_float4get(f_1,a);
mi_float4get(f_2,b);
+ /*
+ The following may give a compiler warning about floating point
+ comparison not being safe, but this is ok in this context as
+ we are bascily doing sorting
+ */
if (piks && (flag = CMP_NUM(f_1,f_2)))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a= end;
@@ -317,6 +322,11 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
case HA_KEYTYPE_DOUBLE:
mi_float8get(d_1,a);
mi_float8get(d_2,b);
+ /*
+ The following may give a compiler warning about floating point
+ comparison not being safe, but this is ok in this context as
+ we are bascily doing sorting
+ */
if (piks && (flag = CMP_NUM(d_1,d_2)))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a= end;
diff --git a/mysys/my_pread.c b/mysys/my_pread.c
index 6a55a3cd8de..3d02e368720 100644
--- a/mysys/my_pread.c
+++ b/mysys/my_pread.c
@@ -115,11 +115,12 @@ uint my_pwrite(int Filedes, const byte *Buffer, uint Count, my_off_t offset,
if (my_thread_var->abort)
MyFlags&= ~ MY_WAIT_IF_FULL; /* End if aborted by user */
#endif
- if (my_errno == ENOSPC && (MyFlags & MY_WAIT_IF_FULL))
+ if ((my_errno == ENOSPC || my_errno == EDQUOT) &&
+ (MyFlags & MY_WAIT_IF_FULL))
{
if (!(errors++ % MY_WAIT_GIVE_USER_A_MESSAGE))
my_error(EE_DISK_FULL,MYF(ME_BELL | ME_NOREFRESH),
- my_filename(Filedes));
+ my_filename(Filedes),my_errno,MY_WAIT_FOR_USER_TO_FIX_PANIC);
VOID(sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC));
continue;
}
@@ -131,7 +132,7 @@ uint my_pwrite(int Filedes, const byte *Buffer, uint Count, my_off_t offset,
{
if (MyFlags & (MY_WME | MY_FAE | MY_FNABP))
{
- my_error(EE_WRITE, MYF(ME_BELL+ME_WAITTANG),
+ my_error(EE_WRITE, MYF(ME_BELL | ME_WAITTANG),
my_filename(Filedes),my_errno);
}
DBUG_RETURN(MY_FILE_ERROR); /* Error on read */
@@ -142,4 +143,4 @@ uint my_pwrite(int Filedes, const byte *Buffer, uint Count, my_off_t offset,
if (MyFlags & (MY_NABP | MY_FNABP))
DBUG_RETURN(0); /* Want only errors */
DBUG_RETURN(writenbytes+written); /* purecov: inspected */
-} /* my_write */
+} /* my_pwrite */
diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c
index 0ce59bee346..36b37f68b46 100644
--- a/mysys/my_thr_init.c
+++ b/mysys/my_thr_init.c
@@ -64,6 +64,11 @@ my_bool my_thread_global_init(void)
}
#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
pthread_mutexattr_init(&my_fast_mutexattr);
+ /*
+ Note that the following statement may give a compiler warning under
+ some configurations, but there isn't anything we can do about this as
+ this is a bug in the header files for the thread implementation
+ */
pthread_mutexattr_setkind_np(&my_fast_mutexattr,PTHREAD_MUTEX_ADAPTIVE_NP);
#endif
#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
diff --git a/mysys/my_write.c b/mysys/my_write.c
index 37d885f04cd..2df3a31e774 100644
--- a/mysys/my_write.c
+++ b/mysys/my_write.c
@@ -48,12 +48,13 @@ uint my_write(int Filedes, const byte *Buffer, uint Count, myf MyFlags)
if (my_thread_var->abort)
MyFlags&= ~ MY_WAIT_IF_FULL; /* End if aborted by user */
#endif
- if (my_errno == ENOSPC && (MyFlags & MY_WAIT_IF_FULL) &&
+ if ((my_errno == ENOSPC || my_errno == EDQUOT) &&
+ (MyFlags & MY_WAIT_IF_FULL) &&
(uint) writenbytes != (uint) -1)
{
if (!(errors++ % MY_WAIT_GIVE_USER_A_MESSAGE))
my_error(EE_DISK_FULL,MYF(ME_BELL | ME_NOREFRESH),
- my_filename(Filedes));
+ my_filename(Filedes),my_errno,MY_WAIT_FOR_USER_TO_FIX_PANIC);
VOID(sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC));
continue;
}
diff --git a/mysys/mysys_priv.h b/mysys/mysys_priv.h
index 6abadd48aeb..89a6d8aa2a7 100644
--- a/mysys/mysys_priv.h
+++ b/mysys/mysys_priv.h
@@ -34,3 +34,10 @@ extern pthread_mutex_t THR_LOCK_charset;
#include <my_no_pthread.h>
#endif
+/*
+ EDQUOT is used only in 3 C files only in mysys/. If it does not exist on
+ system, we set it to some value which can never happen.
+*/
+#ifndef EDQUOT
+#define EDQUOT (-1)
+#endif
diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c
index d9e46fe1beb..d47ca8de183 100644
--- a/mysys/thr_lock.c
+++ b/mysys/thr_lock.c
@@ -552,8 +552,14 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type)
!lock->write_wait.data &&
lock->write.data->type == TL_WRITE_ALLOW_WRITE))
{
- /* We have already got a write lock or all locks are
- TL_WRITE_ALLOW_WRITE */
+ /*
+ We have already got a write lock or all locks are
+ TL_WRITE_ALLOW_WRITE
+ */
+ DBUG_PRINT("info", ("write_wait.data: 0x%lx old_type: %d",
+ (ulong) lock->write_wait.data,
+ lock->write.data->type));
+
(*lock->write.last)=data; /* Add to running fifo */
data->prev=lock->write.last;
lock->write.last= &data->next;
@@ -568,6 +574,8 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type)
}
else
{
+ DBUG_PRINT("info", ("write_wait.data: 0x%lx",
+ (ulong) lock->write_wait.data));
if (!lock->write_wait.data)
{ /* no scheduled write locks */
if (lock_type == TL_WRITE_CONCURRENT_INSERT &&