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

Fix some bugs introduced with the new my_getopt

Added counting of rollback's and commits
Fixed bug in 'SELECT 0 LIMIT 0'
Fixed bug in 'SELECT SQL_CALC_FOUND_ROWS'
parent 040b5c29
...@@ -48385,6 +48385,11 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}. ...@@ -48385,6 +48385,11 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}.
@itemize @bullet @itemize @bullet
@item @item
Fixed a bug where @code{SQL_CALC_ROWS} returned a wrong value when used
with one table and @code{ORDER BY} and with InnoDB tables.
@item
Fixed that @code{SELECT 0 LIMIT 0} doesn't hang thread.
@item
Fixed some problems with @code{USE KEYS} / @code{IGNORE KEYS} when using Fixed some problems with @code{USE KEYS} / @code{IGNORE KEYS} when using
many keys with the same start column. many keys with the same start column.
@item @item
...@@ -188,7 +188,7 @@ AC_DEFINE(SPRINTF_RETURNS_INT) AC_MSG_RESULT("int"), ...@@ -188,7 +188,7 @@ AC_DEFINE(SPRINTF_RETURNS_INT) AC_MSG_RESULT("int"),
# option, cache_name, variable, # option, cache_name, variable,
# code to execute if yes, code to exectute if fal # code to execute if yes, code to exectute if fail
AC_DEFUN(AC_SYS_COMPILER_FLAG, AC_DEFUN(AC_SYS_COMPILER_FLAG,
[ [
AC_MSG_CHECKING($1) AC_MSG_CHECKING($1)
......
...@@ -193,7 +193,7 @@ static struct my_option my_long_options[] = ...@@ -193,7 +193,7 @@ static struct my_option my_long_options[] =
0, 0, 0, GET_NO_ARG, NO_ARG, 'i', 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 'i', 0, 0, 0, 0, 0, 0},
{"keys-used", "Tell MyISAM to update only some specific keys. # is a bit mask of which keys to use. This can be used to get faster inserts!", {"keys-used", "Tell MyISAM to update only some specific keys. # is a bit mask of which keys to use. This can be used to get faster inserts!",
(gptr*) &check_param.keys_in_use, (gptr*) &check_param.keys_in_use, 0, (gptr*) &check_param.keys_in_use, (gptr*) &check_param.keys_in_use, 0,
GET_LONG, REQUIRED_ARG, 'k', 0, 0, 0, 0, 0, 0}, GET_LL, REQUIRED_ARG, 'k', -1LL, 0, 0, 0, 0, 0},
{"medium-check", {"medium-check",
"Faster than extended-check, but only finds 99.99% of all errors. Should be good enough for most cases.", 0, 0, 0, GET_NO_ARG, NO_ARG, 'm', 0, 0, 0, 0, 0, "Faster than extended-check, but only finds 99.99% of all errors. Should be good enough for most cases.", 0, 0, 0, GET_NO_ARG, NO_ARG, 'm', 0, 0, 0, 0, 0,
0}, 0},
...@@ -384,8 +384,6 @@ get_one_option(int optid, ...@@ -384,8 +384,6 @@ get_one_option(int optid,
const struct my_option *opt __attribute__((unused)), const struct my_option *opt __attribute__((unused)),
char *argument) char *argument)
{ {
uint old_testflag;
switch (optid) { switch (optid) {
case 'a': case 'a':
if (argument && *argument == '0') if (argument && *argument == '0')
...@@ -417,10 +415,7 @@ get_one_option(int optid, ...@@ -417,10 +415,7 @@ get_one_option(int optid,
break; break;
case 'C': case 'C':
if (argument && *argument == '0') if (argument && *argument == '0')
{ check_param.testflag&= ~(T_CHECK | T_CHECK_ONLY_CHANGED);
check_param.testflag&= ~T_CHECK;
check_param.testflag&= ~T_CHECK_ONLY_CHANGED;
}
else else
check_param.testflag|= T_CHECK | T_CHECK_ONLY_CHANGED; check_param.testflag|= T_CHECK | T_CHECK_ONLY_CHANGED;
break; break;
...@@ -429,11 +424,7 @@ get_one_option(int optid, ...@@ -429,11 +424,7 @@ get_one_option(int optid,
break; break;
case 's': /* silent */ case 's': /* silent */
if (argument && *argument == '0') if (argument && *argument == '0')
{ check_param.testflag&= ~(T_SILENT | T_VERY_SILENT);
if (check_param.testflag & T_VERY_SILENT)
check_param.testflag&= ~T_VERY_SILENT;
check_param.testflag&= ~T_SILENT;
}
else else
{ {
if (check_param.testflag & T_SILENT) if (check_param.testflag & T_SILENT)
...@@ -467,8 +458,16 @@ get_one_option(int optid, ...@@ -467,8 +458,16 @@ get_one_option(int optid,
check_param.testflag|= T_INFO; check_param.testflag|= T_INFO;
break; break;
case 'f': case 'f':
check_param.tmpfile_createflag= O_RDWR | O_TRUNC; if (argument && *argument == '0')
check_param.testflag|= T_FORCE_CREATE | T_UPDATE_STATE; {
check_param.tmpfile_createflag= O_RDWR | O_TRUNC | O_EXCL;
check_param.testflag&= ~(T_FORCE_CREATE | T_UPDATE_STATE);
}
else
{
check_param.tmpfile_createflag= O_RDWR | O_TRUNC;
check_param.testflag|= T_FORCE_CREATE | T_UPDATE_STATE;
}
break; break;
case 'F': case 'F':
if (argument && *argument == '0') if (argument && *argument == '0')
...@@ -486,61 +485,82 @@ get_one_option(int optid, ...@@ -486,61 +485,82 @@ get_one_option(int optid,
check_param.testflag|= T_MEDIUM; /* Medium check */ check_param.testflag|= T_MEDIUM; /* Medium check */
break; break;
case 'r': /* Repair table */ case 'r': /* Repair table */
check_param.testflag= (check_param.testflag & ~T_REP) | T_REP_BY_SORT; if (argument && *argument == '0')
check_param.testflag&= ~(T_REP | T_REP_BY_SORT);
else
check_param.testflag= (check_param.testflag & ~T_REP) | T_REP_BY_SORT;
break; break;
case 'o': case 'o':
check_param.testflag= (check_param.testflag & ~T_REP_BY_SORT) | T_REP; if (argument && *argument == '0')
check_param.force_sort=0; {
my_disable_async_io=1; /* More safety */ check_param.testflag&= ~(T_REP | T_REP_BY_SORT);
check_param.force_sort= 0;
}
else
{
check_param.testflag= (check_param.testflag & ~T_REP_BY_SORT) | T_REP;
check_param.force_sort= 0;
my_disable_async_io= 1; /* More safety */
}
break; break;
case 'n': case 'n':
check_param.testflag= (check_param.testflag & ~T_REP) | T_REP_BY_SORT; if (argument && *argument == '0')
check_param.force_sort= 1; {
check_param.testflag&= ~(T_REP | T_REP_BY_SORT);
check_param.force_sort= 0;
}
else
{
check_param.testflag= (check_param.testflag & ~T_REP) | T_REP_BY_SORT;
check_param.force_sort= 1;
}
break; break;
case 'q': case 'q':
if (argument && *argument == '0') if (argument && *argument == '0')
check_param.opt_rep_quick--; check_param.opt_rep_quick=0;
else else
check_param.opt_rep_quick++; check_param.opt_rep_quick++;
break; break;
case 'u': case 'u':
if (argument && *argument == '0') if (argument && *argument == '0')
{ check_param.testflag&= ~(T_UNPACK | T_REP_BY_SORT);
check_param.testflag&= ~T_UNPACK;
check_param.testflag&= ~T_REP_BY_SORT;
}
else else
check_param.testflag|= T_UNPACK | T_REP_BY_SORT; check_param.testflag|= T_UNPACK | T_REP_BY_SORT;
break; break;
case 'v': /* Verbose */ case 'v': /* Verbose */
if (argument && *argument == '0') if (argument && *argument == '0')
{
check_param.testflag&= ~T_VERBOSE; check_param.testflag&= ~T_VERBOSE;
check_param.verbose=0;
}
else else
{
check_param.testflag|= T_VERBOSE; check_param.testflag|= T_VERBOSE;
check_param.verbose++; check_param.verbose++;
}
break; break;
case 'R': /* Sort records */ case 'R': /* Sort records */
old_testflag= check_param.testflag; if (argument && *argument == '0')
check_param.testflag|= T_SORT_RECORDS; check_param.testflag&= ~T_SORT_RECORDS;
check_param.opt_sort_key= (uint) atoi(argument) - 1; else
if (check_param.opt_sort_key >= MI_MAX_KEY)
{ {
fprintf(stderr, check_param.testflag|= T_SORT_RECORDS;
"The value of the sort key is bigger than max key: %d.\n", check_param.opt_sort_key= (uint) atoi(argument) - 1;
MI_MAX_KEY); if (check_param.opt_sort_key >= MI_MAX_KEY)
exit(1); {
fprintf(stderr,
"The value of the sort key is bigger than max key: %d.\n",
MI_MAX_KEY);
exit(1);
}
} }
break; break;
case 'S': /* Sort index */ case 'S': /* Sort index */
old_testflag= check_param.testflag;
if (argument && *argument == '0') if (argument && *argument == '0')
check_param.testflag&= ~T_SORT_INDEX; check_param.testflag&= ~T_SORT_INDEX;
else else
check_param.testflag|= T_SORT_INDEX; check_param.testflag|= T_SORT_INDEX;
break; break;
case 't':
check_param.tmpdir= argument;
break;
case 'T': case 'T':
if (argument && *argument == '0') if (argument && *argument == '0')
check_param.testflag&= ~T_READONLY; check_param.testflag&= ~T_READONLY;
...@@ -554,7 +574,10 @@ get_one_option(int optid, ...@@ -554,7 +574,10 @@ get_one_option(int optid,
check_param.testflag|= T_UPDATE_STATE; check_param.testflag|= T_UPDATE_STATE;
break; break;
case '#': case '#':
DBUG_PUSH(argument ? argument : "d:t:o,/tmp/myisamchk.trace"); if (argument && *argument == '0')
DBUG_POP();
else
DBUG_PUSH(argument ? argument : "d:t:o,/tmp/myisamchk.trace");
break; break;
case 'V': case 'V':
print_version(); print_version();
......
...@@ -48,3 +48,5 @@ i ...@@ -48,3 +48,5 @@ i
2 2
1 1
drop table t1; drop table t1;
select 0 limit 0;
0
...@@ -7,7 +7,7 @@ use test; ...@@ -7,7 +7,7 @@ use test;
drop table if exists t1,t3; drop table if exists t1,t3;
create table t1 (word char(20) not null); create table t1 (word char(20) not null);
load data infile '../../std_data/words.dat' into table t1; load data infile '../../std_data/words.dat' into table t1;
load data local infile '/home/sasha/bk/mysql-4.0/mysql-test/std_data/words.dat' into table t1; load data local infile 'MYSQL_TEST_DIR/std_data/words.dat' into table t1;
select * from t1; select * from t1;
word word
Aarhus Aarhus
......
...@@ -1331,10 +1331,10 @@ table type possible_keys key key_len ref rows Extra ...@@ -1331,10 +1331,10 @@ table type possible_keys key key_len ref rows Extra
t2 ref fld3 fld3 30 const 1 where used; Using index t2 ref fld3 fld3 30 const 1 where used; Using index
explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle'; explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle';
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t2 index fld3 fld3 30 NULL 1199 where used; Using index t2 index NULL fld3 30 NULL 1199 where used; Using index
explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle'; explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle';
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t2 index fld3 fld3 30 NULL 1199 where used; Using index t2 index NULL fld3 30 NULL 1199 where used; Using index
explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle'; explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle';
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t2 ref fld3 fld3 30 const 1 where used; Using index t2 ref fld3 fld3 30 const 1 where used; Using index
......
...@@ -45,3 +45,20 @@ select found_rows(); ...@@ -45,3 +45,20 @@ select found_rows();
FOUND_ROWS() FOUND_ROWS()
8 8
drop table t1; drop table t1;
create table t1 (a int not null primary key);
insert into t1 values (1),(2),(3),(4),(5);
select sql_calc_found_rows a from t1 where a in (1,2,3) order by a desc limit 0,2;
a
3
2
select FOUND_ROWS();
FOUND_ROWS()
3
select sql_calc_found_rows a from t1 where a in (1,2,3) order by a+2 desc limit 0,2;
a
3
2
select FOUND_ROWS();
FOUND_ROWS()
3
drop table t1;
...@@ -28,3 +28,5 @@ delete from t1 limit 0; ...@@ -28,3 +28,5 @@ delete from t1 limit 0;
update t1 set i=3 limit 0; update t1 set i=3 limit 0;
select * from t1; select * from t1;
drop table t1; drop table t1;
select 0 limit 0;
...@@ -5,6 +5,7 @@ use test; ...@@ -5,6 +5,7 @@ use test;
drop table if exists t1,t3; drop table if exists t1,t3;
create table t1 (word char(20) not null); create table t1 (word char(20) not null);
load data infile '../../std_data/words.dat' into table t1; load data infile '../../std_data/words.dat' into table t1;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
eval load data local infile '$MYSQL_TEST_DIR/std_data/words.dat' into table t1; eval load data local infile '$MYSQL_TEST_DIR/std_data/words.dat' into table t1;
select * from t1; select * from t1;
set password for root@"localhost" = password('foo'); set password for root@"localhost" = password('foo');
......
...@@ -18,3 +18,15 @@ select found_rows(); ...@@ -18,3 +18,15 @@ select found_rows();
select SQL_CALC_FOUND_ROWS * from t1 left join t1 as t2 on (t1.b=t2.a) limit 2,1; select SQL_CALC_FOUND_ROWS * from t1 left join t1 as t2 on (t1.b=t2.a) limit 2,1;
select found_rows(); select found_rows();
drop table t1; drop table t1;
#
# Test SQL_CALC_FOUND_ROWS optimization when used with one table and filesort
#
create table t1 (a int not null primary key);
insert into t1 values (1),(2),(3),(4),(5);
select sql_calc_found_rows a from t1 where a in (1,2,3) order by a desc limit 0,2;
select FOUND_ROWS();
select sql_calc_found_rows a from t1 where a in (1,2,3) order by a+2 desc limit 0,2;
select FOUND_ROWS();
drop table t1;
...@@ -45,6 +45,7 @@ static int NEAR_F delete_file(const char *name,const char *ext,int extflag); ...@@ -45,6 +45,7 @@ static int NEAR_F delete_file(const char *name,const char *ext,int extflag);
ulong ha_read_count, ha_write_count, ha_delete_count, ha_update_count, ulong ha_read_count, ha_write_count, ha_delete_count, ha_update_count,
ha_read_key_count, ha_read_next_count, ha_read_prev_count, ha_read_key_count, ha_read_next_count, ha_read_prev_count,
ha_read_first_count, ha_read_last_count, ha_read_first_count, ha_read_last_count,
ha_commit_count, ha_rollback_count,
ha_read_rnd_count, ha_read_rnd_next_count; ha_read_rnd_count, ha_read_rnd_next_count;
const char *ha_table_type[] = { const char *ha_table_type[] = {
...@@ -267,6 +268,7 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans) ...@@ -267,6 +268,7 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans)
#ifdef USING_TRANSACTIONS #ifdef USING_TRANSACTIONS
if (opt_using_transactions) if (opt_using_transactions)
{ {
bool operation_done=0;
/* Update the binary log if we have cached some queries */ /* Update the binary log if we have cached some queries */
if (trans == &thd->transaction.all && mysql_bin_log.is_open() && if (trans == &thd->transaction.all && mysql_bin_log.is_open() &&
my_b_tell(&thd->transaction.trans_log)) my_b_tell(&thd->transaction.trans_log))
...@@ -297,12 +299,17 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans) ...@@ -297,12 +299,17 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans)
} }
trans->innodb_active_trans=0; trans->innodb_active_trans=0;
if (trans == &thd->transaction.all) if (trans == &thd->transaction.all)
{
query_cache.invalidate(Query_cache_table::INNODB); query_cache.invalidate(Query_cache_table::INNODB);
operation_done=1;
}
} }
#endif #endif
if (error && trans == &thd->transaction.all && mysql_bin_log.is_open()) if (error && trans == &thd->transaction.all && mysql_bin_log.is_open())
sql_print_error("Error: Got error during commit; Binlog is not up to date!"); sql_print_error("Error: Got error during commit; Binlog is not up to date!");
thd->tx_isolation=thd->session_tx_isolation; thd->tx_isolation=thd->session_tx_isolation;
if (operation_done)
statistic_increment(ha_commit_count,&LOCK_status);
} }
#endif // using transactions #endif // using transactions
DBUG_RETURN(error); DBUG_RETURN(error);
...@@ -316,6 +323,7 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans) ...@@ -316,6 +323,7 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans)
#ifdef USING_TRANSACTIONS #ifdef USING_TRANSACTIONS
if (opt_using_transactions) if (opt_using_transactions)
{ {
bool operation_done=0;
#ifdef HAVE_BERKELEY_DB #ifdef HAVE_BERKELEY_DB
if (trans->bdb_tid) if (trans->bdb_tid)
{ {
...@@ -325,6 +333,7 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans) ...@@ -325,6 +333,7 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans)
error=1; error=1;
} }
trans->bdb_tid=0; trans->bdb_tid=0;
operation_done=1;
} }
#endif #endif
#ifdef HAVE_INNOBASE_DB #ifdef HAVE_INNOBASE_DB
...@@ -336,6 +345,7 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans) ...@@ -336,6 +345,7 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans)
error=1; error=1;
} }
trans->innodb_active_trans=0; trans->innodb_active_trans=0;
operation_done=1;
} }
#endif #endif
if (trans == &thd->transaction.all) if (trans == &thd->transaction.all)
...@@ -343,6 +353,8 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans) ...@@ -343,6 +353,8 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans)
WRITE_CACHE, (my_off_t) 0, 0, 1); WRITE_CACHE, (my_off_t) 0, 0, 1);
thd->transaction.trans_log.end_of_file= max_binlog_cache_size; thd->transaction.trans_log.end_of_file= max_binlog_cache_size;
thd->tx_isolation=thd->session_tx_isolation; thd->tx_isolation=thd->session_tx_isolation;
if (operation_done)
statistic_increment(ha_rollback_count,&LOCK_status);
} }
#endif /* USING_TRANSACTIONS */ #endif /* USING_TRANSACTIONS */
DBUG_RETURN(error); DBUG_RETURN(error);
......
...@@ -586,7 +586,8 @@ extern char f_fyllchar; ...@@ -586,7 +586,8 @@ extern char f_fyllchar;
extern ulong ha_read_count, ha_write_count, ha_delete_count, ha_update_count, extern ulong ha_read_count, ha_write_count, ha_delete_count, ha_update_count,
ha_read_key_count, ha_read_next_count, ha_read_prev_count, ha_read_key_count, ha_read_next_count, ha_read_prev_count,
ha_read_first_count, ha_read_last_count, ha_read_first_count, ha_read_last_count,
ha_read_rnd_count, ha_read_rnd_next_count; ha_read_rnd_count, ha_read_rnd_next_count,
ha_commit_count, ha_rollback_count;
extern MY_BITMAP temp_pool; extern MY_BITMAP temp_pool;
extern uchar *days_in_month; extern uchar *days_in_month;
extern DATE_FORMAT dayord; extern DATE_FORMAT dayord;
......
...@@ -3211,6 +3211,7 @@ struct show_var_st status_vars[]= { ...@@ -3211,6 +3211,7 @@ struct show_var_st status_vars[]= {
{"Delayed_writes", (char*) &delayed_insert_writes, SHOW_LONG}, {"Delayed_writes", (char*) &delayed_insert_writes, SHOW_LONG},
{"Delayed_errors", (char*) &delayed_insert_errors, SHOW_LONG}, {"Delayed_errors", (char*) &delayed_insert_errors, SHOW_LONG},
{"Flush_commands", (char*) &refresh_version, SHOW_LONG_CONST}, {"Flush_commands", (char*) &refresh_version, SHOW_LONG_CONST},
{"Handler_commit", (char*) &ha_commit_count, SHOW_LONG},
{"Handler_delete", (char*) &ha_delete_count, SHOW_LONG}, {"Handler_delete", (char*) &ha_delete_count, SHOW_LONG},
{"Handler_read_first", (char*) &ha_read_first_count, SHOW_LONG}, {"Handler_read_first", (char*) &ha_read_first_count, SHOW_LONG},
{"Handler_read_key", (char*) &ha_read_key_count, SHOW_LONG}, {"Handler_read_key", (char*) &ha_read_key_count, SHOW_LONG},
...@@ -3218,6 +3219,7 @@ struct show_var_st status_vars[]= { ...@@ -3218,6 +3219,7 @@ struct show_var_st status_vars[]= {
{"Handler_read_prev", (char*) &ha_read_prev_count, SHOW_LONG}, {"Handler_read_prev", (char*) &ha_read_prev_count, SHOW_LONG},
{"Handler_read_rnd", (char*) &ha_read_rnd_count, SHOW_LONG}, {"Handler_read_rnd", (char*) &ha_read_rnd_count, SHOW_LONG},
{"Handler_read_rnd_next", (char*) &ha_read_rnd_next_count, SHOW_LONG}, {"Handler_read_rnd_next", (char*) &ha_read_rnd_next_count, SHOW_LONG},
{"Handler_rollback", (char*) &ha_rollback_count, SHOW_LONG},
{"Handler_update", (char*) &ha_update_count, SHOW_LONG}, {"Handler_update", (char*) &ha_update_count, SHOW_LONG},
{"Handler_write", (char*) &ha_write_count, SHOW_LONG}, {"Handler_write", (char*) &ha_write_count, SHOW_LONG},
{"Key_blocks_used", (char*) &_my_blocks_used, SHOW_LONG_CONST}, {"Key_blocks_used", (char*) &_my_blocks_used, SHOW_LONG_CONST},
......
...@@ -2929,17 +2929,17 @@ return_zero_rows(select_result *result,TABLE_LIST *tables,List<Item> &fields, ...@@ -2929,17 +2929,17 @@ return_zero_rows(select_result *result,TABLE_LIST *tables,List<Item> &fields,
if (having && having->val_int() == 0) if (having && having->val_int() == 0)
send_row=0; send_row=0;
} }
if (!tables || !(result->send_fields(fields,1))) if (!(result->send_fields(fields,1)))
{ {
if (send_row) if (send_row)
result->send_data(fields); result->send_data(fields);
if (tables) // Not from do_select() if (tables) // Not from do_select()
{ {
/* Close open cursors */ /* Close open cursors */
for (TABLE_LIST *table=tables; table ; table=table->next) for (TABLE_LIST *table=tables; table ; table=table->next)
table->table->file->index_end(); table->table->file->index_end();
result->send_eof(); // Should be safe
} }
result->send_eof(); // Should be safe
} }
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -4877,8 +4877,10 @@ end_send(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), ...@@ -4877,8 +4877,10 @@ end_send(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
{ {
JOIN_TAB *jt=join->join_tab; JOIN_TAB *jt=join->join_tab;
if ((join->tables == 1) && !join->tmp_table && !join->sort_and_group if ((join->tables == 1) && !join->tmp_table && !join->sort_and_group
&& !join->send_group_parts && !join->having && !jt->select_cond) && !join->send_group_parts && !join->having && !jt->select_cond &&
!(jt->table->file->option_flag() & HA_NOT_EXACT_COUNT))
{ {
/* Join over all rows in table; Return number of found rows */
join->select_options ^= OPTION_FOUND_ROWS; join->select_options ^= OPTION_FOUND_ROWS;
join->send_records = jt->records; join->send_records = jt->records;
} }
...@@ -5603,6 +5605,7 @@ create_sort_index(JOIN_TAB *tab,ORDER *order,ha_rows select_limit) ...@@ -5603,6 +5605,7 @@ create_sort_index(JOIN_TAB *tab,ORDER *order,ha_rows select_limit)
table->file->info(HA_STATUS_VARIABLE); // Get record count table->file->info(HA_STATUS_VARIABLE); // Get record count
table->found_records=filesort(table,sortorder,length, table->found_records=filesort(table,sortorder,length,
select, 0L, select_limit, &examined_rows); select, 0L, select_limit, &examined_rows);
tab->records=table->found_records; // For SQL_CALC_ROWS
delete select; // filesort did select delete select; // filesort did select
tab->select=0; tab->select=0;
tab->select_cond=0; tab->select_cond=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