From 8b8f17ddd6df97947b64d1c79f39b3a6c5061057 Mon Sep 17 00:00:00 2001 From: "marty@linux.site" <> Date: Tue, 4 Jan 2005 16:18:45 +0100 Subject: [PATCH] Hide internal unique index naming --- .../ndbapi_simple_index.cpp | 6 +-- ndb/src/ndbapi/NdbTransaction.cpp | 37 +++++++++++++------ 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/ndb/examples/ndbapi_simple_index_example/ndbapi_simple_index.cpp b/ndb/examples/ndbapi_simple_index_example/ndbapi_simple_index.cpp index efd77b96eae..39574fae208 100644 --- a/ndb/examples/ndbapi_simple_index_example/ndbapi_simple_index.cpp +++ b/ndb/examples/ndbapi_simple_index_example/ndbapi_simple_index.cpp @@ -143,7 +143,7 @@ int main() if (myTransaction == NULL) APIERROR(myNdb->getNdbError()); NdbIndexOperation *myIndexOperation= - myTransaction->getNdbIndexOperation("MYINDEXNAME$unique","MYTABLENAME"); + myTransaction->getNdbIndexOperation("MYINDEXNAME","MYTABLENAME"); if (myIndexOperation == NULL) APIERROR(myTransaction->getNdbError()); myIndexOperation->readTuple(NdbOperation::LM_Read); @@ -166,7 +166,7 @@ int main() if (myTransaction == NULL) APIERROR(myNdb->getNdbError()); NdbIndexOperation *myIndexOperation= - myTransaction->getNdbIndexOperation("MYINDEXNAME$unique", "MYTABLENAME"); + myTransaction->getNdbIndexOperation("MYINDEXNAME", "MYTABLENAME"); if (myIndexOperation == NULL) APIERROR(myTransaction->getNdbError()); myIndexOperation->updateTuple(); @@ -187,7 +187,7 @@ int main() if (myTransaction == NULL) APIERROR(myNdb->getNdbError()); NdbIndexOperation *myIndexOperation= - myTransaction->getNdbIndexOperation("MYINDEXNAME$unique", "MYTABLENAME"); + myTransaction->getNdbIndexOperation("MYINDEXNAME", "MYTABLENAME"); if (myIndexOperation == NULL) APIERROR(myTransaction->getNdbError()); myIndexOperation->deleteTuple(); diff --git a/ndb/src/ndbapi/NdbTransaction.cpp b/ndb/src/ndbapi/NdbTransaction.cpp index 40a79421fdd..d010c0ae0d8 100644 --- a/ndb/src/ndbapi/NdbTransaction.cpp +++ b/ndb/src/ndbapi/NdbTransaction.cpp @@ -1076,15 +1076,15 @@ NdbTransaction::getNdbScanOperation(const char* aTableName) }//NdbTransaction::getNdbScanOperation() /***************************************************************************** -NdbScanOperation* getNdbScanOperation(const char* anIndexName, const char* aTableName); +NdbScanOperation* getNdbIndexScanOperation(const char* anIndexName, const char* aTableName); -Return Value Return a pointer to a NdbScanOperation object if getNdbScanOperation was succesful. +Return Value Return a pointer to a NdbIndexScanOperation object if getNdbIndexScanOperation was succesful. Return NULL : In all other case. Parameters: anIndexName : Name of the index to use. aTableName : Name of the database table. -Remark: Get an operation from NdbScanOperation idlelist and get the NdbTransaction object +Remark: Get an operation from NdbIndexScanOperation idlelist and get the NdbTransaction object who was fetch by startTransaction pointing to this operation - getOperation will set the theTableId in the NdbOperation object.synchronous + getOperation will set the theTableId in the NdbIndexScanOperation object.synchronous ******************************************************************************/ NdbIndexScanOperation* NdbTransaction::getNdbIndexScanOperation(const char* anIndexName, @@ -1134,12 +1134,12 @@ NdbTransaction::getNdbIndexScanOperation(const NdbDictionary::Index * index, /***************************************************************************** NdbScanOperation* getNdbScanOperation(int aTableId); -Return Value Return a pointer to a NdbOperation object if getNdbOperation was succesful. +Return Value Return a pointer to a NdbScanOperation object if getNdbScanOperation was succesful. Return NULL: In all other case. Parameters: tableId : Id of the database table beeing deleted. Remark: Get an operation from NdbScanOperation object idlelist and get the NdbTransaction object who was fetch by startTransaction pointing to this operation - getOperation will set the theTableId in the NdbOperation object, synchronous. + getOperation will set the theTableId in the NdbScanOperation object, synchronous. *****************************************************************************/ NdbIndexScanOperation* NdbTransaction::getNdbScanOperation(const NdbTableImpl * tab) @@ -1203,12 +1203,12 @@ NdbTransaction::getNdbScanOperation(const NdbDictionary::Table * table) NdbIndexOperation* getNdbIndexOperation(const char* anIndexName, const char* aTableName); -Return Value Return a pointer to a NdbOperation object if getNdbScanOperation was succesful. +Return Value Return a pointer to a NdbOperation object if getNdbIndexOperation was succesful. Return NULL : In all other case. Parameters: aTableName : Name of the database table. -Remark: Get an operation from NdbScanOperation idlelist and get the NdbTransaction object - who was fetch by startTransaction pointing to this operation - getOperation will set the theTableId in the NdbScanOperation object.synchronous +Remark: Get an operation from NdbIndexOperation idlelist and get the NdbTransaction object + who was fetch by startTransaction pointing to this operation + getOperation will set the theTableId in the NdbIndexOperation object.synchronous ******************************************************************************/ NdbIndexOperation* NdbTransaction::getNdbIndexOperation(const char* anIndexName, @@ -1216,8 +1216,21 @@ NdbTransaction::getNdbIndexOperation(const char* anIndexName, { if (theCommitStatus == Started) { NdbTableImpl * table = theNdb->theDictionary->getTable(aTableName); - NdbIndexImpl * index = theNdb->theDictionary->getIndex(anIndexName, - aTableName); + NdbIndexImpl * index; + + if (table->m_frm.get_data()) + { + // This unique index is defined from SQL level + static const char* uniqueSuffix= "$unique"; + char uniqueIndexName[MAX_TAB_NAME_SIZE]; + + strxnmov(uniqueIndexName, MAX_TAB_NAME_SIZE, anIndexName, uniqueSuffix, NullS); + index = theNdb->theDictionary->getIndex(uniqueIndexName, + aTableName); + } + else + index = theNdb->theDictionary->getIndex(anIndexName, + aTableName); if(table != 0 && index != 0){ return getNdbIndexOperation(index, table); } -- 2.30.9