mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
Bug #31890 Partitions: ORDER BY DESC in InnoDB not working.
It's not InnoDB specific bug. Error is in QUEUE code, about the way we handle queue->max_at_top. It's either '0' or '-2' and we do '^' operation to get the proper direction. Though queue->compare() function can return '-2' as a result of comparison sometimes. So we'll get queue->compare() ^ queue->max_at_top == 0 (when max_at_top is -2) and _downheap() function code will go wrong way here: ... if (next_index < elements && (queue->compare(queue->first_cmp_arg, queue->root[next_index]+offset_to_key, queue->root[next_index+1]+offset_to_key) ^ queue->max_at_top) > 0) next_index++; ... Fixed by changing max_at_top to be either 1 or -1, doing '* max_at_top' to get proper direction. include/queues.h: Bug #31890 Partitions: ORDER BY DESC in InnoDB not working max_at_top policy changed mysql-test/r/partition.result: Bug #31890 Partitions: ORDER BY DESC in InnoDB not working test result mysql-test/t/partition.test: Bug #31890 Partitions: ORDER BY DESC in InnoDB not working test case mysys/queues.c: Bug #31890 Partitions: ORDER BY DESC in InnoDB not working. queue->max_at_top policy changed - now it can either be '1' or '-1'. We multiply comparison result on max_at_top to get the proper direction.
This commit is contained in:
@@ -31,8 +31,8 @@ typedef struct st_queue {
|
||||
void *first_cmp_arg;
|
||||
uint elements;
|
||||
uint max_elements;
|
||||
uint offset_to_key; /* compare is done on element+offset */
|
||||
int max_at_top; /* Set if queue_top gives max */
|
||||
uint offset_to_key; /* compare is done on element+offset */
|
||||
int max_at_top; /* Normally 1, set to -1 if queue_top gives max */
|
||||
int (*compare)(void *, uchar *,uchar *);
|
||||
uint auto_extent;
|
||||
} QUEUE;
|
||||
@@ -43,7 +43,7 @@ typedef struct st_queue {
|
||||
#define queue_replaced(queue) _downheap(queue,1)
|
||||
#define queue_set_cmp_arg(queue, set_arg) (queue)->first_cmp_arg= set_arg
|
||||
#define queue_set_max_at_top(queue, set_arg) \
|
||||
(queue)->max_at_top= set_arg ? (-1 ^ 1) : 0
|
||||
(queue)->max_at_top= set_arg ? -1 : 1
|
||||
typedef int (*queue_compare)(void *,uchar *, uchar *);
|
||||
|
||||
int init_queue(QUEUE *queue,uint max_elements,uint offset_to_key,
|
||||
|
Reference in New Issue
Block a user