From 658bac84bf8fcc8d57c94e65e2097164af88eb50 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Feb 2005 11:16:17 +0200 Subject: [PATCH 1/8] InnoDB: Create temporary files in the MySQL tmpdir instead of $TMPDIR. (Bug #5822) sql/ha_innodb.cc: innobase_mysql_tmpfile(): pass mysql_tmpdir to create_temp_file(), so that the MySQL startup option tmpdir will be honored instead of the environment variable TMPDIR. (Bug #5822) --- sql/ha_innodb.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 1a870ce3abf..81a803e36b9 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -424,7 +424,7 @@ innobase_mysql_tmpfile(void) { char filename[FN_REFLEN]; int fd2 = -1; - File fd = create_temp_file(filename, NullS, "ib", + File fd = create_temp_file(filename, mysql_tmpdir, "ib", #ifdef __WIN__ O_BINARY | O_TRUNC | O_SEQUENTIAL | O_TEMPORARY | O_SHORT_LIVED | From dbff1150c5195cd4ae8c76bf9b7c6234af57df7e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Feb 2005 12:45:59 +0100 Subject: [PATCH 2/8] ndb - fix old decimal type mysql vs ndb mysql-test/r/ndb_index_ordered.result: fix old decimal type mysql vs ndb (re-commit 3) mysql-test/t/ndb_index_ordered.test: fix old decimal type mysql vs ndb (re-commit 3) ndb/include/kernel/signaldata/DictTabInfo.hpp: fix old decimal type mysql vs ndb (re-commit 3) ndb/include/ndbapi/NdbDictionary.hpp: fix old decimal type mysql vs ndb (re-commit 3) ndb/include/util/NdbSqlUtil.hpp: fix old decimal type mysql vs ndb (re-commit 3) ndb/src/common/util/NdbSqlUtil.cpp: fix old decimal type mysql vs ndb (re-commit 3) ndb/src/ndbapi/NdbDictionary.cpp: fix old decimal type mysql vs ndb (re-commit 3) ndb/src/ndbapi/NdbDictionaryImpl.cpp: fix old decimal type mysql vs ndb (re-commit 3) ndb/src/ndbapi/NdbRecAttr.cpp: fix old decimal type mysql vs ndb (re-commit 3) ndb/test/include/NdbSchemaOp.hpp: fix old decimal type mysql vs ndb (re-commit 3) ndb/tools/restore/consumer.cpp: fix old decimal type mysql vs ndb (re-commit 3) sql/ha_ndbcluster.cc: fix old decimal type mysql vs ndb (re-commit 3) --- mysql-test/r/ndb_index_ordered.result | 83 +++++++++++++ mysql-test/t/ndb_index_ordered.test | 52 ++++++++ ndb/include/kernel/signaldata/DictTabInfo.hpp | 20 ++- ndb/include/ndbapi/NdbDictionary.hpp | 13 +- ndb/include/util/NdbSqlUtil.hpp | 13 +- ndb/src/common/util/NdbSqlUtil.cpp | 114 ++++++++++++------ ndb/src/ndbapi/NdbDictionary.cpp | 7 +- ndb/src/ndbapi/NdbDictionaryImpl.cpp | 6 +- ndb/src/ndbapi/NdbRecAttr.cpp | 15 ++- ndb/test/include/NdbSchemaOp.hpp | 3 +- ndb/tools/restore/consumer.cpp | 5 +- sql/ha_ndbcluster.cc | 34 ++++-- 12 files changed, 304 insertions(+), 61 deletions(-) diff --git a/mysql-test/r/ndb_index_ordered.result b/mysql-test/r/ndb_index_ordered.result index 12438f247c3..f5794d477f3 100644 --- a/mysql-test/r/ndb_index_ordered.result +++ b/mysql-test/r/ndb_index_ordered.result @@ -445,6 +445,89 @@ select count(*)-9 from t1 use index (ts) where ts <= '2001-01-01 23:59:59'; count(*)-9 0 drop table t1; +create table t1 ( +a int primary key, +s decimal(12), +t decimal(12, 5), +u decimal(12) unsigned, +v decimal(12, 5) unsigned, +key (s), +key (t), +key (u), +key (v) +) engine=ndb; +insert into t1 values +( 0, -000000000007, -0000061.00003, 000000000061, 0000965.00042), +( 1, -000000000007, -0000061.00042, 000000000061, 0000965.00003), +( 2, -071006035767, 4210253.00024, 000000000001, 0000001.84488), +( 3, 000000007115, 0000000.77607, 000077350625, 0000018.00013), +( 4, -000000068391, -0346486.00000, 000000005071, 0005334.00002), +( 5, -521579890459, -1936874.00001, 000000000154, 0000003.00018), +( 6, -521579890459, -1936874.00018, 000000000154, 0000003.00001), +( 7, 000000000333, 0000051.39140, 000000907958, 0788643.08374), +( 8, 000042731229, 0000009.00000, 000000000009, 6428667.00000), +( 9, -000008159769, 0000918.00004, 000096951421, 7607730.00008); +select count(*)- 5 from t1 use index (s) where s < -000000000007; +count(*)- 5 +0 +select count(*)- 7 from t1 use index (s) where s <= -000000000007; +count(*)- 7 +0 +select count(*)- 2 from t1 use index (s) where s = -000000000007; +count(*)- 2 +0 +select count(*)- 5 from t1 use index (s) where s >= -000000000007; +count(*)- 5 +0 +select count(*)- 3 from t1 use index (s) where s > -000000000007; +count(*)- 3 +0 +select count(*)- 4 from t1 use index (t) where t < -0000061.00003; +count(*)- 4 +0 +select count(*)- 5 from t1 use index (t) where t <= -0000061.00003; +count(*)- 5 +0 +select count(*)- 1 from t1 use index (t) where t = -0000061.00003; +count(*)- 1 +0 +select count(*)- 6 from t1 use index (t) where t >= -0000061.00003; +count(*)- 6 +0 +select count(*)- 5 from t1 use index (t) where t > -0000061.00003; +count(*)- 5 +0 +select count(*)- 2 from t1 use index (u) where u < 000000000061; +count(*)- 2 +0 +select count(*)- 4 from t1 use index (u) where u <= 000000000061; +count(*)- 4 +0 +select count(*)- 2 from t1 use index (u) where u = 000000000061; +count(*)- 2 +0 +select count(*)- 8 from t1 use index (u) where u >= 000000000061; +count(*)- 8 +0 +select count(*)- 6 from t1 use index (u) where u > 000000000061; +count(*)- 6 +0 +select count(*)- 5 from t1 use index (v) where v < 0000965.00042; +count(*)- 5 +0 +select count(*)- 6 from t1 use index (v) where v <= 0000965.00042; +count(*)- 6 +0 +select count(*)- 1 from t1 use index (v) where v = 0000965.00042; +count(*)- 1 +0 +select count(*)- 5 from t1 use index (v) where v >= 0000965.00042; +count(*)- 5 +0 +select count(*)- 4 from t1 use index (v) where v > 0000965.00042; +count(*)- 4 +0 +drop table t1; create table t1(a int primary key, b int not null, index(b)); insert into t1 values (1,1), (2,2); set autocommit=0; diff --git a/mysql-test/t/ndb_index_ordered.test b/mysql-test/t/ndb_index_ordered.test index 47e6b93eb81..010060a694d 100644 --- a/mysql-test/t/ndb_index_ordered.test +++ b/mysql-test/t/ndb_index_ordered.test @@ -249,6 +249,58 @@ select count(*)-9 from t1 use index (ts) where ts <= '2001-01-01 23:59:59'; drop table t1; +# decimal (not the new 5.0 thing) + +create table t1 ( + a int primary key, + s decimal(12), + t decimal(12, 5), + u decimal(12) unsigned, + v decimal(12, 5) unsigned, + key (s), + key (t), + key (u), + key (v) +) engine=ndb; +# +insert into t1 values + ( 0, -000000000007, -0000061.00003, 000000000061, 0000965.00042), + ( 1, -000000000007, -0000061.00042, 000000000061, 0000965.00003), + ( 2, -071006035767, 4210253.00024, 000000000001, 0000001.84488), + ( 3, 000000007115, 0000000.77607, 000077350625, 0000018.00013), + ( 4, -000000068391, -0346486.00000, 000000005071, 0005334.00002), + ( 5, -521579890459, -1936874.00001, 000000000154, 0000003.00018), + ( 6, -521579890459, -1936874.00018, 000000000154, 0000003.00001), + ( 7, 000000000333, 0000051.39140, 000000907958, 0788643.08374), + ( 8, 000042731229, 0000009.00000, 000000000009, 6428667.00000), + ( 9, -000008159769, 0000918.00004, 000096951421, 7607730.00008); +# +select count(*)- 5 from t1 use index (s) where s < -000000000007; +select count(*)- 7 from t1 use index (s) where s <= -000000000007; +select count(*)- 2 from t1 use index (s) where s = -000000000007; +select count(*)- 5 from t1 use index (s) where s >= -000000000007; +select count(*)- 3 from t1 use index (s) where s > -000000000007; +# +select count(*)- 4 from t1 use index (t) where t < -0000061.00003; +select count(*)- 5 from t1 use index (t) where t <= -0000061.00003; +select count(*)- 1 from t1 use index (t) where t = -0000061.00003; +select count(*)- 6 from t1 use index (t) where t >= -0000061.00003; +select count(*)- 5 from t1 use index (t) where t > -0000061.00003; +# +select count(*)- 2 from t1 use index (u) where u < 000000000061; +select count(*)- 4 from t1 use index (u) where u <= 000000000061; +select count(*)- 2 from t1 use index (u) where u = 000000000061; +select count(*)- 8 from t1 use index (u) where u >= 000000000061; +select count(*)- 6 from t1 use index (u) where u > 000000000061; +# +select count(*)- 5 from t1 use index (v) where v < 0000965.00042; +select count(*)- 6 from t1 use index (v) where v <= 0000965.00042; +select count(*)- 1 from t1 use index (v) where v = 0000965.00042; +select count(*)- 5 from t1 use index (v) where v >= 0000965.00042; +select count(*)- 4 from t1 use index (v) where v > 0000965.00042; + +drop table t1; + # bug#7798 create table t1(a int primary key, b int not null, index(b)); insert into t1 values (1,1), (2,2); diff --git a/ndb/include/kernel/signaldata/DictTabInfo.hpp b/ndb/include/kernel/signaldata/DictTabInfo.hpp index ade6c22a5bd..a2f9fcc9799 100644 --- a/ndb/include/kernel/signaldata/DictTabInfo.hpp +++ b/ndb/include/kernel/signaldata/DictTabInfo.hpp @@ -302,7 +302,8 @@ public: ExtBigunsigned = NdbSqlUtil::Type::Bigunsigned, ExtFloat = NdbSqlUtil::Type::Float, ExtDouble = NdbSqlUtil::Type::Double, - ExtDecimal = NdbSqlUtil::Type::Decimal, + ExtOlddecimal = NdbSqlUtil::Type::Olddecimal, + ExtOlddecimalunsigned = NdbSqlUtil::Type::Olddecimalunsigned, ExtChar = NdbSqlUtil::Type::Char, ExtVarchar = NdbSqlUtil::Type::Varchar, ExtBinary = NdbSqlUtil::Type::Binary, @@ -411,9 +412,20 @@ public: AttributeSize = DictTabInfo::a64Bit; AttributeArraySize = AttributeExtLength; return true; - case DictTabInfo::ExtDecimal: - // not yet implemented anywhere - break; + case DictTabInfo::ExtOlddecimal: + AttributeType = DictTabInfo::StringType; + AttributeSize = DictTabInfo::an8Bit; + AttributeArraySize = + (1 + AttributeExtPrecision + (int(AttributeExtScale) > 0)) * + AttributeExtLength; + return true; + case DictTabInfo::ExtOlddecimalunsigned: + AttributeType = DictTabInfo::StringType; + AttributeSize = DictTabInfo::an8Bit; + AttributeArraySize = + (0 + AttributeExtPrecision + (int(AttributeExtScale) > 0)) * + AttributeExtLength; + return true; case DictTabInfo::ExtChar: case DictTabInfo::ExtBinary: AttributeType = DictTabInfo::StringType; diff --git a/ndb/include/ndbapi/NdbDictionary.hpp b/ndb/include/ndbapi/NdbDictionary.hpp index 49afbd695c9..6aa675a2319 100644 --- a/ndb/include/ndbapi/NdbDictionary.hpp +++ b/ndb/include/ndbapi/NdbDictionary.hpp @@ -179,7 +179,7 @@ public: Bigunsigned, ///< 64 Bit. 8 byte signed integer, can be used in array Float, ///< 32-bit float. 4 bytes float, can be used in array Double, ///< 64-bit float. 8 byte float, can be used in array - Decimal, ///< Precision, Scale are applicable + Olddecimal, ///< MySQL < 5.0 signed decimal, Precision, Scale Char, ///< Len. A fixed array of 1-byte chars Varchar, ///< Max len Binary, ///< Len @@ -190,7 +190,8 @@ public: Text, ///< Text blob Time = 25, ///< Time without date Year = 26, ///< Year 1901-2155 (1 byte) - Timestamp = 27 ///< Unix time + Timestamp = 27, ///< Unix time + Olddecimalunsigned = 28 }; /** @@ -276,25 +277,25 @@ public: /** * Set precision of column. - * @note Only applicable for builtin type Decimal + * @note Only applicable for decimal types */ void setPrecision(int); /** * Get precision of column. - * @note Only applicable for builtin type Decimal + * @note Only applicable for decimal types */ int getPrecision() const; /** * Set scale of column. - * @note Only applicable for builtin type Decimal + * @note Only applicable for decimal types */ void setScale(int); /** * Get scale of column. - * @note Only applicable for builtin type Decimal + * @note Only applicable for decimal types */ int getScale() const; diff --git a/ndb/include/util/NdbSqlUtil.hpp b/ndb/include/util/NdbSqlUtil.hpp index 3787814052a..5b27bd4e0c4 100644 --- a/ndb/include/util/NdbSqlUtil.hpp +++ b/ndb/include/util/NdbSqlUtil.hpp @@ -75,7 +75,7 @@ public: Bigunsigned, // 64 Bit Float, // 32-bit float Double, // 64-bit float - Decimal, // Precision, Scale + Olddecimal, // Precision, Scale Char, // Len Varchar, // Max len Binary, // Len @@ -86,7 +86,8 @@ public: Text, // Text blob Time = 25, // Time without date Year = 26, // Year (size 1 byte) - Timestamp = 27 // Unix seconds (uint32) + Timestamp = 27, // Unix seconds (uint32) + Olddecimalunsigned = 28 }; Enum m_typeId; Cmp* m_cmp; // comparison method @@ -109,6 +110,11 @@ public: static bool usable_in_hash_index(Uint32 typeId, const void* cs); static bool usable_in_ordered_index(Uint32 typeId, const void* cs); + /** + * Compare decimal numbers. + */ + static int cmp_olddecimal(const uchar* s1, const uchar* s2, unsigned n); + private: /** * List of all types. Must match Type::Enum. @@ -129,7 +135,7 @@ private: static Cmp cmpBigunsigned; static Cmp cmpFloat; static Cmp cmpDouble; - static Cmp cmpDecimal; + static Cmp cmpOlddecimal; static Cmp cmpChar; static Cmp cmpVarchar; static Cmp cmpBinary; @@ -141,6 +147,7 @@ private: static Cmp cmpTime; static Cmp cmpYear; static Cmp cmpTimestamp; + static Cmp cmpOlddecimalunsigned; }; #endif diff --git a/ndb/src/common/util/NdbSqlUtil.cpp b/ndb/src/common/util/NdbSqlUtil.cpp index 53fa5d69215..c4114ad5ffa 100644 --- a/ndb/src/common/util/NdbSqlUtil.cpp +++ b/ndb/src/common/util/NdbSqlUtil.cpp @@ -76,117 +76,121 @@ NdbSqlUtil::char_like(const char* s1, unsigned n1, const NdbSqlUtil::Type NdbSqlUtil::m_typeList[] = { - { + { // 0 Type::Undefined, NULL }, - { + { // 1 Type::Tinyint, cmpTinyint }, - { + { // 2 Type::Tinyunsigned, cmpTinyunsigned }, - { + { // 3 Type::Smallint, cmpSmallint }, - { + { // 4 Type::Smallunsigned, cmpSmallunsigned }, - { + { // 5 Type::Mediumint, cmpMediumint }, - { + { // 6 Type::Mediumunsigned, cmpMediumunsigned }, - { + { // 7 Type::Int, cmpInt }, - { + { // 8 Type::Unsigned, cmpUnsigned }, - { + { // 9 Type::Bigint, cmpBigint }, - { + { // 10 Type::Bigunsigned, cmpBigunsigned }, - { + { // 11 Type::Float, cmpFloat }, - { + { // 12 Type::Double, cmpDouble }, - { - Type::Decimal, - NULL // cmpDecimal + { // 13 + Type::Olddecimal, + cmpOlddecimal }, - { + { // 14 Type::Char, cmpChar }, - { + { // 15 Type::Varchar, cmpVarchar }, - { + { // 16 Type::Binary, cmpBinary }, - { + { // 17 Type::Varbinary, cmpVarbinary }, - { + { // 18 Type::Datetime, cmpDatetime }, - { + { // 19 Type::Date, cmpDate }, - { + { // 20 Type::Blob, cmpBlob }, - { + { // 21 Type::Text, cmpText }, - { + { // 22 Type::Undefined, // 5.0 Bit NULL }, - { + { // 23 Type::Undefined, // 5.0 Longvarchar NULL }, - { + { // 24 Type::Undefined, // 5.0 Longvarbinary NULL }, - { + { // 25 Type::Time, cmpTime }, - { + { // 26 Type::Year, cmpYear }, - { + { // 27 Type::Timestamp, cmpTimestamp + }, + { // 28 + Type::Olddecimalunsigned, + cmpOlddecimalunsigned } }; @@ -411,12 +415,54 @@ NdbSqlUtil::cmpDouble(const void* info, const Uint32* p1, const Uint32* p2, Uint } int -NdbSqlUtil::cmpDecimal(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size) +NdbSqlUtil::cmp_olddecimal(const uchar* s1, const uchar* s2, unsigned n) +{ + int sgn = +1; + unsigned i = 0; + while (i < n) { + int c1 = s1[i]; + int c2 = s2[i]; + if (c1 == c2) { + if (c1 == '-') + sgn = -1; + } else if (c1 == '-') { + return -1; + } else if (c2 == '-') { + return +1; + } else if (c1 < c2) { + return -1 * sgn; + } else { + return +1 * sgn; + } + i++; + } + return 0; +} + +int +NdbSqlUtil::cmpOlddecimal(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size) { assert(full >= size && size > 0); - // not used by MySQL or NDB - assert(false); - return 0; + if (full == size) { + union { const Uint32* p; const uchar* v; } u1, u2; + u1.p = p1; + u2.p = p2; + return cmp_olddecimal(u1.v, u2.v, full << 2); + } + return CmpUnknown; +} + +int +NdbSqlUtil::cmpOlddecimalunsigned(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size) +{ + assert(full >= size && size > 0); + if (full == size) { + union { const Uint32* p; const uchar* v; } u1, u2; + u1.p = p1; + u2.p = p2; + return cmp_olddecimal(u1.v, u2.v, full << 2); + } + return CmpUnknown; } int diff --git a/ndb/src/ndbapi/NdbDictionary.cpp b/ndb/src/ndbapi/NdbDictionary.cpp index 58b35c6c306..00db5704949 100644 --- a/ndb/src/ndbapi/NdbDictionary.cpp +++ b/ndb/src/ndbapi/NdbDictionary.cpp @@ -918,8 +918,11 @@ operator<<(NdbOut& out, const NdbDictionary::Column& col) case NdbDictionary::Column::Double: out << "Double"; break; - case NdbDictionary::Column::Decimal: - out << "Decimal(" << col.getScale() << "," << col.getPrecision() << ")"; + case NdbDictionary::Column::Olddecimal: + out << "Olddecimal(" << col.getPrecision() << "," << col.getScale() << ")"; + break; + case NdbDictionary::Column::Olddecimalunsigned: + out << "Olddecimalunsigned(" << col.getPrecision() << "," << col.getScale() << ")"; break; case NdbDictionary::Column::Char: out << "Char(" << col.getLength() << ";" << csname << ")"; diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp index 530f15d3a2e..b9ae13a93ec 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -114,7 +114,8 @@ NdbColumnImpl::init(Type t) m_length = 1; m_cs = NULL; break; - case Decimal: + case Olddecimal: + case Olddecimalunsigned: m_precision = 10; m_scale = 0; m_length = 1; @@ -1176,7 +1177,8 @@ columnTypeMapping[] = { { DictTabInfo::ExtBigunsigned, NdbDictionary::Column::Bigunsigned }, { DictTabInfo::ExtFloat, NdbDictionary::Column::Float }, { DictTabInfo::ExtDouble, NdbDictionary::Column::Double }, - { DictTabInfo::ExtDecimal, NdbDictionary::Column::Decimal }, + { DictTabInfo::ExtOlddecimal, NdbDictionary::Column::Olddecimal }, + { DictTabInfo::ExtOlddecimalunsigned, NdbDictionary::Column::Olddecimalunsigned }, { DictTabInfo::ExtChar, NdbDictionary::Column::Char }, { DictTabInfo::ExtVarchar, NdbDictionary::Column::Varchar }, { DictTabInfo::ExtBinary, NdbDictionary::Column::Binary }, diff --git a/ndb/src/ndbapi/NdbRecAttr.cpp b/ndb/src/ndbapi/NdbRecAttr.cpp index 9c9a9cea8da..db83e9c5fcf 100644 --- a/ndb/src/ndbapi/NdbRecAttr.cpp +++ b/ndb/src/ndbapi/NdbRecAttr.cpp @@ -156,7 +156,8 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r) return out; } - uint length = r.getColumn()->getLength(); + const NdbDictionary::Column* c = r.getColumn(); + uint length = c->getLength(); if (length > 1) out << "["; @@ -208,6 +209,18 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r) case NdbDictionary::Column::Double: out << r.double_value(); break; + case NdbDictionary::Column::Olddecimal: + { + short len = 1 + c->getPrecision() + (c->getScale() > 0); + out.print("%.*s", len, r.aRef()); + } + break; + case NdbDictionary::Column::Olddecimalunsigned: + { + short len = 0 + c->getPrecision() + (c->getScale() > 0); + out.print("%.*s", len, r.aRef()); + } + break; // for dates cut-and-paste from field.cc case NdbDictionary::Column::Datetime: { diff --git a/ndb/test/include/NdbSchemaOp.hpp b/ndb/test/include/NdbSchemaOp.hpp index 77e704c0e5c..e8ab542b00a 100644 --- a/ndb/test/include/NdbSchemaOp.hpp +++ b/ndb/test/include/NdbSchemaOp.hpp @@ -567,7 +567,8 @@ convertColumnTypeToAttrType(NdbDictionary::Column::Type _type) case NdbDictionary::Column::Unsigned: return UnSigned; case NdbDictionary::Column::Float: - case NdbDictionary::Column::Decimal: + case NdbDictionary::Column::Olddecimal: + case NdbDictionary::Column::Olddecimalunsigned: case NdbDictionary::Column::Double: return Float; case NdbDictionary::Column::Char: diff --git a/ndb/tools/restore/consumer.cpp b/ndb/tools/restore/consumer.cpp index 4d228230423..ecbdbbf8f4e 100644 --- a/ndb/tools/restore/consumer.cpp +++ b/ndb/tools/restore/consumer.cpp @@ -44,9 +44,12 @@ BackupConsumer::create_table_string(const TableS & table, case NdbDictionary::Column::Float: pos += sprintf(buf+pos, "%s", "float"); break; - case NdbDictionary::Column::Decimal: + case NdbDictionary::Column::Olddecimal: pos += sprintf(buf+pos, "%s", "decimal"); break; + case NdbDictionary::Column::Olddecimalunsigned: + pos += sprintf(buf+pos, "%s", "decimal unsigned"); + break; case NdbDictionary::Column::Char: pos += sprintf(buf+pos, "%s", "char"); break; diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 9e34baae198..47cca937544 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -2276,10 +2276,14 @@ void ha_ndbcluster::print_results() fprintf(DBUG_FILE, "Double\t%f", value); break; } - case NdbDictionary::Column::Decimal: { + case NdbDictionary::Column::Olddecimal: { char *value= field->ptr; - - fprintf(DBUG_FILE, "Decimal\t'%-*s'", field->pack_length(), value); + fprintf(DBUG_FILE, "Olddecimal\t'%-*s'", field->pack_length(), value); + break; + } + case NdbDictionary::Column::Olddecimalunsigned: { + char *value= field->ptr; + fprintf(DBUG_FILE, "Olddecimalunsigned\t'%-*s'", field->pack_length(), value); break; } case NdbDictionary::Column::Char:{ @@ -3312,10 +3316,6 @@ static int create_ndb_column(NDBCOL &col, const enum enum_field_types mysql_type= field->real_type(); switch (mysql_type) { // Numeric types - case MYSQL_TYPE_DECIMAL: - col.setType(NDBCOL::Char); - col.setLength(field->pack_length()); - break; case MYSQL_TYPE_TINY: if (field->flags & UNSIGNED_FLAG) col.setType(NDBCOL::Tinyunsigned); @@ -3359,6 +3359,26 @@ static int create_ndb_column(NDBCOL &col, col.setType(NDBCOL::Double); col.setLength(1); break; + case MYSQL_TYPE_DECIMAL: + { + Field_decimal *f= (Field_decimal*)field; + uint precision= f->pack_length(); + uint scale= f->decimals(); + if (field->flags & UNSIGNED_FLAG) + { + col.setType(NDBCOL::Olddecimalunsigned); + precision-= (scale > 0); + } + else + { + col.setType(NDBCOL::Olddecimal); + precision-= 1 + (scale > 0); + } + col.setPrecision(precision); + col.setScale(scale); + col.setLength(1); + } + break; // Date types case MYSQL_TYPE_DATETIME: col.setType(NDBCOL::Datetime); From 1f6617562a5e9e22c0964abb08afb20288dd626d Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Feb 2005 14:59:17 +0100 Subject: [PATCH 3/8] ndb - post-merge fixes ndb/include/ndb_constants.h: post-merge fixes ndb/include/ndbapi/NdbDictionary.hpp: post-merge fixes ndb/src/common/util/NdbSqlUtil.cpp: post-merge fixes ndb/test/src/HugoCalculator.cpp: post-merge fixes --- ndb/include/ndb_constants.h | 5 +++-- ndb/include/ndbapi/NdbDictionary.hpp | 3 +-- ndb/src/common/util/NdbSqlUtil.cpp | 1 + ndb/test/src/HugoCalculator.cpp | 3 ++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ndb/include/ndb_constants.h b/ndb/include/ndb_constants.h index da3fc2cbdd8..36d7ec95b3e 100644 --- a/ndb/include/ndb_constants.h +++ b/ndb/include/ndb_constants.h @@ -48,7 +48,7 @@ #define NDB_TYPE_BIGUNSIGNED 10 #define NDB_TYPE_FLOAT 11 #define NDB_TYPE_DOUBLE 12 -#define NDB_TYPE_DECIMAL 13 /* not used */ +#define NDB_TYPE_OLDDECIMAL 13 #define NDB_TYPE_CHAR 14 #define NDB_TYPE_VARCHAR 15 #define NDB_TYPE_BINARY 16 @@ -63,7 +63,8 @@ #define NDB_TYPE_TIME 25 #define NDB_TYPE_YEAR 26 #define NDB_TYPE_TIMESTAMP 27 +#define NDB_TYPE_OLDDECIMALUNSIGNED 28 -#define NDB_TYPE_MAX 28 +#define NDB_TYPE_MAX 29 #endif diff --git a/ndb/include/ndbapi/NdbDictionary.hpp b/ndb/include/ndbapi/NdbDictionary.hpp index 391f0374afc..26f0e71b25c 100644 --- a/ndb/include/ndbapi/NdbDictionary.hpp +++ b/ndb/include/ndbapi/NdbDictionary.hpp @@ -184,9 +184,8 @@ public: Bigunsigned = NDB_TYPE_BIGUNSIGNED, ///< 64 Bit. 8 byte signed integer, can be used in array Float = NDB_TYPE_FLOAT, ///< 32-bit float. 4 bytes float, can be used in array Double = NDB_TYPE_DOUBLE, ///< 64-bit float. 8 byte float, can be used in array - Decimal = NDB_TYPE_DECIMAL, ///< Precision, Scale are applicable Olddecimal = NDB_TYPE_OLDDECIMAL, ///< MySQL < 5.0 signed decimal, Precision, Scale - Olddecimalunsigned = NDB_TYPE_OLDDECIMAL_UNSIGNED, + Olddecimalunsigned = NDB_TYPE_OLDDECIMALUNSIGNED, Char = NDB_TYPE_CHAR, ///< Len. A fixed array of 1-byte chars Varchar = NDB_TYPE_VARCHAR, ///< Length bytes: 1, Max: 255 Binary = NDB_TYPE_BINARY, ///< Len diff --git a/ndb/src/common/util/NdbSqlUtil.cpp b/ndb/src/common/util/NdbSqlUtil.cpp index 08a436e13f7..2686ad5c05f 100644 --- a/ndb/src/common/util/NdbSqlUtil.cpp +++ b/ndb/src/common/util/NdbSqlUtil.cpp @@ -434,6 +434,7 @@ NdbSqlUtil::cmpDouble(const void* info, const void* p1, unsigned n1, const void* return CmpUnknown; } +int NdbSqlUtil::cmp_olddecimal(const uchar* s1, const uchar* s2, unsigned n) { int sgn = +1; diff --git a/ndb/test/src/HugoCalculator.cpp b/ndb/test/src/HugoCalculator.cpp index 44edb34295a..0a5b9c342c8 100644 --- a/ndb/test/src/HugoCalculator.cpp +++ b/ndb/test/src/HugoCalculator.cpp @@ -145,7 +145,8 @@ HugoCalculator::calcValue(int record, case NdbDictionary::Column::Bigunsigned: case NdbDictionary::Column::Float: case NdbDictionary::Column::Double: - case NdbDictionary::Column::Decimal: + case NdbDictionary::Column::Olddecimal: + case NdbDictionary::Column::Olddecimalunsigned: case NdbDictionary::Column::Binary: case NdbDictionary::Column::Datetime: case NdbDictionary::Column::Time: From 0f466d046cae40468492dbe41ccb1c54a5509418 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Feb 2005 16:06:41 +0100 Subject: [PATCH 4/8] Fixed BUG#8540: Local variable overrides an alias. mysql-test/r/sp.result: New test case for BUG#8540. mysql-test/t/sp.test: New test case for BUG#8540. sql/item.h: Use the existing name (if any) for a SP local variable (to get the correct field name in a select in the case of an alias). --- mysql-test/r/sp.result | 10 ++++++++++ mysql-test/t/sp.test | 16 ++++++++++++++++ sql/item.h | 5 ++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 0af6b821ce0..05803e57ba0 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -2059,6 +2059,16 @@ call bug6029()| 1136 drop procedure bug6029| drop table t3| +drop procedure if exists bug8540| +create procedure bug8540() +begin +declare x int default 1; +select x as y, x+0 as z; +end| +call bug8540()| +y z +1 1 +drop procedure bug8540| drop table if exists fac| create table fac (n int unsigned not null primary key, f bigint unsigned)| drop procedure if exists ifac| diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index bdc5ec0dc22..8b59af6e494 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -2520,6 +2520,22 @@ call bug6029()| drop procedure bug6029| drop table t3| +# +# BUG#8540: Local variable overrides an alias +# +--disable_warnings +drop procedure if exists bug8540| +--enable_warnings + +create procedure bug8540() +begin + declare x int default 1; + select x as y, x+0 as z; +end| + +call bug8540()| +drop procedure bug8540| + # # Some "real" examples diff --git a/sql/item.h b/sql/item.h index 299bc6c081b..7d9526b53a8 100644 --- a/sql/item.h +++ b/sql/item.h @@ -460,7 +460,10 @@ public: { Item *it= this_item(); - it->set_name(m_name.str, m_name.length, system_charset_info); + if (name) + it->set_name(name, strlen(name), system_charset_info); + else + it->set_name(m_name.str, m_name.length, system_charset_info); it->make_field(field); } From eab44eaaca1f0f7cb1b88cc979591fa21cbed78f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Feb 2005 16:05:18 +0000 Subject: [PATCH 5/8] Bug#4445 Make a more informative platform info for Windows --- include/config-win.h | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/include/config-win.h b/include/config-win.h index 152e85c8e68..42aa23c3afe 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -23,18 +23,25 @@ #include #include -#if defined(__NT__) -#define SYSTEM_TYPE "NT" -#elif defined(__WIN2000__) -#define SYSTEM_TYPE "WIN2000" +#if defined(_WIN64) || defined(WIN64) +#define SYSTEM_TYPE "Win64" +#elif defined(_WIN32) || defined(WIN32) +#define SYSTEM_TYPE "Win32" #else -#define SYSTEM_TYPE "Win95/Win98" +#define SYSTEM_TYPE "Windows" #endif -#if defined(_WIN64) || defined(WIN64) -#define MACHINE_TYPE "ia64" /* Define to machine type name */ +#if defined(_M_IA64) +#define MACHINE_TYPE "ia64" +#elif defined(_M_IX86) +#define MACHINE_TYPE "ia32" +#elif defined(_M_ALPHA) +#define MACHINE_TYPE "axp" #else -#define MACHINE_TYPE "i32" /* Define to machine type name */ +#define MACHINE_TYPE "unknown" /* Define to machine type name */ +#endif + +#if !(defined(_WIN64) || defined(WIN64)) #ifndef _WIN32 #define _WIN32 /* Compatible with old source */ #endif From 3b592d3273eeae7610d20940bf86145010047e8a Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Feb 2005 17:10:17 +0100 Subject: [PATCH 6/8] ndb - temp: comment out decimal tests t/ndb* mysql-test/r/ndb_index_ordered.result: temp: comment out decimal mysql-test/t/ndb_index_ordered.test: temp: comment out decimal --- mysql-test/r/ndb_index_ordered.result | 83 ----------------------- mysql-test/t/ndb_index_ordered.test | 96 +++++++++++++-------------- 2 files changed, 48 insertions(+), 131 deletions(-) diff --git a/mysql-test/r/ndb_index_ordered.result b/mysql-test/r/ndb_index_ordered.result index 212c843cc44..9aa7559d660 100644 --- a/mysql-test/r/ndb_index_ordered.result +++ b/mysql-test/r/ndb_index_ordered.result @@ -554,89 +554,6 @@ select count(*)-9 from t1 use index (ts) where ts <= '2001-01-01 23:59:59'; count(*)-9 0 drop table t1; -create table t1 ( -a int primary key, -s decimal(12), -t decimal(12, 5), -u decimal(12) unsigned, -v decimal(12, 5) unsigned, -key (s), -key (t), -key (u), -key (v) -) engine=ndb; -insert into t1 values -( 0, -000000000007, -0000061.00003, 000000000061, 0000965.00042), -( 1, -000000000007, -0000061.00042, 000000000061, 0000965.00003), -( 2, -071006035767, 4210253.00024, 000000000001, 0000001.84488), -( 3, 000000007115, 0000000.77607, 000077350625, 0000018.00013), -( 4, -000000068391, -0346486.00000, 000000005071, 0005334.00002), -( 5, -521579890459, -1936874.00001, 000000000154, 0000003.00018), -( 6, -521579890459, -1936874.00018, 000000000154, 0000003.00001), -( 7, 000000000333, 0000051.39140, 000000907958, 0788643.08374), -( 8, 000042731229, 0000009.00000, 000000000009, 6428667.00000), -( 9, -000008159769, 0000918.00004, 000096951421, 7607730.00008); -select count(*)- 5 from t1 use index (s) where s < -000000000007; -count(*)- 5 -0 -select count(*)- 7 from t1 use index (s) where s <= -000000000007; -count(*)- 7 -0 -select count(*)- 2 from t1 use index (s) where s = -000000000007; -count(*)- 2 -0 -select count(*)- 5 from t1 use index (s) where s >= -000000000007; -count(*)- 5 -0 -select count(*)- 3 from t1 use index (s) where s > -000000000007; -count(*)- 3 -0 -select count(*)- 4 from t1 use index (t) where t < -0000061.00003; -count(*)- 4 -0 -select count(*)- 5 from t1 use index (t) where t <= -0000061.00003; -count(*)- 5 -0 -select count(*)- 1 from t1 use index (t) where t = -0000061.00003; -count(*)- 1 -0 -select count(*)- 6 from t1 use index (t) where t >= -0000061.00003; -count(*)- 6 -0 -select count(*)- 5 from t1 use index (t) where t > -0000061.00003; -count(*)- 5 -0 -select count(*)- 2 from t1 use index (u) where u < 000000000061; -count(*)- 2 -0 -select count(*)- 4 from t1 use index (u) where u <= 000000000061; -count(*)- 4 -0 -select count(*)- 2 from t1 use index (u) where u = 000000000061; -count(*)- 2 -0 -select count(*)- 8 from t1 use index (u) where u >= 000000000061; -count(*)- 8 -0 -select count(*)- 6 from t1 use index (u) where u > 000000000061; -count(*)- 6 -0 -select count(*)- 5 from t1 use index (v) where v < 0000965.00042; -count(*)- 5 -0 -select count(*)- 6 from t1 use index (v) where v <= 0000965.00042; -count(*)- 6 -0 -select count(*)- 1 from t1 use index (v) where v = 0000965.00042; -count(*)- 1 -0 -select count(*)- 5 from t1 use index (v) where v >= 0000965.00042; -count(*)- 5 -0 -select count(*)- 4 from t1 use index (v) where v > 0000965.00042; -count(*)- 4 -0 -drop table t1; create table t1(a int primary key, b int not null, index(b)); insert into t1 values (1,1), (2,2); set autocommit=0; diff --git a/mysql-test/t/ndb_index_ordered.test b/mysql-test/t/ndb_index_ordered.test index 2ebf06b78a8..1e07ca93c30 100644 --- a/mysql-test/t/ndb_index_ordered.test +++ b/mysql-test/t/ndb_index_ordered.test @@ -282,55 +282,55 @@ drop table t1; # decimal (not the new 5.0 thing) -create table t1 ( - a int primary key, - s decimal(12), - t decimal(12, 5), - u decimal(12) unsigned, - v decimal(12, 5) unsigned, - key (s), - key (t), - key (u), - key (v) -) engine=ndb; +#create table t1 ( +# a int primary key, +# s decimal(12), +# t decimal(12, 5), +# u decimal(12) unsigned, +# v decimal(12, 5) unsigned, +# key (s), +# key (t), +# key (u), +# key (v) +#) engine=ndb; +## +#insert into t1 values +# ( 0, -000000000007, -0000061.00003, 000000000061, 0000965.00042), +# ( 1, -000000000007, -0000061.00042, 000000000061, 0000965.00003), +# ( 2, -071006035767, 4210253.00024, 000000000001, 0000001.84488), +# ( 3, 000000007115, 0000000.77607, 000077350625, 0000018.00013), +# ( 4, -000000068391, -0346486.00000, 000000005071, 0005334.00002), +# ( 5, -521579890459, -1936874.00001, 000000000154, 0000003.00018), +# ( 6, -521579890459, -1936874.00018, 000000000154, 0000003.00001), +# ( 7, 000000000333, 0000051.39140, 000000907958, 0788643.08374), +# ( 8, 000042731229, 0000009.00000, 000000000009, 6428667.00000), +# ( 9, -000008159769, 0000918.00004, 000096951421, 7607730.00008); +## +#select count(*)- 5 from t1 use index (s) where s < -000000000007; +#select count(*)- 7 from t1 use index (s) where s <= -000000000007; +#select count(*)- 2 from t1 use index (s) where s = -000000000007; +#select count(*)- 5 from t1 use index (s) where s >= -000000000007; +#select count(*)- 3 from t1 use index (s) where s > -000000000007; +## +#select count(*)- 4 from t1 use index (t) where t < -0000061.00003; +#select count(*)- 5 from t1 use index (t) where t <= -0000061.00003; +#select count(*)- 1 from t1 use index (t) where t = -0000061.00003; +#select count(*)- 6 from t1 use index (t) where t >= -0000061.00003; +#select count(*)- 5 from t1 use index (t) where t > -0000061.00003; +## +#select count(*)- 2 from t1 use index (u) where u < 000000000061; +#select count(*)- 4 from t1 use index (u) where u <= 000000000061; +#select count(*)- 2 from t1 use index (u) where u = 000000000061; +#select count(*)- 8 from t1 use index (u) where u >= 000000000061; +#select count(*)- 6 from t1 use index (u) where u > 000000000061; +## +#select count(*)- 5 from t1 use index (v) where v < 0000965.00042; +#select count(*)- 6 from t1 use index (v) where v <= 0000965.00042; +#select count(*)- 1 from t1 use index (v) where v = 0000965.00042; +#select count(*)- 5 from t1 use index (v) where v >= 0000965.00042; +#select count(*)- 4 from t1 use index (v) where v > 0000965.00042; # -insert into t1 values - ( 0, -000000000007, -0000061.00003, 000000000061, 0000965.00042), - ( 1, -000000000007, -0000061.00042, 000000000061, 0000965.00003), - ( 2, -071006035767, 4210253.00024, 000000000001, 0000001.84488), - ( 3, 000000007115, 0000000.77607, 000077350625, 0000018.00013), - ( 4, -000000068391, -0346486.00000, 000000005071, 0005334.00002), - ( 5, -521579890459, -1936874.00001, 000000000154, 0000003.00018), - ( 6, -521579890459, -1936874.00018, 000000000154, 0000003.00001), - ( 7, 000000000333, 0000051.39140, 000000907958, 0788643.08374), - ( 8, 000042731229, 0000009.00000, 000000000009, 6428667.00000), - ( 9, -000008159769, 0000918.00004, 000096951421, 7607730.00008); -# -select count(*)- 5 from t1 use index (s) where s < -000000000007; -select count(*)- 7 from t1 use index (s) where s <= -000000000007; -select count(*)- 2 from t1 use index (s) where s = -000000000007; -select count(*)- 5 from t1 use index (s) where s >= -000000000007; -select count(*)- 3 from t1 use index (s) where s > -000000000007; -# -select count(*)- 4 from t1 use index (t) where t < -0000061.00003; -select count(*)- 5 from t1 use index (t) where t <= -0000061.00003; -select count(*)- 1 from t1 use index (t) where t = -0000061.00003; -select count(*)- 6 from t1 use index (t) where t >= -0000061.00003; -select count(*)- 5 from t1 use index (t) where t > -0000061.00003; -# -select count(*)- 2 from t1 use index (u) where u < 000000000061; -select count(*)- 4 from t1 use index (u) where u <= 000000000061; -select count(*)- 2 from t1 use index (u) where u = 000000000061; -select count(*)- 8 from t1 use index (u) where u >= 000000000061; -select count(*)- 6 from t1 use index (u) where u > 000000000061; -# -select count(*)- 5 from t1 use index (v) where v < 0000965.00042; -select count(*)- 6 from t1 use index (v) where v <= 0000965.00042; -select count(*)- 1 from t1 use index (v) where v = 0000965.00042; -select count(*)- 5 from t1 use index (v) where v >= 0000965.00042; -select count(*)- 4 from t1 use index (v) where v > 0000965.00042; - -drop table t1; +#drop table t1; # bug#7798 create table t1(a int primary key, b int not null, index(b)); From 4d9e12438250c1a9d9b624746dca468d69b4a2b7 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Feb 2005 20:37:14 +0100 Subject: [PATCH 7/8] removed NdbMgmHandle from TransporterRegistry constructor changed to set NdbMgmHandle from IPPConfig, and use info from configuration, instead of mgm handle from config retrieval ndb/src/ndbapi/Ndb.cpp: added som debug printout ndb/src/ndbapi/NdbTransaction.cpp: added some debug printout --- .../transporter/TransporterRegistry.hpp | 5 +- ndb/src/common/mgmcommon/IPCConfig.cpp | 29 +++++++++ .../transporter/TransporterRegistry.cpp | 60 ++++++++++++------- ndb/src/kernel/main.cpp | 4 -- ndb/src/mgmsrv/MgmtSrvr.cpp | 2 +- ndb/src/ndbapi/Ndb.cpp | 4 +- ndb/src/ndbapi/NdbTransaction.cpp | 8 ++- ndb/src/ndbapi/TransporterFacade.cpp | 5 +- ndb/src/ndbapi/TransporterFacade.hpp | 3 +- ndb/src/ndbapi/ndb_cluster_connection.cpp | 2 +- 10 files changed, 82 insertions(+), 40 deletions(-) diff --git a/ndb/include/transporter/TransporterRegistry.hpp b/ndb/include/transporter/TransporterRegistry.hpp index 3773a0fc686..15f16320619 100644 --- a/ndb/include/transporter/TransporterRegistry.hpp +++ b/ndb/include/transporter/TransporterRegistry.hpp @@ -97,12 +97,11 @@ public: /** * Constructor */ - TransporterRegistry(NdbMgmHandle mgm_handle=NULL, - void * callback = 0 , + TransporterRegistry(void * callback = 0 , unsigned maxTransporters = MAX_NTRANSPORTERS, unsigned sizeOfLongSignalMemory = 100); - void set_mgm_handle(NdbMgmHandle h) { m_mgm_handle = h; }; + void set_mgm_handle(NdbMgmHandle h); NdbMgmHandle get_mgm_handle(void) { return m_mgm_handle; }; bool init(NodeId localNodeId); diff --git a/ndb/src/common/mgmcommon/IPCConfig.cpp b/ndb/src/common/mgmcommon/IPCConfig.cpp index af24e738e05..f188a433f1b 100644 --- a/ndb/src/common/mgmcommon/IPCConfig.cpp +++ b/ndb/src/common/mgmcommon/IPCConfig.cpp @@ -170,6 +170,35 @@ IPCConfig::configureTransporters(Uint32 nodeId, DBUG_ENTER("IPCConfig::configureTransporters"); + /** + * Iterate over all MGM's an construct a connectstring + * create mgm_handle and give it to the Transporter Registry + */ + { + const char *separator= ""; + BaseString connect_string; + ndb_mgm_configuration_iterator iter(config, CFG_SECTION_NODE); + for(iter.first(); iter.valid(); iter.next()) + { + Uint32 type; + if(iter.get(CFG_TYPE_OF_SECTION, &type)) continue; + if(type != NODE_TYPE_MGM) continue; + const char* hostname; + Uint32 port; + if(iter.get(CFG_NODE_HOST, &hostname)) continue; + if( strlen(hostname) == 0 ) continue; + if(iter.get(CFG_MGM_PORT, &port)) continue; + connect_string.appfmt("%s%s:port",separator,hostname,port); + separator= ","; + } + NdbMgmHandle h= ndb_mgm_create_handle(); + if ( h && connect_string.length() > 0 ) + { + ndb_mgm_set_connectstring(h,connect_string.c_str()); + tr.set_mgm_handle(h); + } + } + Uint32 noOfTransportersCreated= 0; ndb_mgm_configuration_iterator iter(config, CFG_SECTION_CONNECTION); diff --git a/ndb/src/common/transporter/TransporterRegistry.cpp b/ndb/src/common/transporter/TransporterRegistry.cpp index f07deafc98d..f489d12f91a 100644 --- a/ndb/src/common/transporter/TransporterRegistry.cpp +++ b/ndb/src/common/transporter/TransporterRegistry.cpp @@ -71,15 +71,14 @@ SocketServer::Session * TransporterService::newSession(NDB_SOCKET_TYPE sockfd) DBUG_RETURN(0); } -TransporterRegistry::TransporterRegistry(NdbMgmHandle mgm_handle, - void * callback, +TransporterRegistry::TransporterRegistry(void * callback, unsigned _maxTransporters, unsigned sizeOfLongSignalMemory) { nodeIdSpecified = false; maxTransporters = _maxTransporters; sendCounter = 1; - m_mgm_handle = mgm_handle; + m_mgm_handle= 0; callbackObj=callback; @@ -114,6 +113,27 @@ TransporterRegistry::TransporterRegistry(NdbMgmHandle mgm_handle, theOSEJunkSocketRecv = 0; } +void TransporterRegistry::set_mgm_handle(NdbMgmHandle h) +{ + DBUG_ENTER("TransporterRegistry::set_mgm_handle"); + if (m_mgm_handle) + ndb_mgm_destroy_handle(&m_mgm_handle); + m_mgm_handle= h; +#ifndef DBUG_OFF + if (h) + { + char buf[256]; + DBUG_PRINT("info",("handle set with connectstring: %s", + ndb_mgm_get_connectstring(h,buf, sizeof(buf)))); + } + else + { + DBUG_PRINT("info",("handle set to NULL")); + } +#endif + DBUG_VOID_RETURN; +}; + TransporterRegistry::~TransporterRegistry() { removeAll(); @@ -134,6 +154,8 @@ TransporterRegistry::~TransporterRegistry() { theOSEReceiver = 0; } #endif + if (m_mgm_handle) + ndb_mgm_destroy_handle(&m_mgm_handle); } void @@ -1211,40 +1233,32 @@ TransporterRegistry::start_clients_thread() switch(performStates[nodeId]){ case CONNECTING: if(!t->isConnected() && !t->isServer) { - int result= 0; + bool connected= false; /** * First, we try to connect (if we have a port number). */ if (t->get_s_port()) - result= t->connect_client(); + connected= t->connect_client(); - - if (result<0 && t->get_s_port()!=0) - g_eventLogger.warning("Error while trying to make connection " - "(Node %u to %u via port %u) " - "error: %d. Retrying...", - t->getRemoteNodeId(), - t->getLocalNodeId(), - t->get_s_port()); - /** * If dynamic, get the port for connecting from the management server */ - if(t->get_s_port() <= 0) { // Port is dynamic + if( !connected && t->get_s_port() <= 0) { // Port is dynamic int server_port= 0; struct ndb_mgm_reply mgm_reply; - int res; + int res= -1; if(!ndb_mgm_is_connected(m_mgm_handle)) if(ndb_mgm_connect(m_mgm_handle, 0, 0, 0)<0) ndbout_c("Failed to reconnect to management server"); - - res= ndb_mgm_get_connection_int_parameter(m_mgm_handle, - t->getRemoteNodeId(), - t->getLocalNodeId(), - CFG_CONNECTION_SERVER_PORT, - &server_port, - &mgm_reply); + else + res= + ndb_mgm_get_connection_int_parameter(m_mgm_handle, + t->getRemoteNodeId(), + t->getLocalNodeId(), + CFG_CONNECTION_SERVER_PORT, + &server_port, + &mgm_reply); DBUG_PRINT("info",("Got dynamic port %d for %d -> %d (ret: %d)", server_port,t->getRemoteNodeId(), t->getLocalNodeId(),res)); diff --git a/ndb/src/kernel/main.cpp b/ndb/src/kernel/main.cpp index b511f003429..4bc99c61f69 100644 --- a/ndb/src/kernel/main.cpp +++ b/ndb/src/kernel/main.cpp @@ -92,10 +92,6 @@ int main(int argc, char** argv) } } - globalTransporterRegistry.set_mgm_handle(theConfig - ->get_config_retriever() - ->get_mgmHandle()); - #ifndef NDB_WIN32 for(pid_t child = fork(); child != 0; child = fork()){ /** diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp index c584356927b..cf98f3a09ae 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -576,7 +576,7 @@ MgmtSrvr::start(BaseString &error_string) } } theFacade= TransporterFacade::theFacadeInstance - = new TransporterFacade(m_config_retriever->get_mgmHandle()); + = new TransporterFacade(); if(theFacade == 0) { DEBUG("MgmtSrvr.cpp: theFacade is NULL."); diff --git a/ndb/src/ndbapi/Ndb.cpp b/ndb/src/ndbapi/Ndb.cpp index 59d1e45ca46..b047ae1bd1a 100644 --- a/ndb/src/ndbapi/Ndb.cpp +++ b/ndb/src/ndbapi/Ndb.cpp @@ -84,7 +84,9 @@ NdbTransaction* Ndb::doConnect(Uint32 tConNode) } else if (TretCode != 0) { tAnyAlive= 1; }//if - DBUG_PRINT("info",("tried node %d TretCode %d", tNode, TretCode)); + DBUG_PRINT("info",("tried node %d, TretCode %d, error code %d, %s", + tNode, TretCode, getNdbError().code, + getNdbError().message)); } } else // just do a regular round robin diff --git a/ndb/src/ndbapi/NdbTransaction.cpp b/ndb/src/ndbapi/NdbTransaction.cpp index ab6c0ca3e38..67581e4a0f8 100644 --- a/ndb/src/ndbapi/NdbTransaction.cpp +++ b/ndb/src/ndbapi/NdbTransaction.cpp @@ -1420,14 +1420,18 @@ Remark: Sets TC Connect pointer. int NdbTransaction::receiveTCSEIZEREF(NdbApiSignal* aSignal) { + DBUG_ENTER("NdbTransaction::receiveTCSEIZEREF"); if (theStatus != Connecting) { - return -1; + DBUG_RETURN(-1); } else { theStatus = ConnectFailure; theNdb->theError.code = aSignal->readData(2); - return 0; + DBUG_PRINT("info",("error code %d, %s", + theNdb->getNdbError().code, + theNdb->getNdbError().message)); + DBUG_RETURN(0); } }//NdbTransaction::receiveTCSEIZEREF() diff --git a/ndb/src/ndbapi/TransporterFacade.cpp b/ndb/src/ndbapi/TransporterFacade.cpp index 5b5394f0965..7f1e68a42d3 100644 --- a/ndb/src/ndbapi/TransporterFacade.cpp +++ b/ndb/src/ndbapi/TransporterFacade.cpp @@ -466,8 +466,7 @@ void TransporterFacade::threadMainReceive(void) theTransporterRegistry->stopReceiving(); } -TransporterFacade::TransporterFacade(NdbMgmHandle mgm_handle) : - m_mgm_handle(mgm_handle), +TransporterFacade::TransporterFacade() : theTransporterRegistry(0), theStopReceive(0), theSendThread(NULL), @@ -496,7 +495,7 @@ bool TransporterFacade::init(Uint32 nodeId, const ndb_mgm_configuration* props) { theOwnId = nodeId; - theTransporterRegistry = new TransporterRegistry(m_mgm_handle,this); + theTransporterRegistry = new TransporterRegistry(this); const int res = IPCConfig::configureTransporters(nodeId, * props, diff --git a/ndb/src/ndbapi/TransporterFacade.hpp b/ndb/src/ndbapi/TransporterFacade.hpp index bd3fc67a8d6..e74f4b51e00 100644 --- a/ndb/src/ndbapi/TransporterFacade.hpp +++ b/ndb/src/ndbapi/TransporterFacade.hpp @@ -47,7 +47,7 @@ extern "C" { class TransporterFacade { public: - TransporterFacade(NdbMgmHandle mgm_handle); + TransporterFacade(); virtual ~TransporterFacade(); bool init(Uint32, const ndb_mgm_configuration *); @@ -133,7 +133,6 @@ private: bool isConnected(NodeId aNodeId); void doStop(); - NdbMgmHandle m_mgm_handle; TransporterRegistry* theTransporterRegistry; SocketServer m_socket_server; int sendPerformedLastInterval; diff --git a/ndb/src/ndbapi/ndb_cluster_connection.cpp b/ndb/src/ndbapi/ndb_cluster_connection.cpp index 4a33be7c597..e6f5d464d80 100644 --- a/ndb/src/ndbapi/ndb_cluster_connection.cpp +++ b/ndb/src/ndbapi/ndb_cluster_connection.cpp @@ -284,7 +284,7 @@ Ndb_cluster_connection_impl::Ndb_cluster_connection_impl(const char * m_transporter_facade= TransporterFacade::theFacadeInstance= - new TransporterFacade(m_config_retriever->get_mgmHandle()); + new TransporterFacade(); DBUG_VOID_RETURN; } From fced35f74a0c93fbbea0f1d2a21da13378467caf Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Feb 2005 21:19:42 +0100 Subject: [PATCH 8/8] ndb - fix new decimal type mysql vs. ndb mysql-test/r/ndb_index_ordered.result: fix new decimal mysql vs. ndb mysql-test/t/ndb_index_ordered.test: fix new decimal mysql vs. ndb ndb/include/kernel/signaldata/DictTabInfo.hpp: fix new decimal mysql vs. ndb ndb/include/ndb_constants.h: fix new decimal mysql vs. ndb ndb/include/ndbapi/NdbDictionary.hpp: fix new decimal mysql vs. ndb ndb/include/util/NdbSqlUtil.hpp: fix new decimal mysql vs. ndb ndb/src/common/util/NdbSqlUtil.cpp: fix new decimal mysql vs. ndb ndb/src/ndbapi/NdbDictionary.cpp: fix new decimal mysql vs. ndb ndb/src/ndbapi/NdbDictionaryImpl.cpp: fix new decimal mysql vs. ndb ndb/src/ndbapi/NdbRecAttr.cpp: fix new decimal mysql vs. ndb ndb/test/include/NdbSchemaOp.hpp: fix new decimal mysql vs. ndb ndb/test/src/HugoCalculator.cpp: fix new decimal mysql vs. ndb ndb/tools/restore/consumer.cpp: fix new decimal mysql vs. ndb sql/ha_ndbcluster.cc: fix new decimal mysql vs. ndb --- mysql-test/r/ndb_index_ordered.result | 83 ++++++++++++++++ mysql-test/t/ndb_index_ordered.test | 96 +++++++++---------- ndb/include/kernel/signaldata/DictTabInfo.hpp | 37 +++++++ ndb/include/ndb_constants.h | 4 +- ndb/include/ndbapi/NdbDictionary.hpp | 2 + ndb/include/util/NdbSqlUtil.hpp | 6 +- ndb/src/common/util/NdbSqlUtil.cpp | 36 +++++++ ndb/src/ndbapi/NdbDictionary.cpp | 6 ++ ndb/src/ndbapi/NdbDictionaryImpl.cpp | 2 + ndb/src/ndbapi/NdbRecAttr.cpp | 5 + ndb/test/include/NdbSchemaOp.hpp | 2 + ndb/test/src/HugoCalculator.cpp | 2 + ndb/tools/restore/consumer.cpp | 2 + sql/ha_ndbcluster.cc | 21 +++- 14 files changed, 253 insertions(+), 51 deletions(-) diff --git a/mysql-test/r/ndb_index_ordered.result b/mysql-test/r/ndb_index_ordered.result index 9aa7559d660..212c843cc44 100644 --- a/mysql-test/r/ndb_index_ordered.result +++ b/mysql-test/r/ndb_index_ordered.result @@ -554,6 +554,89 @@ select count(*)-9 from t1 use index (ts) where ts <= '2001-01-01 23:59:59'; count(*)-9 0 drop table t1; +create table t1 ( +a int primary key, +s decimal(12), +t decimal(12, 5), +u decimal(12) unsigned, +v decimal(12, 5) unsigned, +key (s), +key (t), +key (u), +key (v) +) engine=ndb; +insert into t1 values +( 0, -000000000007, -0000061.00003, 000000000061, 0000965.00042), +( 1, -000000000007, -0000061.00042, 000000000061, 0000965.00003), +( 2, -071006035767, 4210253.00024, 000000000001, 0000001.84488), +( 3, 000000007115, 0000000.77607, 000077350625, 0000018.00013), +( 4, -000000068391, -0346486.00000, 000000005071, 0005334.00002), +( 5, -521579890459, -1936874.00001, 000000000154, 0000003.00018), +( 6, -521579890459, -1936874.00018, 000000000154, 0000003.00001), +( 7, 000000000333, 0000051.39140, 000000907958, 0788643.08374), +( 8, 000042731229, 0000009.00000, 000000000009, 6428667.00000), +( 9, -000008159769, 0000918.00004, 000096951421, 7607730.00008); +select count(*)- 5 from t1 use index (s) where s < -000000000007; +count(*)- 5 +0 +select count(*)- 7 from t1 use index (s) where s <= -000000000007; +count(*)- 7 +0 +select count(*)- 2 from t1 use index (s) where s = -000000000007; +count(*)- 2 +0 +select count(*)- 5 from t1 use index (s) where s >= -000000000007; +count(*)- 5 +0 +select count(*)- 3 from t1 use index (s) where s > -000000000007; +count(*)- 3 +0 +select count(*)- 4 from t1 use index (t) where t < -0000061.00003; +count(*)- 4 +0 +select count(*)- 5 from t1 use index (t) where t <= -0000061.00003; +count(*)- 5 +0 +select count(*)- 1 from t1 use index (t) where t = -0000061.00003; +count(*)- 1 +0 +select count(*)- 6 from t1 use index (t) where t >= -0000061.00003; +count(*)- 6 +0 +select count(*)- 5 from t1 use index (t) where t > -0000061.00003; +count(*)- 5 +0 +select count(*)- 2 from t1 use index (u) where u < 000000000061; +count(*)- 2 +0 +select count(*)- 4 from t1 use index (u) where u <= 000000000061; +count(*)- 4 +0 +select count(*)- 2 from t1 use index (u) where u = 000000000061; +count(*)- 2 +0 +select count(*)- 8 from t1 use index (u) where u >= 000000000061; +count(*)- 8 +0 +select count(*)- 6 from t1 use index (u) where u > 000000000061; +count(*)- 6 +0 +select count(*)- 5 from t1 use index (v) where v < 0000965.00042; +count(*)- 5 +0 +select count(*)- 6 from t1 use index (v) where v <= 0000965.00042; +count(*)- 6 +0 +select count(*)- 1 from t1 use index (v) where v = 0000965.00042; +count(*)- 1 +0 +select count(*)- 5 from t1 use index (v) where v >= 0000965.00042; +count(*)- 5 +0 +select count(*)- 4 from t1 use index (v) where v > 0000965.00042; +count(*)- 4 +0 +drop table t1; create table t1(a int primary key, b int not null, index(b)); insert into t1 values (1,1), (2,2); set autocommit=0; diff --git a/mysql-test/t/ndb_index_ordered.test b/mysql-test/t/ndb_index_ordered.test index 1e07ca93c30..2ebf06b78a8 100644 --- a/mysql-test/t/ndb_index_ordered.test +++ b/mysql-test/t/ndb_index_ordered.test @@ -282,55 +282,55 @@ drop table t1; # decimal (not the new 5.0 thing) -#create table t1 ( -# a int primary key, -# s decimal(12), -# t decimal(12, 5), -# u decimal(12) unsigned, -# v decimal(12, 5) unsigned, -# key (s), -# key (t), -# key (u), -# key (v) -#) engine=ndb; -## -#insert into t1 values -# ( 0, -000000000007, -0000061.00003, 000000000061, 0000965.00042), -# ( 1, -000000000007, -0000061.00042, 000000000061, 0000965.00003), -# ( 2, -071006035767, 4210253.00024, 000000000001, 0000001.84488), -# ( 3, 000000007115, 0000000.77607, 000077350625, 0000018.00013), -# ( 4, -000000068391, -0346486.00000, 000000005071, 0005334.00002), -# ( 5, -521579890459, -1936874.00001, 000000000154, 0000003.00018), -# ( 6, -521579890459, -1936874.00018, 000000000154, 0000003.00001), -# ( 7, 000000000333, 0000051.39140, 000000907958, 0788643.08374), -# ( 8, 000042731229, 0000009.00000, 000000000009, 6428667.00000), -# ( 9, -000008159769, 0000918.00004, 000096951421, 7607730.00008); -## -#select count(*)- 5 from t1 use index (s) where s < -000000000007; -#select count(*)- 7 from t1 use index (s) where s <= -000000000007; -#select count(*)- 2 from t1 use index (s) where s = -000000000007; -#select count(*)- 5 from t1 use index (s) where s >= -000000000007; -#select count(*)- 3 from t1 use index (s) where s > -000000000007; -## -#select count(*)- 4 from t1 use index (t) where t < -0000061.00003; -#select count(*)- 5 from t1 use index (t) where t <= -0000061.00003; -#select count(*)- 1 from t1 use index (t) where t = -0000061.00003; -#select count(*)- 6 from t1 use index (t) where t >= -0000061.00003; -#select count(*)- 5 from t1 use index (t) where t > -0000061.00003; -## -#select count(*)- 2 from t1 use index (u) where u < 000000000061; -#select count(*)- 4 from t1 use index (u) where u <= 000000000061; -#select count(*)- 2 from t1 use index (u) where u = 000000000061; -#select count(*)- 8 from t1 use index (u) where u >= 000000000061; -#select count(*)- 6 from t1 use index (u) where u > 000000000061; -## -#select count(*)- 5 from t1 use index (v) where v < 0000965.00042; -#select count(*)- 6 from t1 use index (v) where v <= 0000965.00042; -#select count(*)- 1 from t1 use index (v) where v = 0000965.00042; -#select count(*)- 5 from t1 use index (v) where v >= 0000965.00042; -#select count(*)- 4 from t1 use index (v) where v > 0000965.00042; +create table t1 ( + a int primary key, + s decimal(12), + t decimal(12, 5), + u decimal(12) unsigned, + v decimal(12, 5) unsigned, + key (s), + key (t), + key (u), + key (v) +) engine=ndb; # -#drop table t1; +insert into t1 values + ( 0, -000000000007, -0000061.00003, 000000000061, 0000965.00042), + ( 1, -000000000007, -0000061.00042, 000000000061, 0000965.00003), + ( 2, -071006035767, 4210253.00024, 000000000001, 0000001.84488), + ( 3, 000000007115, 0000000.77607, 000077350625, 0000018.00013), + ( 4, -000000068391, -0346486.00000, 000000005071, 0005334.00002), + ( 5, -521579890459, -1936874.00001, 000000000154, 0000003.00018), + ( 6, -521579890459, -1936874.00018, 000000000154, 0000003.00001), + ( 7, 000000000333, 0000051.39140, 000000907958, 0788643.08374), + ( 8, 000042731229, 0000009.00000, 000000000009, 6428667.00000), + ( 9, -000008159769, 0000918.00004, 000096951421, 7607730.00008); +# +select count(*)- 5 from t1 use index (s) where s < -000000000007; +select count(*)- 7 from t1 use index (s) where s <= -000000000007; +select count(*)- 2 from t1 use index (s) where s = -000000000007; +select count(*)- 5 from t1 use index (s) where s >= -000000000007; +select count(*)- 3 from t1 use index (s) where s > -000000000007; +# +select count(*)- 4 from t1 use index (t) where t < -0000061.00003; +select count(*)- 5 from t1 use index (t) where t <= -0000061.00003; +select count(*)- 1 from t1 use index (t) where t = -0000061.00003; +select count(*)- 6 from t1 use index (t) where t >= -0000061.00003; +select count(*)- 5 from t1 use index (t) where t > -0000061.00003; +# +select count(*)- 2 from t1 use index (u) where u < 000000000061; +select count(*)- 4 from t1 use index (u) where u <= 000000000061; +select count(*)- 2 from t1 use index (u) where u = 000000000061; +select count(*)- 8 from t1 use index (u) where u >= 000000000061; +select count(*)- 6 from t1 use index (u) where u > 000000000061; +# +select count(*)- 5 from t1 use index (v) where v < 0000965.00042; +select count(*)- 6 from t1 use index (v) where v <= 0000965.00042; +select count(*)- 1 from t1 use index (v) where v = 0000965.00042; +select count(*)- 5 from t1 use index (v) where v >= 0000965.00042; +select count(*)- 4 from t1 use index (v) where v > 0000965.00042; + +drop table t1; # bug#7798 create table t1(a int primary key, b int not null, index(b)); diff --git a/ndb/include/kernel/signaldata/DictTabInfo.hpp b/ndb/include/kernel/signaldata/DictTabInfo.hpp index 23926374dd6..09b00cf8993 100644 --- a/ndb/include/kernel/signaldata/DictTabInfo.hpp +++ b/ndb/include/kernel/signaldata/DictTabInfo.hpp @@ -24,6 +24,28 @@ #include #include +#ifndef my_decimal_h + +// sql/my_decimal.h requires many more sql/*.h new to ndb +// for now, copy the bit we need TODO proper fix + +#define DECIMAL_MAX_LENGTH ((8 * 9) - 8) + +#ifndef NOT_FIXED_DEC +#define NOT_FIXED_DEC 31 +#endif + +C_MODE_START +extern int decimal_bin_size(int, int); +C_MODE_END + +inline int my_decimal_get_binary_size(uint precision, uint scale) +{ + return decimal_bin_size((int)precision, (int)scale); +} + +#endif + #define DTIMAP(x, y, z) \ { DictTabInfo::y, offsetof(x, z), SimpleProperties::Uint32Value, 0, (~0), 0 } @@ -266,6 +288,8 @@ public: ExtDouble = NdbSqlUtil::Type::Double, ExtOlddecimal = NdbSqlUtil::Type::Olddecimal, ExtOlddecimalunsigned = NdbSqlUtil::Type::Olddecimalunsigned, + ExtDecimal = NdbSqlUtil::Type::Decimal, + ExtDecimalunsigned = NdbSqlUtil::Type::Decimalunsigned, ExtChar = NdbSqlUtil::Type::Char, ExtVarchar = NdbSqlUtil::Type::Varchar, ExtBinary = NdbSqlUtil::Type::Binary, @@ -358,6 +382,19 @@ public: (0 + AttributeExtPrecision + (int(AttributeExtScale) > 0)) * AttributeExtLength; break; + case DictTabInfo::ExtDecimal: + case DictTabInfo::ExtDecimalunsigned: + { + // copy from Field_new_decimal ctor + uint precision = AttributeExtPrecision; + uint scale = AttributeExtScale; + if (precision > DECIMAL_MAX_LENGTH || scale >= NOT_FIXED_DEC) + precision = DECIMAL_MAX_LENGTH; + uint bin_size = my_decimal_get_binary_size(precision, scale); + AttributeSize = DictTabInfo::an8Bit; + AttributeArraySize = bin_size * AttributeExtLength; + } + break; case DictTabInfo::ExtChar: case DictTabInfo::ExtBinary: AttributeSize = DictTabInfo::an8Bit; diff --git a/ndb/include/ndb_constants.h b/ndb/include/ndb_constants.h index 36d7ec95b3e..c7c15063cc5 100644 --- a/ndb/include/ndb_constants.h +++ b/ndb/include/ndb_constants.h @@ -64,7 +64,9 @@ #define NDB_TYPE_YEAR 26 #define NDB_TYPE_TIMESTAMP 27 #define NDB_TYPE_OLDDECIMALUNSIGNED 28 +#define NDB_TYPE_DECIMAL 29 +#define NDB_TYPE_DECIMALUNSIGNED 30 -#define NDB_TYPE_MAX 29 +#define NDB_TYPE_MAX 31 #endif diff --git a/ndb/include/ndbapi/NdbDictionary.hpp b/ndb/include/ndbapi/NdbDictionary.hpp index 26f0e71b25c..44851b70958 100644 --- a/ndb/include/ndbapi/NdbDictionary.hpp +++ b/ndb/include/ndbapi/NdbDictionary.hpp @@ -186,6 +186,8 @@ public: Double = NDB_TYPE_DOUBLE, ///< 64-bit float. 8 byte float, can be used in array Olddecimal = NDB_TYPE_OLDDECIMAL, ///< MySQL < 5.0 signed decimal, Precision, Scale Olddecimalunsigned = NDB_TYPE_OLDDECIMALUNSIGNED, + Decimal = NDB_TYPE_DECIMAL, ///< MySQL >= 5.0 signed decimal, Precision, Scale + Decimalunsigned = NDB_TYPE_DECIMALUNSIGNED, Char = NDB_TYPE_CHAR, ///< Len. A fixed array of 1-byte chars Varchar = NDB_TYPE_VARCHAR, ///< Length bytes: 1, Max: 255 Binary = NDB_TYPE_BINARY, ///< Len diff --git a/ndb/include/util/NdbSqlUtil.hpp b/ndb/include/util/NdbSqlUtil.hpp index 8cf1d166aa9..41e4dadfd60 100644 --- a/ndb/include/util/NdbSqlUtil.hpp +++ b/ndb/include/util/NdbSqlUtil.hpp @@ -95,7 +95,9 @@ public: Time = NDB_TYPE_TIME, Year = NDB_TYPE_YEAR, Timestamp = NDB_TYPE_TIMESTAMP, - Olddecimalunsigned = NDB_TYPE_OLDDECIMALUNSIGNED + Olddecimalunsigned = NDB_TYPE_OLDDECIMALUNSIGNED, + Decimal = NDB_TYPE_DECIMAL, + Decimalunsigned = NDB_TYPE_DECIMALUNSIGNED }; Enum m_typeId; // redundant Cmp* m_cmp; // comparison method @@ -172,6 +174,8 @@ private: static Cmp cmpYear; static Cmp cmpTimestamp; static Cmp cmpOlddecimalunsigned; + static Cmp cmpDecimal; + static Cmp cmpDecimalunsigned; }; #endif diff --git a/ndb/src/common/util/NdbSqlUtil.cpp b/ndb/src/common/util/NdbSqlUtil.cpp index 2686ad5c05f..7ecfb5194b8 100644 --- a/ndb/src/common/util/NdbSqlUtil.cpp +++ b/ndb/src/common/util/NdbSqlUtil.cpp @@ -192,6 +192,14 @@ NdbSqlUtil::m_typeList[] = { { // 28 Type::Olddecimalunsigned, cmpOlddecimalunsigned + }, + { // 29 + Type::Decimal, + cmpDecimal + }, + { // 30 + Type::Decimalunsigned, + cmpDecimalunsigned } }; @@ -483,6 +491,34 @@ NdbSqlUtil::cmpOlddecimalunsigned(const void* info, const void* p1, unsigned n1, return CmpUnknown; } +int +NdbSqlUtil::cmpDecimal(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2, bool full) +{ + const uchar* v1 = (const uchar*)p1; + const uchar* v2 = (const uchar*)p2; + // compare as binary strings + unsigned n = (n1 <= n2 ? n1 : n2); + int k = memcmp(v1, v2, n); + if (k == 0) { + k = (full ? n1 : n) - n2; + } + return k < 0 ? -1 : k > 0 ? +1 : full ? 0 : CmpUnknown; +} + +int +NdbSqlUtil::cmpDecimalunsigned(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2, bool full) +{ + const uchar* v1 = (const uchar*)p1; + const uchar* v2 = (const uchar*)p2; + // compare as binary strings + unsigned n = (n1 <= n2 ? n1 : n2); + int k = memcmp(v1, v2, n); + if (k == 0) { + k = (full ? n1 : n) - n2; + } + return k < 0 ? -1 : k > 0 ? +1 : full ? 0 : CmpUnknown; +} + int NdbSqlUtil::cmpChar(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2, bool full) { diff --git a/ndb/src/ndbapi/NdbDictionary.cpp b/ndb/src/ndbapi/NdbDictionary.cpp index aee0b455b28..664d568aee0 100644 --- a/ndb/src/ndbapi/NdbDictionary.cpp +++ b/ndb/src/ndbapi/NdbDictionary.cpp @@ -954,6 +954,12 @@ operator<<(NdbOut& out, const NdbDictionary::Column& col) case NdbDictionary::Column::Olddecimalunsigned: out << "Olddecimalunsigned(" << col.getPrecision() << "," << col.getScale() << ")"; break; + case NdbDictionary::Column::Decimal: + out << "Decimal(" << col.getPrecision() << "," << col.getScale() << ")"; + break; + case NdbDictionary::Column::Decimalunsigned: + out << "Decimalunsigned(" << col.getPrecision() << "," << col.getScale() << ")"; + break; case NdbDictionary::Column::Char: out << "Char(" << col.getLength() << ";" << csname << ")"; break; diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp index c50a73c1069..8c3f238404f 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -111,6 +111,8 @@ NdbColumnImpl::init(Type t) break; case Olddecimal: case Olddecimalunsigned: + case Decimal: + case Decimalunsigned: m_precision = 10; m_scale = 0; m_length = 1; diff --git a/ndb/src/ndbapi/NdbRecAttr.cpp b/ndb/src/ndbapi/NdbRecAttr.cpp index 51ae14653eb..86a777e79d2 100644 --- a/ndb/src/ndbapi/NdbRecAttr.cpp +++ b/ndb/src/ndbapi/NdbRecAttr.cpp @@ -250,6 +250,10 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r) out.print("%.*s", len, r.aRef()); } break; + case NdbDictionary::Column::Decimal: + case NdbDictionary::Column::Decimalunsigned: + goto unknown; // TODO + break; // for dates cut-and-paste from field.cc case NdbDictionary::Column::Datetime: { @@ -359,6 +363,7 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r) j = length; } break; + unknown: default: /* no print functions for the rest, just print type */ out << (int) r.getType(); j = length; diff --git a/ndb/test/include/NdbSchemaOp.hpp b/ndb/test/include/NdbSchemaOp.hpp index e8ab542b00a..da55f5f9aa5 100644 --- a/ndb/test/include/NdbSchemaOp.hpp +++ b/ndb/test/include/NdbSchemaOp.hpp @@ -569,6 +569,8 @@ convertColumnTypeToAttrType(NdbDictionary::Column::Type _type) case NdbDictionary::Column::Float: case NdbDictionary::Column::Olddecimal: case NdbDictionary::Column::Olddecimalunsigned: + case NdbDictionary::Column::Decimal: + case NdbDictionary::Column::Decimalunsigned: case NdbDictionary::Column::Double: return Float; case NdbDictionary::Column::Char: diff --git a/ndb/test/src/HugoCalculator.cpp b/ndb/test/src/HugoCalculator.cpp index 0a5b9c342c8..8e01f6442bb 100644 --- a/ndb/test/src/HugoCalculator.cpp +++ b/ndb/test/src/HugoCalculator.cpp @@ -147,6 +147,8 @@ HugoCalculator::calcValue(int record, case NdbDictionary::Column::Double: case NdbDictionary::Column::Olddecimal: case NdbDictionary::Column::Olddecimalunsigned: + case NdbDictionary::Column::Decimal: + case NdbDictionary::Column::Decimalunsigned: case NdbDictionary::Column::Binary: case NdbDictionary::Column::Datetime: case NdbDictionary::Column::Time: diff --git a/ndb/tools/restore/consumer.cpp b/ndb/tools/restore/consumer.cpp index ecbdbbf8f4e..b130c4998d5 100644 --- a/ndb/tools/restore/consumer.cpp +++ b/ndb/tools/restore/consumer.cpp @@ -45,9 +45,11 @@ BackupConsumer::create_table_string(const TableS & table, pos += sprintf(buf+pos, "%s", "float"); break; case NdbDictionary::Column::Olddecimal: + case NdbDictionary::Column::Decimal: pos += sprintf(buf+pos, "%s", "decimal"); break; case NdbDictionary::Column::Olddecimalunsigned: + case NdbDictionary::Column::Decimalunsigned: pos += sprintf(buf+pos, "%s", "decimal unsigned"); break; case NdbDictionary::Column::Char: diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 58a34e21f5f..f62a65cb109 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -446,7 +446,6 @@ bool ha_ndbcluster::get_error_message(int error, static inline bool ndb_supported_type(enum_field_types type) { switch (type) { - case MYSQL_TYPE_DECIMAL: case MYSQL_TYPE_TINY: case MYSQL_TYPE_SHORT: case MYSQL_TYPE_LONG: @@ -454,6 +453,8 @@ static inline bool ndb_supported_type(enum_field_types type) case MYSQL_TYPE_LONGLONG: case MYSQL_TYPE_FLOAT: case MYSQL_TYPE_DOUBLE: + case MYSQL_TYPE_DECIMAL: + case MYSQL_TYPE_NEWDECIMAL: case MYSQL_TYPE_TIMESTAMP: case MYSQL_TYPE_DATETIME: case MYSQL_TYPE_DATE: @@ -3493,6 +3494,24 @@ static int create_ndb_column(NDBCOL &col, col.setLength(1); } break; + case MYSQL_TYPE_NEWDECIMAL: + { + Field_new_decimal *f= (Field_new_decimal*)field; + uint precision= f->field_length; + uint scale= f->decimals(); + if (field->flags & UNSIGNED_FLAG) + { + col.setType(NDBCOL::Decimalunsigned); + } + else + { + col.setType(NDBCOL::Decimal); + } + col.setPrecision(precision); + col.setScale(scale); + col.setLength(1); + } + break; // Date types case MYSQL_TYPE_DATETIME: col.setType(NDBCOL::Datetime);