Commit a4faddc6 authored by stewart@willster.(none)'s avatar stewart@willster.(none)

Merge bk-internal.mysql.com:/home/bk/mysql-4.1-ndb

into  willster.(none):/home/stewart/Documents/MySQL/4.1/bug19914-mk2-merge2
parents 0f74244d 5926602a
...@@ -972,7 +972,7 @@ int ha_archive::index_last(byte * buf) ...@@ -972,7 +972,7 @@ int ha_archive::index_last(byte * buf)
} }
void ha_archive::info(uint flag) int ha_archive::info(uint flag)
{ {
DBUG_ENTER("ha_archive::info"); DBUG_ENTER("ha_archive::info");
...@@ -980,7 +980,7 @@ void ha_archive::info(uint flag) ...@@ -980,7 +980,7 @@ void ha_archive::info(uint flag)
records= share->rows_recorded; records= share->rows_recorded;
deleted= 0; deleted= 0;
DBUG_VOID_RETURN; DBUG_RETURN(0);
} }
int ha_archive::extra(enum ha_extra_function operation) int ha_archive::extra(enum ha_extra_function operation)
......
...@@ -116,7 +116,7 @@ public: ...@@ -116,7 +116,7 @@ public:
int read_data_header(gzFile file_to_read); int read_data_header(gzFile file_to_read);
int write_data_header(gzFile file_to_write); int write_data_header(gzFile file_to_write);
void position(const byte *record); void position(const byte *record);
void info(uint); int info(uint);
int extra(enum ha_extra_function operation); int extra(enum ha_extra_function operation);
int reset(void); int reset(void);
int external_lock(THD *thd, int lock_type); int external_lock(THD *thd, int lock_type);
......
...@@ -486,10 +486,10 @@ int ha_example::rnd_pos(byte * buf, byte *pos) ...@@ -486,10 +486,10 @@ int ha_example::rnd_pos(byte * buf, byte *pos)
sql_update.cc sql_update.cc
*/ */
void ha_example::info(uint flag) int ha_example::info(uint flag)
{ {
DBUG_ENTER("ha_example::info"); DBUG_ENTER("ha_example::info");
DBUG_VOID_RETURN; DBUG_RETURN(0);
} }
......
...@@ -138,7 +138,7 @@ public: ...@@ -138,7 +138,7 @@ public:
int rnd_next(byte *buf); //required int rnd_next(byte *buf); //required
int rnd_pos(byte * buf, byte *pos); //required int rnd_pos(byte * buf, byte *pos); //required
void position(const byte *record); //required void position(const byte *record); //required
void info(uint); //required int info(uint); //required
int extra(enum ha_extra_function operation); int extra(enum ha_extra_function operation);
int reset(void); int reset(void);
......
...@@ -683,13 +683,13 @@ int ha_tina::rnd_pos(byte * buf, byte *pos) ...@@ -683,13 +683,13 @@ int ha_tina::rnd_pos(byte * buf, byte *pos)
Currently this table handler doesn't implement most of the fields Currently this table handler doesn't implement most of the fields
really needed. SHOW also makes use of this data really needed. SHOW also makes use of this data
*/ */
void ha_tina::info(uint flag) int ha_tina::info(uint flag)
{ {
DBUG_ENTER("ha_tina::info"); DBUG_ENTER("ha_tina::info");
/* This is a lie, but you don't want the optimizer to see zero or 1 */ /* This is a lie, but you don't want the optimizer to see zero or 1 */
if (records < 2) if (records < 2)
records= 2; records= 2;
DBUG_VOID_RETURN; DBUG_RETURN(0);
} }
/* /*
......
...@@ -115,7 +115,7 @@ class ha_tina: public handler ...@@ -115,7 +115,7 @@ class ha_tina: public handler
int rnd_pos(byte * buf, byte *pos); int rnd_pos(byte * buf, byte *pos);
int rnd_end(); int rnd_end();
void position(const byte *record); void position(const byte *record);
void info(uint); int info(uint);
int extra(enum ha_extra_function operation); int extra(enum ha_extra_function operation);
int reset(void); int reset(void);
int external_lock(THD *thd, int lock_type); int external_lock(THD *thd, int lock_type);
......
...@@ -1715,7 +1715,7 @@ void ha_berkeley::position(const byte *record) ...@@ -1715,7 +1715,7 @@ void ha_berkeley::position(const byte *record)
} }
void ha_berkeley::info(uint flag) int ha_berkeley::info(uint flag)
{ {
DBUG_ENTER("ha_berkeley::info"); DBUG_ENTER("ha_berkeley::info");
if (flag & HA_STATUS_VARIABLE) if (flag & HA_STATUS_VARIABLE)
...@@ -1735,7 +1735,7 @@ void ha_berkeley::info(uint flag) ...@@ -1735,7 +1735,7 @@ void ha_berkeley::info(uint flag)
/* Don't return key if we got an error for the internal primary key */ /* Don't return key if we got an error for the internal primary key */
if (flag & HA_STATUS_ERRKEY && last_dup_key < table->keys) if (flag & HA_STATUS_ERRKEY && last_dup_key < table->keys)
errkey= last_dup_key; errkey= last_dup_key;
DBUG_VOID_RETURN; DBUG_RETURN(0);
} }
......
...@@ -127,7 +127,7 @@ class ha_berkeley: public handler ...@@ -127,7 +127,7 @@ class ha_berkeley: public handler
int rnd_next(byte *buf); int rnd_next(byte *buf);
int rnd_pos(byte * buf, byte *pos); int rnd_pos(byte * buf, byte *pos);
void position(const byte *record); void position(const byte *record);
void info(uint); int info(uint);
int extra(enum ha_extra_function operation); int extra(enum ha_extra_function operation);
int reset(void); int reset(void);
int external_lock(THD *thd, int lock_type); int external_lock(THD *thd, int lock_type);
......
...@@ -100,7 +100,7 @@ void ha_blackhole::position(const byte *record) ...@@ -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"); DBUG_ENTER("ha_blackhole::info");
...@@ -114,7 +114,7 @@ void ha_blackhole::info(uint flag) ...@@ -114,7 +114,7 @@ void ha_blackhole::info(uint flag)
delete_length= 0; delete_length= 0;
if (flag & HA_STATUS_AUTO) if (flag & HA_STATUS_AUTO)
auto_increment_value= 1; auto_increment_value= 1;
DBUG_VOID_RETURN; DBUG_RETURN(0);
} }
int ha_blackhole::external_lock(THD *thd, int lock_type) int ha_blackhole::external_lock(THD *thd, int lock_type)
......
...@@ -78,7 +78,7 @@ public: ...@@ -78,7 +78,7 @@ public:
int index_first(byte * buf); int index_first(byte * buf);
int index_last(byte * buf); int index_last(byte * buf);
void position(const byte *record); void position(const byte *record);
void info(uint flag); int info(uint flag);
int external_lock(THD *thd, int lock_type); int external_lock(THD *thd, int lock_type);
uint lock_count(void) const; uint lock_count(void) const;
int create(const char *name, TABLE *table_arg, int create(const char *name, TABLE *table_arg,
......
...@@ -282,7 +282,7 @@ void ha_heap::position(const byte *record) ...@@ -282,7 +282,7 @@ void ha_heap::position(const byte *record)
*(HEAP_PTR*) ref= heap_position(file); // Ref is aligned *(HEAP_PTR*) ref= heap_position(file); // Ref is aligned
} }
void ha_heap::info(uint flag) int ha_heap::info(uint flag)
{ {
HEAPINFO info; HEAPINFO info;
(void) heap_info(file,&info,flag); (void) heap_info(file,&info,flag);
...@@ -304,6 +304,7 @@ void ha_heap::info(uint flag) ...@@ -304,6 +304,7 @@ void ha_heap::info(uint flag)
*/ */
if (key_stat_version != file->s->key_stat_version) if (key_stat_version != file->s->key_stat_version)
update_key_stats(); update_key_stats();
return 0;
} }
int ha_heap::extra(enum ha_extra_function operation) int ha_heap::extra(enum ha_extra_function operation)
......
...@@ -80,7 +80,7 @@ public: ...@@ -80,7 +80,7 @@ public:
int rnd_next(byte *buf); int rnd_next(byte *buf);
int rnd_pos(byte * buf, byte *pos); int rnd_pos(byte * buf, byte *pos);
void position(const byte *record); void position(const byte *record);
void info(uint); int info(uint);
int extra(enum ha_extra_function operation); int extra(enum ha_extra_function operation);
int external_lock(THD *thd, int lock_type); int external_lock(THD *thd, int lock_type);
int delete_all_rows(void); int delete_all_rows(void);
......
...@@ -4570,7 +4570,7 @@ ha_innobase::read_time( ...@@ -4570,7 +4570,7 @@ ha_innobase::read_time(
Returns statistics information of the table to the MySQL interpreter, Returns statistics information of the table to the MySQL interpreter,
in various fields of the handle object. */ in various fields of the handle object. */
void int
ha_innobase::info( ha_innobase::info(
/*==============*/ /*==============*/
uint flag) /* in: what information MySQL requests */ uint flag) /* in: what information MySQL requests */
...@@ -4593,7 +4593,7 @@ ha_innobase::info( ...@@ -4593,7 +4593,7 @@ ha_innobase::info(
if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) { if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {
DBUG_VOID_RETURN; DBUG_RETURN(HA_ERR_CRASHED);
} }
/* We do not know if MySQL can call this function before calling /* We do not know if MySQL can call this function before calling
...@@ -4758,7 +4758,7 @@ ha_innobase::info( ...@@ -4758,7 +4758,7 @@ ha_innobase::info(
prebuilt->trx->op_info = (char*)""; prebuilt->trx->op_info = (char*)"";
DBUG_VOID_RETURN; DBUG_RETURN(0);
} }
/************************************************************************** /**************************************************************************
......
...@@ -142,7 +142,7 @@ class ha_innobase: public handler ...@@ -142,7 +142,7 @@ class ha_innobase: public handler
int rnd_pos(byte * buf, byte *pos); int rnd_pos(byte * buf, byte *pos);
void position(const byte *record); void position(const byte *record);
void info(uint); int info(uint);
int analyze(THD* thd,HA_CHECK_OPT* check_opt); int analyze(THD* thd,HA_CHECK_OPT* check_opt);
int optimize(THD* thd,HA_CHECK_OPT* check_opt); int optimize(THD* thd,HA_CHECK_OPT* check_opt);
int discard_or_import_tablespace(my_bool discard); int discard_or_import_tablespace(my_bool discard);
......
...@@ -178,7 +178,7 @@ void ha_isam::position(const byte *record) ...@@ -178,7 +178,7 @@ void ha_isam::position(const byte *record)
ha_store_ptr(ref, ref_length, position); ha_store_ptr(ref, ref_length, position);
} }
void ha_isam::info(uint flag) int ha_isam::info(uint flag)
{ {
N_ISAMINFO info; N_ISAMINFO info;
(void) nisam_info(file,&info,flag); (void) nisam_info(file,&info,flag);
...@@ -224,6 +224,7 @@ void ha_isam::info(uint flag) ...@@ -224,6 +224,7 @@ void ha_isam::info(uint flag)
} }
if (flag & HA_STATUS_TIME) if (flag & HA_STATUS_TIME)
update_time = info.update_time; update_time = info.update_time;
return 0;
} }
......
...@@ -67,7 +67,7 @@ class ha_isam: public handler ...@@ -67,7 +67,7 @@ class ha_isam: public handler
int rnd_next(byte *buf); int rnd_next(byte *buf);
int rnd_pos(byte * buf, byte *pos); int rnd_pos(byte * buf, byte *pos);
void position(const byte *record); void position(const byte *record);
void info(uint); int info(uint);
int extra(enum ha_extra_function operation); int extra(enum ha_extra_function operation);
int external_lock(THD *thd, int lock_type); int external_lock(THD *thd, int lock_type);
ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key); 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) ...@@ -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; MERGE_INFO info;
(void) mrg_info(file,&info,flag); (void) mrg_info(file,&info,flag);
...@@ -163,6 +163,7 @@ void ha_isammrg::info(uint flag) ...@@ -163,6 +163,7 @@ void ha_isammrg::info(uint flag)
block_size=0; block_size=0;
update_time=0; update_time=0;
ref_length=4; // Should be big enough ref_length=4; // Should be big enough
return 0;
} }
......
...@@ -58,7 +58,7 @@ class ha_isammrg: public handler ...@@ -58,7 +58,7 @@ class ha_isammrg: public handler
int rnd_next(byte *buf); int rnd_next(byte *buf);
int rnd_pos(byte * buf, byte *pos); int rnd_pos(byte * buf, byte *pos);
void position(const byte *record); void position(const byte *record);
void info(uint); int info(uint);
int extra(enum ha_extra_function operation); int extra(enum ha_extra_function operation);
int external_lock(THD *thd, int lock_type); int external_lock(THD *thd, int lock_type);
uint lock_count(void) const; uint lock_count(void) const;
......
...@@ -1214,7 +1214,7 @@ void ha_myisam::position(const byte* record) ...@@ -1214,7 +1214,7 @@ void ha_myisam::position(const byte* record)
ha_store_ptr(ref, ref_length, position); ha_store_ptr(ref, ref_length, position);
} }
void ha_myisam::info(uint flag) int ha_myisam::info(uint flag)
{ {
MI_ISAMINFO info; MI_ISAMINFO info;
char name_buff[FN_REFLEN]; char name_buff[FN_REFLEN];
...@@ -1273,6 +1273,8 @@ void ha_myisam::info(uint flag) ...@@ -1273,6 +1273,8 @@ void ha_myisam::info(uint flag)
update_time = info.update_time; update_time = info.update_time;
if (flag & HA_STATUS_AUTO) if (flag & HA_STATUS_AUTO)
auto_increment_value= info.auto_increment; auto_increment_value= info.auto_increment;
return 0;
} }
......
...@@ -100,7 +100,7 @@ class ha_myisam: public handler ...@@ -100,7 +100,7 @@ class ha_myisam: public handler
int rnd_pos(byte * buf, byte *pos); int rnd_pos(byte * buf, byte *pos);
int restart_rnd_next(byte *buf, byte *pos); int restart_rnd_next(byte *buf, byte *pos);
void position(const byte *record); void position(const byte *record);
void info(uint); int info(uint);
int extra(enum ha_extra_function operation); int extra(enum ha_extra_function operation);
int extra_opt(enum ha_extra_function operation, ulong cache_size); int extra_opt(enum ha_extra_function operation, ulong cache_size);
int external_lock(THD *thd, int lock_type); int external_lock(THD *thd, int lock_type);
......
...@@ -218,7 +218,7 @@ ha_rows ha_myisammrg::records_in_range(uint inx, key_range *min_key, ...@@ -218,7 +218,7 @@ ha_rows ha_myisammrg::records_in_range(uint inx, key_range *min_key,
} }
void ha_myisammrg::info(uint flag) int ha_myisammrg::info(uint flag)
{ {
MYMERGE_INFO info; MYMERGE_INFO info;
(void) myrg_status(file,&info,flag); (void) myrg_status(file,&info,flag);
...@@ -266,6 +266,7 @@ void ha_myisammrg::info(uint flag) ...@@ -266,6 +266,7 @@ void ha_myisammrg::info(uint flag)
min(file->keys, table->key_parts)); min(file->keys, table->key_parts));
} }
} }
return 0;
} }
......
...@@ -71,7 +71,7 @@ class ha_myisammrg: public handler ...@@ -71,7 +71,7 @@ class ha_myisammrg: public handler
int rnd_pos(byte * buf, byte *pos); int rnd_pos(byte * buf, byte *pos);
void position(const byte *record); void position(const byte *record);
ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key); ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key);
void info(uint); int info(uint);
int extra(enum ha_extra_function operation); int extra(enum ha_extra_function operation);
int extra_opt(enum ha_extra_function operation, ulong cache_size); int extra_opt(enum ha_extra_function operation, ulong cache_size);
int external_lock(THD *thd, int lock_type); int external_lock(THD *thd, int lock_type);
......
...@@ -85,7 +85,7 @@ static int packfrm(const void *data, uint len, const void **pack_data, uint *pac ...@@ -85,7 +85,7 @@ static int packfrm(const void *data, uint len, const void **pack_data, uint *pac
static int unpackfrm(const void **data, uint *len, static int unpackfrm(const void **data, uint *len,
const void* pack_data); const void* pack_data);
static int ndb_get_table_statistics(Ndb*, const char *, static int ndb_get_table_statistics(ha_ndbcluster*, bool, Ndb*, const char *,
Uint64* rows, Uint64* commits); Uint64* rows, Uint64* commits);
...@@ -258,11 +258,13 @@ void ha_ndbcluster::set_rec_per_key() ...@@ -258,11 +258,13 @@ void ha_ndbcluster::set_rec_per_key()
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
void ha_ndbcluster::records_update() int ha_ndbcluster::records_update()
{ {
if (m_ha_not_exact_count) if (m_ha_not_exact_count)
return; return 0;
DBUG_ENTER("ha_ndbcluster::records_update"); DBUG_ENTER("ha_ndbcluster::records_update");
int result= 0;
struct Ndb_local_table_statistics *info= struct Ndb_local_table_statistics *info=
(struct Ndb_local_table_statistics *)m_table_info; (struct Ndb_local_table_statistics *)m_table_info;
DBUG_PRINT("info", ("id=%d, no_uncommitted_rows_count=%d", DBUG_PRINT("info", ("id=%d, no_uncommitted_rows_count=%d",
...@@ -273,7 +275,9 @@ void ha_ndbcluster::records_update() ...@@ -273,7 +275,9 @@ void ha_ndbcluster::records_update()
Ndb *ndb= get_ndb(); Ndb *ndb= get_ndb();
Uint64 rows; Uint64 rows;
ndb->setDatabaseName(m_dbname); ndb->setDatabaseName(m_dbname);
if(ndb_get_table_statistics(ndb, m_tabname, &rows, 0) == 0){ result= ndb_get_table_statistics(this, true, ndb, m_tabname, &rows, 0);
if(result == 0)
{
info->records= rows; info->records= rows;
} }
} }
...@@ -282,8 +286,9 @@ void ha_ndbcluster::records_update() ...@@ -282,8 +286,9 @@ void ha_ndbcluster::records_update()
if (((Thd_ndb*)(thd->transaction.thd_ndb))->error) if (((Thd_ndb*)(thd->transaction.thd_ndb))->error)
info->no_uncommitted_rows_count= 0; info->no_uncommitted_rows_count= 0;
} }
records= info->records+ info->no_uncommitted_rows_count; if(result==0)
DBUG_VOID_RETURN; records= info->records+ info->no_uncommitted_rows_count;
DBUG_RETURN(result);
} }
void ha_ndbcluster::no_uncommitted_rows_execute_failure() void ha_ndbcluster::no_uncommitted_rows_execute_failure()
...@@ -2886,8 +2891,9 @@ void ha_ndbcluster::position(const byte *record) ...@@ -2886,8 +2891,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_ENTER("info");
DBUG_PRINT("enter", ("flag: %d", flag)); DBUG_PRINT("enter", ("flag: %d", flag));
...@@ -2905,17 +2911,17 @@ void ha_ndbcluster::info(uint flag) ...@@ -2905,17 +2911,17 @@ void ha_ndbcluster::info(uint flag)
if (m_ha_not_exact_count) if (m_ha_not_exact_count)
records= 100; records= 100;
else else
records_update(); result= records_update();
} }
else else
{ {
if ((my_errno= check_ndb_connection())) if ((my_errno= check_ndb_connection()))
DBUG_VOID_RETURN; DBUG_RETURN(my_errno);
Ndb *ndb= get_ndb(); Ndb *ndb= get_ndb();
Uint64 rows= 100; Uint64 rows= 100;
ndb->setDatabaseName(m_dbname); ndb->setDatabaseName(m_dbname);
if (current_thd->variables.ndb_use_exact_count) if (current_thd->variables.ndb_use_exact_count)
ndb_get_table_statistics(ndb, m_tabname, &rows, 0); result= ndb_get_table_statistics(this, true, ndb, m_tabname, &rows, 0);
records= rows; records= rows;
} }
} }
...@@ -2940,7 +2946,11 @@ void ha_ndbcluster::info(uint flag) ...@@ -2940,7 +2946,11 @@ void ha_ndbcluster::info(uint flag)
ndb->readAutoIncrementValue((const NDBTAB *) m_table); ndb->readAutoIncrementValue((const NDBTAB *) m_table);
} }
} }
DBUG_VOID_RETURN;
if(result == -1)
result= HA_ERR_NO_CONNECTION;
DBUG_RETURN(result);
} }
...@@ -4394,7 +4404,15 @@ int ha_ndbcluster::open(const char *name, int mode, uint test_if_locked) ...@@ -4394,7 +4404,15 @@ int ha_ndbcluster::open(const char *name, int mode, uint test_if_locked)
res= get_metadata(name); res= get_metadata(name);
if (!res) if (!res)
info(HA_STATUS_VARIABLE | HA_STATUS_CONST); {
Ndb *ndb= get_ndb();
ndb->setDatabaseName(m_dbname);
Uint64 rows= 0;
res= ndb_get_table_statistics(NULL, false, ndb, m_tabname, &rows, 0);
records= rows;
if(!res)
res= info(HA_STATUS_CONST);
}
DBUG_RETURN(res); DBUG_RETURN(res);
} }
...@@ -5276,13 +5294,15 @@ static int unpackfrm(const void **unpack_data, uint *unpack_len, ...@@ -5276,13 +5294,15 @@ static int unpackfrm(const void **unpack_data, uint *unpack_len,
static static
int int
ndb_get_table_statistics(Ndb* ndb, const char * table, ndb_get_table_statistics(ha_ndbcluster* file, bool report_error, Ndb* ndb,
const char * table,
Uint64* row_count, Uint64* commit_count) Uint64* row_count, Uint64* commit_count)
{ {
DBUG_ENTER("ndb_get_table_statistics"); DBUG_ENTER("ndb_get_table_statistics");
DBUG_PRINT("enter", ("table: %s", table)); DBUG_PRINT("enter", ("table: %s", table));
NdbConnection* pTrans; NdbConnection* pTrans;
NdbError error; NdbError error;
int reterr= 0;
int retries= 10; int retries= 10;
int retry_sleep= 30 * 1000; /* 30 milliseconds */ int retry_sleep= 30 * 1000; /* 30 milliseconds */
...@@ -5351,6 +5371,19 @@ ndb_get_table_statistics(Ndb* ndb, const char * table, ...@@ -5351,6 +5371,19 @@ ndb_get_table_statistics(Ndb* ndb, const char * table,
DBUG_RETURN(0); DBUG_RETURN(0);
retry: retry:
if(report_error)
{
if (file)
{
reterr= file->ndb_err(pTrans);
}
else
{
const NdbError& tmp= error;
ERR_PRINT(tmp);
reterr= ndb_to_mysql_error(&tmp);
}
}
if (pTrans) if (pTrans)
{ {
ndb->closeTransaction(pTrans); ndb->closeTransaction(pTrans);
...@@ -5363,8 +5396,9 @@ retry: ...@@ -5363,8 +5396,9 @@ retry:
} }
break; break;
} while(1); } while(1);
DBUG_PRINT("exit", ("failed, error %u(%s)", error.code, error.message)); DBUG_PRINT("exit", ("failed, reterr: %u, NdbError %u(%s)", reterr,
ERR_RETURN(error); error.code, error.message));
DBUG_RETURN(reterr);
} }
/* /*
......
...@@ -115,7 +115,7 @@ class ha_ndbcluster: public handler ...@@ -115,7 +115,7 @@ class ha_ndbcluster: public handler
int read_range_next(); int read_range_next();
bool get_error_message(int error, String *buf); bool get_error_message(int error, String *buf);
void info(uint); int info(uint);
int extra(enum ha_extra_function operation); int extra(enum ha_extra_function operation);
int extra_opt(enum ha_extra_function operation, ulong cache_size); int extra_opt(enum ha_extra_function operation, ulong cache_size);
int reset(); int reset();
...@@ -153,7 +153,12 @@ class ha_ndbcluster: public handler ...@@ -153,7 +153,12 @@ class ha_ndbcluster: public handler
static void set_dbname(const char *pathname, char *dbname); static void set_dbname(const char *pathname, char *dbname);
static void set_tabname(const char *pathname, char *tabname); static void set_tabname(const char *pathname, char *tabname);
/*
* Internal to ha_ndbcluster, used by C functions
*/
int ndb_err(NdbConnection*);
private: private:
int alter_table_name(const char *to); int alter_table_name(const char *to);
int drop_table(); int drop_table();
...@@ -206,7 +211,6 @@ class ha_ndbcluster: public handler ...@@ -206,7 +211,6 @@ class ha_ndbcluster: public handler
longlong get_auto_increment(); longlong get_auto_increment();
void invalidate_dictionary_cache(bool global); void invalidate_dictionary_cache(bool global);
int ndb_err(NdbConnection*);
bool uses_blob_value(bool all_fields); bool uses_blob_value(bool all_fields);
int write_ndb_file(); int write_ndb_file();
...@@ -256,7 +260,7 @@ class ha_ndbcluster: public handler ...@@ -256,7 +260,7 @@ class ha_ndbcluster: public handler
Ndb *get_ndb(); Ndb *get_ndb();
void set_rec_per_key(); void set_rec_per_key();
void records_update(); int records_update();
void no_uncommitted_rows_execute_failure(); void no_uncommitted_rows_execute_failure();
void no_uncommitted_rows_update(int); void no_uncommitted_rows_update(int);
void no_uncommitted_rows_init(THD *); void no_uncommitted_rows_init(THD *);
......
...@@ -394,7 +394,7 @@ public: ...@@ -394,7 +394,7 @@ public:
key_range *max_key) key_range *max_key)
{ return (ha_rows) 10; } { return (ha_rows) 10; }
virtual void position(const byte *record)=0; virtual void position(const byte *record)=0;
virtual void info(uint)=0; virtual int info(uint)=0;
virtual int extra(enum ha_extra_function operation) virtual int extra(enum ha_extra_function operation)
{ return 0; } { return 0; }
virtual int extra_opt(enum ha_extra_function operation, ulong cache_size) virtual int extra_opt(enum ha_extra_function operation, ulong cache_size)
......
...@@ -1410,12 +1410,20 @@ bool Item_sum_count_distinct::add() ...@@ -1410,12 +1410,20 @@ bool Item_sum_count_distinct::add()
longlong Item_sum_count_distinct::val_int() longlong Item_sum_count_distinct::val_int()
{ {
int error;
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
if (!table) // Empty query if (!table) // Empty query
return LL(0); return LL(0);
if (use_tree) if (use_tree)
return tree->elements_in_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; return table->file->records;
} }
......
...@@ -125,7 +125,12 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds) ...@@ -125,7 +125,12 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
} }
else else
{ {
tl->table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK); error= tl->table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
if(error)
{
tl->table->file->print_error(error, MYF(0));
return error;
}
count*= tl->table->file->records; count*= tl->table->file->records;
} }
} }
......
...@@ -43,7 +43,12 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ...@@ -43,7 +43,12 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
if ((open_and_lock_tables(thd, table_list))) if ((open_and_lock_tables(thd, table_list)))
DBUG_RETURN(-1); DBUG_RETURN(-1);
table= table_list->table; 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"; thd->proc_info="init";
table->map=1; table->map=1;
......
...@@ -538,6 +538,8 @@ JOIN::optimize() ...@@ -538,6 +538,8 @@ JOIN::optimize()
{ {
if (res > 1) if (res > 1)
{ {
thd->fatal_error();
error= res;
DBUG_RETURN(1); DBUG_RETURN(1);
} }
if (res < 0) if (res < 0)
...@@ -1796,7 +1798,12 @@ make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds, ...@@ -1796,7 +1798,12 @@ make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds,
s->checked_keys.init(); s->checked_keys.init();
s->needed_reg.init(); s->needed_reg.init();
table_vector[i]=s->table=table=tables->table; 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->quick_keys.clear_all();
table->reginfo.join_tab=s; table->reginfo.join_tab=s;
table->reginfo.not_exists_optimize=0; table->reginfo.not_exists_optimize=0;
......
...@@ -492,7 +492,12 @@ int st_select_lex_unit::exec() ...@@ -492,7 +492,12 @@ int st_select_lex_unit::exec()
DBUG_RETURN(res); DBUG_RETURN(res);
} }
/* Needed for the following test and for records_at_start in next loop */ /* 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 && if (found_rows_for_union && !sl->braces &&
select_limit_cnt != HA_POS_ERROR) 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