summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
Diffstat (limited to 'storage')
-rw-r--r--storage/ndb/config/common.mk.am2
-rw-r--r--storage/ndb/src/mgmsrv/ConfigInfo.cpp33
-rw-r--r--storage/ndb/src/ndbapi/ndberror.c2
-rw-r--r--storage/ndb/tools/restore/consumer_restore.cpp35
-rw-r--r--storage/ndb/tools/restore/consumer_restore.hpp2
-rw-r--r--storage/ndb/tools/restore/restore_main.cpp13
6 files changed, 78 insertions, 9 deletions
diff --git a/storage/ndb/config/common.mk.am b/storage/ndb/config/common.mk.am
index 5ed3855f31e..9633a52e91f 100644
--- a/storage/ndb/config/common.mk.am
+++ b/storage/ndb/config/common.mk.am
@@ -25,3 +25,5 @@ INCLUDES = $(INCLUDES_LOC)
LDADD = $(LDADD_LOC)
DEFS = @DEFS@ @NDB_DEFS@ $(DEFS_LOC) $(NDB_EXTRA_FLAGS)
NDB_CXXFLAGS=@ndb_cxxflags_fix@ $(NDB_CXXFLAGS_LOC)
+NDB_AM_CXXFLAGS:= $(AM_CXXFLAGS)
+AM_CXXFLAGS=$(NDB_AM_CXXFLAGS) $(NDB_CXXFLAGS)
diff --git a/storage/ndb/src/mgmsrv/ConfigInfo.cpp b/storage/ndb/src/mgmsrv/ConfigInfo.cpp
index 26e50cb8a68..e27e55d2a13 100644
--- a/storage/ndb/src/mgmsrv/ConfigInfo.cpp
+++ b/storage/ndb/src/mgmsrv/ConfigInfo.cpp
@@ -2897,25 +2897,50 @@ static bool fixNodeId(InitConfigFileParser::Context & ctx, const char * data)
char buf[] = "NodeIdX"; buf[6] = data[sizeof("NodeI")];
char sysbuf[] = "SystemX"; sysbuf[6] = data[sizeof("NodeI")];
const char* nodeId;
- require(ctx.m_currentSection->get(buf, &nodeId));
+ if(!ctx.m_currentSection->get(buf, &nodeId))
+ {
+ ctx.reportError("Mandatory parameter %s missing from section"
+ "[%s] starting at line: %d",
+ buf, ctx.fname, ctx.m_sectionLineno);
+ return false;
+ }
char tmpLine[MAX_LINE_LENGTH];
strncpy(tmpLine, nodeId, MAX_LINE_LENGTH);
char* token1 = strtok(tmpLine, ".");
char* token2 = strtok(NULL, ".");
Uint32 id;
-
+
+ if(!token1)
+ {
+ ctx.reportError("Value for mandatory parameter %s missing from section "
+ "[%s] starting at line: %d",
+ buf, ctx.fname, ctx.m_sectionLineno);
+ return false;
+ }
if (token2 == NULL) { // Only a number given
errno = 0;
char* p;
id = strtol(token1, &p, 10);
- if (errno != 0) warning("STRTOK1", nodeId);
+ if (errno != 0 || id <= 0x0 || id > MAX_NODES)
+ {
+ ctx.reportError("Illegal value for mandatory parameter %s from section "
+ "[%s] starting at line: %d",
+ buf, ctx.fname, ctx.m_sectionLineno);
+ return false;
+ }
require(ctx.m_currentSection->put(buf, id, true));
} else { // A pair given (e.g. "uppsala.32")
errno = 0;
char* p;
id = strtol(token2, &p, 10);
- if (errno != 0) warning("STRTOK2", nodeId);
+ if (errno != 0 || id <= 0x0 || id > MAX_NODES)
+ {
+ ctx.reportError("Illegal value for mandatory parameter %s from section "
+ "[%s] starting at line: %d",
+ buf, ctx.fname, ctx.m_sectionLineno);
+ return false;
+ }
require(ctx.m_currentSection->put(buf, id, true));
require(ctx.m_currentSection->put(sysbuf, token1));
}
diff --git a/storage/ndb/src/ndbapi/ndberror.c b/storage/ndb/src/ndbapi/ndberror.c
index 3cecd15684d..8c40ddf2116 100644
--- a/storage/ndb/src/ndbapi/ndberror.c
+++ b/storage/ndb/src/ndbapi/ndberror.c
@@ -151,7 +151,7 @@ ErrorBundle ErrorCodes[] = {
*/
{ 4007, DMEC, UR, "Send to ndbd node failed" },
{ 4008, DMEC, UR, "Receive from NDB failed" },
- { 4009, DMEC, UR, "Cluster Failure" },
+ { 4009, HA_ERR_NO_CONNECTION, UR, "Cluster Failure" },
{ 4012, DMEC, UR,
"Request ndbd time-out, maybe due to high load or communication problems"},
{ 4013, DMEC, UR, "Request timed out in waiting for node failure"},
diff --git a/storage/ndb/tools/restore/consumer_restore.cpp b/storage/ndb/tools/restore/consumer_restore.cpp
index 3dd4b072671..b7db8145c56 100644
--- a/storage/ndb/tools/restore/consumer_restore.cpp
+++ b/storage/ndb/tools/restore/consumer_restore.cpp
@@ -894,6 +894,21 @@ BackupRestore::table(const TableS & table){
{
copy.setMaxRows(table.getNoOfRecords());
}
+
+ NdbTableImpl &tableImpl = NdbTableImpl::getImpl(copy);
+ if (table.getBackupVersion() < MAKE_VERSION(5,1,0) && !m_no_upgrade){
+ for(int i= 0; i < copy.getNoOfColumns(); i++)
+ {
+ NdbDictionary::Column::Type t = copy.getColumn(i)->getType();
+
+ if (t == NdbDictionary::Column::Varchar ||
+ t == NdbDictionary::Column::Varbinary)
+ tableImpl.getColumn(i)->setArrayType(NdbDictionary::Column::ArrayTypeShortVar);
+ if (t == NdbDictionary::Column::Longvarchar ||
+ t == NdbDictionary::Column::Longvarbinary)
+ tableImpl.getColumn(i)->setArrayType(NdbDictionary::Column::ArrayTypeMediumVar);
+ }
+ }
if (dict->createTable(copy) == -1)
{
@@ -1141,8 +1156,22 @@ void BackupRestore::tuple_a(restore_callback_t *cb)
int size = attr_desc->size;
int arraySize = attr_desc->arraySize;
char * dataPtr = attr_data->string_value;
- Uint32 length = attr_data->size;
-
+ Uint32 length = 0;
+
+ const unsigned char * src = (const unsigned char *)dataPtr;
+ switch(attr_desc->m_column->getType()){
+ case NdbDictionary::Column::Varchar:
+ case NdbDictionary::Column::Varbinary:
+ length = src[0] + 1;
+ break;
+ case NdbDictionary::Column::Longvarchar:
+ case NdbDictionary::Column::Longvarbinary:
+ length = src[0] + (src[1] << 8) + 2;
+ break;
+ default:
+ length = attr_data->size;
+ break;
+ }
if (j == 0 && tup.getTable()->have_auto_inc(i))
tup.getTable()->update_max_auto_val(dataPtr,size*arraySize);
@@ -1162,7 +1191,7 @@ void BackupRestore::tuple_a(restore_callback_t *cb)
if (ret < 0) {
ndbout_c("Column: %d type %d %d %d %d",i,
attr_desc->m_column->getType(),
- size, arraySize, attr_data->size);
+ size, arraySize, length);
break;
}
}
diff --git a/storage/ndb/tools/restore/consumer_restore.hpp b/storage/ndb/tools/restore/consumer_restore.hpp
index 0bc9d8e8d20..8694cbffb0c 100644
--- a/storage/ndb/tools/restore/consumer_restore.hpp
+++ b/storage/ndb/tools/restore/consumer_restore.hpp
@@ -51,6 +51,7 @@ public:
m_callback = 0;
m_free_callback = 0;
m_temp_error = false;
+ m_no_upgrade = false;
m_transactions = 0;
m_cache.m_old_table = 0;
}
@@ -91,6 +92,7 @@ public:
bool m_restore_meta;
bool m_no_restore_disk;
bool m_restore_epoch;
+ bool m_no_upgrade; // for upgrade ArrayType from 5.0 backup file.
Uint32 m_logCount;
Uint32 m_dataCount;
diff --git a/storage/ndb/tools/restore/restore_main.cpp b/storage/ndb/tools/restore/restore_main.cpp
index adccd024d88..79aebbaac45 100644
--- a/storage/ndb/tools/restore/restore_main.cpp
+++ b/storage/ndb/tools/restore/restore_main.cpp
@@ -34,6 +34,7 @@ static int ga_nodeId = 0;
static int ga_nParallelism = 128;
static int ga_backupId = 0;
static bool ga_dont_ignore_systab_0 = false;
+static bool ga_no_upgrade = false;
static Vector<class BackupConsumer *> g_consumers;
static BackupPrinter* g_printer = NULL;
@@ -115,6 +116,10 @@ static struct my_option my_long_options[] =
"Restore meta data into NDB Cluster using NDBAPI",
(gptr*) &_restore_meta, (gptr*) &_restore_meta, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
+ { "no-upgrade", 'u',
+ "Don't upgrade array type for var attributes, which don't resize VAR data and don't change column attributes",
+ (gptr*) &ga_no_upgrade, (gptr*) &ga_no_upgrade, 0,
+ GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "no-restore-disk-objects", 'd',
"Dont restore disk objects (tablespace/logfilegroups etc)",
(gptr*) &_no_restore_disk, (gptr*) &_no_restore_disk, 0,
@@ -460,6 +465,11 @@ o verify nodegroup mapping
restore->m_no_restore_disk = true;
}
+ if (ga_no_upgrade)
+ {
+ restore->m_no_upgrade = true;
+ }
+
if (ga_restore_epoch)
{
restore->m_restore_epoch = true;
@@ -644,6 +654,8 @@ main(int argc, char** argv)
g_options.appfmt(" -n %d", ga_nodeId);
if (_restore_meta)
g_options.appfmt(" -m");
+ if (ga_no_upgrade)
+ g_options.appfmt(" -u");
if (ga_skip_table_check)
g_options.appfmt(" -s");
if (_restore_data)
@@ -655,7 +667,6 @@ main(int argc, char** argv)
g_options.appfmt(" -p %d", ga_nParallelism);
g_connect_string = opt_connect_str;
-
/**
* we must always load meta data, even if we will only print it to stdout
*/