BUG#19914 SELECT COUNT(*) sometimes returns MAX_INT on cluster tables

post-review fixes as indicated by Serg.

manual testing of error cases done in 5.0 due to support for DBUG_EXECUTE_IF
to insert errors.
Unable to write test case for mysql-test until 5.1 due to support for setting
debug options at runtime.
parent 3ecc09e0
......@@ -100,7 +100,7 @@ void ha_blackhole::position(const byte *record)
}
void ha_blackhole::info(uint flag)
int ha_blackhole::info(uint flag)
{
DBUG_ENTER("ha_blackhole::info");
......@@ -114,7 +114,7 @@ void ha_blackhole::info(uint flag)
delete_length= 0;
if (flag & HA_STATUS_AUTO)
auto_increment_value= 1;
DBUG_VOID_RETURN;
DBUG_RETURN(0);
}
int ha_blackhole::external_lock(THD *thd, int lock_type)
......
......@@ -78,7 +78,7 @@ public:
int index_first(byte * buf);
int index_last(byte * buf);
void position(const byte *record);
void info(uint flag);
int info(uint flag);
int external_lock(THD *thd, int lock_type);
uint lock_count(void) const;
int create(const char *name, TABLE *table_arg,
......
......@@ -178,7 +178,7 @@ void ha_isam::position(const byte *record)
ha_store_ptr(ref, ref_length, position);
}
void ha_isam::info(uint flag)
int ha_isam::info(uint flag)
{
N_ISAMINFO info;
(void) nisam_info(file,&info,flag);
......@@ -224,6 +224,7 @@ void ha_isam::info(uint flag)
}
if (flag & HA_STATUS_TIME)
update_time = info.update_time;
return 0;
}
......
......@@ -67,7 +67,7 @@ class ha_isam: public handler
int rnd_next(byte *buf);
int rnd_pos(byte * buf, byte *pos);
void position(const byte *record);
void info(uint);
int info(uint);
int extra(enum ha_extra_function operation);
int external_lock(THD *thd, int lock_type);
ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key);
......
......@@ -149,7 +149,7 @@ void ha_isammrg::position(const byte *record)
}
void ha_isammrg::info(uint flag)
int ha_isammrg::info(uint flag)
{
MERGE_INFO info;
(void) mrg_info(file,&info,flag);
......@@ -163,6 +163,7 @@ void ha_isammrg::info(uint flag)
block_size=0;
update_time=0;
ref_length=4; // Should be big enough
return 0;
}
......
......@@ -58,7 +58,7 @@ class ha_isammrg: public handler
int rnd_next(byte *buf);
int rnd_pos(byte * buf, byte *pos);
void position(const byte *record);
void info(uint);
int info(uint);
int extra(enum ha_extra_function operation);
int external_lock(THD *thd, int lock_type);
uint lock_count(void) const;
......
......@@ -1410,12 +1410,20 @@ bool Item_sum_count_distinct::add()
longlong Item_sum_count_distinct::val_int()
{
int error;
DBUG_ASSERT(fixed == 1);
if (!table) // Empty query
return LL(0);
if (use_tree)
return tree->elements_in_tree;
table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
error= table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
if(error)
{
table->file->print_error(error, MYF(0));
}
return table->file->records;
}
......
......@@ -43,7 +43,12 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
if ((open_and_lock_tables(thd, table_list)))
DBUG_RETURN(-1);
table= table_list->table;
table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
error= table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
if (error)
{
table->file->print_error(error, MYF(0));
DBUG_RETURN(error);
}
thd->proc_info="init";
table->map=1;
......
......@@ -1786,7 +1786,12 @@ make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds,
s->checked_keys.init();
s->needed_reg.init();
table_vector[i]=s->table=table=tables->table;
table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);// record count
error= table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
if(error)
{
table->file->print_error(error, MYF(0));
DBUG_RETURN(1);
}
table->quick_keys.clear_all();
table->reginfo.join_tab=s;
table->reginfo.not_exists_optimize=0;
......
......@@ -492,7 +492,12 @@ int st_select_lex_unit::exec()
DBUG_RETURN(res);
}
/* Needed for the following test and for records_at_start in next loop */
table->file->info(HA_STATUS_VARIABLE);
int error= table->file->info(HA_STATUS_VARIABLE);
if(error)
{
table->file->print_error(error, MYF(0));
DBUG_RETURN(1);
}
if (found_rows_for_union && !sl->braces &&
select_limit_cnt != HA_POS_ERROR)
{
......
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