From 705060f10ccb6a0e3ce5899f7d8c2fdfc2a6a777 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 8 Oct 2006 11:24:53 +0800 Subject: [PATCH 1/4] BUG #21858 Make sure retry when EINTR returns, which decreases memory leak chance. ndb/src/common/util/File.cpp: Avoid memory leak when EINTR error returns. Even though a close-error happens, a ERROR message in out file is given, and this shouldn't affect the normally running. --- ndb/src/common/util/File.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/ndb/src/common/util/File.cpp b/ndb/src/common/util/File.cpp index 12626f29e7d..00741d3a576 100644 --- a/ndb/src/common/util/File.cpp +++ b/ndb/src/common/util/File.cpp @@ -123,13 +123,25 @@ bool File_class::close() { bool rc = true; + int retval = 0; + if (m_file != NULL) { ::fflush(m_file); - rc = (::fclose(m_file) == 0 ? true : false); - m_file = NULL; // Try again? + retval = ::fclose(m_file); + while ( (retval != 0) && (errno == EINTR) ){ + retval = ::fclose(m_file); + } + if( retval == 0){ + rc = true; + } + else { + rc = false; + ndbout_c("ERROR: Close file error in File.cpp for %s",strerror(errno)); + } } - + m_file = NULL; + return rc; } From 82ac37e2dfc4b4c8b9dba64eb613c411a80bb04d Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 5 Jan 2007 15:33:39 +0100 Subject: [PATCH 2/4] remove unused errorcode corrected previous patch removing "if (signal)", which should acually be "if (signum)" ndb/src/common/debugger/EventLogger.cpp: corrected previous patch removing "if (signal)", which should acually be "if (signum)" ndb/src/kernel/blocks/dbtc/Dbtc.hpp: remove unused errorcode ndb/src/ndbapi/ndberror.c: remove unused errorcode --- ndb/src/common/debugger/EventLogger.cpp | 3 ++- ndb/src/kernel/blocks/dbtc/Dbtc.hpp | 1 - ndb/src/ndbapi/ndberror.c | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ndb/src/common/debugger/EventLogger.cpp b/ndb/src/common/debugger/EventLogger.cpp index e168c705d47..3efd52808e2 100644 --- a/ndb/src/common/debugger/EventLogger.cpp +++ b/ndb/src/common/debugger/EventLogger.cpp @@ -115,7 +115,8 @@ void getTextNDBStopForced(QQQQ) { int sphase = theData[4]; int extra = theData[5]; getRestartAction(theData[1],action_str); - reason_str.appfmt(" Initiated by signal %d.", signum); + if (signum) + reason_str.appfmt(" Initiated by signal %d.", signum); if (error) { ndbd_exit_classification cl; diff --git a/ndb/src/kernel/blocks/dbtc/Dbtc.hpp b/ndb/src/kernel/blocks/dbtc/Dbtc.hpp index c6089113382..d6c4529bb72 100644 --- a/ndb/src/kernel/blocks/dbtc/Dbtc.hpp +++ b/ndb/src/kernel/blocks/dbtc/Dbtc.hpp @@ -138,7 +138,6 @@ #define ZNOT_FOUND 626 #define ZALREADYEXIST 630 -#define ZINCONSISTENTHASHINDEX 892 #define ZNOTUNIQUE 893 #define ZINVALID_KEY 290 diff --git a/ndb/src/ndbapi/ndberror.c b/ndb/src/ndbapi/ndberror.c index 8800aedae5a..45248000703 100644 --- a/ndb/src/ndbapi/ndberror.c +++ b/ndb/src/ndbapi/ndberror.c @@ -208,7 +208,6 @@ ErrorBundle ErrorCodes[] = { /** * Internal errors */ - { 892, IE, "Inconsistent hash index. The index needs to be dropped and recreated" }, { 896, IE, "Tuple corrupted - wrong checksum or column data in invalid format" }, { 901, IE, "Inconsistent ordered index. The index needs to be dropped and recreated" }, { 202, IE, "202" }, From 5f9e20de6ccb1d9d2dbdb9640c70d59405f6bf32 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 23 Jan 2007 00:34:00 +0700 Subject: [PATCH 3/4] bug#25746 ndb: 4209 error with 2 VARCHAR primary keys - make sure keys are copied correctly when varchar has 2 length bytes - test case mysql-test/r/ndb_basic.result: bug#25746 ndb: 4209 error with 2 VARCHAR primary keys - test case mysql-test/t/ndb_basic.test: bug#25746 ndb: 4209 error with 2 VARCHAR primary keys - test case sql/ha_ndbcluster.cc: bug#25746 ndb: 4209 error with 2 VARCHAR primary keys - make sure keys are copied correctly when varchar has 2 length bytes --- mysql-test/r/ndb_basic.result | 16 ++++++++++++++++ mysql-test/t/ndb_basic.test | 19 +++++++++++++++++++ sql/ha_ndbcluster.cc | 26 ++++++++++++++++---------- 3 files changed, 51 insertions(+), 10 deletions(-) diff --git a/mysql-test/r/ndb_basic.result b/mysql-test/r/ndb_basic.result index d2111db24fe..fab10867acd 100644 --- a/mysql-test/r/ndb_basic.result +++ b/mysql-test/r/ndb_basic.result @@ -749,3 +749,19 @@ f1 f2 f3 222222 bbbbbb 2 drop table t1; Illegal ndb error code: 1186 +CREATE TABLE t1 ( +a VARBINARY(40) NOT NULL, +b VARCHAR (256) CHARACTER SET UTF8 NOT NULL, +c VARCHAR(256) CHARACTER SET UTF8 NOT NULL, +PRIMARY KEY (b,c)) ENGINE=ndbcluster; +INSERT INTO t1 VALUES +("a","ab","abc"),("b","abc","abcd"),("c","abc","ab"),("d","ab","ab"),("e","abc","abc"); +SELECT * FROM t1 ORDER BY a; +a b c +a ab abc +b abc abcd +c abc ab +d ab ab +e abc abc +DROP TABLE t1; +End of 5.0 tests diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test index 6c1a4e44f4b..a1ceddcd183 100644 --- a/mysql-test/t/ndb_basic.test +++ b/mysql-test/t/ndb_basic.test @@ -710,3 +710,22 @@ drop table t1; --error 1 --exec $MY_PERROR --ndb 1186 2>&1 +# +# Bug #25746 - VARCHAR UTF8 PK issue +# - prior to bugfix 4209, illegal length parameter would be +# returned in SELECT * + +CREATE TABLE t1 ( +a VARBINARY(40) NOT NULL, +b VARCHAR (256) CHARACTER SET UTF8 NOT NULL, +c VARCHAR(256) CHARACTER SET UTF8 NOT NULL, +PRIMARY KEY (b,c)) ENGINE=ndbcluster; +INSERT INTO t1 VALUES +("a","ab","abc"),("b","abc","abcd"),("c","abc","ab"),("d","ab","ab"),("e","abc","abc"); +SELECT * FROM t1 ORDER BY a; +DROP TABLE t1; + +# End of 5.0 tests +--echo End of 5.0 tests + + diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index f9984b27077..6cff3637cf3 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -3144,20 +3144,26 @@ void ha_ndbcluster::position(const byte *record) size_t len = key_part->length; const byte * ptr = record + key_part->offset; Field *field = key_part->field; - if ((field->type() == MYSQL_TYPE_VARCHAR) && - ((Field_varstring*)field)->length_bytes == 1) + if (unlikely(field->type() == MYSQL_TYPE_VARCHAR)) { - /** - * Keys always use 2 bytes length - */ - buff[0] = ptr[0]; - buff[1] = 0; - memcpy(buff+2, ptr + 1, len); - len += 2; + if (((Field_varstring*)field)->length_bytes == 1) + { + /** + * Keys always use 2 bytes length + */ + buff[0] = ptr[0]; + buff[1] = 0; + memcpy(buff+2, ptr + 1, len); + } + else + { + memcpy(buff, ptr, len + 2); + } + len += 2; } else { - memcpy(buff, ptr, len); + memcpy(buff, ptr, len); } buff += len; } From 188899cdfc07d58a534c2bdbf09b986ac94adb4e Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 23 Jan 2007 07:12:03 +0700 Subject: [PATCH 4/4] bug#25746 ndb: 4209 error with 2 VARCHAR primary keys - post review changes --- sql/ha_ndbcluster.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 6cff3637cf3..3c3f6f4e06b 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -3144,7 +3144,7 @@ void ha_ndbcluster::position(const byte *record) size_t len = key_part->length; const byte * ptr = record + key_part->offset; Field *field = key_part->field; - if (unlikely(field->type() == MYSQL_TYPE_VARCHAR)) + if (field->type() == MYSQL_TYPE_VARCHAR) { if (((Field_varstring*)field)->length_bytes == 1) {