summaryrefslogtreecommitdiff
path: root/ndb/tools
diff options
context:
space:
mode:
authorunknown <pekka@mysql.com>2006-02-05 22:51:13 +0100
committerunknown <pekka@mysql.com>2006-02-05 22:51:13 +0100
commiteab7743b50472ce333b8ecd933ef72624e8840d2 (patch)
tree2d26e1d76ab773cef3d4f111d4995da6259de4e5 /ndb/tools
parent26a81f6fb1dc253e9d0ed99768594ac27dae5bb3 (diff)
parent1076e176ce965a9d37fcdc71e6eb3447c3931005 (diff)
downloadmariadb-git-eab7743b50472ce333b8ecd933ef72624e8840d2.tar.gz
Merge pnousiainen@bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/space/pekka/ndb/version/my50
Diffstat (limited to 'ndb/tools')
-rw-r--r--ndb/tools/delete_all.cpp31
1 files changed, 26 insertions, 5 deletions
diff --git a/ndb/tools/delete_all.cpp b/ndb/tools/delete_all.cpp
index 2c395a67900..d6972e33cc0 100644
--- a/ndb/tools/delete_all.cpp
+++ b/ndb/tools/delete_all.cpp
@@ -22,7 +22,8 @@
#include <NdbSleep.h>
#include <NDBT.hpp>
-static int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism=240);
+static int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab,
+ bool commit_across_open_cursor, int parallelism=240);
NDB_STD_OPTS_VARS;
@@ -83,8 +84,18 @@ int main(int argc, char** argv){
ndbout << " Table " << argv[i] << " does not exist!" << endl;
return NDBT_ProgramExit(NDBT_WRONGARGS);
}
+ // Check if we have any blobs
+ bool commit_across_open_cursor = true;
+ for (int j = 0; j < pTab->getNoOfColumns(); j++) {
+ NdbDictionary::Column::Type t = pTab->getColumn(j)->getType();
+ if (t == NdbDictionary::Column::Blob ||
+ t == NdbDictionary::Column::Text) {
+ commit_across_open_cursor = false;
+ break;
+ }
+ }
ndbout << "Deleting all from " << argv[i] << "...";
- if(clear_table(&MyNdb, pTab) == NDBT_FAILED){
+ if(clear_table(&MyNdb, pTab, commit_across_open_cursor) == NDBT_FAILED){
res = NDBT_FAILED;
ndbout << "FAILED" << endl;
}
@@ -93,7 +104,8 @@ int main(int argc, char** argv){
}
-int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism)
+int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab,
+ bool commit_across_open_cursor, int parallelism)
{
// Scan all records exclusive and delete
// them one by one
@@ -154,8 +166,12 @@ int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism)
} while((check = pOp->nextResult(false)) == 0);
if(check != -1){
- check = pTrans->execute(NdbTransaction::Commit);
- pTrans->restart();
+ if (commit_across_open_cursor) {
+ check = pTrans->execute(NdbTransaction::Commit);
+ pTrans->restart(); // new tx id
+ } else {
+ check = pTrans->execute(NdbTransaction::NoCommit);
+ }
}
err = pTrans->getNdbError();
@@ -181,6 +197,11 @@ int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism)
}
goto failed;
}
+ if (! commit_across_open_cursor &&
+ pTrans->execute(NdbTransaction::Commit) != 0) {
+ err = pTrans->getNdbError();
+ goto failed;
+ }
pNdb->closeTransaction(pTrans);
return NDBT_OK;
}