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

Merge willster.(none):/home/stewart/Documents/MySQL/4.1/bug19914-mk2-merge2

into  willster.(none):/home/stewart/Documents/MySQL/5.0/ndb
parents fff4559e 5926602a
...@@ -114,7 +114,7 @@ static int packfrm(const void *data, uint len, const void **pack_data, uint *pac ...@@ -114,7 +114,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 *,
struct Ndb_statistics *); struct Ndb_statistics *);
// Util thread variables // Util thread variables
...@@ -372,7 +372,7 @@ int ha_ndbcluster::records_update() ...@@ -372,7 +372,7 @@ int ha_ndbcluster::records_update()
Ndb *ndb= get_ndb(); Ndb *ndb= get_ndb();
struct Ndb_statistics stat; struct Ndb_statistics stat;
ndb->setDatabaseName(m_dbname); ndb->setDatabaseName(m_dbname);
if ((result= ndb_get_table_statistics(ndb, m_tabname, &stat)) == 0){ if ((result= ndb_get_table_statistics(ndb, true, m_tabname, &stat)) == 0){
mean_rec_length= stat.row_size; mean_rec_length= stat.row_size;
data_file_length= stat.fragment_memory; data_file_length= stat.fragment_memory;
info->records= stat.row_count; info->records= stat.row_count;
...@@ -383,7 +383,8 @@ int ha_ndbcluster::records_update() ...@@ -383,7 +383,8 @@ int ha_ndbcluster::records_update()
if (get_thd_ndb(thd)->error) if (get_thd_ndb(thd)->error)
info->no_uncommitted_rows_count= 0; info->no_uncommitted_rows_count= 0;
} }
records= info->records+ info->no_uncommitted_rows_count; if(result==0)
records= info->records+ info->no_uncommitted_rows_count;
DBUG_RETURN(result); DBUG_RETURN(result);
} }
...@@ -3118,7 +3119,7 @@ int ha_ndbcluster::info(uint flag) ...@@ -3118,7 +3119,7 @@ int ha_ndbcluster::info(uint flag)
struct Ndb_statistics stat; struct Ndb_statistics stat;
ndb->setDatabaseName(m_dbname); ndb->setDatabaseName(m_dbname);
if (current_thd->variables.ndb_use_exact_count && if (current_thd->variables.ndb_use_exact_count &&
(result= ndb_get_table_statistics(ndb, m_tabname, &stat)) == 0) (result= ndb_get_table_statistics(ndb, true, m_tabname, &stat)) == 0)
{ {
mean_rec_length= stat.row_size; mean_rec_length= stat.row_size;
data_file_length= stat.fragment_memory; data_file_length= stat.fragment_memory;
...@@ -4756,7 +4757,15 @@ int ha_ndbcluster::open(const char *name, int mode, uint test_if_locked) ...@@ -4756,7 +4757,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);
} }
...@@ -5899,12 +5908,13 @@ static int unpackfrm(const void **unpack_data, uint *unpack_len, ...@@ -5899,12 +5908,13 @@ 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,
struct Ndb_statistics * ndbstat) struct Ndb_statistics * ndbstat)
{ {
NdbTransaction* pTrans; NdbTransaction* pTrans;
NdbError error; NdbError error;
int retries= 10; int retries= 10;
int reterr= 0;
int retry_sleep= 30 * 1000; /* 30 milliseconds */ int retry_sleep= 30 * 1000; /* 30 milliseconds */
char buff[22], buff2[22], buff3[22], buff4[22]; char buff[22], buff2[22], buff3[22], buff4[22];
DBUG_ENTER("ndb_get_table_statistics"); DBUG_ENTER("ndb_get_table_statistics");
...@@ -5995,6 +6005,19 @@ ndb_get_table_statistics(Ndb* ndb, const char * table, ...@@ -5995,6 +6005,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);
...@@ -6007,8 +6030,9 @@ retry: ...@@ -6007,8 +6030,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);
} }
/* /*
......
...@@ -583,6 +583,12 @@ static void set_tabname(const char *pathname, char *tabname); ...@@ -583,6 +583,12 @@ static void set_tabname(const char *pathname, char *tabname);
void cond_pop(); void cond_pop();
uint8 table_cache_type(); uint8 table_cache_type();
/*
* Internal to ha_ndbcluster, used by C functions
*/
int ndb_err(NdbTransaction*);
my_bool register_query_cache_table(THD *thd, char *table_key, my_bool register_query_cache_table(THD *thd, char *table_key,
uint key_length, uint key_length,
qc_engine_callback *engine_callback, qc_engine_callback *engine_callback,
...@@ -647,8 +653,8 @@ private: ...@@ -647,8 +653,8 @@ private:
ulonglong get_auto_increment(); ulonglong get_auto_increment();
void invalidate_dictionary_cache(bool global); void invalidate_dictionary_cache(bool global);
int ndb_err(NdbTransaction*);
bool uses_blob_value(bool all_fields); bool uses_blob_value(bool all_fields);
char *update_table_comment(const char * comment); char *update_table_comment(const char * comment);
......
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