summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorkaa@polly.(none) <>2007-10-17 20:08:58 +0400
committerkaa@polly.(none) <>2007-10-17 20:08:58 +0400
commit6d1f3e8de56e3cc861272265fc1f6119a41036a9 (patch)
treedf4dfded543b3b043c0b27d956a2b0bab863da1b /mysys
parent80a2d47b22dde619656b55831f2a920bfcf8b5b1 (diff)
downloadmariadb-git-6d1f3e8de56e3cc861272265fc1f6119a41036a9.tar.gz
Fix for bug #31207: Test "join_nested" shows different strategy on IA64
CPUs / Intel's ICC compile The bug is a combination of two problems: 1. IA64/ICC MySQL binaries use glibc's qsort(), not the one in mysys. 2. The order relation implemented by join_tab_cmp() is not transitive, i.e. it is possible to choose such a, b and c that (a < b) && (b < c) but (c < a). This implies that result of a sort using the relation implemented by join_tab_cmp() depends on the order in which elements are compared, i.e. the result is implementation-specific. Since choose_plan() uses qsort() to pre-sort the join tables using join_tab_cmp() as a compare function, the results of the sorting may vary depending on qsort() implementation. It is neither possible nor important to implement a better ordering algorithm in join_tab_cmp(). Therefore the only way to fix it is to force our own qsort() to be used by renaming it to my_qsort(), so we don't depend on linker to decide that. This patch also "fixes" bug #20530: qsort redefinition violates the standard.
Diffstat (limited to 'mysys')
-rw-r--r--mysys/mf_keycache.c2
-rw-r--r--mysys/mf_qsort.c4
-rw-r--r--mysys/mf_sort.c2
-rw-r--r--mysys/my_lib.c6
-rw-r--r--mysys/queues.c4
5 files changed, 9 insertions, 9 deletions
diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c
index 83363e6960d..baf3bffccb8 100644
--- a/mysys/mf_keycache.c
+++ b/mysys/mf_keycache.c
@@ -2268,7 +2268,7 @@ static int flush_cached_blocks(KEY_CACHE *keycache,
As all blocks referred in 'cache' are marked by BLOCK_IN_FLUSH
we are guarunteed no thread will change them
*/
- qsort((byte*) cache, count, sizeof(*cache), (qsort_cmp) cmp_sec_link);
+ my_qsort((byte*) cache, count, sizeof(*cache), (qsort_cmp) cmp_sec_link);
keycache_pthread_mutex_lock(&keycache->cache_lock);
for ( ; cache != end ; cache++)
diff --git a/mysys/mf_qsort.c b/mysys/mf_qsort.c
index 3d52d56c952..4b3ecb603a6 100644
--- a/mysys/mf_qsort.c
+++ b/mysys/mf_qsort.c
@@ -91,10 +91,10 @@ typedef struct st_stack
*****************************************************************************/
#ifdef QSORT_EXTRA_CMP_ARGUMENT
-qsort_t qsort2(void *base_ptr, size_t count, size_t size, qsort2_cmp cmp,
+qsort_t my_qsort2(void *base_ptr, size_t count, size_t size, qsort2_cmp cmp,
void *cmp_argument)
#else
-qsort_t qsort(void *base_ptr, size_t count, size_t size, qsort_cmp cmp)
+qsort_t my_qsort(void *base_ptr, size_t count, size_t size, qsort_cmp cmp)
#endif
{
char *low, *high, *pivot;
diff --git a/mysys/mf_sort.c b/mysys/mf_sort.c
index e7fd6873eee..a0c74642cb0 100644
--- a/mysys/mf_sort.c
+++ b/mysys/mf_sort.c
@@ -35,7 +35,7 @@ void my_string_ptr_sort(void *base, uint items, size_s size)
if (size && items)
{
uint size_arg=size;
- qsort2(base,items,sizeof(byte*),get_ptr_compare(size),(void*) &size_arg);
+ my_qsort2(base,items,sizeof(byte*),get_ptr_compare(size),(void*) &size_arg);
}
}
}
diff --git a/mysys/my_lib.c b/mysys/my_lib.c
index 61de4ff9065..a076a0c971d 100644
--- a/mysys/my_lib.c
+++ b/mysys/my_lib.c
@@ -187,7 +187,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
result->number_off_files= dir_entries_storage->elements;
if (!(MyFlags & MY_DONT_SORT))
- qsort((void *) result->dir_entry, result->number_off_files,
+ my_qsort((void *) result->dir_entry, result->number_off_files,
sizeof(FILEINFO), (qsort_cmp) comp_names);
DBUG_RETURN(result);
@@ -498,7 +498,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
result->number_off_files= dir_entries_storage->elements;
if (!(MyFlags & MY_DONT_SORT))
- qsort((void *) result->dir_entry, result->number_off_files,
+ my_qsort((void *) result->dir_entry, result->number_off_files,
sizeof(FILEINFO), (qsort_cmp) comp_names);
DBUG_PRINT("exit", ("found %d files", result->number_off_files));
DBUG_RETURN(result);
@@ -605,7 +605,7 @@ MY_DIR *my_dir(const char* path, myf MyFlags)
result->number_off_files= dir_entries_storage->elements;
if (!(MyFlags & MY_DONT_SORT))
- qsort((void *) result->dir_entry, result->number_off_files,
+ my_qsort((void *) result->dir_entry, result->number_off_files,
sizeof(FILEINFO), (qsort_cmp) comp_names);
DBUG_RETURN(result);
diff --git a/mysys/queues.c b/mysys/queues.c
index 7809c97131c..6b88420a1cd 100644
--- a/mysys/queues.c
+++ b/mysys/queues.c
@@ -250,6 +250,6 @@ static int queue_fix_cmp(QUEUE *queue, void **a, void **b)
void queue_fix(QUEUE *queue)
{
- qsort2(queue->root+1,queue->elements, sizeof(void *),
- (qsort2_cmp)queue_fix_cmp, queue);
+ my_qsort2(queue->root+1,queue->elements, sizeof(void *),
+ (qsort2_cmp)queue_fix_cmp, queue);
}