summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bzrignore1
-rw-r--r--mysql-test/r/func_gconcat.result9
-rw-r--r--mysql-test/r/information_schema.result11
-rw-r--r--mysql-test/r/variables.result7
-rw-r--r--mysql-test/t/func_gconcat.test10
-rw-r--r--mysql-test/t/information_schema.test14
-rw-r--r--mysql-test/t/variables.test9
-rw-r--r--ndb/test/ndbapi/testSRBank.cpp246
-rw-r--r--sql/item_sum.cc1
-rw-r--r--sql/set_var.cc29
-rw-r--r--sql/set_var.h3
-rw-r--r--sql/sql_show.cc21
-rw-r--r--storage/ndb/src/common/portlib/NdbThread.c10
-rw-r--r--storage/ndb/test/include/NDBT_Test.hpp3
-rw-r--r--storage/ndb/test/ndbapi/Makefile.am5
-rw-r--r--storage/ndb/test/ndbapi/bank/Bank.cpp168
-rw-r--r--storage/ndb/test/ndbapi/bank/Bank.hpp2
-rw-r--r--storage/ndb/test/src/NDBT_Test.cpp9
18 files changed, 443 insertions, 115 deletions
diff --git a/.bzrignore b/.bzrignore
index 00d207919a8..3932ed4d127 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -859,6 +859,7 @@ ndb/test/ndbapi/testNodeRestart
ndb/test/ndbapi/testOIBasic
ndb/test/ndbapi/testOperations
ndb/test/ndbapi/testRestartGci
+ndb/test/ndbapi/testSRBank
ndb/test/ndbapi/testScan
ndb/test/ndbapi/testScan.dsp
ndb/test/ndbapi/testScanInterpreter
diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result
index c4e8e08929d..1ad412209ad 100644
--- a/mysql-test/r/func_gconcat.result
+++ b/mysql-test/r/func_gconcat.result
@@ -469,6 +469,15 @@ select collation(group_concat(a,b)) from t1;
ERROR HY000: Illegal mix of collations (cp1250_general_ci,IMPLICIT) and (koi8r_general_ci,IMPLICIT) for operation 'group_concat'
drop table t1;
drop table t2;
+CREATE TABLE t1 (a CHAR(10) CHARACTER SET cp850);
+INSERT INTO t1 VALUES ('À');
+SELECT a FROM t1;
+a
+SELECT GROUP_CONCAT(a) FROM t1;
+GROUP_CONCAT(a)
+DROP TABLE t1;
CREATE TABLE t1 (id int);
SELECT GROUP_CONCAT(id) AS gc FROM t1 HAVING gc IS NULL;
gc
diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result
index 20b2f12f0a8..9a7a0b48f47 100644
--- a/mysql-test/r/information_schema.result
+++ b/mysql-test/r/information_schema.result
@@ -979,3 +979,14 @@ WHERE TABLE_SCHEMA='test' AND TABLE_TYPE='BASE TABLE');
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MyISAM 10 Fixed 0 0 0 # 1024 0 NULL # # NULL latin1_swedish_ci NULL
t2 MyISAM 10 Fixed 0 0 0 # 1024 0 NULL # # NULL latin1_swedish_ci NULL
+DROP TABLE t1,t2;
+create table t1(f1 int);
+create view v1 (c) as select f1 from t1;
+select database();
+database()
+NULL
+show fields from test.v1;
+Field Type Null Key Default Extra
+c int(11) YES NULL
+drop view v1;
+drop table t1;
diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result
index a5b76c03b29..265f353ae3c 100644
--- a/mysql-test/r/variables.result
+++ b/mysql-test/r/variables.result
@@ -545,3 +545,10 @@ select @@max_heap_table_size > 0;
select @@have_innodb;
@@have_innodb
#
+select @@character_set_system;
+@@character_set_system
+utf8
+set global character_set_system = latin1;
+ERROR HY000: Variable 'character_set_system' is a read only variable
+set @@global.version_compile_os='234';
+ERROR HY000: Variable 'version_compile_os' is a read only variable
diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test
index 0b61a445270..896c377662b 100644
--- a/mysql-test/t/func_gconcat.test
+++ b/mysql-test/t/func_gconcat.test
@@ -282,6 +282,16 @@ drop table t1;
drop table t2;
#
+# Bug #12829
+# Cannot convert the charset of a GROUP_CONCAT result
+#
+CREATE TABLE t1 (a CHAR(10) CHARACTER SET cp850);
+INSERT INTO t1 VALUES ('À');
+SELECT a FROM t1;
+SELECT GROUP_CONCAT(a) FROM t1;
+DROP TABLE t1;
+
+#
# bug #7769: group_concat returning null is checked in having
#
CREATE TABLE t1 (id int);
diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test
index 6be193e0e0c..aa1b632f919 100644
--- a/mysql-test/t/information_schema.test
+++ b/mysql-test/t/information_schema.test
@@ -665,4 +665,16 @@ SHOW TABLE STATUS FROM test
WHERE name IN ( SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA='test' AND TABLE_TYPE='BASE TABLE');
-DROP TABLE t1,t2
+DROP TABLE t1,t2;
+
+#
+# Bug #12905 show fields from view behaving erratically with current database
+#
+create table t1(f1 int);
+create view v1 (c) as select f1 from t1;
+connect (con5,localhost,root,,*NO-ONE*);
+select database();
+show fields from test.v1;
+connection default;
+drop view v1;
+drop table t1;
diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test
index 372e865467e..afd0fe23805 100644
--- a/mysql-test/t/variables.test
+++ b/mysql-test/t/variables.test
@@ -435,3 +435,12 @@ select @@max_heap_table_size > 0;
--replace_column 1 #
select @@have_innodb;
+
+#
+# Bug #11775 Variable character_set_system does not exist (sometimes)
+#
+select @@character_set_system;
+--error 1238
+set global character_set_system = latin1;
+--error 1238
+set @@global.version_compile_os='234';
diff --git a/ndb/test/ndbapi/testSRBank.cpp b/ndb/test/ndbapi/testSRBank.cpp
new file mode 100644
index 00000000000..6d57724f4c6
--- /dev/null
+++ b/ndb/test/ndbapi/testSRBank.cpp
@@ -0,0 +1,246 @@
+/* Copyright (C) 2003 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#include <NDBT.hpp>
+#include <NDBT_Test.hpp>
+#include <HugoTransactions.hpp>
+#include <UtilTransactions.hpp>
+#include <NdbBackup.hpp>
+
+#include "bank/Bank.hpp"
+
+int runCreateBank(NDBT_Context* ctx, NDBT_Step* step){
+ Bank bank(ctx->m_cluster_connection);
+ int overWriteExisting = true;
+ if (bank.createAndLoadBank(overWriteExisting, 10) != NDBT_OK)
+ return NDBT_FAILED;
+ return NDBT_OK;
+}
+
+/**
+ *
+ * SR 0 - normal
+ * SR 1 - shutdown in progress
+ * SR 2 - restart in progress
+ */
+int runBankTimer(NDBT_Context* ctx, NDBT_Step* step){
+ int wait = 5; // Max seconds between each "day"
+ int yield = 1; // Loops before bank returns
+
+ ctx->incProperty("ThreadCount");
+ while (!ctx->isTestStopped())
+ {
+ Bank bank(ctx->m_cluster_connection);
+ while(!ctx->isTestStopped() && ctx->getProperty("SR") <= 1)
+ if(bank.performIncreaseTime(wait, yield) == NDBT_FAILED)
+ break;
+
+ ndbout_c("runBankTimer is stopped");
+ ctx->incProperty("ThreadStopped");
+ if(ctx->getPropertyWait("SR", (Uint32)0))
+ break;
+ }
+ return NDBT_OK;
+}
+
+int runBankTransactions(NDBT_Context* ctx, NDBT_Step* step){
+ int wait = 0; // Max ms between each transaction
+ int yield = 1; // Loops before bank returns
+
+ ctx->incProperty("ThreadCount");
+ while (!ctx->isTestStopped())
+ {
+ Bank bank(ctx->m_cluster_connection);
+ while(!ctx->isTestStopped() && ctx->getProperty("SR") <= 1)
+ if(bank.performTransactions(0, 1) == NDBT_FAILED)
+ break;
+
+ ndbout_c("runBankTransactions is stopped");
+ ctx->incProperty("ThreadStopped");
+ if(ctx->getPropertyWait("SR", (Uint32)0))
+ break;
+ }
+ return NDBT_OK;
+}
+
+int runBankGL(NDBT_Context* ctx, NDBT_Step* step){
+ int yield = 1; // Loops before bank returns
+ int result = NDBT_OK;
+
+ ctx->incProperty("ThreadCount");
+ while (ctx->isTestStopped() == false)
+ {
+ Bank bank(ctx->m_cluster_connection);
+ while(!ctx->isTestStopped() && ctx->getProperty("SR") <= 1)
+ if (bank.performMakeGLs(yield) != NDBT_OK)
+ {
+ if(ctx->getProperty("SR") != 0)
+ break;
+ ndbout << "bank.performMakeGLs FAILED" << endl;
+ return NDBT_FAILED;
+ }
+
+ ndbout_c("runBankGL is stopped");
+ ctx->incProperty("ThreadStopped");
+ if(ctx->getPropertyWait("SR", (Uint32)0))
+ break;
+ }
+ return NDBT_OK;
+}
+
+int runBankSum(NDBT_Context* ctx, NDBT_Step* step){
+ Bank bank(ctx->m_cluster_connection);
+ int wait = 2000; // Max ms between each sum of accounts
+ int yield = 1; // Loops before bank returns
+ int result = NDBT_OK;
+
+ while (ctx->isTestStopped() == false) {
+ if (bank.performSumAccounts(wait, yield) != NDBT_OK){
+ ndbout << "bank.performSumAccounts FAILED" << endl;
+ result = NDBT_FAILED;
+ }
+ }
+ return result ;
+}
+
+#define CHECK(b) if (!(b)) { \
+ g_err << "ERR: "<< step->getName() \
+ << " failed on line " << __LINE__ << endl; \
+ result = NDBT_FAILED; \
+ continue; }
+
+int runSR(NDBT_Context* ctx, NDBT_Step* step)
+{
+ int result = NDBT_OK;
+ int runtime = ctx->getNumLoops();
+ int sleeptime = ctx->getNumRecords();
+ NdbRestarter restarter;
+ bool abort = true;
+ int timeout = 180;
+
+ Uint32 now;
+ const Uint32 stop = time(0)+ runtime;
+ while(!ctx->isTestStopped() && ((now= time(0)) < stop) && result == NDBT_OK)
+ {
+ ndbout << " -- Sleep " << sleeptime << "s " << endl;
+ NdbSleep_SecSleep(sleeptime);
+ ndbout << " -- Shutting down " << endl;
+ ctx->setProperty("SR", 1);
+ CHECK(restarter.restartAll(false, true, abort) == 0);
+ ctx->setProperty("SR", 2);
+ CHECK(restarter.waitClusterNoStart(timeout) == 0);
+
+ Uint32 cnt = ctx->getProperty("ThreadCount");
+ Uint32 curr= ctx->getProperty("ThreadStopped");
+ while(curr != cnt)
+ {
+ ndbout_c("%d %d", curr, cnt);
+ NdbSleep_MilliSleep(100);
+ curr= ctx->getProperty("ThreadStopped");
+ }
+
+ ctx->setProperty("ThreadStopped", (Uint32)0);
+ CHECK(restarter.startAll() == 0);
+ CHECK(restarter.waitClusterStarted(timeout) == 0);
+
+ ndbout << " -- Validating starts " << endl;
+ {
+ int wait = 0;
+ int yield = 1;
+ Bank bank(ctx->m_cluster_connection);
+ if (bank.performSumAccounts(wait, yield) != 0)
+ {
+ ndbout << "bank.performSumAccounts FAILED" << endl;
+ return NDBT_FAILED;
+ }
+
+ if (bank.performValidateAllGLs() != 0)
+ {
+ ndbout << "bank.performValidateAllGLs FAILED" << endl;
+ return NDBT_FAILED;
+ }
+ }
+
+ ndbout << " -- Validating complete " << endl;
+ ctx->setProperty("SR", (Uint32)0);
+ ctx->broadcast();
+ }
+ ctx->stopTest();
+ return NDBT_OK;
+}
+
+int runDropBank(NDBT_Context* ctx, NDBT_Step* step){
+ Bank bank(ctx->m_cluster_connection);
+ if (bank.dropBank() != NDBT_OK)
+ return NDBT_FAILED;
+ return NDBT_OK;
+}
+
+
+NDBT_TESTSUITE(testSRBank);
+TESTCASE("Graceful",
+ " Test that a consistent bank is restored after graceful shutdown\n"
+ "1. Create bank\n"
+ "2. Start bank and let it run\n"
+ "3. Restart ndb and verify consistency\n"
+ "4. Drop bank\n")
+{
+ INITIALIZER(runCreateBank);
+ STEP(runBankTimer);
+ STEP(runBankTransactions);
+ STEP(runBankTransactions);
+ STEP(runBankTransactions);
+ STEP(runBankTransactions);
+ STEP(runBankTransactions);
+ STEP(runBankTransactions);
+ STEP(runBankTransactions);
+ STEP(runBankTransactions);
+ STEP(runBankTransactions);
+ STEP(runBankTransactions);
+ STEP(runBankGL);
+ STEP(runSR);
+}
+TESTCASE("Abort",
+ " Test that a consistent bank is restored after graceful shutdown\n"
+ "1. Create bank\n"
+ "2. Start bank and let it run\n"
+ "3. Restart ndb and verify consistency\n"
+ "4. Drop bank\n")
+{
+ INITIALIZER(runCreateBank);
+ STEP(runBankTimer);
+ STEP(runBankTransactions);
+ STEP(runBankTransactions);
+ STEP(runBankTransactions);
+ STEP(runBankTransactions);
+ STEP(runBankTransactions);
+ STEP(runBankTransactions);
+ STEP(runBankTransactions);
+ STEP(runBankTransactions);
+ STEP(runBankTransactions);
+ STEP(runBankTransactions);
+ STEP(runBankGL);
+ STEP(runSR);
+ FINALIZER(runDropBank);
+}
+NDBT_TESTSUITE_END(testSRBank);
+
+int main(int argc, const char** argv){
+ ndb_init();
+ return testSRBank.execute(argc, argv);
+}
+
+
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index f6544d76504..17d82e3fc98 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -3001,6 +3001,7 @@ Item_func_group_concat::fix_fields(THD *thd, Item **ref)
args, arg_count, MY_COLL_ALLOW_CONV))
return 1;
+ result.set_charset(collation.collation);
result_field= 0;
null_value= 1;
thd->allow_sum_func= 1;
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 0f1b523529f..f1ab86ace51 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -142,11 +142,8 @@ sys_var_long_ptr sys_binlog_cache_size("binlog_cache_size",
sys_var_thd_ulong sys_bulk_insert_buff_size("bulk_insert_buffer_size",
&SV::bulk_insert_buff_size);
sys_var_character_set_server sys_character_set_server("character_set_server");
-sys_var_str sys_charset_system("character_set_system",
- sys_check_charset,
- sys_update_charset,
- sys_set_default_charset,
- (char *)my_charset_utf8_general_ci.name);
+sys_var_const_str sys_charset_system("character_set_system",
+ (char *)my_charset_utf8_general_ci.name);
sys_var_character_set_database sys_character_set_database("character_set_database");
sys_var_character_set_client sys_character_set_client("character_set_client");
sys_var_character_set_connection sys_character_set_connection("character_set_connection");
@@ -571,6 +568,7 @@ sys_var *sys_variables[]=
&sys_character_set_client,
&sys_character_set_connection,
&sys_character_set_results,
+ &sys_charset_system,
&sys_collation_connection,
&sys_collation_database,
&sys_collation_server,
@@ -1122,27 +1120,6 @@ static void sys_default_ftb_syntax(THD *thd, enum_var_type type)
sizeof(ft_boolean_syntax)-1);
}
-/*
- The following 3 functions need to be changed in 4.1 when we allow
- one to change character sets
-*/
-
-static int sys_check_charset(THD *thd, set_var *var)
-{
- return 0;
-}
-
-
-static bool sys_update_charset(THD *thd, set_var *var)
-{
- return 0;
-}
-
-
-static void sys_set_default_charset(THD *thd, enum_var_type type)
-{
-}
-
/*
If one sets the LOW_PRIORIY UPDATES flag, we also must change the
diff --git a/sql/set_var.h b/sql/set_var.h
index b1c847973c1..8c1444870eb 100644
--- a/sql/set_var.h
+++ b/sql/set_var.h
@@ -190,6 +190,7 @@ public:
return 1;
}
bool check_default(enum_var_type type) { return 1; }
+ bool is_readonly() const { return 1; }
};
@@ -901,7 +902,7 @@ int sql_set_variables(THD *thd, List<set_var_base> *var_list);
bool not_all_support_one_shot(List<set_var_base> *var_list);
void fix_delay_key_write(THD *thd, enum_var_type type);
ulong fix_sql_mode(ulong sql_mode);
-extern sys_var_str sys_charset_system;
+extern sys_var_const_str sys_charset_system;
extern sys_var_str sys_init_connect;
extern sys_var_str sys_init_slave;
extern sys_var_thd_time_zone sys_time_zone;
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 934f8bc9952..c346f4cc291 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -2010,10 +2010,20 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
/*
get_all_tables() returns 1 on failure and 0 on success thus
return only these and not the result code of ::process_table()
+
+ We should use show_table_list->alias instead of
+ show_table_list->table_name because table_name
+ could be changed during opening of I_S tables. It's safe
+ to use alias because alias contains original table name
+ in this case(this part of code is used only for
+ 'show columns' & 'show statistics' commands).
*/
error= test(schema_table->process_table(thd, show_table_list,
- table, res, show_table_list->db,
- show_table_list->alias));
+ table, res,
+ (show_table_list->view ?
+ show_table_list->view_db.str :
+ show_table_list->db),
+ show_table_list->alias));
close_thread_tables(thd);
show_table_list->table= 0;
goto err;
@@ -2114,6 +2124,13 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
lex->derived_tables= 0;
res= open_normal_and_derived_tables(thd, show_table_list,
MYSQL_LOCK_IGNORE_FLUSH);
+ /*
+ We should use show_table_list->alias instead of
+ show_table_list->table_name because table_name
+ could be changed during opening of I_S tables. It's safe
+ to use alias because alias contains original table name
+ in this case.
+ */
res= schema_table->process_table(thd, show_table_list, table,
res, base_name,
show_table_list->alias);
diff --git a/storage/ndb/src/common/portlib/NdbThread.c b/storage/ndb/src/common/portlib/NdbThread.c
index 0914eede7de..d501ea2559a 100644
--- a/storage/ndb/src/common/portlib/NdbThread.c
+++ b/storage/ndb/src/common/portlib/NdbThread.c
@@ -67,6 +67,16 @@ ndb_thread_wrapper(void* _ss){
NdbThread_set_shm_sigmask(TRUE);
#endif
{
+ /**
+ * Block all signals to thread by default
+ * let them go to main process instead
+ */
+ sigset_t mask;
+ sigfillset(&mask);
+ pthread_sigmask(SIG_BLOCK, &mask, 0);
+ }
+
+ {
void *ret;
struct NdbThread * ss = (struct NdbThread *)_ss;
ret= (* ss->func)(ss->object);
diff --git a/storage/ndb/test/include/NDBT_Test.hpp b/storage/ndb/test/include/NDBT_Test.hpp
index 1b9c2751f64..027ac356e0c 100644
--- a/storage/ndb/test/include/NDBT_Test.hpp
+++ b/storage/ndb/test/include/NDBT_Test.hpp
@@ -67,7 +67,8 @@ public:
const char* getPropertyWait(const char*, const char* );
void decProperty(const char *);
-
+ void incProperty(const char *);
+
// Communicate with other tests
void stopTest();
bool isTestStopped();
diff --git a/storage/ndb/test/ndbapi/Makefile.am b/storage/ndb/test/ndbapi/Makefile.am
index f096a7c74e9..bf993d30111 100644
--- a/storage/ndb/test/ndbapi/Makefile.am
+++ b/storage/ndb/test/ndbapi/Makefile.am
@@ -34,7 +34,8 @@ test_event ndbapi_slow_select testReadPerf testLcp \
testPartitioning \
testBitfield \
DbCreate DbAsyncGenerator \
-test_event_multi_table
+test_event_multi_table \
+testSRBank
#flexTimedAsynch
#testBlobs
@@ -78,6 +79,7 @@ testBitfield_SOURCES = testBitfield.cpp
DbCreate_SOURCES = bench/mainPopulate.cpp bench/dbPopulate.cpp bench/userInterface.cpp bench/dbPopulate.h bench/userInterface.h bench/testData.h bench/testDefinitions.h bench/ndb_schema.hpp bench/ndb_error.hpp
DbAsyncGenerator_SOURCES = bench/mainAsyncGenerator.cpp bench/asyncGenerator.cpp bench/ndb_async2.cpp bench/dbGenerator.h bench/macros.h bench/userInterface.h bench/testData.h bench/testDefinitions.h bench/ndb_schema.hpp bench/ndb_error.hpp
test_event_multi_table_SOURCES = test_event_multi_table.cpp
+testSRBank_SOURCES = testSRBank.cpp
INCLUDES_LOC = -I$(top_srcdir)/storage/ndb/include/kernel
@@ -89,6 +91,7 @@ include $(top_srcdir)/storage/ndb/config/type_ndbapitest.mk.am
##testSystemRestart_INCLUDES = $(INCLUDES) -I$(top_srcdir)/ndb/include/kernel
##testTransactions_INCLUDES = $(INCLUDES) -I$(top_srcdir)/ndb/include/kernel
testBackup_LDADD = $(LDADD) bank/libbank.a
+testSRBank_LDADD = bank/libbank.a $(LDADD)
# Don't update the files from bitkeeper
%::SCCS/s.%
diff --git a/storage/ndb/test/ndbapi/bank/Bank.cpp b/storage/ndb/test/ndbapi/bank/Bank.cpp
index 40819ecc849..37224fdd055 100644
--- a/storage/ndb/test/ndbapi/bank/Bank.cpp
+++ b/storage/ndb/test/ndbapi/bank/Bank.cpp
@@ -19,12 +19,13 @@
#include <NdbSleep.h>
#include <UtilTransactions.hpp>
-Bank::Bank(Ndb_cluster_connection& con):
+Bank::Bank(Ndb_cluster_connection& con, bool _init):
m_ndb(&con, "BANK"),
m_maxAccount(-1),
m_initialized(false)
{
-
+ if(_init)
+ init();
}
int Bank::init(){
@@ -34,40 +35,39 @@ int Bank::init(){
myRandom48Init(NdbTick_CurrentMillisecond());
m_ndb.init();
- while (m_ndb.waitUntilReady(10) != 0)
- ndbout << "Waiting for ndb to be ready" << endl;
-
+ if (m_ndb.waitUntilReady(30) != 0)
+ {
+ ndbout << "Ndb not ready" << endl;
+ return NDBT_FAILED;
+ }
+
if (getNumAccounts() != NDBT_OK)
return NDBT_FAILED;
+
+ m_initialized = true;
return NDBT_OK;
}
int Bank::performTransactions(int maxSleepBetweenTrans, int yield){
- if (init() != NDBT_OK)
- return NDBT_FAILED;
int transactions = 0;
- while(1){
-
- while(m_ndb.waitUntilReady(10) != 0)
- ndbout << "Waiting for ndb to be ready" << endl;
-
- while(performTransaction() != NDBT_FAILED){
- transactions++;
-
- if (maxSleepBetweenTrans > 0){
- int val = myRandom48(maxSleepBetweenTrans);
- NdbSleep_MilliSleep(val);
- }
-
- if((transactions % 100) == 0)
- g_info << transactions << endl;
-
- if (yield != 0 && transactions >= yield)
- return NDBT_OK;
+ while(performTransaction() == NDBT_OK)
+ {
+ transactions++;
+
+ if (maxSleepBetweenTrans > 0){
+ int val = myRandom48(maxSleepBetweenTrans);
+ NdbSleep_MilliSleep(val);
}
+
+ if((transactions % 100) == 0)
+ g_info << transactions << endl;
+
+ if (yield != 0 && transactions >= yield)
+ return NDBT_OK;
}
+
return NDBT_FAILED;
}
@@ -92,7 +92,7 @@ int Bank::performTransaction(){
int amount = myRandom48(maxAmount);
- retry_transaction:
+retry_transaction:
int res = performTransaction(fromAccount, toAccount, amount);
if (res != 0){
switch (res){
@@ -158,8 +158,9 @@ int Bank::performTransactionImpl1(int fromAccountId,
// Ok, all clear to do the transaction
Uint64 transId;
- if (getNextTransactionId(transId) != NDBT_OK){
- return NDBT_FAILED;
+ int result = NDBT_OK;
+ if ((result= getNextTransactionId(transId)) != NDBT_OK){
+ return result;
}
NdbConnection* pTrans = m_ndb.startTransaction();
@@ -500,8 +501,6 @@ int Bank::performTransactionImpl1(int fromAccountId,
int Bank::performMakeGLs(int yield){
int result;
- if (init() != NDBT_OK)
- return NDBT_FAILED;
int counter, maxCounter;
int yieldCounter = 0;
@@ -512,9 +511,6 @@ int Bank::performMakeGLs(int yield){
counter = 0;
maxCounter = 50 + myRandom48(100);
- while(m_ndb.waitUntilReady(10) != 0)
- ndbout << "Waiting for ndb to be ready" << endl;
-
/**
* Validate GLs and Transactions for previous days
*
@@ -526,6 +522,7 @@ int Bank::performMakeGLs(int yield){
return NDBT_FAILED;
}
g_info << "performValidateGLs failed" << endl;
+ return NDBT_FAILED;
continue;
}
@@ -536,7 +533,7 @@ int Bank::performMakeGLs(int yield){
return NDBT_FAILED;
}
g_info << "performValidatePurged failed" << endl;
- continue;
+ return NDBT_FAILED;
}
while (1){
@@ -607,14 +604,9 @@ int Bank::performMakeGLs(int yield){
int Bank::performValidateAllGLs(){
int result;
- if (init() != NDBT_OK)
- return NDBT_FAILED;
while (1){
- while(m_ndb.waitUntilReady(10) != 0)
- ndbout << "Waiting for ndb to be ready" << endl;
-
/**
* Validate GLs and Transactions for previous days
* Set age so that ALL GL's are validated
@@ -1930,39 +1922,29 @@ int Bank::findTransactionsToPurge(const Uint64 glTime,
}
- int Bank::performIncreaseTime(int maxSleepBetweenDays, int yield){
- if (init() != NDBT_OK)
- return NDBT_FAILED;
-
+int Bank::performIncreaseTime(int maxSleepBetweenDays, int yield)
+{
int yieldCounter = 0;
-
- while(1){
-
- while(m_ndb.waitUntilReady(10) != 0)
- ndbout << "Waiting for ndb to be ready" << endl;
-
- while(1){
-
- Uint64 currTime;
- if (incCurrTime(currTime) != NDBT_OK)
- break;
-
- g_info << "Current time is " << currTime << endl;
- if (maxSleepBetweenDays > 0){
- int val = myRandom48(maxSleepBetweenDays);
- NdbSleep_SecSleep(val);
- }
-
- yieldCounter++;
- if (yield != 0 && yieldCounter >= yield)
- return NDBT_OK;
-
- }
- }
- return NDBT_FAILED;
- }
-
-
+
+ while(1){
+
+ Uint64 currTime;
+ if (incCurrTime(currTime) != NDBT_OK)
+ break;
+
+ g_info << "Current time is " << currTime << endl;
+ if (maxSleepBetweenDays > 0){
+ int val = myRandom48(maxSleepBetweenDays);
+ NdbSleep_SecSleep(val);
+ }
+
+ yieldCounter++;
+ if (yield != 0 && yieldCounter >= yield)
+ return NDBT_OK;
+
+ }
+ return NDBT_FAILED;
+}
int Bank::readSystemValue(SystemValueId sysValId, Uint64 & value){
@@ -1971,22 +1953,30 @@ int Bank::readSystemValue(SystemValueId sysValId, Uint64 & value){
NdbConnection* pTrans = m_ndb.startTransaction();
if (pTrans == NULL){
ERR(m_ndb.getNdbError());
+ if(m_ndb.getNdbError().status == NdbError::TemporaryError)
+ return NDBT_TEMPORARY;
return NDBT_FAILED;
}
- if (prepareReadSystemValueOp(pTrans, sysValId, value) != NDBT_OK) {
+ int result;
+ if ((result= prepareReadSystemValueOp(pTrans, sysValId, value)) != NDBT_OK) {
ERR(pTrans->getNdbError());
m_ndb.closeTransaction(pTrans);
- return NDBT_FAILED;
+ return result;
}
check = pTrans->execute(Commit);
if( check == -1 ) {
ERR(pTrans->getNdbError());
+ if(pTrans->getNdbError().status == NdbError::TemporaryError)
+ {
+ m_ndb.closeTransaction(pTrans);
+ return NDBT_TEMPORARY;
+ }
m_ndb.closeTransaction(pTrans);
return NDBT_FAILED;
}
-
+
m_ndb.closeTransaction(pTrans);
return NDBT_OK;
@@ -2092,6 +2082,8 @@ int Bank::increaseSystemValue(SystemValueId sysValId, Uint64 &value){
NdbConnection* pTrans = m_ndb.startTransaction();
if (pTrans == NULL){
ERR(m_ndb.getNdbError());
+ if (m_ndb.getNdbError().status == NdbError::TemporaryError)
+ DBUG_RETURN(NDBT_TEMPORARY);
DBUG_RETURN(NDBT_FAILED);
}
@@ -2127,6 +2119,11 @@ int Bank::increaseSystemValue(SystemValueId sysValId, Uint64 &value){
check = pTrans->execute(NoCommit);
if( check == -1 ) {
ERR(pTrans->getNdbError());
+ if (pTrans->getNdbError().status == NdbError::TemporaryError)
+ {
+ m_ndb.closeTransaction(pTrans);
+ DBUG_RETURN(NDBT_TEMPORARY);
+ }
m_ndb.closeTransaction(pTrans);
DBUG_RETURN(NDBT_FAILED);
}
@@ -2201,16 +2198,21 @@ int Bank::increaseSystemValue(SystemValueId sysValId, Uint64 &value){
check = pTrans->execute(Commit);
if( check == -1 ) {
ERR(pTrans->getNdbError());
+ if (pTrans->getNdbError().status == NdbError::TemporaryError)
+ {
+ m_ndb.closeTransaction(pTrans);
+ DBUG_RETURN(NDBT_TEMPORARY);
+ }
m_ndb.closeTransaction(pTrans);
DBUG_RETURN(NDBT_FAILED);
}
// Check that value updated equals the value we read after the update
if (valueNewRec->u_64_value() != value){
-
+
printf("value actual=%lld\n", valueNewRec->u_64_value());
printf("value expected=%lld actual=%lld\n", value, valueNewRec->u_64_value());
-
+
DBUG_PRINT("info", ("value expected=%ld actual=%ld", value, valueNewRec->u_64_value()));
g_err << "getNextTransactionId: value was not updated" << endl;
m_ndb.closeTransaction(pTrans);
@@ -2218,7 +2220,7 @@ int Bank::increaseSystemValue(SystemValueId sysValId, Uint64 &value){
}
m_ndb.closeTransaction(pTrans);
-
+
DBUG_RETURN(0);
}
@@ -2235,6 +2237,8 @@ int Bank::increaseSystemValue2(SystemValueId sysValId, Uint64 &value){
NdbConnection* pTrans = m_ndb.startTransaction();
if (pTrans == NULL){
ERR(m_ndb.getNdbError());
+ if(m_ndb.getNdbError().status == NdbError::TemporaryError)
+ return NDBT_TEMPORARY;
return NDBT_FAILED;
}
@@ -2277,6 +2281,11 @@ int Bank::increaseSystemValue2(SystemValueId sysValId, Uint64 &value){
check = pTrans->execute(Commit);
if( check == -1 ) {
ERR(pTrans->getNdbError());
+ if(pTrans->getNdbError().status == NdbError::TemporaryError)
+ {
+ m_ndb.closeTransaction(pTrans);
+ return NDBT_TEMPORARY;
+ }
m_ndb.closeTransaction(pTrans);
return NDBT_FAILED;
}
@@ -2301,16 +2310,11 @@ int Bank::prepareGetCurrTimeOp(NdbConnection *pTrans, Uint64 &time){
int Bank::performSumAccounts(int maxSleepBetweenSums, int yield){
- if (init() != NDBT_OK)
- return NDBT_FAILED;
int yieldCounter = 0;
while (1){
- while (m_ndb.waitUntilReady(10) != 0)
- ndbout << "Waiting for ndb to be ready" << endl;
-
Uint32 sumAccounts = 0;
Uint32 numAccounts = 0;
if (getSumAccounts(sumAccounts, numAccounts) != NDBT_OK){
diff --git a/storage/ndb/test/ndbapi/bank/Bank.hpp b/storage/ndb/test/ndbapi/bank/Bank.hpp
index d9dd7b25944..b80f02dae97 100644
--- a/storage/ndb/test/ndbapi/bank/Bank.hpp
+++ b/storage/ndb/test/ndbapi/bank/Bank.hpp
@@ -27,7 +27,7 @@
class Bank {
public:
- Bank(Ndb_cluster_connection&);
+ Bank(Ndb_cluster_connection&, bool init = true);
int createAndLoadBank(bool overWrite, int num_accounts=10);
int dropBank();
diff --git a/storage/ndb/test/src/NDBT_Test.cpp b/storage/ndb/test/src/NDBT_Test.cpp
index 7fd92db533e..8fecf56531f 100644
--- a/storage/ndb/test/src/NDBT_Test.cpp
+++ b/storage/ndb/test/src/NDBT_Test.cpp
@@ -148,6 +148,15 @@ NDBT_Context::decProperty(const char * name){
NdbCondition_Broadcast(propertyCondPtr);
NdbMutex_Unlock(propertyMutexPtr);
}
+void
+NDBT_Context::incProperty(const char * name){
+ NdbMutex_Lock(propertyMutexPtr);
+ Uint32 val = 0;
+ props.get(name, &val);
+ props.put(name, (val + 1), true);
+ NdbCondition_Broadcast(propertyCondPtr);
+ NdbMutex_Unlock(propertyMutexPtr);
+}
void NDBT_Context::setProperty(const char* _name, const char* _val){
NdbMutex_Lock(propertyMutexPtr);