Loading mysql-test/r/ndb_index_ordered.result +83 −0 Original line number Diff line number Diff line Loading @@ -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; Loading mysql-test/t/ndb_index_ordered.test +48 −48 Original line number Diff line number Diff line Loading @@ -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; # 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; # #drop table t1; 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)); Loading ndb/include/kernel/signaldata/DictTabInfo.hpp +37 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,28 @@ #include <trigger_definitions.h> #include <NdbSqlUtil.hpp> #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 } Loading Loading @@ -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, Loading Loading @@ -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; Loading ndb/include/ndb_constants.h +3 −1 Original line number Diff line number Diff line Loading @@ -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 ndb/include/ndbapi/NdbDictionary.hpp +2 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading
mysql-test/r/ndb_index_ordered.result +83 −0 Original line number Diff line number Diff line Loading @@ -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; Loading
mysql-test/t/ndb_index_ordered.test +48 −48 Original line number Diff line number Diff line Loading @@ -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; # 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; # #drop table t1; 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)); Loading
ndb/include/kernel/signaldata/DictTabInfo.hpp +37 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,28 @@ #include <trigger_definitions.h> #include <NdbSqlUtil.hpp> #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 } Loading Loading @@ -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, Loading Loading @@ -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; Loading
ndb/include/ndb_constants.h +3 −1 Original line number Diff line number Diff line Loading @@ -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
ndb/include/ndbapi/NdbDictionary.hpp +2 −0 Original line number Diff line number Diff line Loading @@ -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 Loading