From 600b5fea57b32ef60f32bec61a12f7290c42bae1 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 1 Sep 2005 19:31:08 +0500 Subject: [PATCH 01/16] Bug#12891: UNION doesn't return DISTINCT result for multi-byte characters hp_hash.c: This piece of code was pretty wrong, looks like no necessary changes were made after cut-and-paste from fixed length segment processing. Itroduced two new variables safe_length1 and safe_length2 to remember the original lengths. Fixing my_charpos and set_if_smaller calls to pass correct parameters. ctype_utf8.result, ctype_utf8.test: adding test case heap/hp_hash.c: Bug#12891: UNION doesn't return DISTINCT result for multi-byte characters This piece of code was pretty wrong. mysql-test/t/ctype_utf8.test: adding test case mysql-test/r/ctype_utf8.result: adding test case --- heap/hp_hash.c | 10 ++++++---- mysql-test/r/ctype_utf8.result | 12 ++++++++++++ mysql-test/t/ctype_utf8.test | 11 +++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/heap/hp_hash.c b/heap/hp_hash.c index d643f776731..77f3cf6d80b 100644 --- a/heap/hp_hash.c +++ b/heap/hp_hash.c @@ -551,11 +551,13 @@ int hp_rec_key_cmp(HP_KEYDEF *keydef, const byte *rec1, const byte *rec2, } if (cs->mbmaxlen > 1) { + uint safe_length1= char_length1; + uint safe_length2= char_length2; uint char_length= seg->length / cs->mbmaxlen; - char_length1= my_charpos(cs, pos1, pos1 + char_length1, char_length1); - set_if_smaller(char_length1, seg->length); - char_length2= my_charpos(cs, pos2, pos2 + char_length2, char_length2); - set_if_smaller(char_length2, seg->length); + char_length1= my_charpos(cs, pos1, pos1 + char_length1, char_length); + set_if_smaller(char_length1, safe_length1); + char_length2= my_charpos(cs, pos2, pos2 + char_length2, char_length); + set_if_smaller(char_length2, safe_length2); } if (cs->coll->strnncollsp(seg->charset, diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 64c693a292a..ee109887dd3 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -1023,3 +1023,15 @@ aa xxx yyy DROP TABLE t1; +set names utf8; +create table t1 (a char(1)) default character set utf8; +create table t2 (a char(1)) default character set utf8; +insert into t1 values('a'),('a'),(0xE38182),(0xE38182); +insert into t1 values('i'),('i'),(0xE38184),(0xE38184); +select * from t1 union distinct select * from t2; +a +a +あ +i +い +drop table t1,t2; diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index ce259f465d9..eda64b82f38 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -857,3 +857,14 @@ SELECT DISTINCT id FROM t1; SELECT DISTINCT id FROM t1 ORDER BY id; DROP TABLE t1; + +# +# Bug#12891: UNION doesn't return DISTINCT result for multi-byte characters +# +set names utf8; +create table t1 (a char(1)) default character set utf8; +create table t2 (a char(1)) default character set utf8; +insert into t1 values('a'),('a'),(0xE38182),(0xE38182); +insert into t1 values('i'),('i'),(0xE38184),(0xE38184); +select * from t1 union distinct select * from t2; +drop table t1,t2; From d0b53181323af5f9d70f30aeb474b7815e5142b9 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Sep 2005 15:39:20 +0200 Subject: [PATCH 02/16] Added synchronization to rpl_slave_status.test mysql-test/t/rpl_slave_status.test: Added synchronization to make result deterministic --- mysql-test/t/rpl_slave_status.test | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/t/rpl_slave_status.test b/mysql-test/t/rpl_slave_status.test index 2c5bd2bffb0..247e562eafa 100644 --- a/mysql-test/t/rpl_slave_status.test +++ b/mysql-test/t/rpl_slave_status.test @@ -19,6 +19,7 @@ select * from t1; connection master; delete from mysql.user where user='rpl'; flush privileges; +sync_slave_with_master; connection slave; stop slave; start slave; From 43fb5cd358aa61e1bbd7a4e1a84e46f8dfcfb626 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 7 Sep 2005 14:04:36 +0200 Subject: [PATCH 03/16] ndb - bug#11623 - "ndb become inresponsive but did not really die" block signals in threads making main process get all signals... --- ndb/src/common/portlib/NdbThread.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ndb/src/common/portlib/NdbThread.c b/ndb/src/common/portlib/NdbThread.c index 55ebc4c8111..48d00956ec2 100644 --- a/ndb/src/common/portlib/NdbThread.c +++ b/ndb/src/common/portlib/NdbThread.c @@ -52,6 +52,16 @@ ndb_thread_wrapper(void* _ss){ pthread_sigmask(SIG_BLOCK, &mask, 0); } #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; From a51cd7109d762ef3258475fde41c040e808fb42c Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 8 Sep 2005 15:47:21 +0300 Subject: [PATCH 04/16] Fix compiler errors on InnoDB offline checksum tool innochecksum. extra/Makefile.am: Add innochecksum back to compiled programs. --- extra/Makefile.am | 2 +- extra/innochecksum.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/extra/Makefile.am b/extra/Makefile.am index 9fac05d0160..457fddce673 100644 --- a/extra/Makefile.am +++ b/extra/Makefile.am @@ -38,7 +38,7 @@ $(top_builddir)/include/mysqld_ername.h: $(top_builddir)/include/mysqld_error.h $(top_builddir)/include/sql_state.h: $(top_builddir)/include/mysqld_error.h bin_PROGRAMS = replace comp_err perror resolveip my_print_defaults \ - resolve_stack_dump mysql_waitpid # innochecksum + resolve_stack_dump mysql_waitpid innochecksum noinst_PROGRAMS = charset2html # Don't update the files from bitkeeper diff --git a/extra/innochecksum.c b/extra/innochecksum.c index bce4214847d..bbeb96224c9 100644 --- a/extra/innochecksum.c +++ b/extra/innochecksum.c @@ -140,10 +140,11 @@ int main(int argc, char **argv) { int now; // current time int lastt; // last time ulint oldcsum, oldcsumfield, csum, csumfield, logseq, logseqfield; // ulints for checksum storage - struct stat64 st; // for stat, if you couldn't guess + struct stat st; // for stat, if you couldn't guess unsigned long long int size; // size of file (has to be 64 bits) ulint pages; // number of pages in file ulint start_page = 0, end_page = 0, use_end_page = 0; // for starting and ending at certain pages + off_t offset = 0; int just_count = 0; // if true, just print page count int verbose = 0; int debug = 0; @@ -202,7 +203,7 @@ int main(int argc, char **argv) { } // stat the file to get size and page count - if (stat64(argv[optind], &st)) { + if (stat(argv[optind], &st)) { perror("error statting file"); return 1; } @@ -217,7 +218,7 @@ int main(int argc, char **argv) { } // open the file for reading - f = fopen64(argv[optind], "r"); + f = fopen(argv[optind], "r"); if (!f) { perror("error opening file"); return 1; @@ -230,7 +231,10 @@ int main(int argc, char **argv) { perror("unable to obtain file descriptor number"); return 1; } - if (lseek64(fd, start_page * UNIV_PAGE_SIZE, SEEK_SET) != (start_page * UNIV_PAGE_SIZE)) { + + offset = (off_t)start_page * (off_t)UNIV_PAGE_SIZE; + + if (lseek(fd, offset, SEEK_SET) != offset) { perror("unable to seek to necessary offset"); return 1; } From af05c8d303a09f7ef70017e63977c0f40e75159a Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 9 Sep 2005 12:51:43 +0500 Subject: [PATCH 05/16] A fix (bug #12917: The --defaults-extra-file option is ignored by the 5.0 client binaries). mysql-test/mysql-test-run.pl: A fix (bug #12917: The --defaults-extra-file option is ignored by the 5.0 client binaries). MYSQL_MY_PRINT_DEFAULTS added mysql-test/mysql-test-run.sh: A fix (bug #12917: The --defaults-extra-file option is ignored by the 5.0 client binaries). MYSQL_MY_PRINT_DEFAULTS added mysys/default.c: A fix (bug #12917: The --defaults-extra-file option is ignored by the 5.0 client binaries). Set defaults_extra_file as we use it widely. --- mysql-test/mysql-test-run.pl | 6 ++++++ mysql-test/mysql-test-run.sh | 4 +++- mysql-test/r/mysqldump.result | 2 ++ mysql-test/t/mysqldump.test | 10 ++++++++++ mysys/default.c | 3 +++ 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 2d97e5572d1..3ef878c9854 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -179,6 +179,7 @@ our $exe_mysql_fix_system_tables; our $exe_mysqltest; our $exe_slave_mysqld; our $exe_im; +our $exe_my_print_defaults; our $opt_bench= 0; our $opt_small_bench= 0; @@ -872,6 +873,8 @@ sub executable_setup () { $exe_mysql= mtr_exe_exists("$path_client_bindir/mysql"); $exe_mysql_fix_system_tables= mtr_script_exists("$glob_basedir/scripts/mysql_fix_privilege_tables"); + $exe_my_print_defaults= + mtr_script_exists("$glob_basedir/extra/my_print_defaults"); $path_ndb_tools_dir= mtr_path_exists("$glob_basedir/ndb/tools"); $exe_ndb_mgm= "$glob_basedir/ndb/src/mgmclient/ndb_mgm"; } @@ -887,6 +890,8 @@ sub executable_setup () { $exe_mysql_fix_system_tables= mtr_script_exists("$path_client_bindir/mysql_fix_privilege_tables", "$glob_basedir/scripts/mysql_fix_privilege_tables"); + $exe_my_print_defaults= + mtr_script_exists("path_client_bindir/my_print_defaults"); $path_language= mtr_path_exists("$glob_basedir/share/mysql/english/", "$glob_basedir/share/english/"); @@ -2384,6 +2389,7 @@ sub run_mysqltest ($) { $ENV{'MYSQL_FIX_SYSTEM_TABLES'}= $cmdline_mysql_fix_system_tables; $ENV{'MYSQL_CLIENT_TEST'}= $cmdline_mysql_client_test; $ENV{'CHARSETSDIR'}= $path_charsetsdir; + $ENV{'MYSQL_MY_PRINT_DEFAULTS'}= $exe_my_print_defaults; $ENV{'NDB_STATUS_OK'}= $flag_ndb_status_ok; $ENV{'NDB_MGM'}= $exe_ndb_mgm; diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index b7391f40d30..d9460dcdd72 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -575,6 +575,7 @@ if [ x$SOURCE_DIST = x1 ] ; then CLIENT_BINDIR="$BASEDIR/client" MYSQLADMIN="$CLIENT_BINDIR/mysqladmin" WAIT_PID="$BASEDIR/extra/mysql_waitpid" + MYSQL_MY_PRINT_DEFAULTS="$BASEDIR/extra/my_print_defaults" MYSQL_MANAGER_CLIENT="$CLIENT_BINDIR/mysqltestmanagerc" MYSQL_MANAGER="$BASEDIR/tools/mysqltestmanager" MYSQL_MANAGER_PWGEN="$CLIENT_BINDIR/mysqltestmanager-pwgen" @@ -635,6 +636,7 @@ else MYSQL_BINLOG="$CLIENT_BINDIR/mysqlbinlog" MYSQLADMIN="$CLIENT_BINDIR/mysqladmin" WAIT_PID="$CLIENT_BINDIR/mysql_waitpid" + MYSQL_MY_PRINT_DEFAULTS="$CLIENT_BINDIR/my_print_defaults" MYSQL_MANAGER="$CLIENT_BINDIR/mysqltestmanager" MYSQL_MANAGER_CLIENT="$CLIENT_BINDIR/mysqltestmanagerc" MYSQL_MANAGER_PWGEN="$CLIENT_BINDIR/mysqltestmanager-pwgen" @@ -716,7 +718,7 @@ MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --local-load=$MYSQL_TMP_DIR --charact MYSQL_FIX_SYSTEM_TABLES="$MYSQL_FIX_SYSTEM_TABLES --no-defaults --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD --basedir=$BASEDIR --bindir=$CLIENT_BINDIR --verbose" MYSQL="$MYSQL --no-defaults --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD" export MYSQL MYSQL_DUMP MYSQL_SHOW MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES -export CLIENT_BINDIR MYSQL_CLIENT_TEST CHARSETSDIR +export CLIENT_BINDIR MYSQL_CLIENT_TEST CHARSETSDIR MYSQL_MY_PRINT_DEFAULTS export NDB_TOOLS_DIR export NDB_MGM export NDB_BACKUP_DIR diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 917724580cf..c79f182bb5a 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -1875,3 +1875,5 @@ set @fired:= "No"; end if; end BEFORE # STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER DROP TABLE t1, t2; +--port=1234 +--port=1234 diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 27bea937dcf..e05584e2485 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -761,3 +761,13 @@ show tables; --replace_column 6 # show triggers; DROP TABLE t1, t2; + +# +# Bugs #9136, #12917: problems with --defaults-extra-file option +# + +--exec echo "[client]" > $MYSQL_TEST_DIR/var/tmp/tmp.cnf +--exec echo "port=1234" >> $MYSQL_TEST_DIR/var/tmp/tmp.cnf +--exec $MYSQL_MY_PRINT_DEFAULTS -c $MYSQL_TEST_DIR/var/tmp/tmp.cnf client +--exec $MYSQL_MY_PRINT_DEFAULTS -e $MYSQL_TEST_DIR/var/tmp/tmp.cnf client +--exec rm $MYSQL_TEST_DIR/var/tmp/tmp.cnf diff --git a/mysys/default.c b/mysys/default.c index bde7cbf2563..bca3ec0fed3 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -136,6 +136,9 @@ int my_search_option_files(const char *conf_file, int *argc, char ***argv, if (! defaults_group_suffix) defaults_group_suffix= getenv(STRINGIFY_ARG(DEFAULT_GROUP_SUFFIX_ENV)); + + if (forced_extra_defaults) + defaults_extra_file= forced_extra_defaults; /* We can only handle 'defaults-group-suffix' if we are called from From b1fab24ce22695221f022fd825391b2475ff0908 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 9 Sep 2005 12:39:06 +0200 Subject: [PATCH 06/16] ndb new testprogram testSRBank BitKeeper/etc/ignore: Added ndb/test/ndbapi/testSRBank to the ignore list ndb/test/include/NDBT_Test.hpp: incProperty ndb/test/ndbapi/Makefile.am: new test program ndb/test/ndbapi/bank/Bank.cpp: remove endless wait until ready loop fix lots of retry loops to better handle error ndb/test/ndbapi/bank/Bank.hpp: remove endless wait until ready loop fix lots of retry loops to better handle error ndb/test/src/NDBT_Test.cpp: incProperty ndb/test/src/UtilTransactions.cpp: close transaction if failed ndb/test/ndbapi/testSRBank.cpp: New BitKeeper file ``ndb/test/ndbapi/testSRBank.cpp'' --- .bzrignore | 1 + ndb/test/include/NDBT_Test.hpp | 3 +- ndb/test/ndbapi/Makefile.am | 5 +- ndb/test/ndbapi/bank/Bank.cpp | 168 ++++++++++---------- ndb/test/ndbapi/bank/Bank.hpp | 2 +- ndb/test/ndbapi/testSRBank.cpp | 246 ++++++++++++++++++++++++++++++ ndb/test/src/NDBT_Test.cpp | 9 ++ ndb/test/src/UtilTransactions.cpp | 22 ++- 8 files changed, 368 insertions(+), 88 deletions(-) create mode 100644 ndb/test/ndbapi/testSRBank.cpp diff --git a/.bzrignore b/.bzrignore index f9f9c146692..ce63dcaf5a9 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1056,3 +1056,4 @@ vio/viotest-ssl ndb/tools/ndb_config support-files/MacOSX/postflight support-files/MacOSX/preflight +ndb/test/ndbapi/testSRBank diff --git a/ndb/test/include/NDBT_Test.hpp b/ndb/test/include/NDBT_Test.hpp index a60228c1a5d..bcaa0bf4d40 100644 --- a/ndb/test/include/NDBT_Test.hpp +++ b/ndb/test/include/NDBT_Test.hpp @@ -64,7 +64,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/ndb/test/ndbapi/Makefile.am b/ndb/test/ndbapi/Makefile.am index 6f04ac3fce2..7b4a96f5890 100644 --- a/ndb/test/ndbapi/Makefile.am +++ b/ndb/test/ndbapi/Makefile.am @@ -31,7 +31,8 @@ testTimeout \ testTransactions \ testDeadlock \ test_event ndbapi_slow_select testReadPerf testLcp \ -DbCreate DbAsyncGenerator +DbCreate DbAsyncGenerator \ +testSRBank #flexTimedAsynch #testBlobs @@ -72,6 +73,7 @@ testReadPerf_SOURCES = testReadPerf.cpp testLcp_SOURCES = testLcp.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 +testSRBank_SOURCES = testSRBank.cpp INCLUDES_LOC = -I$(top_srcdir)/ndb/include/kernel @@ -83,6 +85,7 @@ include $(top_srcdir)/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/ndb/test/ndbapi/bank/Bank.cpp b/ndb/test/ndbapi/bank/Bank.cpp index c6029259357..346442367fc 100644 --- a/ndb/test/ndbapi/bank/Bank.cpp +++ b/ndb/test/ndbapi/bank/Bank.cpp @@ -19,12 +19,13 @@ #include #include -Bank::Bank(): +Bank::Bank(bool _init): m_ndb("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 @@ -1937,39 +1929,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){ @@ -1978,22 +1960,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; @@ -2099,6 +2089,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); } @@ -2134,6 +2126,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); } @@ -2208,16 +2205,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); @@ -2225,7 +2227,7 @@ int Bank::increaseSystemValue(SystemValueId sysValId, Uint64 &value){ } m_ndb.closeTransaction(pTrans); - + DBUG_RETURN(0); } @@ -2242,6 +2244,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; } @@ -2284,6 +2288,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; } @@ -2308,16 +2317,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/ndb/test/ndbapi/bank/Bank.hpp b/ndb/test/ndbapi/bank/Bank.hpp index 34c5ff51cc2..14e01df29d5 100644 --- a/ndb/test/ndbapi/bank/Bank.hpp +++ b/ndb/test/ndbapi/bank/Bank.hpp @@ -27,7 +27,7 @@ class Bank { public: - Bank(); + Bank(bool init = true); int createAndLoadBank(bool overWrite, int num_accounts=10); int dropBank(); diff --git a/ndb/test/ndbapi/testSRBank.cpp b/ndb/test/ndbapi/testSRBank.cpp new file mode 100644 index 00000000000..5677f551da6 --- /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 +#include +#include +#include +#include + +#include "bank/Bank.hpp" + +int runCreateBank(NDBT_Context* ctx, NDBT_Step* step){ + Bank bank; + 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; + 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; + 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; + 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; + 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; + 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; + 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/ndb/test/src/NDBT_Test.cpp b/ndb/test/src/NDBT_Test.cpp index 600a5443f40..6355c21c997 100644 --- a/ndb/test/src/NDBT_Test.cpp +++ b/ndb/test/src/NDBT_Test.cpp @@ -145,6 +145,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); diff --git a/ndb/test/src/UtilTransactions.cpp b/ndb/test/src/UtilTransactions.cpp index 869f7fc76cb..92073143d34 100644 --- a/ndb/test/src/UtilTransactions.cpp +++ b/ndb/test/src/UtilTransactions.cpp @@ -766,19 +766,29 @@ UtilTransactions::selectCount(Ndb* pNdb, int check; NdbScanOperation *pOp; - if(!pTrans) - pTrans = pNdb->startTransaction(); while (true){ - if (retryAttempt >= retryMax){ g_info << "ERROR: has retried this operation " << retryAttempt << " times, failing!" << endl; return NDBT_FAILED; } + if(!pTrans) + pTrans = pNdb->startTransaction(); + + if(!pTrans) + { + const NdbError err = pNdb->getNdbError(); + + if (err.status == NdbError::TemporaryError) + continue; + return NDBT_FAILED; + } + pOp = pTrans->getNdbScanOperation(tab.getName()); if (pOp == NULL) { ERR(pTrans->getNdbError()); pNdb->closeTransaction(pTrans); + pTrans = 0; return NDBT_FAILED; } @@ -786,6 +796,7 @@ UtilTransactions::selectCount(Ndb* pNdb, if( rs == 0) { ERR(pTrans->getNdbError()); pNdb->closeTransaction(pTrans); + pTrans = 0; return NDBT_FAILED; } @@ -799,6 +810,7 @@ UtilTransactions::selectCount(Ndb* pNdb, if( check == -1 ) { ERR(pTrans->getNdbError()); pNdb->closeTransaction(pTrans); + pTrans = 0; return NDBT_FAILED; } } @@ -808,6 +820,7 @@ UtilTransactions::selectCount(Ndb* pNdb, if( check == -1 ) { ERR(pTrans->getNdbError()); pNdb->closeTransaction(pTrans); + pTrans = 0; return NDBT_FAILED; } @@ -823,16 +836,19 @@ UtilTransactions::selectCount(Ndb* pNdb, if (err.status == NdbError::TemporaryError){ pNdb->closeTransaction(pTrans); + pTrans = 0; NdbSleep_MilliSleep(50); retryAttempt++; continue; } ERR(err); pNdb->closeTransaction(pTrans); + pTrans = 0; return NDBT_FAILED; } pNdb->closeTransaction(pTrans); + pTrans = 0; if (count_rows != NULL){ *count_rows = rows; From 394d180b5e04504c9e2d52d1eaa4904b2056eb19 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 9 Sep 2005 13:14:35 +0200 Subject: [PATCH 07/16] merge fixes --- ndb/test/ndbapi/testSRBank.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ndb/test/ndbapi/testSRBank.cpp b/ndb/test/ndbapi/testSRBank.cpp index 5677f551da6..6d57724f4c6 100644 --- a/ndb/test/ndbapi/testSRBank.cpp +++ b/ndb/test/ndbapi/testSRBank.cpp @@ -23,7 +23,7 @@ #include "bank/Bank.hpp" int runCreateBank(NDBT_Context* ctx, NDBT_Step* step){ - Bank bank; + Bank bank(ctx->m_cluster_connection); int overWriteExisting = true; if (bank.createAndLoadBank(overWriteExisting, 10) != NDBT_OK) return NDBT_FAILED; @@ -43,7 +43,7 @@ int runBankTimer(NDBT_Context* ctx, NDBT_Step* step){ ctx->incProperty("ThreadCount"); while (!ctx->isTestStopped()) { - Bank bank; + Bank bank(ctx->m_cluster_connection); while(!ctx->isTestStopped() && ctx->getProperty("SR") <= 1) if(bank.performIncreaseTime(wait, yield) == NDBT_FAILED) break; @@ -63,7 +63,7 @@ int runBankTransactions(NDBT_Context* ctx, NDBT_Step* step){ ctx->incProperty("ThreadCount"); while (!ctx->isTestStopped()) { - Bank bank; + Bank bank(ctx->m_cluster_connection); while(!ctx->isTestStopped() && ctx->getProperty("SR") <= 1) if(bank.performTransactions(0, 1) == NDBT_FAILED) break; @@ -83,7 +83,7 @@ int runBankGL(NDBT_Context* ctx, NDBT_Step* step){ ctx->incProperty("ThreadCount"); while (ctx->isTestStopped() == false) { - Bank bank; + Bank bank(ctx->m_cluster_connection); while(!ctx->isTestStopped() && ctx->getProperty("SR") <= 1) if (bank.performMakeGLs(yield) != NDBT_OK) { @@ -102,7 +102,7 @@ int runBankGL(NDBT_Context* ctx, NDBT_Step* step){ } int runBankSum(NDBT_Context* ctx, NDBT_Step* step){ - Bank bank; + 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; @@ -160,7 +160,7 @@ int runSR(NDBT_Context* ctx, NDBT_Step* step) { int wait = 0; int yield = 1; - Bank bank; + Bank bank(ctx->m_cluster_connection); if (bank.performSumAccounts(wait, yield) != 0) { ndbout << "bank.performSumAccounts FAILED" << endl; @@ -183,7 +183,7 @@ int runSR(NDBT_Context* ctx, NDBT_Step* step) } int runDropBank(NDBT_Context* ctx, NDBT_Step* step){ - Bank bank; + Bank bank(ctx->m_cluster_connection); if (bank.dropBank() != NDBT_OK) return NDBT_FAILED; return NDBT_OK; From 19fa54f04e5580a5ba9ac11dac0e57f60462bd6a Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 9 Sep 2005 20:02:13 +0300 Subject: [PATCH 08/16] Fixed Bug#10716, Procedure Analyse results in wrong values for optimal field type Added test case. --- mysql-test/r/analyse.result | 6 ++++++ mysql-test/t/analyse.test | 9 +++++++++ sql/sql_analyse.cc | 15 ++++++++++----- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/analyse.result b/mysql-test/r/analyse.result index 09c606b5a04..0ebd4a3e409 100644 --- a/mysql-test/r/analyse.result +++ b/mysql-test/r/analyse.result @@ -102,3 +102,9 @@ select * from t1 procedure analyse(); Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype test.t1.v " \\ 1 19 0 0 3.7619 NULL ENUM('"','""','"c','\'\0\\"','\'','\'\'','\'b','a\0\0\0b','a\0','a""""b','a\'\'\'\'b','abc','abc\'def\\hij"klm\0opq','a\\\\\\\\b','b\'','c"','d\\','The\ZEnd','\\','\\d','\\\\') NOT NULL drop table t1; +create table t1 (d double); +insert into t1 values (100000); +select * from t1 procedure analyse (1,1); +Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype +test.t1.d 100000 100000 6 6 0 0 100000 0 MEDIUMINT(6) UNSIGNED NOT NULL +drop table t1; diff --git a/mysql-test/t/analyse.test b/mysql-test/t/analyse.test index e7fbf09c19a..e38e43381bc 100644 --- a/mysql-test/t/analyse.test +++ b/mysql-test/t/analyse.test @@ -48,4 +48,13 @@ insert into t1 values ('abc'),('abc\'def\\hij\"klm\0opq'),('\''),('\"'),('\\'),( select * from t1 procedure analyse(); drop table t1; +# +# Bug#10716 - Procedure Analyse results in wrong values for optimal field type +# + +create table t1 (d double); +insert into t1 values (100000); +select * from t1 procedure analyse (1,1); +drop table t1; + # End of 4.1 tests diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index fb5d0eb0a3f..c2cb427a5eb 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -789,18 +789,23 @@ void field_real::get_opt_type(String *answer, if (!max_notzero_dec_len) { if (min_arg >= -128 && max_arg <= (min_arg >= 0 ? 255 : 127)) - sprintf(buff, "TINYINT(%d)", (int) max_length - (item->decimals + 1)); + sprintf(buff, "TINYINT(%d)", (int) max_length - + ((item->decimals == NOT_FIXED_DEC) ? 0 : (item->decimals + 1))); else if (min_arg >= INT_MIN16 && max_arg <= (min_arg >= 0 ? UINT_MAX16 : INT_MAX16)) - sprintf(buff, "SMALLINT(%d)", (int) max_length - (item->decimals + 1)); + sprintf(buff, "SMALLINT(%d)", (int) max_length - + ((item->decimals == NOT_FIXED_DEC) ? 0 : (item->decimals + 1))); else if (min_arg >= INT_MIN24 && max_arg <= (min_arg >= 0 ? UINT_MAX24 : INT_MAX24)) - sprintf(buff, "MEDIUMINT(%d)", (int) max_length - (item->decimals + 1)); + sprintf(buff, "MEDIUMINT(%d)", (int) max_length - + ((item->decimals == NOT_FIXED_DEC) ? 0 : (item->decimals + 1))); else if (min_arg >= INT_MIN32 && max_arg <= (min_arg >= 0 ? UINT_MAX32 : INT_MAX32)) - sprintf(buff, "INT(%d)", (int) max_length - (item->decimals + 1)); + sprintf(buff, "INT(%d)", (int) max_length - + ((item->decimals == NOT_FIXED_DEC) ? 0 : (item->decimals + 1))); else - sprintf(buff, "BIGINT(%d)", (int) max_length - (item->decimals + 1)); + sprintf(buff, "BIGINT(%d)", (int) max_length - + ((item->decimals == NOT_FIXED_DEC) ? 0 : (item->decimals + 1))); answer->append(buff, (uint) strlen(buff)); if (min_arg >= 0) answer->append(" UNSIGNED"); From fa13c29b2e36d33fdda46777390aca6df2b0faeb Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 10 Sep 2005 02:30:26 +0400 Subject: [PATCH 09/16] insert_select.result, insert_select.test: Customer's test case for bug#12695 Item_func_isnull::update_used_tables() did not update const_item_cache. mysql-test/t/insert_select.test: Customer's test case for bug#12695 Item_func_isnull::update_used_tables() did not update const_item_cache. mysql-test/r/insert_select.result: Customer's test case for bug#12695 Item_func_isnull::update_used_tables() did not update const_item_cache. --- mysql-test/r/insert_select.result | 10 ++++++++++ mysql-test/t/insert_select.test | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result index 2ac73fe7662..d4eb4e8b788 100644 --- a/mysql-test/r/insert_select.result +++ b/mysql-test/r/insert_select.result @@ -668,3 +668,13 @@ ERROR 42S02: Unknown table 't2' in field list insert into t1 select t2.a from t2 group by t2.a on duplicate key update a= t1.a + t2.b; ERROR 42S02: Unknown table 't2' in field list drop table t1,t2,t3; +create table t1(f1 varchar(5) key); +insert into t1(f1) select if(max(f1) is null, '2000',max(f1)+1) from t1; +insert into t1(f1) select if(max(f1) is null, '2000',max(f1)+1) from t1; +insert into t1(f1) select if(max(f1) is null, '2000',max(f1)+1) from t1; +select * from t1; +f1 +2000 +2001 +2002 +drop table t1; diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test index 14853b38db2..6fcdef6ab03 100644 --- a/mysql-test/t/insert_select.test +++ b/mysql-test/t/insert_select.test @@ -204,4 +204,14 @@ insert into t1 select t2.a from t2 on duplicate key update t2.a= a + t2.b; insert into t1 select t2.a from t2 group by t2.a on duplicate key update a= t1.a + t2.b; drop table t1,t2,t3; +# +# Bug #12695 Item_func_isnull::update_used_tables() did not update +# const_item_cache +create table t1(f1 varchar(5) key); +insert into t1(f1) select if(max(f1) is null, '2000',max(f1)+1) from t1; +insert into t1(f1) select if(max(f1) is null, '2000',max(f1)+1) from t1; +insert into t1(f1) select if(max(f1) is null, '2000',max(f1)+1) from t1; +select * from t1; +drop table t1; + # End of 4.1 tests From e6560c0da090d4355b761c07ae500aacd7f6b0db Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 11 Sep 2005 00:57:31 +0200 Subject: [PATCH 10/16] Removed redundant reset_one_shot_variables calls sql/sql_parse.cc: Optimization, this reset is executed below anyway --- sql/sql_parse.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 76d4c5c27dc..131fe3d691d 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3327,7 +3327,6 @@ purposes internal to the MySQL server", MYF(0)); !db_ok_with_wild_table(lex->name))) { my_error(ER_SLAVE_IGNORED_TABLE, MYF(0)); - reset_one_shot_variables(thd); break; } #endif @@ -3363,7 +3362,6 @@ purposes internal to the MySQL server", MYF(0)); !db_ok_with_wild_table(lex->name))) { my_error(ER_SLAVE_IGNORED_TABLE, MYF(0)); - reset_one_shot_variables(thd); break; } #endif @@ -3404,7 +3402,6 @@ purposes internal to the MySQL server", MYF(0)); !db_ok_with_wild_table(db))) { my_error(ER_SLAVE_IGNORED_TABLE, MYF(0)); - reset_one_shot_variables(thd); break; } #endif From 49be919a89e0cc26f346ae9e5575c15061eabb14 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 11 Sep 2005 22:10:04 +0300 Subject: [PATCH 11/16] Merged from 4.1 --- mysql-test/r/analyse.result | 6 ++++++ mysql-test/t/analyse.test | 15 ++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/analyse.result b/mysql-test/r/analyse.result index a56902e8ae7..df524b491f1 100644 --- a/mysql-test/r/analyse.result +++ b/mysql-test/r/analyse.result @@ -109,3 +109,9 @@ select * from t1 procedure analyse(); Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype test.t1.df 1.1 2.2 8 8 0 0 1.650000000 0.302500000 ENUM('1.1','2.2') NOT NULL drop table t1; +create table t1 (d double); +insert into t1 values (100000); +select * from t1 procedure analyse (1,1); +Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype +test.t1.d 100000 100000 6 6 0 0 100000 0 MEDIUMINT(6) UNSIGNED NOT NULL +drop table t1; diff --git a/mysql-test/t/analyse.test b/mysql-test/t/analyse.test index 101101fdda4..4060892c389 100644 --- a/mysql-test/t/analyse.test +++ b/mysql-test/t/analyse.test @@ -48,6 +48,14 @@ insert into t1 values ('abc'),('abc\'def\\hij\"klm\0opq'),('\''),('\"'),('\\'),( select * from t1 procedure analyse(); drop table t1; +#decimal-related test + +create table t1 (df decimal(5,1)); +insert into t1 values(1.1); +insert into t1 values(2.2); +select * from t1 procedure analyse(); +drop table t1; + # # Bug#10716 - Procedure Analyse results in wrong values for optimal field type # @@ -59,10 +67,3 @@ drop table t1; # End of 4.1 tests -#decimal-related test - -create table t1 (df decimal(5,1)); -insert into t1 values(1.1); -insert into t1 values(2.2); -select * from t1 procedure analyse(); -drop table t1; From 25fb012dcf4ddfbb018609292fb4cb9f56fc1c5f Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Sep 2005 08:28:53 +0300 Subject: [PATCH 12/16] Fix for BUG#13067 "JOIN ... USING is case sensitive". mysql-test/r/select.result: Test for BUG#13067 mysql-test/t/select.test: Test for BUG#13067 sql/sql_base.cc: Correctly compare field names with respect to case sensitivity. --- mysql-test/r/select.result | 10 ++++++++++ mysql-test/t/select.test | 12 ++++++++++++ sql/sql_base.cc | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 24c89039566..5f2f5f50a16 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2912,3 +2912,13 @@ ERROR 23000: Column 'id' in from clause is ambiguous SELECT id,t3.id FROM (t1 JOIN t2 ON (t2.id=t1.id)) LEFT JOIN t3 USING (id); ERROR 23000: Column 'id' in from clause is ambiguous drop table t1, t2, t3; +create table t1 (a int(10),b int(10)); +create table t2 (a int(10),b int(10)); +insert into t1 values (1,10),(2,20),(3,30); +insert into t2 values (1,10); +select * from t1 inner join t2 using (A); +a b b +1 10 10 +select * from t1 inner join t2 using (a); +a b b +1 10 10 diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 62687a869b7..c4b50a7556b 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -2487,3 +2487,15 @@ SELECT id,t3.id FROM t1 JOIN t2 ON (t2.id=t1.id) LEFT JOIN t3 USING (id); SELECT id,t3.id FROM (t1 JOIN t2 ON (t2.id=t1.id)) LEFT JOIN t3 USING (id); drop table t1, t2, t3; + +# +# Bug #13067 JOIN xxx USING is case sensitive +# + +create table t1 (a int(10),b int(10)); +create table t2 (a int(10),b int(10)); +insert into t1 values (1,10),(2,20),(3,30); +insert into t2 values (1,10); +# both queries should produce the same result +select * from t1 inner join t2 using (A); +select * from t1 inner join t2 using (a); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 8a5c5643ce2..766840e667c 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -3414,7 +3414,7 @@ test_if_string_in_list(const char *find, List *str_list) { if (find_length != curr_str->length()) continue; - if (!strncmp(find, curr_str->ptr(), find_length)) + if (!my_strcasecmp(system_charset_info, find, curr_str->ptr())) return TRUE; } return FALSE; From 820e145679895ca114af56feab2ec783e98c3d53 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Sep 2005 09:36:07 +0200 Subject: [PATCH 13/16] Repair of condition pushdown after Item_func_between/in objects now directly represent NOT BETWEEN/IN expressions (ChangeSet@1.2402.1.1) --- sql/ha_ndbcluster.cc | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index a39f541b992..146fbee93c8 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -6618,13 +6618,24 @@ void ndb_serialize_cond(const Item *item, void *arg) case Item_func::BETWEEN: { DBUG_PRINT("info", ("BETWEEN, rewriting using AND")); + Item_func_between *between_func= (Item_func_between *) func_item; Ndb_rewrite_context *rewrite_context= new Ndb_rewrite_context(func_item); rewrite_context->next= context->rewrite_stack; context->rewrite_stack= rewrite_context; + if (between_func->negated) + { + DBUG_PRINT("info", ("NOT_FUNC")); + curr_cond->ndb_item= new Ndb_item(Item_func::NOT_FUNC, 1); + prev_cond= curr_cond; + curr_cond= context->cond_ptr= new Ndb_cond(); + curr_cond->prev= prev_cond; + prev_cond->next= curr_cond; + } DBUG_PRINT("info", ("COND_AND_FUNC")); - curr_cond->ndb_item= new Ndb_item(Item_func::COND_AND_FUNC, - func_item->argument_count() - 1); + curr_cond->ndb_item= + new Ndb_item(Item_func::COND_AND_FUNC, + func_item->argument_count() - 1); context->expect_only(Item::FIELD_ITEM); context->expect(Item::INT_ITEM); context->expect(Item::STRING_ITEM); @@ -6635,10 +6646,20 @@ void ndb_serialize_cond(const Item *item, void *arg) case Item_func::IN_FUNC: { DBUG_PRINT("info", ("IN_FUNC, rewriting using OR")); + Item_func_in *in_func= (Item_func_in *) func_item; Ndb_rewrite_context *rewrite_context= new Ndb_rewrite_context(func_item); rewrite_context->next= context->rewrite_stack; context->rewrite_stack= rewrite_context; + if (in_func->negated) + { + DBUG_PRINT("info", ("NOT_FUNC")); + curr_cond->ndb_item= new Ndb_item(Item_func::NOT_FUNC, 1); + prev_cond= curr_cond; + curr_cond= context->cond_ptr= new Ndb_cond(); + curr_cond->prev= prev_cond; + prev_cond->next= curr_cond; + } DBUG_PRINT("info", ("COND_OR_FUNC")); curr_cond->ndb_item= new Ndb_item(Item_func::COND_OR_FUNC, func_item->argument_count() - 1); @@ -6960,6 +6981,7 @@ void ndb_serialize_cond(const Item *item, void *arg) DBUG_PRINT("info", ("End of condition group")); prev_cond= curr_cond; curr_cond= context->cond_ptr= new Ndb_cond(); + curr_cond->prev= prev_cond; prev_cond->next= curr_cond; curr_cond->ndb_item= new Ndb_item(NDB_END_COND); // Pop rewrite stack From eac9a337781a67eb6b64846465af6f89d356e174 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Sep 2005 10:50:42 +0200 Subject: [PATCH 14/16] Reverted old fix with sync_slave_with_master and added a replace commands to eliminate nondeterminism in slave start --- mysql-test/r/rpl_slave_status.result | 2 +- mysql-test/t/rpl_slave_status.test | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/rpl_slave_status.result b/mysql-test/r/rpl_slave_status.result index 8badbab85ff..2146132aeb0 100644 --- a/mysql-test/r/rpl_slave_status.result +++ b/mysql-test/r/rpl_slave_status.result @@ -19,7 +19,7 @@ flush privileges; stop slave; start slave; show slave status; -Slave_IO_State Connecting to master +Slave_IO_State # Master_Host 127.0.0.1 Master_User rpl Master_Port MASTER_MYPORT diff --git a/mysql-test/t/rpl_slave_status.test b/mysql-test/t/rpl_slave_status.test index 247e562eafa..67d3816f443 100644 --- a/mysql-test/t/rpl_slave_status.test +++ b/mysql-test/t/rpl_slave_status.test @@ -19,12 +19,13 @@ select * from t1; connection master; delete from mysql.user where user='rpl'; flush privileges; -sync_slave_with_master; connection slave; stop slave; start slave; --replace_result $MASTER_MYPORT MASTER_MYPORT ---replace_column 7 # 8 # 9 # 22 # 23 # +# Column 1 is replaced, since the output can be either +# "Connecting to master" or "Waiting for master update" +--replace_column 1 # 7 # 8 # 9 # 22 # 23 # --vertical_results show slave status; From e98e15db9b05da3b4c1ad5d788f2c6e5a3b78a15 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Sep 2005 14:21:38 +0500 Subject: [PATCH 15/16] ps_6bdb, ps_7ndb tests failure fix --- mysql-test/r/ps_6bdb.result | 6 +++--- mysql-test/r/ps_7ndb.result | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/ps_6bdb.result b/mysql-test/r/ps_6bdb.result index ef74e13a41d..acd7f45de95 100644 --- a/mysql-test/r/ps_6bdb.result +++ b/mysql-test/r/ps_6bdb.result @@ -1153,12 +1153,12 @@ def id 8 3 1 N 32929 0 63 def select_type 253 19 6 N 1 31 8 def table 253 64 2 Y 0 31 8 def type 253 10 3 Y 0 31 8 -def possible_keys 252 4096 0 Y 0 31 8 +def possible_keys 253 4096 0 Y 0 31 8 def key 253 64 0 Y 0 31 8 def key_len 8 3 0 Y 32928 0 63 -def ref 252 1024 0 Y 0 31 8 +def ref 253 1024 0 Y 0 31 8 def rows 8 10 1 Y 32928 0 63 -def Extra 252 255 0 N 1 31 8 +def Extra 253 255 0 N 1 31 8 id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t9 ALL NULL NULL NULL NULL 3 test_sequence diff --git a/mysql-test/r/ps_7ndb.result b/mysql-test/r/ps_7ndb.result index e7ffbb7c6ef..27a1ea0925d 100644 --- a/mysql-test/r/ps_7ndb.result +++ b/mysql-test/r/ps_7ndb.result @@ -1153,12 +1153,12 @@ def id 8 3 1 N 32929 0 63 def select_type 253 19 6 N 1 31 8 def table 253 64 2 Y 0 31 8 def type 253 10 3 Y 0 31 8 -def possible_keys 252 4096 0 Y 0 31 8 +def possible_keys 253 4096 0 Y 0 31 8 def key 253 64 0 Y 0 31 8 def key_len 8 3 0 Y 32928 0 63 -def ref 252 1024 0 Y 0 31 8 +def ref 253 1024 0 Y 0 31 8 def rows 8 10 1 Y 32928 0 63 -def Extra 252 255 0 N 1 31 8 +def Extra 253 255 0 N 1 31 8 id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t9 ALL NULL NULL NULL NULL 2 test_sequence From 0a3202bedfbe3666e29690b12ce94123e73f8945 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Sep 2005 14:03:23 +0200 Subject: [PATCH 16/16] removed a few aborts from mgmapi corrected typo in ndb Parser --- ndb/include/util/Parser.hpp | 2 +- ndb/src/mgmapi/mgmapi.cpp | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/ndb/include/util/Parser.hpp b/ndb/include/util/Parser.hpp index c117498e1ba..3baf7601a6c 100644 --- a/ndb/include/util/Parser.hpp +++ b/ndb/include/util/Parser.hpp @@ -285,7 +285,7 @@ template inline void Parser::setBreakOnInvalidArg(bool v){ - impl->m_breakOnInvalidArg; + impl->m_breakOnInvalidArg = v; } #endif diff --git a/ndb/src/mgmapi/mgmapi.cpp b/ndb/src/mgmapi/mgmapi.cpp index bf78adec970..06b534ac0ca 100644 --- a/ndb/src/mgmapi/mgmapi.cpp +++ b/ndb/src/mgmapi/mgmapi.cpp @@ -638,12 +638,10 @@ ndb_mgm_get_status(NdbMgmHandle handle) Vector split; tmp.split(split, ":"); if(split.size() != 2){ - abort(); return NULL; } if(!(split[0].trim() == "nodes")){ - abort(); return NULL; } @@ -692,7 +690,6 @@ ndb_mgm_get_status(NdbMgmHandle handle) if(i+1 != noOfNodes){ free(state); - abort(); return NULL; }