summaryrefslogtreecommitdiff
path: root/storage/ndb/src/ndbapi/Ndb.cpp
diff options
context:
space:
mode:
authorunknown <tulin@dl145b.mysql.com>2005-06-08 17:12:09 +0200
committerunknown <tulin@dl145b.mysql.com>2005-06-08 17:12:09 +0200
commit97a3ff8e66475fcd18413e99b851328f62c4dd67 (patch)
tree53320dc04d2342b7dc043b456fc11aa8789f5495 /storage/ndb/src/ndbapi/Ndb.cpp
parentad34f7db24c6d1397336edf56ea39f360d414efb (diff)
parent86c4e1d2d9a84e4e04a543de7bd6d219e4dbf1de (diff)
downloadmariadb-git-97a3ff8e66475fcd18413e99b851328f62c4dd67.tar.gz
Merge tulin@bk-internal.mysql.com:/home/bk/mysql-5.0-ndb
into dl145b.mysql.com:/home/ndbdev/tomas/mysql-5.1 libmysqld/Makefile.am: Auto merged mysql-test/mysql-test-run.sh: Auto merged sql/field.cc: Auto merged sql/ha_ndbcluster.cc: Auto merged sql/sql_select.cc: Auto merged storage/ndb/include/kernel/AttributeList.hpp: Auto merged storage/ndb/include/ndbapi/Ndb.hpp: Auto merged storage/ndb/include/transporter/TransporterDefinitions.hpp: Auto merged storage/ndb/include/util/SimpleProperties.hpp: Auto merged storage/ndb/src/common/transporter/SCI_Transporter.cpp: Auto merged storage/ndb/src/common/util/SimpleProperties.cpp: Auto merged storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp: Auto merged storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp: Auto merged storage/ndb/src/ndbapi/DictCache.cpp: Auto merged storage/ndb/src/ndbapi/DictCache.hpp: Auto merged storage/ndb/src/ndbapi/Ndb.cpp: Auto merged storage/ndb/src/ndbapi/NdbBlob.cpp: Auto merged storage/ndb/src/ndbapi/NdbDictionary.cpp: Auto merged storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp: Auto merged storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp: Auto merged storage/ndb/src/ndbapi/NdbImpl.hpp: Auto merged storage/ndb/src/ndbapi/NdbLinHash.hpp: Auto merged storage/ndb/src/ndbapi/NdbTransaction.cpp: Auto merged storage/ndb/test/ndbapi/testBlobs.cpp: Auto merged storage/ndb/test/ndbapi/testDict.cpp: Auto merged storage/ndb/test/ndbapi/testNodeRestart.cpp: Auto merged storage/ndb/test/ndbapi/testOIBasic.cpp: Auto merged storage/ndb/tools/restore/Restore.hpp: Auto merged storage/ndb/src/kernel/blocks/backup/Backup.cpp: Auto merged storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp: Auto merged storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: Auto merged storage/ndb/test/ndbapi/testNdbApi.cpp: Auto merged storage/ndb/test/run-test/daily-basic-tests.txt: Auto merged storage/ndb/tools/restore/Restore.cpp: Auto merged storage/ndb/tools/restore/consumer_restore.cpp: Auto merged BitKeeper/etc/logging_ok: auto-union configure.in: Auto merged sql/sql_parse.cc: Auto merged
Diffstat (limited to 'storage/ndb/src/ndbapi/Ndb.cpp')
-rw-r--r--storage/ndb/src/ndbapi/Ndb.cpp107
1 files changed, 72 insertions, 35 deletions
diff --git a/storage/ndb/src/ndbapi/Ndb.cpp b/storage/ndb/src/ndbapi/Ndb.cpp
index c48e70f1d51..9bf5be259c6 100644
--- a/storage/ndb/src/ndbapi/Ndb.cpp
+++ b/storage/ndb/src/ndbapi/Ndb.cpp
@@ -751,16 +751,14 @@ Remark: Returns a new TupleId to the application.
The TupleId comes from SYSTAB_0 where SYSKEY_0 = TableId.
It is initialized to (TableId << 48) + 1 in NdbcntrMain.cpp.
****************************************************************************/
-#define DEBUG_TRACE(msg) \
-// ndbout << __FILE__ << " line: " << __LINE__ << " msg: " << msg << endl
-
Uint64
Ndb::getAutoIncrementValue(const char* aTableName, Uint32 cacheSize)
{
DBUG_ENTER("getAutoIncrementValue");
- const char * internalTableName = internalizeTableName(aTableName);
+ BaseString internal_tabname(internalize_table_name(aTableName));
+
Ndb_local_table_info *info=
- theDictionary->get_local_table_info(internalTableName, false);
+ theDictionary->get_local_table_info(internal_tabname, false);
if (info == 0)
DBUG_RETURN(~(Uint64)0);
const NdbTableImpl *table= info->m_table_impl;
@@ -812,7 +810,7 @@ Ndb::getTupleIdFromNdb(Uint32 aTableId, Uint32 cacheSize)
Uint64
Ndb::readAutoIncrementValue(const char* aTableName)
{
- DBUG_ENTER("readtAutoIncrementValue");
+ DBUG_ENTER("readAutoIncrementValue");
const NdbTableImpl* table = theDictionary->getTable(aTableName);
if (table == 0) {
theError= theDictionary->getNdbError();
@@ -826,7 +824,7 @@ Ndb::readAutoIncrementValue(const char* aTableName)
Uint64
Ndb::readAutoIncrementValue(const NdbDictionary::Table * aTable)
{
- DBUG_ENTER("readtAutoIncrementValue");
+ DBUG_ENTER("readAutoIncrementValue");
if (aTable == 0)
DBUG_RETURN(~(Uint64)0);
const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable);
@@ -848,62 +846,63 @@ Ndb::readTupleIdFromNdb(Uint32 aTableId)
bool
Ndb::setAutoIncrementValue(const char* aTableName, Uint64 val, bool increase)
{
- DEBUG_TRACE("setAutoIncrementValue " << val);
- const char * internalTableName= internalizeTableName(aTableName);
+ DBUG_ENTER("setAutoIncrementValue");
+ BaseString internal_tabname(internalize_table_name(aTableName));
+
Ndb_local_table_info *info=
- theDictionary->get_local_table_info(internalTableName, false);
+ theDictionary->get_local_table_info(internal_tabname, false);
if (info == 0) {
theError= theDictionary->getNdbError();
- return false;
+ DBUG_RETURN(false);
}
const NdbTableImpl* table= info->m_table_impl;
- return setTupleIdInNdb(table->m_tableId, val, increase);
+ DBUG_RETURN(setTupleIdInNdb(table->m_tableId, val, increase));
}
bool
Ndb::setAutoIncrementValue(const NdbDictionary::Table * aTable, Uint64 val, bool increase)
{
- DEBUG_TRACE("setAutoIncrementValue " << val);
+ DBUG_ENTER("setAutoIncrementValue");
if (aTable == 0)
- return ~(Uint64)0;
+ DBUG_RETURN(~(Uint64)0);
const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable);
- return setTupleIdInNdb(table->m_tableId, val, increase);
+ DBUG_RETURN(setTupleIdInNdb(table->m_tableId, val, increase));
}
-bool
+bool
Ndb::setTupleIdInNdb(const char* aTableName, Uint64 val, bool increase )
{
- DEBUG_TRACE("setTupleIdInNdb");
+ DBUG_ENTER("setTupleIdInNdb(const char*, ...)");
const NdbTableImpl* table = theDictionary->getTable(aTableName);
if (table == 0) {
theError= theDictionary->getNdbError();
- return false;
+ DBUG_RETURN(false);
}
- return setTupleIdInNdb(table->m_tableId, val, increase);
+ DBUG_RETURN(setTupleIdInNdb(table->m_tableId, val, increase));
}
bool
Ndb::setTupleIdInNdb(Uint32 aTableId, Uint64 val, bool increase )
{
- DEBUG_TRACE("setTupleIdInNdb");
+ DBUG_ENTER("setTupleIdInNdb(Uint32, ...)");
if (increase)
{
if (theFirstTupleId[aTableId] != theLastTupleId[aTableId])
{
// We have a cache sequence
if (val <= theFirstTupleId[aTableId]+1)
- return false;
+ DBUG_RETURN(false);
if (val <= theLastTupleId[aTableId])
{
theFirstTupleId[aTableId] = val - 1;
- return true;
+ DBUG_RETURN(true);
}
// else continue;
- }
- return (opTupleIdOnNdb(aTableId, val, 2) == val);
+ }
+ DBUG_RETURN((opTupleIdOnNdb(aTableId, val, 2) == val));
}
else
- return (opTupleIdOnNdb(aTableId, val, 1) == val);
+ DBUG_RETURN((opTupleIdOnNdb(aTableId, val, 1) == val));
}
Uint64
@@ -1143,25 +1142,63 @@ Ndb::externalizeIndexName(const char * internalIndexName)
return externalizeIndexName(internalIndexName, usingFullyQualifiedNames());
}
-const char *
-Ndb::internalizeTableName(const char * externalTableName)
+
+const BaseString
+Ndb::internalize_table_name(const char *external_name) const
{
+ BaseString ret;
+ DBUG_ENTER("internalize_table_name");
+ DBUG_PRINT("enter", ("external_name: %s", external_name));
+
if (fullyQualifiedNames)
- return theImpl->internalize_table_name(externalTableName);
+ {
+ /* Internal table name format <db>/<schema>/<table>
+ <db>/<schema> is already available in m_prefix
+ so just concat the two strings
+ */
+ ret.assfmt("%s%s",
+ theImpl->m_prefix.c_str(),
+ external_name);
+ }
else
- return externalTableName;
+ ret.assign(external_name);
+
+ DBUG_PRINT("exit", ("internal_name: %s", ret.c_str()));
+ DBUG_RETURN(ret);
}
-
-const char *
-Ndb::internalizeIndexName(const NdbTableImpl * table,
- const char * externalIndexName)
+
+
+const BaseString
+Ndb::internalize_index_name(const NdbTableImpl * table,
+ const char * external_name) const
{
+ BaseString ret;
+ DBUG_ENTER("internalize_index_name");
+ DBUG_PRINT("enter", ("external_name: %s, table_id: %d",
+ external_name, table ? table->m_tableId : ~0));
+ if (!table)
+ {
+ DBUG_PRINT("error", ("!table"));
+ return ret;
+ }
+
if (fullyQualifiedNames)
- return theImpl->internalize_index_name(table, externalIndexName);
+ {
+ /* Internal index name format <db>/<schema>/<tabid>/<table> */
+ ret.assfmt("%s%d%c%s",
+ theImpl->m_prefix.c_str(),
+ table->m_tableId,
+ table_name_separator,
+ external_name);
+ }
else
- return externalIndexName;
+ ret.assign(external_name);
+
+ DBUG_PRINT("exit", ("internal_name: %s", ret.c_str()));
+ DBUG_RETURN(ret);
}
+
const BaseString
Ndb::getDatabaseFromInternalName(const char * internalName)
{