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

allow handler::info to return an error code (that will be returned to the user)


sql/ha_berkeley.cc:
  update handler::info interface to return int
sql/ha_berkeley.h:
  update handler::info interface to return int
sql/ha_heap.cc:
  update handler::info interface to return int
sql/ha_heap.h:
  update handler::info interface to return int
sql/ha_innodb.cc:
  update handler::info interface to return int
sql/ha_innodb.h:
  update handler::info interface to return int
sql/ha_myisam.cc:
  update handler::info interface to return int
sql/examples/ha_archive.cc:
  update handler::info interface to return int
sql/examples/ha_archive.h:
  update handler::info interface to return int
sql/examples/ha_example.cc:
  update handler::info interface to return int
sql/examples/ha_example.h:
  update handler::info interface to return int
sql/examples/ha_tina.cc:
  update handler::info interface to return int
sql/examples/ha_tina.h:
  update handler::info interface to return int
sql/ha_myisam.h:
  update handler::info interface to return int
sql/ha_myisammrg.cc:
  update handler::info interface to return int
sql/ha_myisammrg.h:
  update handler::info interface to return int
sql/ha_ndbcluster.cc:
  update handler::info interface to return int
sql/ha_ndbcluster.h:
  update handler::info interface to return int
sql/handler.h:
  update handler::info interface to return int
sql/opt_sum.cc:
  If we get an error when using handler::info to get count(*),
  print and return the error.
sql/sql_select.cc:
  if error, set fatal error.
This commit is contained in:
unknown 2006-08-10 22:55:20 +08:00
commit e34496e5d8
21 changed files with 53 additions and 35 deletions

View file

@ -256,11 +256,13 @@ void ha_ndbcluster::set_rec_per_key()
DBUG_VOID_RETURN;
}
void ha_ndbcluster::records_update()
int ha_ndbcluster::records_update()
{
if (m_ha_not_exact_count)
return;
return 0;
DBUG_ENTER("ha_ndbcluster::records_update");
int result= 0;
struct Ndb_local_table_statistics *info=
(struct Ndb_local_table_statistics *)m_table_info;
DBUG_PRINT("info", ("id=%d, no_uncommitted_rows_count=%d",
@ -271,7 +273,7 @@ void ha_ndbcluster::records_update()
Ndb *ndb= get_ndb();
Uint64 rows;
ndb->setDatabaseName(m_dbname);
if(ndb_get_table_statistics(ndb, m_tabname, &rows, 0) == 0){
if((result= ndb_get_table_statistics(ndb, m_tabname, &rows, 0)) == 0){
info->records= rows;
}
}
@ -281,7 +283,7 @@ void ha_ndbcluster::records_update()
info->no_uncommitted_rows_count= 0;
}
records= info->records+ info->no_uncommitted_rows_count;
DBUG_VOID_RETURN;
DBUG_RETURN(result);
}
void ha_ndbcluster::no_uncommitted_rows_execute_failure()
@ -2858,8 +2860,9 @@ void ha_ndbcluster::position(const byte *record)
}
void ha_ndbcluster::info(uint flag)
int ha_ndbcluster::info(uint flag)
{
int result= 0;
DBUG_ENTER("info");
DBUG_PRINT("enter", ("flag: %d", flag));
@ -2877,17 +2880,17 @@ void ha_ndbcluster::info(uint flag)
if (m_ha_not_exact_count)
records= 100;
else
records_update();
result= records_update();
}
else
{
if ((my_errno= check_ndb_connection()))
DBUG_VOID_RETURN;
DBUG_RETURN(my_errno);
Ndb *ndb= get_ndb();
Uint64 rows= 100;
ndb->setDatabaseName(m_dbname);
if (current_thd->variables.ndb_use_exact_count)
ndb_get_table_statistics(ndb, m_tabname, &rows, 0);
result= ndb_get_table_statistics(ndb, m_tabname, &rows, 0);
records= rows;
}
}
@ -2912,7 +2915,11 @@ void ha_ndbcluster::info(uint flag)
ndb->readAutoIncrementValue((const NDBTAB *) m_table);
}
}
DBUG_VOID_RETURN;
if(result == -1)
result= HA_ERR_NO_CONNECTION;
DBUG_RETURN(result);
}