From f23b561e834917b46e29a14beef42d31b800cc17 Mon Sep 17 00:00:00 2001 From: unknown <pekka@mysql.com> Date: Sun, 26 Dec 2004 22:40:42 +0100 Subject: [PATCH] ndb: wl-1442 mysql vs ndb datatypes: prepare ndb/include/Makefile.am: unify api/kernel types deprecate 2-bit AttributeType, use 5-bit AttributeExtType upgradable from 4.1 via nr/sr/backup ndb/include/kernel/AttributeDescriptor.hpp: unify api/kernel types deprecate 2-bit AttributeType, use 5-bit AttributeExtType upgradable from 4.1 via nr/sr/backup ndb/include/kernel/signaldata/DictTabInfo.hpp: unify api/kernel types deprecate 2-bit AttributeType, use 5-bit AttributeExtType upgradable from 4.1 via nr/sr/backup ndb/include/ndb_constants.h: unify api/kernel types deprecate 2-bit AttributeType, use 5-bit AttributeExtType upgradable from 4.1 via nr/sr/backup ndb/include/ndb_types.h: unify api/kernel types deprecate 2-bit AttributeType, use 5-bit AttributeExtType upgradable from 4.1 via nr/sr/backup ndb/include/ndbapi/NdbDictionary.hpp: unify api/kernel types deprecate 2-bit AttributeType, use 5-bit AttributeExtType upgradable from 4.1 via nr/sr/backup ndb/include/util/NdbSqlUtil.hpp: unify api/kernel types deprecate 2-bit AttributeType, use 5-bit AttributeExtType upgradable from 4.1 via nr/sr/backup ndb/src/common/debugger/signaldata/DictTabInfo.cpp: unify api/kernel types deprecate 2-bit AttributeType, use 5-bit AttributeExtType upgradable from 4.1 via nr/sr/backup ndb/src/kernel/blocks/dbdict/Dbdict.cpp: unify api/kernel types deprecate 2-bit AttributeType, use 5-bit AttributeExtType upgradable from 4.1 via nr/sr/backup ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp: unify api/kernel types deprecate 2-bit AttributeType, use 5-bit AttributeExtType upgradable from 4.1 via nr/sr/backup ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp: unify api/kernel types deprecate 2-bit AttributeType, use 5-bit AttributeExtType upgradable from 4.1 via nr/sr/backup ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp: unify api/kernel types deprecate 2-bit AttributeType, use 5-bit AttributeExtType upgradable from 4.1 via nr/sr/backup ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp: unify api/kernel types deprecate 2-bit AttributeType, use 5-bit AttributeExtType upgradable from 4.1 via nr/sr/backup ndb/src/kernel/vm/MetaData.hpp: unify api/kernel types deprecate 2-bit AttributeType, use 5-bit AttributeExtType upgradable from 4.1 via nr/sr/backup ndb/src/ndbapi/Ndb.cpp: unify api/kernel types deprecate 2-bit AttributeType, use 5-bit AttributeExtType upgradable from 4.1 via nr/sr/backup ndb/src/ndbapi/NdbDictionaryImpl.cpp: unify api/kernel types deprecate 2-bit AttributeType, use 5-bit AttributeExtType upgradable from 4.1 via nr/sr/backup ndb/src/ndbapi/NdbDictionaryImpl.hpp: unify api/kernel types deprecate 2-bit AttributeType, use 5-bit AttributeExtType upgradable from 4.1 via nr/sr/backup ndb/src/ndbapi/NdbScanOperation.cpp: unify api/kernel types deprecate 2-bit AttributeType, use 5-bit AttributeExtType upgradable from 4.1 via nr/sr/backup --- ndb/include/Makefile.am | 1 + ndb/include/kernel/AttributeDescriptor.hpp | 40 ++++-------- ndb/include/kernel/signaldata/DictTabInfo.hpp | 34 ++-------- ndb/include/ndb_constants.h | 64 +++++++++++++++++++ ndb/include/ndb_types.h | 1 + ndb/include/ndbapi/NdbDictionary.hpp | 46 ++++++------- ndb/include/util/NdbSqlUtil.hpp | 50 +++++++-------- .../debugger/signaldata/DictTabInfo.cpp | 6 +- ndb/src/kernel/blocks/dbdict/Dbdict.cpp | 15 ++--- .../kernel/blocks/dbtup/DbtupExecQuery.cpp | 7 +- ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp | 3 +- ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp | 2 +- ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp | 4 -- ndb/src/kernel/vm/MetaData.hpp | 1 - ndb/src/ndbapi/Ndb.cpp | 11 +++- ndb/src/ndbapi/NdbDictionaryImpl.cpp | 49 ++------------ ndb/src/ndbapi/NdbDictionaryImpl.hpp | 2 - ndb/src/ndbapi/NdbScanOperation.cpp | 2 +- 18 files changed, 158 insertions(+), 180 deletions(-) create mode 100644 ndb/include/ndb_constants.h diff --git a/ndb/include/Makefile.am b/ndb/include/Makefile.am index 49857c53fb1..a0ac90fec13 100644 --- a/ndb/include/Makefile.am +++ b/ndb/include/Makefile.am @@ -2,6 +2,7 @@ include $(top_srcdir)/ndb/config/common.mk.am ndbinclude_HEADERS = \ +ndb_constants.h \ ndb_types.h \ ndb_version.h diff --git a/ndb/include/kernel/AttributeDescriptor.hpp b/ndb/include/kernel/AttributeDescriptor.hpp index e4c142270db..af28e777213 100644 --- a/ndb/include/kernel/AttributeDescriptor.hpp +++ b/ndb/include/kernel/AttributeDescriptor.hpp @@ -28,7 +28,6 @@ private: static void setType(Uint32 &, Uint32 type); static void setSize(Uint32 &, Uint32 size); static void setArray(Uint32 &, Uint32 arraySize); - static void setOriginal(Uint32 &, Uint32 original); static void setNullable(Uint32 &, Uint32 nullable); static void setDKey(Uint32 &, Uint32 dkey); static void setPrimaryKey(Uint32 &, Uint32 dkey); @@ -40,7 +39,6 @@ private: static Uint32 getSizeInWords(const Uint32 &); static Uint32 getArrayType(const Uint32 &); static Uint32 getArraySize(const Uint32 &); - static Uint32 getOriginal(const Uint32 &); static Uint32 getNullable(const Uint32 &); static Uint32 getDKey(const Uint32 &); static Uint32 getPrimaryKey(const Uint32 &); @@ -50,19 +48,19 @@ private: /** * * a = Array type - 2 Bits -> Max 3 (Bit 0-1) - * t = Attribute type - 2 Bits -> Max 3 (Bit 2-3) - * s = Attribute size - 3 Bits -> Max 7 (Bit 4-6) - * o = Original attribute - 1 Bit 7 - * n = Nullable - 1 Bit 8 - * d = Disk based - 1 Bit 10 - * k = Distribution Key Ind - 1 Bit 12 + * t = Attribute type - 5 Bits -> Max 31 (Bit 2-6) + * s = Attribute size - 3 Bits -> Max 7 (Bit 8-10) + * d = Disk based - 1 Bit 11 + * n = Nullable - 1 Bit 12 + * k = Distribution Key Ind - 1 Bit 13 * p = Primary key attribute - 1 Bit 14 * y = Dynamic attribute - 1 Bit 15 * z = Array size - 16 Bits -> Max 65535 (Bit 16-31) * * 1111111111222222222233 * 01234567890123456789012345678901 - * aattsss n d k pyzzzzzzzzzzzzzzzz + * aattttt sssdnkpyzzzzzzzzzzzzzzzz + * aattsss n d k pyzzzzzzzzzzzzzzzz [ old format ] * */ @@ -70,20 +68,17 @@ private: #define AD_ARRAY_TYPE_MASK (3) #define AD_TYPE_SHIFT (2) -#define AD_TYPE_MASK (3) +#define AD_TYPE_MASK (31) -#define AD_SIZE_SHIFT (4) +#define AD_SIZE_SHIFT (8) #define AD_SIZE_MASK (7) #define AD_SIZE_IN_BYTES_SHIFT (3) - #define AD_SIZE_IN_WORDS_OFFSET (31) #define AD_SIZE_IN_WORDS_SHIFT (5) -#define AD_ORIGINAL_SHIFT (8) -#define AD_NULLABLE_SHIFT (8) - -#define AD_DISTR_KEY_SHIFT (12) +#define AD_NULLABLE_SHIFT (12) +#define AD_DISTR_KEY_SHIFT (13) #define AD_PRIMARY_KEY (14) #define AD_DYNAMIC (15) @@ -123,13 +118,6 @@ AttributeDescriptor::setNullable(Uint32 & desc, Uint32 nullable){ desc |= (nullable << AD_NULLABLE_SHIFT); } -inline -void -AttributeDescriptor::setOriginal(Uint32 & desc, Uint32 original){ - ASSERT_BOOL(original, "AttributeDescriptor::setOriginal"); - desc |= (original << AD_ORIGINAL_SHIFT); -} - inline void AttributeDescriptor::setDKey(Uint32 & desc, Uint32 dkey){ @@ -199,12 +187,6 @@ AttributeDescriptor::getNullable(const Uint32 & desc){ return (desc >> AD_NULLABLE_SHIFT) & 1; } -inline -Uint32 -AttributeDescriptor::getOriginal(const Uint32 & desc){ - return (desc >> AD_ORIGINAL_SHIFT) & 1; -} - inline Uint32 AttributeDescriptor::getDKey(const Uint32 & desc){ diff --git a/ndb/include/kernel/signaldata/DictTabInfo.hpp b/ndb/include/kernel/signaldata/DictTabInfo.hpp index 4d459ddf813..616da05b3ae 100644 --- a/ndb/include/kernel/signaldata/DictTabInfo.hpp +++ b/ndb/include/kernel/signaldata/DictTabInfo.hpp @@ -100,14 +100,14 @@ public: AttributeName = 1000, // String, Mandatory AttributeId = 1001, //Mandatory between DICT's otherwise not allowed - AttributeType = 1002, //Default UnSignedType + AttributeType = 1002, //for osu 4.1->5.0.x AttributeSize = 1003, //Default DictTabInfo::a32Bit AttributeArraySize = 1005, //Default 1 AttributeKeyFlag = 1006, //Default noKey AttributeStorage = 1007, //Default MainMemory AttributeNullableFlag = 1008, //Default NotNullable AttributeDKey = 1010, //Default NotDKey - AttributeExtType = 1013, //Default 0 (undefined) + AttributeExtType = 1013, //Default ExtUnsigned AttributeExtPrecision = 1014, //Default 0 AttributeExtScale = 1015, //Default 0 AttributeExtLength = 1016, //Default 0 @@ -201,12 +201,6 @@ public: StorePermanent = 2 }; - // AttributeType constants - STATIC_CONST( SignedType = 0 ); - STATIC_CONST( UnSignedType = 1 ); - STATIC_CONST( FloatingPointType = 2 ); - STATIC_CONST( StringType = 3 ); - // AttributeSize constants STATIC_CONST( aBit = 0 ); STATIC_CONST( an8Bit = 3 ); @@ -282,7 +276,7 @@ public: struct Attribute { char AttributeName[MAX_TAB_NAME_SIZE]; Uint32 AttributeId; - Uint32 AttributeType; + Uint32 AttributeType; // for osu 4.1->5.0.x Uint32 AttributeSize; Uint32 AttributeArraySize; Uint32 AttributeKeyFlag; @@ -306,66 +300,55 @@ public: // translate to old kernel types and sizes inline bool translateExtType() { + AttributeType = ~0; // deprecated switch (AttributeExtType) { case DictTabInfo::ExtUndefined: break; case DictTabInfo::ExtTinyint: - AttributeType = DictTabInfo::SignedType; AttributeSize = DictTabInfo::an8Bit; AttributeArraySize = AttributeExtLength; return true; case DictTabInfo::ExtTinyunsigned: - AttributeType = DictTabInfo::UnSignedType; AttributeSize = DictTabInfo::an8Bit; AttributeArraySize = AttributeExtLength; return true; case DictTabInfo::ExtSmallint: - AttributeType = DictTabInfo::SignedType; AttributeSize = DictTabInfo::a16Bit; AttributeArraySize = AttributeExtLength; return true; case DictTabInfo::ExtSmallunsigned: - AttributeType = DictTabInfo::UnSignedType; AttributeSize = DictTabInfo::a16Bit; AttributeArraySize = AttributeExtLength; return true; case DictTabInfo::ExtMediumint: - AttributeType = DictTabInfo::SignedType; AttributeSize = DictTabInfo::an8Bit; AttributeArraySize = 3 * AttributeExtLength; return true; case DictTabInfo::ExtMediumunsigned: - AttributeType = DictTabInfo::UnSignedType; AttributeSize = DictTabInfo::an8Bit; AttributeArraySize = 3 * AttributeExtLength; return true; case DictTabInfo::ExtInt: - AttributeType = DictTabInfo::SignedType; AttributeSize = DictTabInfo::a32Bit; AttributeArraySize = AttributeExtLength; return true; case DictTabInfo::ExtUnsigned: - AttributeType = DictTabInfo::UnSignedType; AttributeSize = DictTabInfo::a32Bit; AttributeArraySize = AttributeExtLength; return true; case DictTabInfo::ExtBigint: - AttributeType = DictTabInfo::SignedType; AttributeSize = DictTabInfo::a64Bit; AttributeArraySize = AttributeExtLength; return true; case DictTabInfo::ExtBigunsigned: - AttributeType = DictTabInfo::UnSignedType; AttributeSize = DictTabInfo::a64Bit; AttributeArraySize = AttributeExtLength; return true; case DictTabInfo::ExtFloat: - AttributeType = DictTabInfo::FloatingPointType; AttributeSize = DictTabInfo::a32Bit; AttributeArraySize = AttributeExtLength; return true; case DictTabInfo::ExtDouble: - AttributeType = DictTabInfo::FloatingPointType; AttributeSize = DictTabInfo::a64Bit; AttributeArraySize = AttributeExtLength; return true; @@ -374,35 +357,32 @@ public: break; case DictTabInfo::ExtChar: case DictTabInfo::ExtBinary: - AttributeType = DictTabInfo::StringType; AttributeSize = DictTabInfo::an8Bit; AttributeArraySize = AttributeExtLength; return true; case DictTabInfo::ExtVarchar: case DictTabInfo::ExtVarbinary: - AttributeType = DictTabInfo::StringType; + // to fix AttributeSize = DictTabInfo::an8Bit; AttributeArraySize = AttributeExtLength + 2; return true; case DictTabInfo::ExtDatetime: - AttributeType = DictTabInfo::StringType; + // to fix AttributeSize = DictTabInfo::an8Bit; AttributeArraySize = 8 * AttributeExtLength; return true; case DictTabInfo::ExtTimespec: - AttributeType = DictTabInfo::StringType; + // to fix AttributeSize = DictTabInfo::an8Bit; AttributeArraySize = 12 * AttributeExtLength; return true; case DictTabInfo::ExtBlob: case DictTabInfo::ExtText: - AttributeType = DictTabInfo::StringType; AttributeSize = DictTabInfo::an8Bit; // head + inline part [ attr precision lower half ] AttributeArraySize = (NDB_BLOB_HEAD_SIZE << 2) + (AttributeExtPrecision & 0xFFFF); return true; case DictTabInfo::ExtBit: - AttributeType = DictTabInfo::UnSignedType; AttributeSize = DictTabInfo::aBit; AttributeArraySize = AttributeExtLength; return true; diff --git a/ndb/include/ndb_constants.h b/ndb/include/ndb_constants.h new file mode 100644 index 00000000000..04d86e267f7 --- /dev/null +++ b/ndb/include/ndb_constants.h @@ -0,0 +1,64 @@ +/* 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 */ + +/** + * @file ndb_constants.h + * + * Constants common to NDB API and NDB kernel. + * Changing the values makes database upgrade impossible. + * + * New or removed definitions must be replicated to + * NdbDictionary.hpp and NdbSqlUtil.cpp. + * + * Not for use by application programs. + * Use the enums provided by NdbDictionary instead. + */ + +#ifndef NDB_CONSTANTS_H +#define NDB_CONSTANTS_H + +/* + * Data type constants. + */ + +#define NDB_TYPE_UNDEFINED 0 + +#define NDB_TYPE_TINYINT 1 +#define NDB_TYPE_TINYUNSIGNED 2 +#define NDB_TYPE_SMALLINT 3 +#define NDB_TYPE_SMALLUNSIGNED 4 +#define NDB_TYPE_MEDIUMINT 5 +#define NDB_TYPE_MEDIUMUNSIGNED 6 +#define NDB_TYPE_INT 7 +#define NDB_TYPE_UNSIGNED 8 +#define NDB_TYPE_BIGINT 9 +#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_CHAR 14 +#define NDB_TYPE_VARCHAR 15 +#define NDB_TYPE_BINARY 16 +#define NDB_TYPE_VARBINARY 17 +#define NDB_TYPE_DATETIME 18 // need to fix +#define NDB_TYPE_TIMESPEC 19 // need to fix +#define NDB_TYPE_BLOB 20 +#define NDB_TYPE_TEXT 21 +#define NDB_TYPE_BIT 22 + +#define NDB_TYPE_MAX 23 + +#endif diff --git a/ndb/include/ndb_types.h b/ndb/include/ndb_types.h index 0d603cc2ab3..cec6c48c15c 100644 --- a/ndb/include/ndb_types.h +++ b/ndb/include/ndb_types.h @@ -56,5 +56,6 @@ typedef unsigned long long Uint64; typedef signed long long Int64; #endif +#include "ndb_constants.h" #endif diff --git a/ndb/include/ndbapi/NdbDictionary.hpp b/ndb/include/ndbapi/NdbDictionary.hpp index 05a9a4fd338..cd687c702a3 100644 --- a/ndb/include/ndbapi/NdbDictionary.hpp +++ b/ndb/include/ndbapi/NdbDictionary.hpp @@ -164,29 +164,29 @@ public: * The builtin column types */ enum Type { - Undefined=0, ///< Undefined - Tinyint, ///< 8 bit. 1 byte signed integer, can be used in array - Tinyunsigned, ///< 8 bit. 1 byte unsigned integer, can be used in array - Smallint, ///< 16 bit. 2 byte signed integer, can be used in array - Smallunsigned, ///< 16 bit. 2 byte unsigned integer, can be used in array - Mediumint, ///< 24 bit. 3 byte signed integer, can be used in array - Mediumunsigned,///< 24 bit. 3 byte unsigned integer, can be used in array - Int, ///< 32 bit. 4 byte signed integer, can be used in array - Unsigned, ///< 32 bit. 4 byte unsigned integer, can be used in array - Bigint, ///< 64 bit. 8 byte signed integer, can be used in array - 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 - Char, ///< Len. A fixed array of 1-byte chars - Varchar, ///< Max len - Binary, ///< Len - Varbinary, ///< Max len - Datetime, ///< Precision down to 1 sec (sizeof(Datetime) == 8 bytes ) - Timespec, ///< Precision down to 1 nsec(sizeof(Datetime) == 12 bytes ) - Blob, ///< Binary large object (see NdbBlob) - Text, ///< Text blob, - Bit ///< Bit, length specifies no of bits + Undefined = NDB_TYPE_UNDEFINED, ///< Undefined + Tinyint = NDB_TYPE_TINYINT, ///< 8 bit. 1 byte signed integer, can be used in array + Tinyunsigned = NDB_TYPE_TINYUNSIGNED, ///< 8 bit. 1 byte unsigned integer, can be used in array + Smallint = NDB_TYPE_SMALLINT, ///< 16 bit. 2 byte signed integer, can be used in array + Smallunsigned = NDB_TYPE_SMALLUNSIGNED, ///< 16 bit. 2 byte unsigned integer, can be used in array + Mediumint = NDB_TYPE_MEDIUMINT, ///< 24 bit. 3 byte signed integer, can be used in array + Mediumunsigned = NDB_TYPE_MEDIUMUNSIGNED,///< 24 bit. 3 byte unsigned integer, can be used in array + Int = NDB_TYPE_INT, ///< 32 bit. 4 byte signed integer, can be used in array + Unsigned = NDB_TYPE_UNSIGNED, ///< 32 bit. 4 byte unsigned integer, can be used in array + Bigint = NDB_TYPE_BIGINT, ///< 64 bit. 8 byte signed integer, can be used in array + 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 + Char = NDB_TYPE_CHAR, ///< Len. A fixed array of 1-byte chars + Varchar = NDB_TYPE_VARCHAR, ///< Max len + Binary = NDB_TYPE_BINARY, ///< Len + Varbinary = NDB_TYPE_VARBINARY, ///< Max len + Datetime = NDB_TYPE_DATETIME, ///< Precision down to 1 sec (sizeof(Datetime) == 8 bytes ) + Timespec = NDB_TYPE_TIMESPEC, ///< Precision down to 1 nsec(sizeof(Datetime) == 12 bytes ) + Blob = NDB_TYPE_BLOB, ///< Binary large object (see NdbBlob) + Text = NDB_TYPE_TEXT, ///< Text blob, + Bit = NDB_TYPE_BIT ///< Bit, length specifies no of bits }; /** diff --git a/ndb/include/util/NdbSqlUtil.hpp b/ndb/include/util/NdbSqlUtil.hpp index 3deaf81cfc7..8ea3e9c8124 100644 --- a/ndb/include/util/NdbSqlUtil.hpp +++ b/ndb/include/util/NdbSqlUtil.hpp @@ -62,35 +62,31 @@ public: CmpUnknown = 2 // insufficient partial data }; - /** - * Kernel data types. Must match m_typeList in NdbSqlUtil.cpp. - * Now also must match types in NdbDictionary. - */ struct Type { enum Enum { - Undefined = 0, // Undefined - Tinyint, // 8 bit - Tinyunsigned, // 8 bit - Smallint, // 16 bit - Smallunsigned, // 16 bit - Mediumint, // 24 bit - Mediumunsigned, // 24 bit - Int, // 32 bit - Unsigned, // 32 bit - Bigint, // 64 bit - Bigunsigned, // 64 Bit - Float, // 32-bit float - Double, // 64-bit float - Decimal, // Precision, Scale - Char, // Len - Varchar, // Max len - Binary, // Len - Varbinary, // Max len - Datetime, // Precision down to 1 sec (size 8 bytes) - Timespec, // Precision down to 1 nsec (size 12 bytes) - Blob, // Blob - Text, // Text blob, - Bit // A bit + Undefined = NDB_TYPE_UNDEFINED, + Tinyint = NDB_TYPE_TINYINT, + Tinyunsigned = NDB_TYPE_TINYUNSIGNED, + Smallint = NDB_TYPE_SMALLINT, + Smallunsigned = NDB_TYPE_SMALLUNSIGNED, + Mediumint = NDB_TYPE_MEDIUMINT, + Mediumunsigned = NDB_TYPE_MEDIUMUNSIGNED, + Int = NDB_TYPE_INT, + Unsigned = NDB_TYPE_UNSIGNED, + Bigint = NDB_TYPE_BIGINT, + Bigunsigned = NDB_TYPE_BIGUNSIGNED, + Float = NDB_TYPE_FLOAT, + Double = NDB_TYPE_DOUBLE, + Decimal = NDB_TYPE_DECIMAL, + Char = NDB_TYPE_CHAR, + Varchar = NDB_TYPE_VARCHAR, + Binary = NDB_TYPE_BINARY, + Varbinary = NDB_TYPE_VARBINARY, + Datetime = NDB_TYPE_DATETIME, + Timespec = NDB_TYPE_TIMESPEC, + Blob = NDB_TYPE_BLOB, + Text = NDB_TYPE_TEXT, + Bit = NDB_TYPE_BIT }; Enum m_typeId; Cmp* m_cmp; // comparison method diff --git a/ndb/src/common/debugger/signaldata/DictTabInfo.cpp b/ndb/src/common/debugger/signaldata/DictTabInfo.cpp index a0a1c4b169d..816c4fb9452 100644 --- a/ndb/src/common/debugger/signaldata/DictTabInfo.cpp +++ b/ndb/src/common/debugger/signaldata/DictTabInfo.cpp @@ -59,7 +59,7 @@ SimpleProperties::SP2StructMapping DictTabInfo::AttributeMapping[] = { DTIMAPS(Attribute, AttributeName, AttributeName, 0, MAX_ATTR_NAME_SIZE), DTIMAP(Attribute, AttributeId, AttributeId), - DTIMAP2(Attribute, AttributeType, AttributeType, 0, 3), + DTIMAP(Attribute, AttributeType, AttributeType), DTIMAP2(Attribute, AttributeSize, AttributeSize, 3, 7), DTIMAP2(Attribute, AttributeArraySize, AttributeArraySize, 0, 65535), DTIMAP2(Attribute, AttributeKeyFlag, AttributeKeyFlag, 0, 1), @@ -126,13 +126,13 @@ void DictTabInfo::Attribute::init(){ memset(AttributeName, 0, sizeof(AttributeName));//AttributeName[0] = 0; AttributeId = 0; - AttributeType = DictTabInfo::UnSignedType; + AttributeType = ~0, // deprecated AttributeSize = DictTabInfo::a32Bit; AttributeArraySize = 1; AttributeKeyFlag = 0; AttributeNullableFlag = 0; AttributeDKey = 0; - AttributeExtType = 0, + AttributeExtType = DictTabInfo::ExtUnsigned, AttributeExtPrecision = 0, AttributeExtScale = 0, AttributeExtLength = 0, diff --git a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp index fa13b359ca6..c895b8ca6f0 100644 --- a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp +++ b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp @@ -290,12 +290,12 @@ Dbdict::packTableIntoPagesImpl(SimpleProperties::Writer & w, const Uint32 nullable = AttributeDescriptor::getNullable(desc); const Uint32 DKey = AttributeDescriptor::getDKey(desc); - w.add(DictTabInfo::AttributeType, attrType); + // AttributeType deprecated w.add(DictTabInfo::AttributeSize, attrSize); w.add(DictTabInfo::AttributeArraySize, arraySize); w.add(DictTabInfo::AttributeNullableFlag, nullable); w.add(DictTabInfo::AttributeDKey, DKey); - w.add(DictTabInfo::AttributeExtType, attrPtr.p->extType); + w.add(DictTabInfo::AttributeExtType, attrType); w.add(DictTabInfo::AttributeExtPrecision, attrPtr.p->extPrecision); w.add(DictTabInfo::AttributeExtScale, attrPtr.p->extScale); w.add(DictTabInfo::AttributeExtLength, attrPtr.p->extLength); @@ -4169,7 +4169,7 @@ Dbdict::sendLQHADDATTRREQ(Signal* signal, LqhAddAttrReq::Entry& entry = req->attributes[i]; entry.attrId = attrPtr.p->attributeId; entry.attrDescriptor = attrPtr.p->attributeDescriptor; - entry.extTypeInfo = attrPtr.p->extType; + entry.extTypeInfo = 0; // charset number passed to TUP, TUX in upper half entry.extTypeInfo |= (attrPtr.p->extPrecision & ~0xFFFF); if (tabPtr.p->isIndex()) { @@ -4792,7 +4792,6 @@ void Dbdict::handleTabInfo(SimpleProperties::Reader & it, attrPtr.p->attributeId = attrDesc.AttributeId; attrPtr.p->tupleKey = (keyCount + 1) * attrDesc.AttributeKeyFlag; - attrPtr.p->extType = attrDesc.AttributeExtType; attrPtr.p->extPrecision = attrDesc.AttributeExtPrecision; attrPtr.p->extScale = attrDesc.AttributeExtScale; attrPtr.p->extLength = attrDesc.AttributeExtLength; @@ -4843,7 +4842,7 @@ void Dbdict::handleTabInfo(SimpleProperties::Reader & it, } Uint32 desc = 0; - AttributeDescriptor::setType(desc, attrDesc.AttributeType); + AttributeDescriptor::setType(desc, attrDesc.AttributeExtType); AttributeDescriptor::setSize(desc, attrDesc.AttributeSize); AttributeDescriptor::setArray(desc, attrDesc.AttributeArraySize); AttributeDescriptor::setNullable(desc, attrDesc.AttributeNullableFlag); @@ -6406,6 +6405,7 @@ Dbdict::createIndex_toCreateTable(Signal* signal, OpCreateIndexPtr opPtr) jam(); const Uint32 a = aRec->attributeDescriptor; bool isNullable = AttributeDescriptor::getNullable(a); + Uint32 attrType = AttributeDescriptor::getType(a); w.add(DictTabInfo::AttributeName, aRec->attributeName); w.add(DictTabInfo::AttributeId, k); if (indexPtr.p->isHashIndex()) { @@ -6416,8 +6416,7 @@ Dbdict::createIndex_toCreateTable(Signal* signal, OpCreateIndexPtr opPtr) w.add(DictTabInfo::AttributeKeyFlag, (Uint32)false); w.add(DictTabInfo::AttributeNullableFlag, (Uint32)isNullable); } - // ext type overrides - w.add(DictTabInfo::AttributeExtType, aRec->extType); + w.add(DictTabInfo::AttributeExtType, attrType); w.add(DictTabInfo::AttributeExtPrecision, aRec->extPrecision); w.add(DictTabInfo::AttributeExtScale, aRec->extScale); w.add(DictTabInfo::AttributeExtLength, aRec->extLength); @@ -6431,7 +6430,6 @@ Dbdict::createIndex_toCreateTable(Signal* signal, OpCreateIndexPtr opPtr) w.add(DictTabInfo::AttributeId, opPtr.p->m_attrList.sz); w.add(DictTabInfo::AttributeKeyFlag, (Uint32)false); w.add(DictTabInfo::AttributeNullableFlag, (Uint32)false); - // ext type overrides w.add(DictTabInfo::AttributeExtType, (Uint32)DictTabInfo::ExtUnsigned); w.add(DictTabInfo::AttributeExtLength, tablePtr.p->tupKeyLength); w.add(DictTabInfo::AttributeEnd, (Uint32)true); @@ -6443,7 +6441,6 @@ Dbdict::createIndex_toCreateTable(Signal* signal, OpCreateIndexPtr opPtr) w.add(DictTabInfo::AttributeId, opPtr.p->m_attrList.sz); w.add(DictTabInfo::AttributeKeyFlag, (Uint32)true); w.add(DictTabInfo::AttributeNullableFlag, (Uint32)false); - // ext type overrides w.add(DictTabInfo::AttributeExtType, (Uint32)DictTabInfo::ExtUnsigned); w.add(DictTabInfo::AttributeExtLength, indexPtr.p->tupKeyLength); w.add(DictTabInfo::AttributeEnd, (Uint32)true); diff --git a/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp b/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp index cb5477a1551..b07e840e25c 100644 --- a/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp +++ b/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp @@ -1540,13 +1540,8 @@ int Dbtup::interpreterNextLab(Signal* signal, // Calculate the number of words of this attribute. // We allow writes into arrays as long as they fit into the 64 bit // register size. - //TEST_MR See to that TattrNoOfWords can be - // read faster from attribute description. /* --------------------------------------------------------------- */ - Uint32 TarraySize = (TattrDesc1 >> 16); - Uint32 TattrLogLen = (TattrDesc1 >> 4) & 0xf; - Uint32 TattrNoOfBits = TarraySize << TattrLogLen; - Uint32 TattrNoOfWords = (TattrNoOfBits + 31) >> 5; + Uint32 TattrNoOfWords = AttributeDescriptor::getSizeInWords(TattrDesc1); Uint32 Toptype = operPtr.p->optype; Uint32 TdataForUpdate[3]; diff --git a/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp b/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp index 13593602abc..4ce807528c4 100644 --- a/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp +++ b/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp @@ -288,8 +288,7 @@ void Dbtup::execTUP_ADD_ATTRREQ(Signal* signal) ptrCheckGuard(fragOperPtr, cnoOfFragoprec, fragoperrec); Uint32 attrId = signal->theData[2]; Uint32 attrDescriptor = signal->theData[3]; - // DICT sends extended type (ignored) and charset number - Uint32 extType = (signal->theData[4] & 0xFF); + // DICT sends charset number in upper half Uint32 csNumber = (signal->theData[4] >> 16); regTabPtr.i = fragOperPtr.p->tableidFrag; diff --git a/ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp b/ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp index 021d3d94d8e..93c4a583624 100644 --- a/ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp +++ b/ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp @@ -201,7 +201,7 @@ Dbtux::execTUX_ADD_ATTRREQ(Signal* signal) DescAttr& descAttr = descEnt.m_descAttr[attrId]; descAttr.m_attrDesc = req->attrDescriptor; descAttr.m_primaryAttrId = req->primaryAttrId; - descAttr.m_typeId = req->extTypeInfo & 0xFF; + descAttr.m_typeId = AttributeDescriptor::getType(req->attrDescriptor); descAttr.m_charset = (req->extTypeInfo >> 16); #ifdef VM_TRACE if (debugFlags & DebugMeta) { diff --git a/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp b/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp index 089cf613b03..e155a51be08 100644 --- a/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp +++ b/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp @@ -1562,13 +1562,9 @@ void Ndbcntr::createSystableLab(Signal* signal, unsigned index) ndbassert(column.pos == i); w.add(DictTabInfo::AttributeName, column.name); w.add(DictTabInfo::AttributeId, (Uint32)column.pos); - //w.add(DictTabInfo::AttributeType, DictTabInfo::UnSignedType); - //w.add(DictTabInfo::AttributeSize, DictTabInfo::a32Bit); - //w.add(DictTabInfo::AttributeArraySize, 1); w.add(DictTabInfo::AttributeKeyFlag, (Uint32)column.keyFlag); //w.add(DictTabInfo::AttributeStorage, (Uint32)DictTabInfo::MainMemory); w.add(DictTabInfo::AttributeNullableFlag, (Uint32)column.nullable); - // ext type overrides w.add(DictTabInfo::AttributeExtType, (Uint32)column.type); w.add(DictTabInfo::AttributeExtLength, (Uint32)column.length); w.add(DictTabInfo::AttributeEnd, (Uint32)true); diff --git a/ndb/src/kernel/vm/MetaData.hpp b/ndb/src/kernel/vm/MetaData.hpp index aded6c96573..1000114a421 100644 --- a/ndb/src/kernel/vm/MetaData.hpp +++ b/ndb/src/kernel/vm/MetaData.hpp @@ -160,7 +160,6 @@ public: Uint32 attributeDescriptor; /* Extended attributes */ - Uint32 extType; Uint32 extPrecision; Uint32 extScale; Uint32 extLength; diff --git a/ndb/src/ndbapi/Ndb.cpp b/ndb/src/ndbapi/Ndb.cpp index 4f08ac5d829..99d6c319611 100644 --- a/ndb/src/ndbapi/Ndb.cpp +++ b/ndb/src/ndbapi/Ndb.cpp @@ -912,7 +912,8 @@ Ndb::setTupleIdInNdb(Uint32 aTableId, Uint64 val, bool increase ) Uint64 Ndb::opTupleIdOnNdb(Uint32 aTableId, Uint64 opValue, Uint32 op) { - DEBUG_TRACE("opTupleIdOnNdb"); + DBUG_ENTER("Ndb::opTupleIdOnNdb"); + DBUG_PRINT("enter", ("table=%u value=%llu op=%u", aTableId, opValue, op)); NdbTransaction* tConnection; NdbOperation* tOperation; @@ -1008,7 +1009,7 @@ Ndb::opTupleIdOnNdb(Uint32 aTableId, Uint64 opValue, Uint32 op) setDatabaseName(currentDb.c_str()); setDatabaseSchemaName(currentSchema.c_str()); - return ret; + DBUG_RETURN(ret); error_handler: theError.code = tConnection->theError.code; @@ -1018,7 +1019,11 @@ Ndb::opTupleIdOnNdb(Uint32 aTableId, Uint64 opValue, Uint32 op) setDatabaseName(currentDb.c_str()); setDatabaseSchemaName(currentSchema.c_str()); - return ~0; + DBUG_PRINT("error", ("ndb=%d con=%d op=%d", + theError.code, + tConnection ? tConnection->theError.code : -1, + tOperation ? tOperation->theError.code : -1)); + DBUG_RETURN(~0); } static const Uint32 MAX_KEY_LEN_64_WORDS = 4; diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp index d677301468b..e0cd39d1813 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -74,7 +74,6 @@ NdbColumnImpl::operator=(const NdbColumnImpl& col) m_autoIncrement = col.m_autoIncrement; m_autoIncrementInitialValue = col.m_autoIncrementInitialValue; m_defaultValue = col.m_defaultValue; - m_attrType = col.m_attrType; m_attrSize = col.m_attrSize; m_arraySize = col.m_arraySize; m_keyInfoPos = col.m_keyInfoPos; @@ -228,7 +227,6 @@ NdbColumnImpl::create_psuedo(const char * name){ col->m_impl.m_attrId = AttributeHeader::RANGE_NO; col->m_impl.m_attrSize = 4; col->m_impl.m_arraySize = 1; - col->m_impl.m_extType = NdbSqlUtil::Type::Unsigned; } else { abort(); } @@ -1149,35 +1147,6 @@ indexTypeMapping[] = { { -1, -1 } }; -// TODO: remove, api-kernel type codes must match now -static const -ApiKernelMapping -columnTypeMapping[] = { - { DictTabInfo::ExtTinyint, NdbDictionary::Column::Tinyint }, - { DictTabInfo::ExtTinyunsigned, NdbDictionary::Column::Tinyunsigned }, - { DictTabInfo::ExtSmallint, NdbDictionary::Column::Smallint }, - { DictTabInfo::ExtSmallunsigned, NdbDictionary::Column::Smallunsigned }, - { DictTabInfo::ExtMediumint, NdbDictionary::Column::Mediumint }, - { DictTabInfo::ExtMediumunsigned, NdbDictionary::Column::Mediumunsigned }, - { DictTabInfo::ExtInt, NdbDictionary::Column::Int }, - { DictTabInfo::ExtUnsigned, NdbDictionary::Column::Unsigned }, - { DictTabInfo::ExtBigint, NdbDictionary::Column::Bigint }, - { DictTabInfo::ExtBigunsigned, NdbDictionary::Column::Bigunsigned }, - { DictTabInfo::ExtFloat, NdbDictionary::Column::Float }, - { DictTabInfo::ExtDouble, NdbDictionary::Column::Double }, - { DictTabInfo::ExtDecimal, NdbDictionary::Column::Decimal }, - { DictTabInfo::ExtChar, NdbDictionary::Column::Char }, - { DictTabInfo::ExtVarchar, NdbDictionary::Column::Varchar }, - { DictTabInfo::ExtBinary, NdbDictionary::Column::Binary }, - { DictTabInfo::ExtVarbinary, NdbDictionary::Column::Varbinary }, - { DictTabInfo::ExtDatetime, NdbDictionary::Column::Datetime }, - { DictTabInfo::ExtTimespec, NdbDictionary::Column::Timespec }, - { DictTabInfo::ExtBlob, NdbDictionary::Column::Blob }, - { DictTabInfo::ExtText, NdbDictionary::Column::Text }, - { DictTabInfo::ExtBit, NdbDictionary::Column::Bit }, - { -1, -1 } -}; - int NdbDictInterface::parseTableInfo(NdbTableImpl ** ret, const Uint32 * data, Uint32 len, @@ -1249,15 +1218,11 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret, NdbColumnImpl * col = new NdbColumnImpl(); col->m_attrId = attrDesc.AttributeId; col->setName(attrDesc.AttributeName); - col->m_type = (NdbDictionary::Column::Type) - getApiConstant(attrDesc.AttributeExtType, - columnTypeMapping, - NdbDictionary::Column::Undefined); - if (col->m_type == NdbDictionary::Column::Undefined) { + if (attrDesc.AttributeExtType >= NDB_TYPE_MAX) { delete impl; return 703; } - col->m_extType = attrDesc.AttributeExtType; + col->m_type = (NdbDictionary::Column::Type)attrDesc.AttributeExtType; col->m_precision = (attrDesc.AttributeExtPrecision & 0xFFFF); col->m_scale = attrDesc.AttributeExtScale; col->m_length = attrDesc.AttributeExtLength; @@ -1281,7 +1246,6 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret, delete impl; return 703; } - col->m_attrType =attrDesc.AttributeType; col->m_attrSize = (1 << attrDesc.AttributeSize) / 8; col->m_arraySize = attrDesc.AttributeArraySize; if(attrDesc.AttributeSize == 0) @@ -1535,10 +1499,11 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, tmpAttr.AttributeNullableFlag = col->m_nullable; tmpAttr.AttributeDKey = col->m_distributionKey; - tmpAttr.AttributeExtType = - getKernelConstant(col->m_type, - columnTypeMapping, - DictTabInfo::ExtUndefined); + if (col->m_type >= NDB_TYPE_MAX) { + m_error.code = 703; + return -1; + } + tmpAttr.AttributeExtType = (Uint32)col->m_type; tmpAttr.AttributeExtPrecision = ((unsigned)col->m_precision & 0xFFFF); tmpAttr.AttributeExtScale = col->m_scale; tmpAttr.AttributeExtLength = col->m_length; diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.hpp b/ndb/src/ndbapi/NdbDictionaryImpl.hpp index 2820ec3d642..8af06209307 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.hpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.hpp @@ -73,11 +73,9 @@ public: /** * Internal types and sizes, and aggregates */ - Uint32 m_attrType; // type outsize API and DICT Uint32 m_attrSize; // element size (size when arraySize==1) Uint32 m_arraySize; // length or length+2 for Var* types Uint32 m_keyInfoPos; - Uint32 m_extType; // used by restore (kernel type in versin v2x) bool getInterpretableType() const ; bool getCharType() const; bool getBlobType() const; diff --git a/ndb/src/ndbapi/NdbScanOperation.cpp b/ndb/src/ndbapi/NdbScanOperation.cpp index 006c9428321..c703f102d81 100644 --- a/ndb/src/ndbapi/NdbScanOperation.cpp +++ b/ndb/src/ndbapi/NdbScanOperation.cpp @@ -1284,7 +1284,7 @@ NdbIndexScanOperation::compare(Uint32 skip, Uint32 cols, const NdbColumnImpl & col = NdbColumnImpl::getImpl(* r1->m_column); Uint32 len = r1->theAttrSize * r1->theArraySize; if(!r1_null){ - const NdbSqlUtil::Type& sqlType = NdbSqlUtil::getType(col.m_extType); + const NdbSqlUtil::Type& sqlType = NdbSqlUtil::getType(col.m_type); int r = (*sqlType.m_cmp)(col.m_cs, d1, len, d2, len, true); if(r){ assert(r != NdbSqlUtil::CmpUnknown); -- 2.30.9