summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgni@dev3-221.dev.cn.tlan <>2007-05-08 09:52:27 +0800
committergni@dev3-221.dev.cn.tlan <>2007-05-08 09:52:27 +0800
commit305d0eaf02ef3b64099bc588576d9862d8309ca5 (patch)
treeb423c42d7750e95d88f0d57fa69c3bde1d77a31a
parent245e6d17404e6d5322fdad6a76c3df671dbc9df9 (diff)
parent31f908899288c209278232e410c84e6620eea1e0 (diff)
downloadmariadb-git-305d0eaf02ef3b64099bc588576d9862d8309ca5.tar.gz
Merge dev3-221.dev.cn.tlan:/home/ngb/mysql/mysql-5.1/mysql-5.1-new-ndb-bj
into dev3-221.dev.cn.tlan:/home/ngb/mysql/mysql-5.1/mysql-5.1-new-ndb
-rw-r--r--config/ac-macros/ha_ndbcluster.m41
-rw-r--r--mysql-test/r/ndb_autodiscover.result2
-rw-r--r--mysql-test/t/rpl_ndb_myisam2ndb-slave.opt2
-rw-r--r--sql/ha_ndbcluster.cc6
-rw-r--r--sql/handler.cc31
-rw-r--r--sql/mysqld.cc7
-rw-r--r--sql/set_var.cc11
-rw-r--r--sql/sql_plugin.cc1
-rw-r--r--sql/sql_table.cc24
-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
15 files changed, 131 insertions, 41 deletions
diff --git a/config/ac-macros/ha_ndbcluster.m4 b/config/ac-macros/ha_ndbcluster.m4
index 2a54638b3ae..04244b9ec13 100644
--- a/config/ac-macros/ha_ndbcluster.m4
+++ b/config/ac-macros/ha_ndbcluster.m4
@@ -197,7 +197,6 @@ AC_DEFUN([MYSQL_SETUP_NDBCLUSTER], [
MAKE_BINARY_DISTRIBUTION_OPTIONS="$MAKE_BINARY_DISTRIBUTION_OPTIONS --with-ndbcluster"
- CXXFLAGS="$CXXFLAGS \$(NDB_CXXFLAGS)"
if test "$have_ndb_debug" = "default"
then
have_ndb_debug=$with_debug
diff --git a/mysql-test/r/ndb_autodiscover.result b/mysql-test/r/ndb_autodiscover.result
index cb85c4ac873..487f52f6427 100644
--- a/mysql-test/r/ndb_autodiscover.result
+++ b/mysql-test/r/ndb_autodiscover.result
@@ -382,7 +382,7 @@ create table t1 (a int primary key) engine=ndb;
select * from t1;
a
select * from t1;
-ERROR HY000: Can't lock file (errno: 4009)
+ERROR HY000: Can't lock file (errno: 157)
use test;
drop database test_only_ndb_tables;
CREATE TABLE t9 (
diff --git a/mysql-test/t/rpl_ndb_myisam2ndb-slave.opt b/mysql-test/t/rpl_ndb_myisam2ndb-slave.opt
index 701dddb075b..7f9eb96dff1 100644
--- a/mysql-test/t/rpl_ndb_myisam2ndb-slave.opt
+++ b/mysql-test/t/rpl_ndb_myisam2ndb-slave.opt
@@ -1 +1 @@
---default-storage-engine=ndbcluster
+--default-storage-engine=ndbcluster
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index 02fbee7237f..be0571de02a 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -6570,9 +6570,9 @@ int ndbcluster_table_exists_in_engine(handlerton *hton, THD* thd,
if (my_strcasecmp(system_charset_info, elmt.name, name))
continue;
DBUG_PRINT("info", ("Found table"));
- DBUG_RETURN(1);
+ DBUG_RETURN(HA_ERR_TABLE_EXIST);
}
- DBUG_RETURN(0);
+ DBUG_RETURN(HA_ERR_NO_SUCH_TABLE);
}
@@ -6936,7 +6936,7 @@ int ndbcluster_find_files(handlerton *hton, THD *thd,
DBUG_PRINT("info", ("%s existed on disk", name));
// The .ndb file exists on disk, but it's not in list of tables in ndb
// Verify that handler agrees table is gone.
- if (ndbcluster_table_exists_in_engine(hton, thd, db, file_name) == 0)
+ if (ndbcluster_table_exists_in_engine(hton, thd, db, file_name) == HA_ERR_NO_SUCH_TABLE)
{
DBUG_PRINT("info", ("NDB says %s does not exists", file_name));
it.remove();
diff --git a/sql/handler.cc b/sql/handler.cc
index e0018a66400..bbfdd34b9fb 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -2858,20 +2858,21 @@ ha_find_files(THD *thd,const char *db,const char *path,
DBUG_RETURN(error);
}
-
-/** @brief
+/*
Ask handler if the table exists in engine
RETURN
- 0 Table does not exist
- 1 Table exists
- # Error code
+ HA_ERR_NO_SUCH_TABLE Table does not exist
+ HA_ERR_TABLE_EXIST Table exists
+ # Error code
+
+ */
-*/
struct st_table_exists_in_engine_args
{
const char *db;
const char *name;
+ int err;
};
static my_bool table_exists_in_engine_handlerton(THD *thd, st_plugin_int *plugin,
@@ -2880,23 +2881,27 @@ static my_bool table_exists_in_engine_handlerton(THD *thd, st_plugin_int *plugin
st_table_exists_in_engine_args *vargs= (st_table_exists_in_engine_args *)arg;
handlerton *hton= (handlerton *)plugin->data;
+ int err= HA_ERR_NO_SUCH_TABLE;
+
if (hton->state == SHOW_OPTION_YES && hton->table_exists_in_engine)
- if ((hton->table_exists_in_engine(hton, thd, vargs->db, vargs->name)) == 1)
- return TRUE;
+ err = hton->table_exists_in_engine(hton, thd, vargs->db, vargs->name);
+
+ vargs->err = err;
+ if (vargs->err == HA_ERR_TABLE_EXIST)
+ return TRUE;
return FALSE;
}
int ha_table_exists_in_engine(THD* thd, const char* db, const char* name)
{
- int error= 0;
DBUG_ENTER("ha_table_exists_in_engine");
DBUG_PRINT("enter", ("db: %s, name: %s", db, name));
- st_table_exists_in_engine_args args= {db, name};
- error= plugin_foreach(thd, table_exists_in_engine_handlerton,
+ st_table_exists_in_engine_args args= {db, name, HA_ERR_NO_SUCH_TABLE};
+ plugin_foreach(thd, table_exists_in_engine_handlerton,
MYSQL_STORAGE_ENGINE_PLUGIN, &args);
- DBUG_PRINT("exit", ("error: %d", error));
- DBUG_RETURN(error);
+ DBUG_PRINT("exit", ("error: %d", args.err));
+ DBUG_RETURN(args.err);
}
#ifdef HAVE_NDB_BINLOG
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index d6efebd32c4..b99fc11cc75 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -418,7 +418,7 @@ extern ulong srv_flush_log_at_trx_commit;
#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
const char *opt_ndbcluster_connectstring= 0;
const char *opt_ndb_connectstring= 0;
-char opt_ndb_constrbuf[1024];
+char opt_ndb_constrbuf[1024]= {0};
unsigned opt_ndb_constrbuf_len= 0;
my_bool opt_ndb_shm, opt_ndb_optimized_node_selection;
ulong opt_ndb_cache_check_time;
@@ -8407,11 +8407,6 @@ ulong srv_commit_concurrency;
#endif
-#ifndef WITH_NDBCLUSTER_STORAGE_ENGINE
-ulong ndb_cache_check_time;
-ulong ndb_extra_logging;
-#endif
-
/*****************************************************************************
Instantiate templates
*****************************************************************************/
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 325167ff9fa..a4f5f6adae6 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -95,8 +95,12 @@ extern ulong srv_flush_log_at_trx_commit;
}
/* WITH_NDBCLUSTER_STORAGE_ENGINE */
+#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
extern ulong ndb_cache_check_time;
+extern char opt_ndb_constrbuf[];
extern ulong ndb_extra_logging;
+#endif
+
#ifdef HAVE_NDB_BINLOG
extern ulong ndb_report_thresh_binlog_epoch_slip;
extern ulong ndb_report_thresh_binlog_mem_usage;
@@ -528,6 +532,7 @@ sys_var_thd_bool
sys_engine_condition_pushdown("engine_condition_pushdown",
&SV::engine_condition_pushdown);
+#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
/* ndb thread specific variable settings */
sys_var_thd_ulong
sys_ndb_autoincrement_prefetch_sz("ndb_autoincrement_prefetch_sz",
@@ -548,6 +553,8 @@ sys_var_thd_bool
sys_ndb_use_transactions("ndb_use_transactions", &SV::ndb_use_transactions);
sys_var_long_ptr
sys_ndb_cache_check_time("ndb_cache_check_time", &ndb_cache_check_time);
+sys_var_const_str
+sys_ndb_connectstring("ndb_connectstring", opt_ndb_constrbuf);
sys_var_thd_bool
sys_ndb_index_stat_enable("ndb_index_stat_enable",
&SV::ndb_index_stat_enable);
@@ -561,6 +568,7 @@ sys_var_long_ptr
sys_ndb_extra_logging("ndb_extra_logging", &ndb_extra_logging);
sys_var_thd_bool
sys_ndb_use_copying_alter_table("ndb_use_copying_alter_table", &SV::ndb_use_copying_alter_table);
+#endif //WITH_NDBCLUSTER_STORAGE_ENGINE
/* Time/date/datetime formats */
@@ -922,9 +930,11 @@ SHOW_VAR init_vars[]= {
#ifdef __NT__
{"named_pipe", (char*) &opt_enable_named_pipe, SHOW_MY_BOOL},
#endif
+#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
{sys_ndb_autoincrement_prefetch_sz.name,
(char*) &sys_ndb_autoincrement_prefetch_sz, SHOW_SYS},
{sys_ndb_cache_check_time.name,(char*) &sys_ndb_cache_check_time, SHOW_SYS},
+ {sys_ndb_connectstring.name,(char*) &sys_ndb_connectstring, SHOW_SYS},
{sys_ndb_extra_logging.name,(char*) &sys_ndb_extra_logging, SHOW_SYS},
{sys_ndb_force_send.name, (char*) &sys_ndb_force_send, SHOW_SYS},
{sys_ndb_index_stat_cache_entries.name, (char*) &sys_ndb_index_stat_cache_entries, SHOW_SYS},
@@ -940,6 +950,7 @@ SHOW_VAR init_vars[]= {
(char*) &sys_ndb_use_copying_alter_table, SHOW_SYS},
{sys_ndb_use_exact_count.name,(char*) &sys_ndb_use_exact_count, SHOW_SYS},
{sys_ndb_use_transactions.name,(char*) &sys_ndb_use_transactions, SHOW_SYS},
+#endif //WITH_NDBCLUSTER_STORAGE_ENGINE
{sys_net_buffer_length.name,(char*) &sys_net_buffer_length, SHOW_SYS},
{sys_net_read_timeout.name, (char*) &sys_net_read_timeout, SHOW_SYS},
{sys_net_retry_count.name, (char*) &sys_net_retry_count, SHOW_SYS},
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index bc3e3cf0b05..740d18f935d 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -1010,6 +1010,7 @@ my_bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func,
rw_unlock(&THR_LOCK_plugin);
}
plugin= plugins[idx];
+ /* It will stop iterating on first engine error when "func" returns TRUE */
if (plugin && func(thd, plugin, arg))
goto err;
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 1047b1ec35d..d29e00351ba 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -3514,15 +3514,25 @@ bool mysql_create_table_internal(THD *thd,
{
bool create_if_not_exists =
create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS;
-
- if (ha_table_exists_in_engine(thd, db, table_name))
+ int retcode = ha_table_exists_in_engine(thd, db, table_name);
+ DBUG_PRINT("info", ("exists_in_engine: %u",retcode));
+ switch (retcode)
{
- DBUG_PRINT("info", ("Table with same name already existed in handler"));
+ case HA_ERR_NO_SUCH_TABLE:
+ /* Normal case, no table exists. we can go and create it */
+ break;
+ case HA_ERR_TABLE_EXIST:
+ DBUG_PRINT("info", ("Table existed in handler"));
- if (create_if_not_exists)
- goto warn;
- my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name);
- goto unlock_and_end;
+ if (create_if_not_exists)
+ goto warn;
+ my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name);
+ goto unlock_and_end;
+ break;
+ default:
+ DBUG_PRINT("info", ("error: %u from storage engine", retcode));
+ my_error(retcode, MYF(0),table_name);
+ goto unlock_and_end;
}
}
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
*/