From 316c96fa81adeae15533e5eeba25ee64a47467ee Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 20 Apr 2006 12:06:22 +0200 Subject: [PATCH 1/4] Fix for bug#19196: Attempt to create index on usupported field type gives wrong error code --- mysql-test/r/ndb_bitfield.result | 4 +- ndb/include/kernel/signaldata/TupFrag.hpp | 3 +- ndb/include/util/NdbSqlUtil.hpp | 6 +-- ndb/src/common/util/NdbSqlUtil.cpp | 52 ++++++++++++----------- ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp | 5 ++- ndb/src/ndbapi/NdbDictionaryImpl.cpp | 18 +++++--- 6 files changed, 49 insertions(+), 39 deletions(-) diff --git a/mysql-test/r/ndb_bitfield.result b/mysql-test/r/ndb_bitfield.result index 9a941862854..389e19f2893 100644 --- a/mysql-test/r/ndb_bitfield.result +++ b/mysql-test/r/ndb_bitfield.result @@ -201,13 +201,13 @@ create table t1 ( pk1 bit(9) not null primary key, b int ) engine=ndbcluster; -ERROR HY000: Can't create table './test/t1.frm' (errno: 739) +ERROR HY000: Can't create table './test/t1.frm' (errno: 906) create table t1 ( pk1 int not null primary key, b bit(9), key(b) ) engine=ndbcluster; -ERROR HY000: Can't create table './test/t1.frm' (errno: 743) +ERROR HY000: Can't create table './test/t1.frm' (errno: 906) create table t1 ( pk1 int primary key, b bit(32) not null diff --git a/ndb/include/kernel/signaldata/TupFrag.hpp b/ndb/include/kernel/signaldata/TupFrag.hpp index 8acb3d28bd6..5fb9d7bcf42 100644 --- a/ndb/include/kernel/signaldata/TupFrag.hpp +++ b/ndb/include/kernel/signaldata/TupFrag.hpp @@ -146,7 +146,8 @@ public: enum ErrorCode { NoError = 0, InvalidCharset = 743, - TooManyBitsUsed = 831 + TooManyBitsUsed = 831, + UnsupportedType = 906 }; private: Uint32 userPtr; diff --git a/ndb/include/util/NdbSqlUtil.hpp b/ndb/include/util/NdbSqlUtil.hpp index 3e98dcd1805..36a75136c45 100644 --- a/ndb/include/util/NdbSqlUtil.hpp +++ b/ndb/include/util/NdbSqlUtil.hpp @@ -117,9 +117,9 @@ public: /** * Check character set. */ - static bool usable_in_pk(Uint32 typeId, const void* info); - static bool usable_in_hash_index(Uint32 typeId, const void* info); - static bool usable_in_ordered_index(Uint32 typeId, const void* info); + static uint check_column_for_pk(Uint32 typeId, const void* info); + static uint check_column_for_hash_index(Uint32 typeId, const void* info); + static uint check_column_for_ordered_index(Uint32 typeId, const void* info); /** * Get number of length bytes and length from variable length string. diff --git a/ndb/src/common/util/NdbSqlUtil.cpp b/ndb/src/common/util/NdbSqlUtil.cpp index 09e150dbacf..f2506eda6d4 100644 --- a/ndb/src/common/util/NdbSqlUtil.cpp +++ b/ndb/src/common/util/NdbSqlUtil.cpp @@ -872,8 +872,8 @@ NdbSqlUtil::likeLongvarbinary(const void* info, const void* p1, unsigned n1, con // check charset -bool -NdbSqlUtil::usable_in_pk(Uint32 typeId, const void* info) +uint +NdbSqlUtil::check_column_for_pk(Uint32 typeId, const void* info) { const Type& type = getType(typeId); switch (type.m_typeId) { @@ -882,12 +882,14 @@ NdbSqlUtil::usable_in_pk(Uint32 typeId, const void* info) case Type::Longvarchar: { const CHARSET_INFO *cs = (const CHARSET_INFO*)info; - return - cs != 0 && - cs->cset != 0 && - cs->coll != 0 && - cs->coll->strnxfrm != 0 && - cs->strxfrm_multiply <= MAX_XFRM_MULTIPLY; + if(cs != 0 && + cs->cset != 0 && + cs->coll != 0 && + cs->coll->strnxfrm != 0 && + cs->strxfrm_multiply <= MAX_XFRM_MULTIPLY) + return 0; + else + return 743; } break; case Type::Undefined: @@ -896,19 +898,19 @@ NdbSqlUtil::usable_in_pk(Uint32 typeId, const void* info) case Type::Bit: break; default: - return true; + return 0; } - return false; + return 906; } -bool -NdbSqlUtil::usable_in_hash_index(Uint32 typeId, const void* info) +uint +NdbSqlUtil::check_column_for_hash_index(Uint32 typeId, const void* info) { - return usable_in_pk(typeId, info); + return check_column_for_pk(typeId, info); } -bool -NdbSqlUtil::usable_in_ordered_index(Uint32 typeId, const void* info) +uint +NdbSqlUtil::check_column_for_ordered_index(Uint32 typeId, const void* info) { const Type& type = getType(typeId); if (type.m_cmp == NULL) @@ -919,13 +921,15 @@ NdbSqlUtil::usable_in_ordered_index(Uint32 typeId, const void* info) case Type::Longvarchar: { const CHARSET_INFO *cs = (const CHARSET_INFO*)info; - return - cs != 0 && - cs->cset != 0 && - cs->coll != 0 && - cs->coll->strnxfrm != 0 && - cs->coll->strnncollsp != 0 && - cs->strxfrm_multiply <= MAX_XFRM_MULTIPLY; + if (cs != 0 && + cs->cset != 0 && + cs->coll != 0 && + cs->coll->strnxfrm != 0 && + cs->coll->strnncollsp != 0 && + cs->strxfrm_multiply <= MAX_XFRM_MULTIPLY) + return 0; + else + return 743; } break; case Type::Undefined: @@ -934,9 +938,9 @@ NdbSqlUtil::usable_in_ordered_index(Uint32 typeId, const void* info) case Type::Bit: // can be fixed break; default: - return true; + return 0; } - return false; + return 906; } // utilities diff --git a/ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp b/ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp index 93c4a583624..c85c8384081 100644 --- a/ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp +++ b/ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp @@ -217,11 +217,12 @@ Dbtux::execTUX_ADD_ATTRREQ(Signal* signal) break; } if (descAttr.m_charset != 0) { + uint err; CHARSET_INFO *cs = all_charsets[descAttr.m_charset]; ndbrequire(cs != 0); - if (! NdbSqlUtil::usable_in_ordered_index(descAttr.m_typeId, cs)) { + if ((err = NdbSqlUtil::check_column_for_ordered_index(descAttr.m_typeId, cs))) { jam(); - errorCode = TuxAddAttrRef::InvalidCharset; + errorCode = (TuxAddAttrRef::ErrorCode) err; break; } } diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp index f7a28eb989c..6cb8e1f9a24 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -1573,7 +1573,7 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, bool alter) { DBUG_ENTER("NdbDictInterface::createOrAlterTable"); - unsigned i; + unsigned i, err; if((unsigned)impl.getNoOfPrimaryKeys() > NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY){ m_error.code= 4317; DBUG_RETURN(-1); @@ -1683,8 +1683,10 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, DBUG_RETURN(-1); } // primary key type check - if (col->m_pk && ! NdbSqlUtil::usable_in_pk(col->m_type, col->m_cs)) { - m_error.code= (col->m_cs != 0 ? 743 : 739); + if (col->m_pk && + (err = NdbSqlUtil::check_column_for_pk(col->m_type, col->m_cs))) + { + m_error.code= err; DBUG_RETURN(-1); } // distribution key not supported for Char attribute @@ -2157,7 +2159,7 @@ NdbDictInterface::createIndex(Ndb & ndb, { //validate(); //aggregate(); - unsigned i; + unsigned i, err; UtilBufferWriter w(m_buffer); const size_t len = strlen(impl.m_externalName.c_str()) + 1; if(len > MAX_TAB_NAME_SIZE) { @@ -2208,10 +2210,12 @@ NdbDictInterface::createIndex(Ndb & ndb, // index key type check if (it == DictTabInfo::UniqueHashIndex && - ! NdbSqlUtil::usable_in_hash_index(col->m_type, col->m_cs) || + (err = NdbSqlUtil::check_column_for_hash_index(col->m_type, col->m_cs)) + || it == DictTabInfo::OrderedIndex && - ! NdbSqlUtil::usable_in_ordered_index(col->m_type, col->m_cs)) { - m_error.code = 743; + (err = NdbSqlUtil::check_column_for_ordered_index(col->m_type, col->m_cs))) + { + m_error.code = err; return -1; } attributeList.id[i] = col->m_attrId; From f9d56ce8efdd6824c540657e9f88537ce4593c92 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 20 Apr 2006 13:32:41 +0200 Subject: [PATCH 2/4] Fix for bug#19196: Attempt to create index on usupported field type gives wrong error code: updated with new expected error codes --- mysql-test/r/ndb_bitfield.result | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/ndb_bitfield.result b/mysql-test/r/ndb_bitfield.result index 13fd31d7e88..9a8c571cfba 100644 --- a/mysql-test/r/ndb_bitfield.result +++ b/mysql-test/r/ndb_bitfield.result @@ -201,21 +201,21 @@ create table t1 ( pk1 bit(9) not null primary key, b int ) engine=ndbcluster; -ERROR HY000: Can't create table 'test.t1' (errno: 140) +ERROR HY000: Can't create table 'test.t1' (errno: 906) show warnings; Level Code Message -Error 1296 Got error 739 'Unsupported primary key length' from NDB -Error 1005 Can't create table 'test.t1' (errno: 140) +Error 1296 Got error 906 'Unsupported attribute type in index' from NDB +Error 1005 Can't create table 'test.t1' (errno: 906) create table t1 ( pk1 int not null primary key, b bit(9), key(b) ) engine=ndbcluster; -ERROR HY000: Can't create table 'test.t1' (errno: 140) +ERROR HY000: Can't create table 'test.t1' (errno: 906) show warnings; Level Code Message -Error 1296 Got error 743 'Unsupported character set in table or index' from NDB -Error 1005 Can't create table 'test.t1' (errno: 140) +Error 1296 Got error 906 'Unsupported attribute type in index' from NDB +Error 1005 Can't create table 'test.t1' (errno: 906) create table t1 ( pk1 int primary key, b bit(32) not null From d9e551672d4bb51f87a637bf3804fe239005d02f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 20 Apr 2006 23:03:13 +0200 Subject: [PATCH 3/4] bug#19220 mi_open() should accept filename w/i extension and with .MYI --- storage/myisam/mi_open.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index abf1d1ea9a7..91bf438035f 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -96,7 +96,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) bzero((byte*) &info,sizeof(info)); my_realpath(name_buff, fn_format(org_name,name,"",MI_NAME_IEXT, - MY_UNPACK_FILENAME|MY_APPEND_EXT),MYF(0)); + MY_UNPACK_FILENAME),MYF(0)); pthread_mutex_lock(&THR_LOCK_myisam); if (!(old_info=test_if_reopen(name_buff))) { From dc3e7bdc877903c1e044e3b43b79ade691824d87 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 20 Apr 2006 23:04:55 +0200 Subject: [PATCH 4/4] fix for make distcheck --- unittest/examples/Makefile.am | 4 ++-- unittest/mytap/t/Makefile.am | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/unittest/examples/Makefile.am b/unittest/examples/Makefile.am index 797784760ff..94a67927d12 100644 --- a/unittest/examples/Makefile.am +++ b/unittest/examples/Makefile.am @@ -1,5 +1,5 @@ -AM_CPPFLAGS = -I$(srcdir) -I$(top_builddir)/include -AM_CPPFLAGS += -I$(top_srcdir)/unittest/mytap +AM_CPPFLAGS = -I$(srcdir) -I$(top_builddir)/include \ + -I$(top_srcdir)/unittest/mytap -I$(top_srcdir)/include AM_LDFLAGS = -L$(top_builddir)/unittest/mytap diff --git a/unittest/mytap/t/Makefile.am b/unittest/mytap/t/Makefile.am index 948132783bc..88c31cfeb7f 100644 --- a/unittest/mytap/t/Makefile.am +++ b/unittest/mytap/t/Makefile.am @@ -1,6 +1,5 @@ -AM_CPPFLAGS = -I$(srcdir) -I$(top_builddir)/include -AM_CPPFLAGS += -I$(srcdir)/.. +AM_CPPFLAGS = -I$(srcdir) -I$(top_builddir)/include -I$(srcdir)/.. -I$(top_srcdir)/include AM_LDFLAGS = -L$(top_builddir)/unittest/mytap