Commit 1ac9e1e6 authored by monty@hundin.mysql.fi's avatar monty@hundin.mysql.fi

Fix bug in SELECT EXPLAIN ... ORDER BY

parent cd78a8be
...@@ -214,12 +214,15 @@ you will not develop sloppy coding habits. ...@@ -214,12 +214,15 @@ you will not develop sloppy coding habits.
If you can write it in fewer lines, do it (as long as the code will not If you can write it in fewer lines, do it (as long as the code will not
be slower or much harder to read). be slower or much harder to read).
@item
Don't use two commands on the same line.
@item @item
Do not check the same pointer for @code{NULL} more than once. Do not check the same pointer for @code{NULL} more than once.
@item @item
Use long function and variable names in English; This makes your Use long function and variable names in English; This makes your code
code easier to read. easier to read. Use the 'varible_name' style instead of 'VariableName'.
@item @item
Think assembly - make it easier for the compiler to optimize your code. Think assembly - make it easier for the compiler to optimize your code.
...@@ -266,6 +269,25 @@ Any @code{#define}'s are in all-caps. ...@@ -266,6 +269,25 @@ Any @code{#define}'s are in all-caps.
@item @item
Matching @samp{@{} are in the same column. Matching @samp{@{} are in the same column.
@item
Put the @samp{@{} after a 'switch' on the same line
@example
switch (arg) {
@end example
Because this gives better overall indentation for the switch statement.
@item
In all other cases, @{ and @} should be on their own line, except
if there is nothing inside @{ @}.
@item
Have a space after 'if'
@item
Put a space after ',' for function arguments
@item @item
Functions return 0 on success, and non-zero on error, so you can do: Functions return 0 on success, and non-zero on error, so you can do:
...@@ -289,6 +311,32 @@ Use pointers rather than array indexing when operating on strings. ...@@ -289,6 +311,32 @@ Use pointers rather than array indexing when operating on strings.
@end itemize @end itemize
Suggested mode in emacs:
@example
(load "cc-mode")
(setq c-mode-common-hook '(lambda ()
(turn-on-font-lock)
(setq comment-column 48)))
(setq c-style-alist
(cons
'("MY"
(c-basic-offset . 2)
(c-comment-only-line-offset . 0)
(c-offsets-alist . ((statement-block-intro . +)
(knr-argdecl-intro . 0)
(substatement-open . 0)
(label . -)
(statement-cont . +)
(arglist-intro . c-lineup-arglist-intro-after-paren)
(arglist-close . c-lineup-arglist)
))
)
c-style-alist))
(c-set-style "MY")
(setq c-default-style "MY")
@end example
@node mysys functions,,, @node mysys functions,,,
@chapter mysys functions @chapter mysys functions
......
...@@ -46853,6 +46853,9 @@ not yet 100% confident in this code. ...@@ -46853,6 +46853,9 @@ not yet 100% confident in this code.
@appendixsubsec Changes in release 3.23.43 @appendixsubsec Changes in release 3.23.43
@itemize @bullet @itemize @bullet
@item @item
Fixed a unlikely core-dump bug when doing @code{EXPLAIN SELECT} when using
many tables and @code{ORDER BY}.
@item
Fixed bug in @code{LOAD DATA FROM MASTER} when using table with Fixed bug in @code{LOAD DATA FROM MASTER} when using table with
@code{CHECKSUM=1}. @code{CHECKSUM=1}.
@item @item
...@@ -1291,10 +1291,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, ...@@ -1291,10 +1291,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
{ {
info->state->data_file_length=sort_info->max_pos; info->state->data_file_length=sort_info->max_pos;
if (param->testflag & T_CALC_CHECKSUM) if (param->testflag & T_CALC_CHECKSUM)
{
DBUG_PRINT("QQ",("set_checksum"));
share->state.checksum=param->glob_crc; share->state.checksum=param->glob_crc;
}
} }
if (!(param->testflag & T_SILENT)) if (!(param->testflag & T_SILENT))
...@@ -2136,10 +2133,7 @@ static int sort_get_next_record(SORT_INFO *sort_info) ...@@ -2136,10 +2133,7 @@ static int sort_get_next_record(SORT_INFO *sort_info)
if (*sort_info->record) if (*sort_info->record)
{ {
if (param->calc_checksum) if (param->calc_checksum)
{
DBUG_PRINT("QQ",("calc_checksum"));
param->glob_crc+= mi_static_checksum(info,sort_info->record); param->glob_crc+= mi_static_checksum(info,sort_info->record);
}
DBUG_RETURN(0); DBUG_RETURN(0);
} }
if (!sort_info->fix_datafile) if (!sort_info->fix_datafile)
......
...@@ -531,8 +531,9 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds, ...@@ -531,8 +531,9 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
if (!(select_options & SELECT_BIG_RESULT) && if (!(select_options & SELECT_BIG_RESULT) &&
((group && join.const_tables != join.tables && ((group && join.const_tables != join.tables &&
!test_if_skip_sort_order(&join.join_tab[join.const_tables], group, (!simple_group ||
HA_POS_ERROR)) || !test_if_skip_sort_order(&join.join_tab[join.const_tables], group,
HA_POS_ERROR))) ||
select_distinct) && select_distinct) &&
join.tmp_table_param.quick_group && !procedure) join.tmp_table_param.quick_group && !procedure)
{ {
...@@ -545,8 +546,10 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds, ...@@ -545,8 +546,10 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
order=group; order=group;
if (order && if (order &&
(join.const_tables == join.tables || (join.const_tables == join.tables ||
test_if_skip_sort_order(&join.join_tab[join.const_tables], order, (simple_order &&
(group ? HA_POS_ERROR : thd->select_limit)))) test_if_skip_sort_order(&join.join_tab[join.const_tables], order,
(group ? HA_POS_ERROR :
thd->select_limit)))))
order=0; order=0;
select_describe(&join,need_tmp, select_describe(&join,need_tmp,
(order != 0 && (order != 0 &&
......
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