Commit a47d6172 authored by unknown's avatar unknown

Merge poseidon.ndb.mysql.com:/home/tomas/mysql-4.1-main

into  poseidon.ndb.mysql.com:/home/tomas/mysql-5.0


sql/ha_ndbcluster.cc:
  manual merge
parents 78c81415 5d506d6b
...@@ -363,6 +363,7 @@ void ha_ndbcluster::records_update() ...@@ -363,6 +363,7 @@ void ha_ndbcluster::records_update()
{ {
Ndb *ndb= get_ndb(); Ndb *ndb= get_ndb();
struct Ndb_statistics stat; struct Ndb_statistics stat;
ndb->setDatabaseName(m_dbname);
if (ndb_get_table_statistics(ndb, m_tabname, &stat) == 0){ if (ndb_get_table_statistics(ndb, 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;
...@@ -3076,6 +3077,7 @@ void ha_ndbcluster::info(uint flag) ...@@ -3076,6 +3077,7 @@ void ha_ndbcluster::info(uint flag)
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
Ndb *ndb= get_ndb(); Ndb *ndb= get_ndb();
struct Ndb_statistics stat; struct Ndb_statistics stat;
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, &stat) == 0) ndb_get_table_statistics(ndb, m_tabname, &stat) == 0)
{ {
...@@ -5836,62 +5838,57 @@ ndb_get_table_statistics(Ndb* ndb, const char * table, ...@@ -5836,62 +5838,57 @@ ndb_get_table_statistics(Ndb* ndb, const char * table,
DBUG_ENTER("ndb_get_table_statistics"); DBUG_ENTER("ndb_get_table_statistics");
DBUG_PRINT("enter", ("table: %s", table)); DBUG_PRINT("enter", ("table: %s", table));
NdbTransaction* pTrans; NdbTransaction* pTrans;
NdbError error;
int retries= 10; int retries= 10;
int retry_sleep= 30 * 1000; /* 30 milliseconds */ int retry_sleep= 30 * 1000; /* 30 milliseconds */
do do
{ {
pTrans= ndb->startTransaction(); Uint64 rows, commits, mem;
if (pTrans == NULL) Uint32 size;
Uint64 sum_rows= 0;
Uint64 sum_commits= 0;
NdbScanOperation*pOp;
NdbResultSet *rs;
int check;
if ((pTrans= ndb->startTransaction()) == NULL)
{ {
if (ndb->getNdbError().status == NdbError::TemporaryError && error= ndb->getNdbError();
retries--) goto retry;
{ }
my_sleep(retry_sleep);
continue; if ((pOp= pTrans->getNdbScanOperation(table)) == NULL)
} {
break; error= pTrans->getNdbError();
goto retry;
} }
NdbScanOperation* pOp= pTrans->getNdbScanOperation(table);
if (pOp == NULL)
break;
if (pOp->readTuples(NdbOperation::LM_CommittedRead)) if (pOp->readTuples(NdbOperation::LM_CommittedRead))
break; {
error= pOp->getNdbError();
goto retry;
}
int check= pOp->interpret_exit_last_row(); if (pOp->interpret_exit_last_row() == -1)
if (check == -1) {
break; error= pOp->getNdbError();
goto retry;
}
Uint64 rows, commits, mem;
Uint32 size;
pOp->getValue(NdbDictionary::Column::ROW_COUNT, (char*)&rows); pOp->getValue(NdbDictionary::Column::ROW_COUNT, (char*)&rows);
pOp->getValue(NdbDictionary::Column::COMMIT_COUNT, (char*)&commits); pOp->getValue(NdbDictionary::Column::COMMIT_COUNT, (char*)&commits);
pOp->getValue(NdbDictionary::Column::ROW_SIZE, (char*)&size); pOp->getValue(NdbDictionary::Column::ROW_SIZE, (char*)&size);
pOp->getValue(NdbDictionary::Column::FRAGMENT_MEMORY, (char*)&mem); pOp->getValue(NdbDictionary::Column::FRAGMENT_MEMORY, (char*)&mem);
check= pTrans->execute(NdbTransaction::NoCommit, if (pTrans->execute(NdbTransaction::NoCommit,
NdbTransaction::AbortOnError, NdbTransaction::AbortOnError,
TRUE); TRUE) == -1)
if (check == -1)
{ {
if (pTrans->getNdbError().status == NdbError::TemporaryError && error= pTrans->getNdbError();
retries--) goto retry;
{
ndb->closeTransaction(pTrans);
pTrans= 0;
my_sleep(retry_sleep);
continue;
}
break;
} }
Uint32 count= 0;
Uint64 sum_rows= 0;
Uint64 sum_commits= 0;
Uint64 sum_row_size= 0;
Uint64 sum_mem= 0;
while ((check= pOp->nextResult(TRUE, TRUE)) == 0) while ((check= pOp->nextResult(TRUE, TRUE)) == 0)
{ {
sum_rows+= rows; sum_rows+= rows;
...@@ -5903,7 +5900,10 @@ ndb_get_table_statistics(Ndb* ndb, const char * table, ...@@ -5903,7 +5900,10 @@ ndb_get_table_statistics(Ndb* ndb, const char * table,
} }
if (check == -1) if (check == -1)
break; {
error= pOp->getNdbError();
goto retry;
}
pOp->close(TRUE); pOp->close(TRUE);
...@@ -5920,12 +5920,21 @@ ndb_get_table_statistics(Ndb* ndb, const char * table, ...@@ -5920,12 +5920,21 @@ ndb_get_table_statistics(Ndb* ndb, const char * table,
sum_mem, count)); sum_mem, count));
DBUG_RETURN(0); DBUG_RETURN(0);
retry:
if (pTrans)
{
ndb->closeTransaction(pTrans);
pTrans= NULL;
}
if (error.status == NdbError::TemporaryError && retries--)
{
my_sleep(retry_sleep);
continue;
}
break;
} while(1); } while(1);
DBUG_PRINT("exit", ("failed, error %u(%s)", error.code, error.message));
if (pTrans) ERR_RETURN(error);
ndb->closeTransaction(pTrans);
DBUG_PRINT("exit", ("failed"));
DBUG_RETURN(-1);
} }
/* /*
......
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