Commit 9a74e4c7 authored by tomas@mc05.(none)'s avatar tomas@mc05.(none)

Merge tulin@bk-internal.mysql.com:/home/bk/mysql-4.1-ndb

into mc05.(none):/space2/tomas/mysql-4.1
parents 67da12a8 e938fb8f
...@@ -49,6 +49,8 @@ ...@@ -49,6 +49,8 @@
#endif #endif
static const char table_name_separator = '/';
#ifdef NDB_VC98 #ifdef NDB_VC98
#define STATIC_CONST(x) enum { x } #define STATIC_CONST(x) enum { x }
#else #else
......
...@@ -1361,9 +1361,9 @@ public: ...@@ -1361,9 +1361,9 @@ public:
* index names as DATABASENAME/SCHEMANAME/TABLENAME/INDEXNAME * index names as DATABASENAME/SCHEMANAME/TABLENAME/INDEXNAME
* @param turnNamingOn bool true - turn naming on, false - turn naming off * @param turnNamingOn bool true - turn naming on, false - turn naming off
*/ */
static void useFullyQualifiedNames(bool turnNamingOn = true); void useFullyQualifiedNames(bool turnNamingOn = true);
static bool usingFullyQualifiedNames(); bool usingFullyQualifiedNames();
/** @} *********************************************************************/ /** @} *********************************************************************/
...@@ -1542,10 +1542,12 @@ private: ...@@ -1542,10 +1542,12 @@ private:
void abortTransactionsAfterNodeFailure(Uint16 aNodeId); void abortTransactionsAfterNodeFailure(Uint16 aNodeId);
static static
const char * externalizeTableName(const char * internalTableName, bool fullyQualifiedNames);
const char * externalizeTableName(const char * internalTableName); const char * externalizeTableName(const char * internalTableName);
const char * internalizeTableName(const char * externalTableName); const char * internalizeTableName(const char * externalTableName);
static static
const char * externalizeIndexName(const char * internalIndexName, bool fullyQualifiedNames);
const char * externalizeIndexName(const char * internalIndexName); const char * externalizeIndexName(const char * internalIndexName);
const char * internalizeIndexName(const NdbTableImpl * table, const char * internalizeIndexName(const NdbTableImpl * table,
const char * externalIndexName); const char * externalIndexName);
...@@ -1582,6 +1584,8 @@ private: ...@@ -1582,6 +1584,8 @@ private:
NdbWaiter theWaiter; NdbWaiter theWaiter;
bool fullyQualifiedNames;
// Ndb database name. // Ndb database name.
char theDataBase[NDB_MAX_DATABASE_NAME_SIZE]; char theDataBase[NDB_MAX_DATABASE_NAME_SIZE];
// Ndb database schema name. // Ndb database schema name.
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#define MAX_THREAD_NAME 16 #define MAX_THREAD_NAME 16
//#define USE_PTHREAD_EXTRAS /*#define USE_PTHREAD_EXTRAS*/
struct NdbThread struct NdbThread
{ {
......
...@@ -101,42 +101,13 @@ RestoreMetaData::getStopGCP() const { ...@@ -101,42 +101,13 @@ RestoreMetaData::getStopGCP() const {
} }
int int
RestoreMetaData::loadContent(const char * catalog, RestoreMetaData::loadContent()
const char * schema)
{ {
#if NDB_VERSION_MAJOR >= VERSION_3X
if(getMajor(m_fileHeader.NdbVersion) < VERSION_3X) {
if(catalog == NULL)
return -1;
if(schema == NULL)
return -1;
}
/**
* if backup is of version 3 or higher, then
* return -2 to indicate for the user that he
* cannot restore tables to a certain catalog/schema
*/
if(getMajor(m_fileHeader.NdbVersion) >= VERSION_3X &&
(catalog != NULL ||
schema != NULL)) {
return -2;
}
#endif
#if NDB_VERSION_MAJOR < VERSION_3X
if(getMajor(m_fileHeader.NdbVersion) >= VERSION_3X)
{
return -2;
}
#endif
Uint32 noOfTables = readMetaTableList(); Uint32 noOfTables = readMetaTableList();
if(noOfTables == 0) if(noOfTables == 0)
return -3; return -3;
for(Uint32 i = 0; i<noOfTables; i++){ for(Uint32 i = 0; i<noOfTables; i++){
if(!readMetaTableDesc(catalog, schema)){ if(!readMetaTableDesc()){
return 0; return 0;
} }
} }
...@@ -170,8 +141,7 @@ RestoreMetaData::readMetaTableList() { ...@@ -170,8 +141,7 @@ RestoreMetaData::readMetaTableList() {
} }
bool bool
RestoreMetaData::readMetaTableDesc(const char * catalog, RestoreMetaData::readMetaTableDesc() {
const char * schema) {
Uint32 sectionInfo[2]; Uint32 sectionInfo[2];
...@@ -198,10 +168,7 @@ RestoreMetaData::readMetaTableDesc(const char * catalog, ...@@ -198,10 +168,7 @@ RestoreMetaData::readMetaTableDesc(const char * catalog,
return false; return false;
} // if } // if
return parseTableDescriptor(m_buffer, return parseTableDescriptor(m_buffer, len);
len,
catalog,
schema);
} }
bool bool
...@@ -287,72 +254,11 @@ static const Uint32 ...@@ -287,72 +254,11 @@ static const Uint32
AttrMapSize = sizeof(RestoreAttrMap) AttrMapSize = sizeof(RestoreAttrMap)
/ sizeof(SimpleProperties::SP2StructMapping); / sizeof(SimpleProperties::SP2StructMapping);
struct v2xKernel_to_v3xAPIMapping {
Int32 kernelConstant;
Int32 apiConstant;
};
enum v2xKernelTypes {
ExtUndefined=0,// Undefined
ExtInt, // 32 bit
ExtUnsigned, // 32 bit
ExtBigint, // 64 bit
ExtBigunsigned,// 64 Bit
ExtFloat, // 32-bit float
ExtDouble, // 64-bit float
ExtDecimal, // Precision, Scale
ExtChar, // Len
ExtVarchar, // Max len
ExtBinary, // Len
ExtVarbinary, // Max len
ExtDatetime, // Precision down to 1 sec (sizeof(Datetime) == 8 bytes )
ExtTimespec // Precision down to 1 nsec (sizeof(Datetime) == 12 bytes )
};
const
v2xKernel_to_v3xAPIMapping
columnTypeMapping[] = {
{ ExtInt, NdbDictionary::Column::Int },
{ ExtUnsigned, NdbDictionary::Column::Unsigned },
{ ExtBigint, NdbDictionary::Column::Bigint },
{ ExtBigunsigned, NdbDictionary::Column::Bigunsigned },
{ ExtFloat, NdbDictionary::Column::Float },
{ ExtDouble, NdbDictionary::Column::Double },
{ ExtDecimal, NdbDictionary::Column::Decimal },
{ ExtChar, NdbDictionary::Column::Char },
{ ExtVarchar, NdbDictionary::Column::Varchar },
{ ExtBinary, NdbDictionary::Column::Binary },
{ ExtVarbinary, NdbDictionary::Column::Varbinary },
{ ExtDatetime, NdbDictionary::Column::Datetime },
{ ExtTimespec, NdbDictionary::Column::Timespec },
{ -1, -1 }
};
static
NdbDictionary::Column::Type
convertToV3x(Int32 kernelConstant, const v2xKernel_to_v3xAPIMapping map[],
Int32 def)
{
int i = 0;
while(map[i].kernelConstant != kernelConstant){
if(map[i].kernelConstant == -1 &&
map[i].apiConstant == -1){
return (NdbDictionary::Column::Type)def;
}
i++;
}
return (NdbDictionary::Column::Type)map[i].apiConstant;
}
// Parse dictTabInfo buffer and pushback to to vector storage // Parse dictTabInfo buffer and pushback to to vector storage
// Using SimpleProperties (here we don't need ntohl, ref:ejonore) // Using SimpleProperties (here we don't need ntohl, ref:ejonore)
bool bool
RestoreMetaData::parseTableDescriptor(const Uint32 * data, RestoreMetaData::parseTableDescriptor(const Uint32 * data, Uint32 len)
Uint32 len, {
const char * catalog,
const char * schema) {
SimplePropertiesLinearReader it(data, len); SimplePropertiesLinearReader it(data, len);
SimpleProperties::UnpackStatus spStatus; SimpleProperties::UnpackStatus spStatus;
...@@ -362,49 +268,9 @@ RestoreMetaData::parseTableDescriptor(const Uint32 * data, ...@@ -362,49 +268,9 @@ RestoreMetaData::parseTableDescriptor(const Uint32 * data,
return false; return false;
} // if } // if
/**
* if backup was taken in v21x then there is no info about catalog,
* and schema. This infomration is concatenated to the tableName.
*
*/
char tableName[MAX_TAB_NAME_SIZE*2]; // * 2 for db and schema.-. char tableName[MAX_TAB_NAME_SIZE*2]; // * 2 for db and schema.-.
it.getString(tableName);
char tmpTableName[MAX_TAB_NAME_SIZE];
it.getString(tmpTableName);
#if NDB_VERSION_MAJOR >= VERSION_3X
/**
* only mess with name in version 3.
*/
/* switch(getMajor(m_fileHeader.NdbVersion)) {
*/
if(getMajor(m_fileHeader.NdbVersion) < VERSION_3X)
{
if(strcmp(tmpTableName, "SYSTAB_0") == 0 ||
strcmp(tmpTableName, "NDB$EVENTS_0") == 0)
{
sprintf(tableName,"sys/def/%s",tmpTableName);
}
else {
if(catalog == NULL && schema == NULL)
{
sprintf(tableName,"%s",tmpTableName);
}
else
{
sprintf(tableName,"%s/%s/%s",catalog,schema,tmpTableName);
}
}
}
else
sprintf(tableName,"%s",tmpTableName);
#elif NDB_VERSION_MAJOR < VERSION_3X
/**
* this is version two!
*/
sprintf(tableName,"%s",tmpTableName);
#endif
if (strlen(tableName) == 0) { if (strlen(tableName) == 0) {
err << "readMetaTableDesc getString table name error" << endl; err << "readMetaTableDesc getString table name error" << endl;
return false; return false;
...@@ -505,35 +371,9 @@ RestoreMetaData::parseTableDescriptor(const Uint32 * data, ...@@ -505,35 +371,9 @@ RestoreMetaData::parseTableDescriptor(const Uint32 * data,
debug << " with " << table->getNoOfAttributes() << " attributes" << endl; debug << " with " << table->getNoOfAttributes() << " attributes" << endl;
allTables.push_back(table); allTables.push_back(table);
#ifndef restore_old_types
NdbTableImpl* tableImpl = 0; NdbTableImpl* tableImpl = 0;
int ret = NdbDictInterface::parseTableInfo(&tableImpl, data, len); int ret = NdbDictInterface::parseTableInfo(&tableImpl, data, len, false);
#if NDB_VERSION_MAJOR >= VERSION_3X
NdbDictionary::Column::Type type;
if(getMajor(m_fileHeader.NdbVersion) < VERSION_3X) {
tableImpl->setName(tableName);
Uint32 noOfColumns = tableImpl->getNoOfColumns();
for(Uint32 i = 0 ; i < noOfColumns; i++) {
type = convertToV3x(tableImpl->getColumn(i)->m_extType,
columnTypeMapping,
-1);
if(type == -1)
{
ndbout_c("Restore: Was not able to map external type %d (in v2x) "
" to a proper type in v3x", tableImpl->getColumn(i)->m_extType);
return false;
}
else
{
tableImpl->getColumn(i)->m_type = type;
}
}
}
#endif
if (ret != 0) { if (ret != 0) {
err << "parseTableInfo " << tableName << " failed" << endl; err << "parseTableInfo " << tableName << " failed" << endl;
return false; return false;
...@@ -542,7 +382,7 @@ RestoreMetaData::parseTableDescriptor(const Uint32 * data, ...@@ -542,7 +382,7 @@ RestoreMetaData::parseTableDescriptor(const Uint32 * data,
return false; return false;
debug << "parseTableInfo " << tableName << " done" << endl; debug << "parseTableInfo " << tableName << " done" << endl;
table->m_dictTable = tableImpl; table->m_dictTable = tableImpl;
#endif
return true; return true;
} }
......
...@@ -26,9 +26,6 @@ ...@@ -26,9 +26,6 @@
#include <ndb_version.h> #include <ndb_version.h>
#include <version.h> #include <version.h>
#define VERSION_3X 3
const int FileNameLenC = 256; const int FileNameLenC = 256;
const int TableNameLenC = 256; const int TableNameLenC = 256;
const int AttrNameLenC = 256; const int AttrNameLenC = 256;
...@@ -148,11 +145,8 @@ class TableS { ...@@ -148,11 +145,8 @@ class TableS {
const bool nullable, const bool nullable,
const KeyType key); const KeyType key);
#ifndef restore_old_types
public: public:
class NdbDictionary::Table* m_dictTable; class NdbDictionary::Table* m_dictTable;
#endif
public:
TableS (const char * name){ TableS (const char * name){
snprintf(tableName, sizeof(tableName), name); snprintf(tableName, sizeof(tableName), name);
m_noOfNullable = m_nullBitmaskSize = 0; m_noOfNullable = m_nullBitmaskSize = 0;
...@@ -242,8 +236,7 @@ class RestoreMetaData : public BackupFile { ...@@ -242,8 +236,7 @@ class RestoreMetaData : public BackupFile {
myVector<TableS *> allTables; myVector<TableS *> allTables;
bool readMetaFileHeader(); bool readMetaFileHeader();
bool readMetaTableDesc(const char * catalog, bool readMetaTableDesc();
const char * schema);
bool readGCPEntry(); bool readGCPEntry();
Uint32 readMetaTableList(); Uint32 readMetaTableList();
...@@ -251,17 +244,14 @@ class RestoreMetaData : public BackupFile { ...@@ -251,17 +244,14 @@ class RestoreMetaData : public BackupFile {
Uint32 m_startGCP; Uint32 m_startGCP;
Uint32 m_stopGCP; Uint32 m_stopGCP;
bool parseTableDescriptor(const Uint32 * data, Uint32 len, bool parseTableDescriptor(const Uint32 * data, Uint32 len);
const char * catalog,
const char * schema);
public: public:
RestoreMetaData(const char * path, Uint32 nodeId, Uint32 bNo); RestoreMetaData(const char * path, Uint32 nodeId, Uint32 bNo);
~RestoreMetaData(); ~RestoreMetaData();
int loadContent(const char * catalog, int loadContent();
const char * schema);
......
...@@ -72,10 +72,6 @@ typedef struct { ...@@ -72,10 +72,6 @@ typedef struct {
} restore_callback_t; } restore_callback_t;
static const char* ga_connect_NDB = NULL; static const char* ga_connect_NDB = NULL;
static const char* ga_schema = NULL;
static const char* ga_catalog = NULL;
/** /**
* print and restore flags * print and restore flags
...@@ -209,18 +205,6 @@ readArguments(const int argc, const char** argv) ...@@ -209,18 +205,6 @@ readArguments(const int argc, const char** argv)
"No of parallel transactions during restore of data." "No of parallel transactions during restore of data."
"(parallelism can be 1 to 1024)", "(parallelism can be 1 to 1024)",
"Parallelism"}, "Parallelism"},
#if NDB_VERSION_MAJOR >= VERSION_3X
{ "catalog", 'd', arg_string, &ga_catalog,
"Specifies the catalog/database where the data should be restored to. "
"Restores only to backups taken with v.2.x and restored on >v.3.x "
"systems. Note: system tables (if restored) defaults to sys/def/ ",
"catalog"},
{ "schema", 's', arg_string, &ga_schema,
"Specifies the schema where the data should be restored to."
"Restores only to backups taken with v.2.x and restored on >v.3.x "
"systems. Note: system tables (if restored) defaults to sys/def/ ",
"schema"},
#endif
#ifdef USE_MYSQL #ifdef USE_MYSQL
{ "use_mysql", '\0', arg_flag, &use_mysql, { "use_mysql", '\0', arg_flag, &use_mysql,
"Restore meta data via mysql. Systab will be ignored. Data is restored " "Restore meta data via mysql. Systab will be ignored. Data is restored "
...@@ -356,10 +340,6 @@ main(int argc, const char** argv) ...@@ -356,10 +340,6 @@ main(int argc, const char** argv)
{ {
return -1; return -1;
} }
// Turn off table name completion
#if NDB_VERSION_MAJOR >= VERSION_3X
Ndb::useFullyQualifiedNames(false);
#endif
/** /**
* we must always load meta data, even if we will only print it to stdout * we must always load meta data, even if we will only print it to stdout
...@@ -371,41 +351,19 @@ main(int argc, const char** argv) ...@@ -371,41 +351,19 @@ main(int argc, const char** argv)
return -1; return -1;
} }
/** /**
* check wheater we can restore the backup (right version, and if that * check wheater we can restore the backup (right version).
* version needs catalog and schema specified.
*/ */
int res = metaData.loadContent(ga_catalog, ga_schema); int res = metaData.loadContent();
if (res == 0) if (res == 0)
{ {
ndbout_c("Restore: Failed to load content"); ndbout_c("Restore: Failed to load content");
return -1; return -1;
} }
if (res == -1)
{
ndbout_c("Restore: The backup is from a NDB Cluster v.2.x version. "
"To restore this backup on a > 3.x version you must specify "
"catalog and schema.");
return -1;
}
if (res == -2)
{
#ifdef NDB_VERSION
ndbout_c("Restore: The backup is from a NDB Cluster v.3.x version "
"Catalog and schema are invalid parameters since they "
"already exist implicitly.");
#endif
#ifdef NDB_KERNEL_VERSION
ndbout_c("Restore: The backup is from a NDB Cluster v.3.x version "
"It is not possible to restore a 3.x backup on v.2.x. ");
#endif
return -1;
}
if (res == -3) if (res == -3)
{ {
ndbout_c("Restore: The backup contains no tables " ndbout_c("Restore: The backup contains no tables ");
"Catalog and schema are invalid parameters. ");
return -1; return -1;
} }
...@@ -882,10 +840,14 @@ BackupRestore::init() ...@@ -882,10 +840,14 @@ BackupRestore::init()
Ndb::setConnectString(ga_connect_NDB); Ndb::setConnectString(ga_connect_NDB);
} }
m_ndb = new Ndb("TEST_DB"); m_ndb = new Ndb();
if (m_ndb == NULL) if (m_ndb == NULL)
return false; return false;
// Turn off table name completion
m_ndb->useFullyQualifiedNames(false);
m_ndb->init(1024); m_ndb->init(1024);
if (m_ndb->waitUntilReady(30) != 0) if (m_ndb->waitUntilReady(30) != 0)
{ {
...@@ -1109,7 +1071,6 @@ BackupRestore::table(const TableS & table){ ...@@ -1109,7 +1071,6 @@ BackupRestore::table(const TableS & table){
{ {
return true; return true;
} }
#ifndef restore_old_types
NdbDictionary::Dictionary* dict = m_ndb->getDictionary(); NdbDictionary::Dictionary* dict = m_ndb->getDictionary();
if (dict->createTable(*table.m_dictTable) == -1) if (dict->createTable(*table.m_dictTable) == -1)
{ {
...@@ -1119,81 +1080,6 @@ BackupRestore::table(const TableS & table){ ...@@ -1119,81 +1080,6 @@ BackupRestore::table(const TableS & table){
} }
info << "Successfully restored table " << table.getTableName()<< endl ; info << "Successfully restored table " << table.getTableName()<< endl ;
return true; return true;
#else
NdbSchemaCon * tableTransaction = 0;
NdbSchemaOp * tableOp = 0;
tableTransaction = m_ndb->startSchemaTransaction();
if (tableTransaction == NULL)
{
err << table.getTableName()
<< " - BackupRestore::table cannot startSchemaTransaction: "
<< tableTransaction->getNdbError() << endl;
return false;
} // if
tableOp = tableTransaction->getNdbSchemaOp();
if (tableOp == NULL)
{
err << table.getTableName()
<< " - BackupRestore::table cannot getNdbSchemaOp: "
<< tableTransaction->getNdbError() << endl;
m_ndb->closeSchemaTransaction(tableTransaction);
return false;
} // if
// TODO: check for errors in table attributes. set aTupleKey
int check = 0;
check = tableOp->createTable(table.getTableName());
// aTableSize = 8, Not used?
// aTupleKey = TupleKey, go through attributes and check if there is a PK
// and so on....
if (check == -1)
{
err << table.getTableName()
<< " - BackupRestore::table cannot createTable: "
<< tableTransaction->getNdbError() << endl;
m_ndb->closeSchemaTransaction(tableTransaction);
return false;
} // if
// Create attributes from meta data
for (int i = 0; i < table.getNoOfAttributes(); i++)
{
const AttributeDesc* desc = table[i];
check = tableOp->createAttribute(desc->name, // Attr name
desc->key, // Key type
desc->size, // bits
desc->arraySize,
desc->type,
MMBased, // only supported
desc->nullable
// Rest is don't care for the moment
);
if (check == -1)
{
err << table.getTableName()
<< " - RestoreDataIterator::createTable cannot createAttribute: "
<< tableTransaction->getNdbError() << endl;
m_ndb->closeSchemaTransaction(tableTransaction);
return false;
} // if
} // for
if (tableTransaction->execute() == -1)
{
err << table.getTableName()
<< " - RestoreDataIterator::createTable cannot execute transaction: "
<< tableTransaction->getNdbError() << endl;
m_ndb->closeSchemaTransaction(tableTransaction);
return false;
} // if
m_ndb->closeSchemaTransaction(tableTransaction);
info << "Successfully created table " << table.getTableName() << endl;
return true ;
#endif
} }
...@@ -1317,26 +1203,6 @@ void BackupRestore::tupleAsynch(const TupleS & tup, restore_callback_t * cbData) ...@@ -1317,26 +1203,6 @@ void BackupRestore::tupleAsynch(const TupleS & tup, restore_callback_t * cbData)
Uint32 length = (size * arraySize) / 8; Uint32 length = (size * arraySize) / 8;
if (key == TupleKey) if (key == TupleKey)
{ {
#if NDB_VERSION_MAJOR >= VERSION3X
/**
* Convert VARCHAR from v.2x to v3x representation
*/
if (getMajor(tup.getTable()->getBackupVersion()) < VERSION_3X &&
((tup.getTable()->m_dictTable->getColumn(i)->getType() ==
NdbDictionary::Column::Varbinary ) ||
(tup.getTable()->m_dictTable->getColumn(i)->getType() ==
NdbDictionary::Column::Varchar)) && !attr->Data.null)
{
char * src = dataPtr;
char var_len[2];
var_len[0]= *(dataPtr+length - 2);
var_len[1]= *(dataPtr+length - 1);
memmove((char*)dataPtr+2, dataPtr, length);
src[0] = var_len[0];
src[1] = var_len[1];
dataPtr = src;
}
#endif
ret = op->equal(i, dataPtr, length); ret = op->equal(i, dataPtr, length);
if (ret<0) if (ret<0)
{ {
...@@ -1361,48 +1227,21 @@ void BackupRestore::tupleAsynch(const TupleS & tup, restore_callback_t * cbData) ...@@ -1361,48 +1227,21 @@ void BackupRestore::tupleAsynch(const TupleS & tup, restore_callback_t * cbData)
KeyType key = attr->Desc->key; KeyType key = attr->Desc->key;
char * dataPtr = attr->Data.string_value; char * dataPtr = attr->Data.string_value;
Uint32 length = (size * arraySize) / 8; Uint32 length = (size * arraySize) / 8;
#if NDB_VERSION_MAJOR >= VERSION3X
/**
* Convert VARCHAR from v.2x to v3x representation
*/
if (getMajor(tup.getTable()->getBackupVersion()) < VERSION_3X &&
((tup.getTable()->m_dictTable->getColumn(i)->getType() ==
NdbDictionary::Column::Varbinary ) ||
(tup.getTable()->m_dictTable->getColumn(i)->getType() ==
NdbDictionary::Column::Varchar)) && !attr->Data.null)
{
char * src = dataPtr;
char var_len[2];
var_len[0]= *(dataPtr+length - 2);//length is last 2 bytes
var_len[1]= *(dataPtr+length - 1);
memmove((char*)dataPtr+2, dataPtr, length);
src[0] = var_len[0];
src[1] = var_len[1];
dataPtr = src;
}
#endif
if (key == NoKey && !attr->Data.null) if (key == NoKey && !attr->Data.null)
{
ret = op->setValue(i, dataPtr, length); ret = op->setValue(i, dataPtr, length);
}
else if (key == NoKey && attr->Data.null) else if (key == NoKey && attr->Data.null)
{
ret = op->setValue(i, NULL, 0); ret = op->setValue(i, NULL, 0);
}
if (ret<0) if (ret<0)
{ {
ndbout_c("Column: %d type %d",i, ndbout_c("Column: %d type %d",i,
tup.getTable()->m_dictTable->getColumn(i)->getType()); tup.getTable()->m_dictTable->getColumn(i)->getType());
if (asynchErrorHandler(asynchTrans[nPreparedTransactions], m_ndb)) if (asynchErrorHandler(asynchTrans[nPreparedTransactions], m_ndb))
{ {
retries++; retries++;
continue; continue;
} }
asynchExitHandler(); asynchExitHandler();
} }
} }
......
...@@ -38,8 +38,6 @@ Name: Ndb.cpp ...@@ -38,8 +38,6 @@ Name: Ndb.cpp
#include <NdbEnv.h> #include <NdbEnv.h>
#include <BaseString.hpp> #include <BaseString.hpp>
static bool fullyQualifiedNames = true;
/**************************************************************************** /****************************************************************************
void connect(); void connect();
...@@ -1019,10 +1017,10 @@ void Ndb::setCatalogName(const char * a_catalog_name) ...@@ -1019,10 +1017,10 @@ void Ndb::setCatalogName(const char * a_catalog_name)
uint schema_len = uint schema_len =
MIN(strlen(theDataBaseSchema), NDB_MAX_SCHEMA_NAME_SIZE - 1); MIN(strlen(theDataBaseSchema), NDB_MAX_SCHEMA_NAME_SIZE - 1);
strncpy(prefixName, theDataBase, NDB_MAX_DATABASE_NAME_SIZE - 1); strncpy(prefixName, theDataBase, NDB_MAX_DATABASE_NAME_SIZE - 1);
prefixName[db_len] = '/'; prefixName[db_len] = table_name_separator;
strncpy(prefixName+db_len+1, theDataBaseSchema, strncpy(prefixName+db_len+1, theDataBaseSchema,
NDB_MAX_SCHEMA_NAME_SIZE - 1); NDB_MAX_SCHEMA_NAME_SIZE - 1);
prefixName[db_len+schema_len+1] = '/'; prefixName[db_len+schema_len+1] = table_name_separator;
prefixName[db_len+schema_len+2] = '\0'; prefixName[db_len+schema_len+2] = '\0';
prefixEnd = prefixName + db_len+schema_len + 2; prefixEnd = prefixName + db_len+schema_len + 2;
} }
...@@ -1042,10 +1040,10 @@ void Ndb::setSchemaName(const char * a_schema_name) ...@@ -1042,10 +1040,10 @@ void Ndb::setSchemaName(const char * a_schema_name)
uint schema_len = uint schema_len =
MIN(strlen(theDataBaseSchema), NDB_MAX_SCHEMA_NAME_SIZE - 1); MIN(strlen(theDataBaseSchema), NDB_MAX_SCHEMA_NAME_SIZE - 1);
strncpy(prefixName, theDataBase, NDB_MAX_DATABASE_NAME_SIZE - 1); strncpy(prefixName, theDataBase, NDB_MAX_DATABASE_NAME_SIZE - 1);
prefixName[db_len] = '/'; prefixName[db_len] = table_name_separator;
strncpy(prefixName+db_len+1, theDataBaseSchema, strncpy(prefixName+db_len+1, theDataBaseSchema,
NDB_MAX_SCHEMA_NAME_SIZE - 1); NDB_MAX_SCHEMA_NAME_SIZE - 1);
prefixName[db_len+schema_len+1] = '/'; prefixName[db_len+schema_len+1] = table_name_separator;
prefixName[db_len+schema_len+2] = '\0'; prefixName[db_len+schema_len+2] = '\0';
prefixEnd = prefixName + db_len+schema_len + 2; prefixEnd = prefixName + db_len+schema_len + 2;
} }
...@@ -1085,43 +1083,36 @@ bool Ndb::usingFullyQualifiedNames() ...@@ -1085,43 +1083,36 @@ bool Ndb::usingFullyQualifiedNames()
} }
const char * const char *
Ndb::externalizeTableName(const char * internalTableName) Ndb::externalizeTableName(const char * internalTableName, bool fullyQualifiedNames)
{ {
if (fullyQualifiedNames) { if (fullyQualifiedNames) {
register const char *ptr = internalTableName; register const char *ptr = internalTableName;
// Skip database name // Skip database name
while (*ptr && *ptr++ != '/'); while (*ptr && *ptr++ != table_name_separator);
// Skip schema name // Skip schema name
while (*ptr && *ptr++ != '/'); while (*ptr && *ptr++ != table_name_separator);
return ptr; return ptr;
} }
else else
return internalTableName; return internalTableName;
} }
const char * const char *
Ndb::internalizeTableName(const char * externalTableName) Ndb::externalizeTableName(const char * internalTableName)
{ {
if (fullyQualifiedNames) { return externalizeTableName(internalTableName, usingFullyQualifiedNames());
strncpy(prefixEnd, externalTableName, NDB_MAX_TAB_NAME_SIZE);
return prefixName;
}
else
return externalTableName;
} }
const char * const char *
Ndb::externalizeIndexName(const char * internalIndexName) Ndb::externalizeIndexName(const char * internalIndexName, bool fullyQualifiedNames)
{ {
if (fullyQualifiedNames) { if (fullyQualifiedNames) {
register const char *ptr = internalIndexName; register const char *ptr = internalIndexName;
// Scan name from the end // Scan name from the end
while (*ptr++); ptr--; // strend while (*ptr++); ptr--; // strend
while (ptr >= internalIndexName && *ptr != '/') while (ptr >= internalIndexName && *ptr != table_name_separator)
ptr--; ptr--;
return ptr + 1; return ptr + 1;
...@@ -1129,6 +1120,23 @@ Ndb::externalizeIndexName(const char * internalIndexName) ...@@ -1129,6 +1120,23 @@ Ndb::externalizeIndexName(const char * internalIndexName)
else else
return internalIndexName; return internalIndexName;
} }
const char *
Ndb::externalizeIndexName(const char * internalIndexName)
{
return externalizeIndexName(internalIndexName, usingFullyQualifiedNames());
}
const char *
Ndb::internalizeTableName(const char * externalTableName)
{
if (fullyQualifiedNames) {
strncpy(prefixEnd, externalTableName, NDB_MAX_TAB_NAME_SIZE);
return prefixName;
}
else
return externalTableName;
}
const char * const char *
Ndb::internalizeIndexName(const NdbTableImpl * table, Ndb::internalizeIndexName(const NdbTableImpl * table,
...@@ -1139,7 +1147,7 @@ Ndb::internalizeIndexName(const NdbTableImpl * table, ...@@ -1139,7 +1147,7 @@ Ndb::internalizeIndexName(const NdbTableImpl * table,
sprintf(tableId, "%d", table->m_tableId); sprintf(tableId, "%d", table->m_tableId);
Uint32 tabIdLen = strlen(tableId); Uint32 tabIdLen = strlen(tableId);
strncpy(prefixEnd, tableId, tabIdLen); strncpy(prefixEnd, tableId, tabIdLen);
prefixEnd[tabIdLen] = '/'; prefixEnd[tabIdLen] = table_name_separator;
strncpy(prefixEnd + tabIdLen + 1, strncpy(prefixEnd + tabIdLen + 1,
externalIndexName, NDB_MAX_TAB_NAME_SIZE); externalIndexName, NDB_MAX_TAB_NAME_SIZE);
return prefixName; return prefixName;
...@@ -1155,8 +1163,8 @@ Ndb::getDatabaseFromInternalName(const char * internalName) ...@@ -1155,8 +1163,8 @@ Ndb::getDatabaseFromInternalName(const char * internalName)
strcpy(databaseName, internalName); strcpy(databaseName, internalName);
register char *ptr = databaseName; register char *ptr = databaseName;
/* Scan name for the first '/' */ /* Scan name for the first table_name_separator */
while (*ptr && *ptr != '/') while (*ptr && *ptr != table_name_separator)
ptr++; ptr++;
*ptr = '\0'; *ptr = '\0';
BaseString ret = BaseString(databaseName); BaseString ret = BaseString(databaseName);
...@@ -1170,12 +1178,12 @@ Ndb::getSchemaFromInternalName(const char * internalName) ...@@ -1170,12 +1178,12 @@ Ndb::getSchemaFromInternalName(const char * internalName)
char * schemaName = new char[strlen(internalName)]; char * schemaName = new char[strlen(internalName)];
register const char *ptr1 = internalName; register const char *ptr1 = internalName;
/* Scan name for the second '/' */ /* Scan name for the second table_name_separator */
while (*ptr1 && *ptr1 != '/') while (*ptr1 && *ptr1 != table_name_separator)
ptr1++; ptr1++;
strcpy(schemaName, ptr1 + 1); strcpy(schemaName, ptr1 + 1);
register char *ptr = schemaName; register char *ptr = schemaName;
while (*ptr && *ptr != '/') while (*ptr && *ptr != table_name_separator)
ptr++; ptr++;
*ptr = '\0'; *ptr = '\0';
BaseString ret = BaseString(schemaName); BaseString ret = BaseString(schemaName);
......
...@@ -621,7 +621,7 @@ NdbDictionaryImpl::getIndexTable(NdbIndexImpl * index, ...@@ -621,7 +621,7 @@ NdbDictionaryImpl::getIndexTable(NdbIndexImpl * index,
const char * internalName = const char * internalName =
m_ndb.internalizeIndexName(table, index->getName()); m_ndb.internalizeIndexName(table, index->getName());
return getTable(Ndb::externalizeTableName(internalName)); return getTable(m_ndb.externalizeTableName(internalName));
} }
bool bool
...@@ -862,7 +862,7 @@ NdbDictInterface::dictSignal(NdbApiSignal* signal, ...@@ -862,7 +862,7 @@ NdbDictInterface::dictSignal(NdbApiSignal* signal,
* get tab info * get tab info
*/ */
NdbTableImpl * NdbTableImpl *
NdbDictInterface::getTable(int tableId) NdbDictInterface::getTable(int tableId, bool fullyQualifiedNames)
{ {
NdbApiSignal tSignal(m_reference); NdbApiSignal tSignal(m_reference);
GetTabInfoReq * const req = CAST_PTR(GetTabInfoReq, tSignal.getDataPtrSend()); GetTabInfoReq * const req = CAST_PTR(GetTabInfoReq, tSignal.getDataPtrSend());
...@@ -876,11 +876,11 @@ NdbDictInterface::getTable(int tableId) ...@@ -876,11 +876,11 @@ NdbDictInterface::getTable(int tableId)
tSignal.theVerId_signalNumber = GSN_GET_TABINFOREQ; tSignal.theVerId_signalNumber = GSN_GET_TABINFOREQ;
tSignal.theLength = GetTabInfoReq::SignalLength; tSignal.theLength = GetTabInfoReq::SignalLength;
return getTable(&tSignal, 0, 0); return getTable(&tSignal, 0, 0, fullyQualifiedNames);
} }
NdbTableImpl * NdbTableImpl *
NdbDictInterface::getTable(const char * name) NdbDictInterface::getTable(const char * name, bool fullyQualifiedNames)
{ {
NdbApiSignal tSignal(m_reference); NdbApiSignal tSignal(m_reference);
GetTabInfoReq * const req = CAST_PTR(GetTabInfoReq, tSignal.getDataPtrSend()); GetTabInfoReq * const req = CAST_PTR(GetTabInfoReq, tSignal.getDataPtrSend());
...@@ -904,13 +904,13 @@ NdbDictInterface::getTable(const char * name) ...@@ -904,13 +904,13 @@ NdbDictInterface::getTable(const char * name)
ptr[0].p = (Uint32*)name; ptr[0].p = (Uint32*)name;
ptr[0].sz = strLen; ptr[0].sz = strLen;
return getTable(&tSignal, ptr, 1); return getTable(&tSignal, ptr, 1, fullyQualifiedNames);
} }
NdbTableImpl * NdbTableImpl *
NdbDictInterface::getTable(class NdbApiSignal * signal, NdbDictInterface::getTable(class NdbApiSignal * signal,
LinearSectionPtr ptr[3], LinearSectionPtr ptr[3],
Uint32 noOfSections) Uint32 noOfSections, bool fullyQualifiedNames)
{ {
//GetTabInfoReq * const req = CAST_PTR(GetTabInfoReq, signal->getDataPtrSend()); //GetTabInfoReq * const req = CAST_PTR(GetTabInfoReq, signal->getDataPtrSend());
int r = dictSignal(signal,ptr,noOfSections, int r = dictSignal(signal,ptr,noOfSections,
...@@ -924,7 +924,7 @@ NdbDictInterface::getTable(class NdbApiSignal * signal, ...@@ -924,7 +924,7 @@ NdbDictInterface::getTable(class NdbApiSignal * signal,
NdbTableImpl * rt = 0; NdbTableImpl * rt = 0;
m_error.code = parseTableInfo(&rt, m_error.code = parseTableInfo(&rt,
(Uint32*)m_buffer.get_data(), (Uint32*)m_buffer.get_data(),
m_buffer.length() / 4); m_buffer.length() / 4, fullyQualifiedNames);
rt->buildColumnHash(); rt->buildColumnHash();
return rt; return rt;
} }
...@@ -1081,7 +1081,8 @@ columnTypeMapping[] = { ...@@ -1081,7 +1081,8 @@ columnTypeMapping[] = {
int int
NdbDictInterface::parseTableInfo(NdbTableImpl ** ret, NdbDictInterface::parseTableInfo(NdbTableImpl ** ret,
const Uint32 * data, Uint32 len) const Uint32 * data, Uint32 len,
bool fullyQualifiedNames)
{ {
SimplePropertiesLinearReader it(data, len); SimplePropertiesLinearReader it(data, len);
DictTabInfo::Table tableDesc; tableDesc.init(); DictTabInfo::Table tableDesc; tableDesc.init();
...@@ -1095,7 +1096,7 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret, ...@@ -1095,7 +1096,7 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret,
return 703; return 703;
} }
const char * internalName = tableDesc.TableName; const char * internalName = tableDesc.TableName;
const char * externalName = Ndb::externalizeTableName(internalName); const char * externalName = Ndb::externalizeTableName(internalName, fullyQualifiedNames);
NdbTableImpl * impl = new NdbTableImpl(); NdbTableImpl * impl = new NdbTableImpl();
impl->m_tableId = tableDesc.TableId; impl->m_tableId = tableDesc.TableId;
...@@ -1124,7 +1125,7 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret, ...@@ -1124,7 +1125,7 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret,
if(impl->m_indexType == NdbDictionary::Index::Undefined){ if(impl->m_indexType == NdbDictionary::Index::Undefined){
} else { } else {
const char * externalPrimary = const char * externalPrimary =
Ndb::externalizeTableName(tableDesc.PrimaryTable); Ndb::externalizeTableName(tableDesc.PrimaryTable, fullyQualifiedNames);
impl->m_primaryTable.assign(externalPrimary); impl->m_primaryTable.assign(externalPrimary);
} }
...@@ -1866,7 +1867,7 @@ int ...@@ -1866,7 +1867,7 @@ int
NdbDictionaryImpl::dropIndex(NdbIndexImpl & impl, const char * tableName) NdbDictionaryImpl::dropIndex(NdbIndexImpl & impl, const char * tableName)
{ {
const char * indexName = impl.getName(); const char * indexName = impl.getName();
if (tableName || Ndb::usingFullyQualifiedNames()) { if (tableName || m_ndb.usingFullyQualifiedNames()) {
NdbTableImpl * timpl = impl.m_table; NdbTableImpl * timpl = impl.m_table;
if (timpl == 0) { if (timpl == 0) {
...@@ -2571,14 +2572,13 @@ NdbDictionaryImpl::listObjects(List& list, NdbDictionary::Object::Type type) ...@@ -2571,14 +2572,13 @@ NdbDictionaryImpl::listObjects(List& list, NdbDictionary::Object::Type type)
req.requestData = 0; req.requestData = 0;
req.setTableType(getKernelConstant(type, objectTypeMapping, 0)); req.setTableType(getKernelConstant(type, objectTypeMapping, 0));
req.setListNames(true); req.setListNames(true);
return m_receiver.listObjects(list, req.requestData); return m_receiver.listObjects(list, req.requestData, m_ndb.usingFullyQualifiedNames());
} }
int int
NdbDictionaryImpl::listIndexes(List& list, const char * tableName) NdbDictionaryImpl::listIndexes(List& list, const char * tableName)
{ {
ListTablesReq ListTablesReq req;
req;
NdbTableImpl* impl = getTable(tableName); NdbTableImpl* impl = getTable(tableName);
if (impl == 0) if (impl == 0)
return -1; return -1;
...@@ -2586,12 +2586,12 @@ NdbDictionaryImpl::listIndexes(List& list, const char * tableName) ...@@ -2586,12 +2586,12 @@ NdbDictionaryImpl::listIndexes(List& list, const char * tableName)
req.setTableId(impl->m_tableId); req.setTableId(impl->m_tableId);
req.setListNames(true); req.setListNames(true);
req.setListIndexes(true); req.setListIndexes(true);
return m_receiver.listObjects(list, req.requestData); return m_receiver.listObjects(list, req.requestData, m_ndb.usingFullyQualifiedNames());
} }
int int
NdbDictInterface::listObjects(NdbDictionary::Dictionary::List& list, NdbDictInterface::listObjects(NdbDictionary::Dictionary::List& list,
Uint32 requestData) Uint32 requestData, bool fullyQualifiedNames)
{ {
NdbApiSignal tSignal(m_reference); NdbApiSignal tSignal(m_reference);
ListTablesReq* const req = CAST_PTR(ListTablesReq, tSignal.getDataPtrSend()); ListTablesReq* const req = CAST_PTR(ListTablesReq, tSignal.getDataPtrSend());
...@@ -2656,7 +2656,7 @@ NdbDictInterface::listObjects(NdbDictionary::Dictionary::List& list, ...@@ -2656,7 +2656,7 @@ NdbDictInterface::listObjects(NdbDictionary::Dictionary::List& list,
memcpy(indexName, &data[pos], n << 2); memcpy(indexName, &data[pos], n << 2);
databaseName = Ndb::getDatabaseFromInternalName(indexName); databaseName = Ndb::getDatabaseFromInternalName(indexName);
schemaName = Ndb::getSchemaFromInternalName(indexName); schemaName = Ndb::getSchemaFromInternalName(indexName);
objectName = BaseString(Ndb::externalizeIndexName(indexName)); objectName = BaseString(Ndb::externalizeIndexName(indexName, fullyQualifiedNames));
delete [] indexName; delete [] indexName;
} else if ((element.type == NdbDictionary::Object::SystemTable) || } else if ((element.type == NdbDictionary::Object::SystemTable) ||
(element.type == NdbDictionary::Object::UserTable)) { (element.type == NdbDictionary::Object::UserTable)) {
...@@ -2664,7 +2664,7 @@ NdbDictInterface::listObjects(NdbDictionary::Dictionary::List& list, ...@@ -2664,7 +2664,7 @@ NdbDictInterface::listObjects(NdbDictionary::Dictionary::List& list,
memcpy(tableName, &data[pos], n << 2); memcpy(tableName, &data[pos], n << 2);
databaseName = Ndb::getDatabaseFromInternalName(tableName); databaseName = Ndb::getDatabaseFromInternalName(tableName);
schemaName = Ndb::getSchemaFromInternalName(tableName); schemaName = Ndb::getSchemaFromInternalName(tableName);
objectName = BaseString(Ndb::externalizeTableName(tableName)); objectName = BaseString(Ndb::externalizeTableName(tableName, fullyQualifiedNames));
delete [] tableName; delete [] tableName;
} }
else { else {
......
...@@ -283,17 +283,18 @@ public: ...@@ -283,17 +283,18 @@ public:
int stopSubscribeEvent(class Ndb & ndb, NdbEventImpl &); int stopSubscribeEvent(class Ndb & ndb, NdbEventImpl &);
int stopSubscribeEvent(NdbApiSignal* signal, LinearSectionPtr ptr[3]); int stopSubscribeEvent(NdbApiSignal* signal, LinearSectionPtr ptr[3]);
int listObjects(NdbDictionary::Dictionary::List& list, Uint32 requestData); int listObjects(NdbDictionary::Dictionary::List& list, Uint32 requestData, bool fullyQualifiedNames);
int listObjects(NdbApiSignal* signal); int listObjects(NdbApiSignal* signal);
NdbTableImpl * getTable(int tableId); NdbTableImpl * getTable(int tableId, bool fullyQualifiedNames);
NdbTableImpl * getTable(const char * name); NdbTableImpl * getTable(const char * name, bool fullyQualifiedNames);
NdbTableImpl * getTable(class NdbApiSignal * signal, NdbTableImpl * getTable(class NdbApiSignal * signal,
LinearSectionPtr ptr[3], LinearSectionPtr ptr[3],
Uint32 noOfSections); Uint32 noOfSections, bool fullyQualifiedNames);
static int parseTableInfo(NdbTableImpl ** dst, static int parseTableInfo(NdbTableImpl ** dst,
const Uint32 * data, Uint32 len); const Uint32 * data, Uint32 len,
bool fullyQualifiedNames);
NdbError & m_error; NdbError & m_error;
private: private:
...@@ -601,7 +602,7 @@ NdbDictionaryImpl::getTableImpl(const char * internalTableName) ...@@ -601,7 +602,7 @@ NdbDictionaryImpl::getTableImpl(const char * internalTableName)
m_globalHash->unlock(); m_globalHash->unlock();
if (ret == 0){ if (ret == 0){
ret = m_receiver.getTable(internalTableName); ret = m_receiver.getTable(internalTableName, m_ndb.usingFullyQualifiedNames());
m_globalHash->lock(); m_globalHash->lock();
m_globalHash->put(internalTableName, ret); m_globalHash->put(internalTableName, ret);
...@@ -624,7 +625,7 @@ NdbIndexImpl * ...@@ -624,7 +625,7 @@ NdbIndexImpl *
NdbDictionaryImpl::getIndex(const char * indexName, NdbDictionaryImpl::getIndex(const char * indexName,
const char * tableName) const char * tableName)
{ {
if (tableName || Ndb::usingFullyQualifiedNames()) { if (tableName || m_ndb.usingFullyQualifiedNames()) {
const char * internalIndexName = 0; const char * internalIndexName = 0;
if (tableName) { if (tableName) {
NdbTableImpl * t = getTable(tableName); NdbTableImpl * t = getTable(tableName);
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <ndb_global.h>
#include "NdbApiSignal.hpp" #include "NdbApiSignal.hpp"
#include "NdbImpl.hpp" #include "NdbImpl.hpp"
//#include "NdbSchemaOp.hpp" //#include "NdbSchemaOp.hpp"
...@@ -92,6 +94,8 @@ Ndb::Ndb( const char* aDataBase , const char* aDataBaseSchema) : ...@@ -92,6 +94,8 @@ Ndb::Ndb( const char* aDataBase , const char* aDataBaseSchema) :
theNdbBlockNumber(-1), theNdbBlockNumber(-1),
theInitState(NotConstructed) theInitState(NotConstructed)
{ {
fullyQualifiedNames = true;
cgetSignals =0; cgetSignals =0;
cfreeSignals = 0; cfreeSignals = 0;
cnewSignals = 0; cnewSignals = 0;
...@@ -126,10 +130,10 @@ Ndb::Ndb( const char* aDataBase , const char* aDataBaseSchema) : ...@@ -126,10 +130,10 @@ Ndb::Ndb( const char* aDataBase , const char* aDataBaseSchema) :
uint schema_len = uint schema_len =
MIN(strlen(theDataBaseSchema), NDB_MAX_SCHEMA_NAME_SIZE - 1); MIN(strlen(theDataBaseSchema), NDB_MAX_SCHEMA_NAME_SIZE - 1);
strncpy(prefixName, theDataBase, NDB_MAX_DATABASE_NAME_SIZE - 1); strncpy(prefixName, theDataBase, NDB_MAX_DATABASE_NAME_SIZE - 1);
prefixName[db_len] = '/'; prefixName[db_len] = table_name_separator;
strncpy(prefixName+db_len+1, theDataBaseSchema, strncpy(prefixName+db_len+1, theDataBaseSchema,
NDB_MAX_SCHEMA_NAME_SIZE - 1); NDB_MAX_SCHEMA_NAME_SIZE - 1);
prefixName[db_len+schema_len+1] = '/'; prefixName[db_len+schema_len+1] = table_name_separator;
prefixName[db_len+schema_len+2] = '\0'; prefixName[db_len+schema_len+2] = '\0';
prefixEnd = prefixName + db_len+schema_len + 2; prefixEnd = prefixName + db_len+schema_len + 2;
......
...@@ -50,9 +50,10 @@ void ...@@ -50,9 +50,10 @@ void
AppNDB::init(const char* connectString) { AppNDB::init(const char* connectString) {
// NdbThread_SetConcurrencyLevel(1+ 2); // NdbThread_SetConcurrencyLevel(1+ 2);
Ndb::useFullyQualifiedNames(false);
m_ndb = new Ndb(""); m_ndb = new Ndb("");
m_ndb->useFullyQualifiedNames(false);
m_ndb->setConnectString(connectString); m_ndb->setConnectString(connectString);
/** /**
* @todo Set proper max no of transactions?? needed?? Default 12?? * @todo Set proper max no of transactions?? needed?? Default 12??
...@@ -539,7 +540,8 @@ AppNDB::prepareMetaRecord(MetaRecord* mr) { ...@@ -539,7 +540,8 @@ AppNDB::prepareMetaRecord(MetaRecord* mr) {
NdbTableImpl * tmp = 0; NdbTableImpl * tmp = 0;
NdbDictionary::Table * table =0; NdbDictionary::Table * table =0;
Uint32 * data =(Uint32*)( ((char*)mr + sizeof(Uint32)*6)); Uint32 * data =(Uint32*)( ((char*)mr + sizeof(Uint32)*6));
int res = NdbDictInterface::parseTableInfo(&tmp, data, mr->dataLen); int res = NdbDictInterface::parseTableInfo(&tmp, data, mr->dataLen,
m_ndb->usingFullyQualifiedNames());
if(res == 0) { if(res == 0) {
table = tmp; table = tmp;
return table; return table;
......
...@@ -273,7 +273,7 @@ Channel::addTable(const char * tableName) ...@@ -273,7 +273,7 @@ Channel::addTable(const char * tableName)
if(strlen(tableName)>MAX_TAB_NAME_SIZE) if(strlen(tableName)>MAX_TAB_NAME_SIZE)
return GrepError::REP_NOT_PROPER_TABLE; return GrepError::REP_NOT_PROPER_TABLE;
/** /**
* No of separators are the number of '/' found in tableName * No of separators are the number of table_name_separator found in tableName
* since a table is defined as <db>/<schema>/tablename. * since a table is defined as <db>/<schema>/tablename.
* if noOfSeparators is not equal to 2, then it is not a valid * if noOfSeparators is not equal to 2, then it is not a valid
* table name. * table name.
...@@ -282,7 +282,7 @@ Channel::addTable(const char * tableName) ...@@ -282,7 +282,7 @@ Channel::addTable(const char * tableName)
if(strlen(tableName) < 5) if(strlen(tableName) < 5)
return GrepError::REP_NOT_PROPER_TABLE; return GrepError::REP_NOT_PROPER_TABLE;
for(Uint32 i =0; i < strlen(tableName); i++) for(Uint32 i =0; i < strlen(tableName); i++)
if(tableName[i]=='/') if(tableName[i]==table_name_separator)
noOfSeps++; noOfSeps++;
if(noOfSeps!=2) if(noOfSeps!=2)
return GrepError::REP_NOT_PROPER_TABLE; return GrepError::REP_NOT_PROPER_TABLE;
...@@ -301,7 +301,7 @@ Channel::removeTable(const char * tableName) ...@@ -301,7 +301,7 @@ Channel::removeTable(const char * tableName)
if(strlen(tableName)>MAX_TAB_NAME_SIZE) if(strlen(tableName)>MAX_TAB_NAME_SIZE)
return GrepError::REP_NOT_PROPER_TABLE; return GrepError::REP_NOT_PROPER_TABLE;
/** /**
* No of separators are the number of '/' found in tableName * No of separators are the number of table_name_separator found in tableName
* since a table is defined as <db>/<schema>/tablename. * since a table is defined as <db>/<schema>/tablename.
* If noOfSeparators is not equal to 2, * If noOfSeparators is not equal to 2,
* then it is not a valid table name. * then it is not a valid table name.
...@@ -310,7 +310,7 @@ Channel::removeTable(const char * tableName) ...@@ -310,7 +310,7 @@ Channel::removeTable(const char * tableName)
if(strlen(tableName) < 5) if(strlen(tableName) < 5)
return GrepError::REP_NOT_PROPER_TABLE; return GrepError::REP_NOT_PROPER_TABLE;
for(Uint32 i =0; i < strlen(tableName); i++) for(Uint32 i =0; i < strlen(tableName); i++)
if(tableName[i]=='/') if(tableName[i]==table_name_separator)
noOfSeps++; noOfSeps++;
if(noOfSeps!=2) if(noOfSeps!=2)
return GrepError::REP_NOT_PROPER_TABLE; return GrepError::REP_NOT_PROPER_TABLE;
......
...@@ -74,16 +74,13 @@ int main(int argc, const char** argv){ ...@@ -74,16 +74,13 @@ int main(int argc, const char** argv){
if(table == 0) if(table == 0)
return NDBT_ProgramExit(NDBT_WRONGARGS); return NDBT_ProgramExit(NDBT_WRONGARGS);
Ndb::useFullyQualifiedNames(false);
Ndb * m_ndb = new Ndb(""); Ndb * m_ndb = new Ndb("");
m_ndb->useFullyQualifiedNames(false);
m_ndb->setConnectString(connectString); m_ndb->setConnectString(connectString);
Ndb::useFullyQualifiedNames(false);
/** /**
* @todo Set proper max no of transactions?? needed?? Default 12?? * @todo Set proper max no of transactions?? needed?? Default 12??
*/ */
m_ndb->init(2048); m_ndb->init(2048);
Ndb::useFullyQualifiedNames(false);
if (m_ndb->waitUntilReady() != 0){ if (m_ndb->waitUntilReady() != 0){
ndbout_c("NDB Cluster not ready for connections"); ndbout_c("NDB Cluster not ready for connections");
} }
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
static Ndb* ndb = 0; static Ndb* ndb = 0;
static NdbDictionary::Dictionary* dic = 0; static NdbDictionary::Dictionary* dic = 0;
static int _unqualified = 0;
static void static void
fatal(char const* fmt, ...) fatal(char const* fmt, ...)
...@@ -59,7 +60,7 @@ list(const char * tabname, ...@@ -59,7 +60,7 @@ list(const char * tabname,
if (dic->listIndexes(list, tabname) == -1) if (dic->listIndexes(list, tabname) == -1)
fatal("listIndexes"); fatal("listIndexes");
} }
if (Ndb::usingFullyQualifiedNames()) if (ndb->usingFullyQualifiedNames())
ndbout_c("%-5s %-20s %-8s %-7s %-12s %-8s %s", "id", "type", "state", "logging", "database", "schema", "name"); ndbout_c("%-5s %-20s %-8s %-7s %-12s %-8s %s", "id", "type", "state", "logging", "database", "schema", "name");
else else
ndbout_c("%-5s %-20s %-8s %-7s %s", "id", "type", "state", "logging", "name"); ndbout_c("%-5s %-20s %-8s %-7s %s", "id", "type", "state", "logging", "name");
...@@ -137,7 +138,7 @@ list(const char * tabname, ...@@ -137,7 +138,7 @@ list(const char * tabname,
break; break;
} }
} }
if (Ndb::usingFullyQualifiedNames()) if (ndb->usingFullyQualifiedNames())
ndbout_c("%-5d %-20s %-8s %-7s %-12s %-8s %s", elt.id, type, state, store, (elt.database)?elt.database:"", (elt.schema)?elt.schema:"", elt.name); ndbout_c("%-5d %-20s %-8s %-7s %-12s %-8s %s", elt.id, type, state, store, (elt.database)?elt.database:"", (elt.schema)?elt.schema:"", elt.name);
else else
ndbout_c("%-5d %-20s %-8s %-7s %s", elt.id, type, state, store, elt.name); ndbout_c("%-5d %-20s %-8s %-7s %s", elt.id, type, state, store, elt.name);
...@@ -148,7 +149,6 @@ int main(int argc, const char** argv){ ...@@ -148,7 +149,6 @@ int main(int argc, const char** argv){
int _loops = 1; int _loops = 1;
const char* _tabname = NULL; const char* _tabname = NULL;
const char* _dbname = "TEST_DB"; const char* _dbname = "TEST_DB";
int _unqualified = 0;
int _type = 0; int _type = 0;
int _help = 0; int _help = 0;
......
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