Below is the list of changes that have just been committed into a local
5.1 repository of tomas. When tomas does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-07-04 16:07:49+02:00, tomas@stripped +3 -0
5.0 compat code for asynch ndbapi
storage/ndb/include/ndbapi/NdbTransaction.hpp@stripped, 2007-07-04 16:07:46+02:00, tomas@stripped +41 -0
5.0 compat code for asynch ndbapi
storage/ndb/test/ndbapi/Makefile.am@stripped, 2007-07-04 16:07:46+02:00, tomas@stripped +6 -1
5.0 compat code for asynch ndbapi
storage/ndb/test/ndbapi/ndbapi_50compat1.cpp@stripped, 2007-07-04 16:07:46+02:00, tomas@stripped +145 -0
New BitKeeper file ``storage/ndb/test/ndbapi/ndbapi_50compat1.cpp''
storage/ndb/test/ndbapi/ndbapi_50compat1.cpp@stripped, 2007-07-04 16:07:46+02:00, tomas@stripped +0 -0
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: tomas
# Host: whalegate.ndb.mysql.com
# Root: /home/tomas/mysql-5.1-telco-6.2
--- 1.68/storage/ndb/include/ndbapi/NdbTransaction.hpp 2007-06-12 14:22:42 +02:00
+++ 1.69/storage/ndb/include/ndbapi/NdbTransaction.hpp 2007-07-04 16:07:46 +02:00
@@ -376,6 +376,7 @@
* to decide on the use of this pointer.
* @param abortOption see @ref execute
*/
+#ifndef NDBAPI_50_COMPAT
void executeAsynchPrepare(ExecType execType,
NdbAsynchCallback callback,
void* anyObject,
@@ -388,6 +389,25 @@
executeAsynchPrepare((ExecType)execType, callback, anyObject,
(NdbOperation::AbortOption)ao); }
#endif
+#else
+ /**
+ * 50 compability layer
+ * Check 50-docs for sematics
+ */
+ void executeAsynchPrepare(ExecType execType,
+ NdbAsynchCallback callback,
+ void* anyObject,
+ NdbOperation::AbortOption);
+
+ void executeAsynchPrepare(NdbTransaction::ExecType execType,
+ NdbAsynchCallback callback,
+ void *anyObject,
+ NdbTransaction::AbortOption abortOption = NdbTransaction::AbortOnError)
+ {
+ executeAsynchPrepare((ExecType)execType, callback, anyObject,
+ (NdbOperation::AbortOption)abortOption);
+ }
+#endif
/**
* Prepare and send an asynchronous transaction.
@@ -402,6 +422,7 @@
* See @ref secAsync for more information on
* how to use this method.
*/
+#ifndef NDBAPI_50_COMPAT
void executeAsynch(ExecType aTypeOfExec,
NdbAsynchCallback aCallback,
void* anyObject,
@@ -416,7 +437,27 @@
{ executeAsynch((ExecType)aTypeOfExec, aCallback, anyObject,
(NdbOperation::AbortOption)abortOption, forceSend); }
#endif
+#else
+ /**
+ * 50 compability layer
+ * Check 50-docs for sematics
+ */
+ void executeAsynch(ExecType aTypeOfExec,
+ NdbAsynchCallback aCallback,
+ void* anyObject,
+ NdbOperation::AbortOption = NdbOperation::DefaultAbortOption,
+ int forceSend= 0);
+ void executeAsynch(NdbTransaction::ExecType aTypeOfExec,
+ NdbAsynchCallback aCallback,
+ void* anyObject,
+ NdbTransaction::AbortOption abortOption = AbortOnError)
+ {
+ executeAsynch((ExecType)aTypeOfExec, aCallback, anyObject,
+ (NdbOperation::AbortOption)abortOption, 0);
+ }
#endif
+#endif
+
/**
* Refresh
* Update timeout counter of this transaction
--- 1.36/storage/ndb/test/ndbapi/Makefile.am 2007-06-12 14:22:42 +02:00
+++ 1.37/storage/ndb/test/ndbapi/Makefile.am 2007-07-04 16:07:46 +02:00
@@ -53,7 +53,8 @@
testSRBank \
test_event_merge \
testIndexStat \
-ndbapi_50compat0
+ndbapi_50compat0 \
+ndbapi_50compat1
EXTRA_PROGRAMS = \
test_event \
@@ -110,6 +111,10 @@
ndbapi_50compat0_CPPFLAGS = -DNDBAPI_50_COMPAT
ndbapi_50compat0_SOURCES = ndbapi_50compat0.cpp
ndbapi_50compat0_LDADD = $(LDADD) $(top_srcdir)/libmysql/libmysqlclient.la
+
+ndbapi_50compat1_CPPFLAGS = -DNDBAPI_50_COMPAT
+ndbapi_50compat1_SOURCES = ndbapi_50compat1.cpp
+ndbapi_50compat1_LDADD = $(LDADD) $(top_srcdir)/libmysql/libmysqlclient.la
INCLUDES_LOC = -I$(top_srcdir)/storage/ndb/include/kernel
--- New file ---
+++ storage/ndb/test/ndbapi/ndbapi_50compat1.cpp 07/07/04 16:07:46
/* Copyright (C) 2003 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
//
// ndbapi_async1.cpp: Using asynchronous transactions in NDB API
//
// Execute ndbapi_example1 to create the table "MYTABLENAME"
// before executing this program.
//
// Correct output from this program is:
//
// Successful insert.
// Successful insert.
#include <mysql.h>
#include <NdbApi.hpp>
// Used for cout
#include <stdio.h>
#include <NdbOut.hpp>
#define APIERROR(error) \
{ ndbout << "Error in " << __FILE__ << ", line:" << __LINE__ << ", code:" \
<< error.code << ", msg: " << error.message << "." << endl; \
exit(-1); }
static void callback(int result, NdbTransaction* NdbObject, void* aObject);
int main()
{
ndb_init();
Ndb_cluster_connection *cluster_connection=
new Ndb_cluster_connection(); // Object representing the cluster
if (cluster_connection->wait_until_ready(30,30))
{
ndbout << "Cluster was not ready within 30 secs." << endl;
exit(-1);
}
int r= cluster_connection->connect(5 /* retries */,
3 /* delay between retries */,
1 /* verbose */);
if (r > 0)
{
ndbout
<< "Cluster connect failed, possibly resolved with more retries.\n";
exit(-1);
}
else if (r < 0)
{
ndbout
<< "Cluster connect failed.\n";
exit(-1);
}
if (cluster_connection->wait_until_ready(30,30))
{
ndbout << "Cluster was not ready within 30 secs." << endl;
exit(-1);
}
Ndb* myNdb = new Ndb( cluster_connection,
"TEST_DB_2" ); // Object representing the database
NdbTransaction* myNdbTransaction[2]; // For transactions
NdbOperation* myNdbOperation; // For operations
if (myNdb->init(2) == -1) { // Want two parallel insert transactions
APIERROR(myNdb->getNdbError());
exit(-1);
}
/******************************************************
* Insert (we do two insert transactions in parallel) *
******************************************************/
const NdbDictionary::Dictionary* myDict= myNdb->getDictionary();
const NdbDictionary::Table *myTable= myDict->getTable("MYTABLENAME");
if (myTable == NULL)
APIERROR(myDict->getNdbError());
for (int i = 0; i < 2; i++) {
myNdbTransaction[i] = myNdb->startTransaction();
if (myNdbTransaction[i] == NULL) APIERROR(myNdb->getNdbError());
myNdbOperation = myNdbTransaction[i]->getNdbOperation(myTable);
if (myNdbOperation == NULL) APIERROR(myNdbTransaction[i]->getNdbError());
myNdbOperation->insertTuple();
myNdbOperation->equal("ATTR1", 20 + i);
myNdbOperation->setValue("ATTR2", 20 + i);
// Prepare transaction (the transaction is NOT yet sent to NDB)
myNdbTransaction[i]->executeAsynchPrepare(NdbTransaction::Commit,
&callback, NULL);
}
// Send all transactions to NDB
myNdb->sendPreparedTransactions(0);
// Poll all transactions
myNdb->pollNdb(3000, 2);
// Close all transactions
for (int i = 0; i < 2; i++)
myNdb->closeTransaction(myNdbTransaction[i]);
delete myNdb;
delete cluster_connection;
ndb_end(0);
return 0;
}
/*
* callback : This is called when the transaction is polled
*
* (This function must have three arguments:
* - The result of the transaction,
* - The NdbTransaction object, and
* - A pointer to an arbitrary object.)
*/
static void
callback(int result, NdbTransaction* myTrans, void* aObject)
{
if (result == -1) {
ndbout << "Poll error: " << endl;
APIERROR(myTrans->getNdbError());
} else {
ndbout << "Successful insert." << endl;
}
}
| Thread |
|---|
| • bk commit into 5.1 tree (tomas:1.2568) | tomas | 4 Jul |