diff options
-rw-r--r-- | mysql-test/r/ndb_index_ordered.result | 45 | ||||
-rw-r--r-- | mysql-test/t/ndb_index_ordered.test | 19 | ||||
-rw-r--r-- | ndb/include/kernel/signaldata/DictTabInfo.hpp | 8 | ||||
-rw-r--r-- | ndb/include/ndbapi/NdbDictionary.hpp | 3 | ||||
-rw-r--r-- | ndb/include/util/NdbSqlUtil.hpp | 4 | ||||
-rw-r--r-- | ndb/src/common/util/NdbSqlUtil.cpp | 33 | ||||
-rw-r--r-- | ndb/src/ndbapi/NdbDictionary.cpp | 3 | ||||
-rw-r--r-- | ndb/src/ndbapi/NdbDictionaryImpl.cpp | 7 | ||||
-rw-r--r-- | ndb/test/include/NdbSchemaOp.hpp | 1 | ||||
-rw-r--r-- | ndb/tools/restore/consumer.cpp | 3 | ||||
-rw-r--r-- | sql/ha_ndbcluster.cc | 10 |
11 files changed, 132 insertions, 4 deletions
diff --git a/mysql-test/r/ndb_index_ordered.result b/mysql-test/r/ndb_index_ordered.result index 466523aafa7..75a5e42732b 100644 --- a/mysql-test/r/ndb_index_ordered.result +++ b/mysql-test/r/ndb_index_ordered.result @@ -375,3 +375,48 @@ count(*)-8 select count(*)-9 from t1 use index (da) where da <= '2055-01-01'; count(*)-9 0 +select count(*)-9 from t1 use index (ye) where ye > '1900'; +count(*)-9 +0 +select count(*)-6 from t1 use index (ye) where ye >= '1955'; +count(*)-6 +0 +select count(*)-5 from t1 use index (ye) where ye > '1955'; +count(*)-5 +0 +select count(*)-5 from t1 use index (ye) where ye < '1970'; +count(*)-5 +0 +select count(*)-6 from t1 use index (ye) where ye < '2001'; +count(*)-6 +0 +select count(*)-8 from t1 use index (ye) where ye <= '2001'; +count(*)-8 +0 +select count(*)-9 from t1 use index (ye) where ye <= '2055'; +count(*)-9 +0 +select count(*)-9 from t1 use index (ti) where ti >= '00:00:00'; +count(*)-9 +0 +select count(*)-7 from t1 use index (ti) where ti > '00:00:00'; +count(*)-7 +0 +select count(*)-7 from t1 use index (ti) where ti > '05:05:05'; +count(*)-7 +0 +select count(*)-5 from t1 use index (ti) where ti > '06:06:06'; +count(*)-5 +0 +select count(*)-5 from t1 use index (ti) where ti < '10:11:11'; +count(*)-5 +0 +select count(*)-6 from t1 use index (ti) where ti <= '10:11:11'; +count(*)-6 +0 +select count(*)-8 from t1 use index (ti) where ti < '23:59:59'; +count(*)-8 +0 +select count(*)-9 from t1 use index (ti) where ti <= '23:59:59'; +count(*)-9 +0 diff --git a/mysql-test/t/ndb_index_ordered.test b/mysql-test/t/ndb_index_ordered.test index ae2f7db53fb..71635159604 100644 --- a/mysql-test/t/ndb_index_ordered.test +++ b/mysql-test/t/ndb_index_ordered.test @@ -217,3 +217,22 @@ select count(*)-5 from t1 use index (da) where da < '1970-03-03'; select count(*)-6 from t1 use index (da) where da < '2001-01-01'; select count(*)-8 from t1 use index (da) where da <= '2001-01-02'; select count(*)-9 from t1 use index (da) where da <= '2055-01-01'; + +# year +select count(*)-9 from t1 use index (ye) where ye > '1900'; +select count(*)-6 from t1 use index (ye) where ye >= '1955'; +select count(*)-5 from t1 use index (ye) where ye > '1955'; +select count(*)-5 from t1 use index (ye) where ye < '1970'; +select count(*)-6 from t1 use index (ye) where ye < '2001'; +select count(*)-8 from t1 use index (ye) where ye <= '2001'; +select count(*)-9 from t1 use index (ye) where ye <= '2055'; + +# time +select count(*)-9 from t1 use index (ti) where ti >= '00:00:00'; +select count(*)-7 from t1 use index (ti) where ti > '00:00:00'; +select count(*)-7 from t1 use index (ti) where ti > '05:05:05'; +select count(*)-5 from t1 use index (ti) where ti > '06:06:06'; +select count(*)-5 from t1 use index (ti) where ti < '10:11:11'; +select count(*)-6 from t1 use index (ti) where ti <= '10:11:11'; +select count(*)-8 from t1 use index (ti) where ti < '23:59:59'; +select count(*)-9 from t1 use index (ti) where ti <= '23:59:59'; diff --git a/ndb/include/kernel/signaldata/DictTabInfo.hpp b/ndb/include/kernel/signaldata/DictTabInfo.hpp index 392b691ae1e..3e73ae67ebe 100644 --- a/ndb/include/kernel/signaldata/DictTabInfo.hpp +++ b/ndb/include/kernel/signaldata/DictTabInfo.hpp @@ -310,7 +310,8 @@ public: ExtDatetime = NdbSqlUtil::Type::Datetime, ExtDate = NdbSqlUtil::Type::Date, ExtBlob = NdbSqlUtil::Type::Blob, - ExtText = NdbSqlUtil::Type::Text + ExtText = NdbSqlUtil::Type::Text, + ExtTime = NdbSqlUtil::Type::Time }; // Attribute data interpretation @@ -440,6 +441,11 @@ public: // head + inline part [ attr precision lower half ] AttributeArraySize = (NDB_BLOB_HEAD_SIZE << 2) + (AttributeExtPrecision & 0xFFFF); return true; + case DictTabInfo::ExtTime: + AttributeType = DictTabInfo::StringType; + AttributeSize = DictTabInfo::an8Bit; + AttributeArraySize = 3 * AttributeExtLength; + return true; }; return false; } diff --git a/ndb/include/ndbapi/NdbDictionary.hpp b/ndb/include/ndbapi/NdbDictionary.hpp index 0ca3744a3d9..454b267d1b0 100644 --- a/ndb/include/ndbapi/NdbDictionary.hpp +++ b/ndb/include/ndbapi/NdbDictionary.hpp @@ -187,7 +187,8 @@ public: Datetime, ///< Precision down to 1 sec (sizeof(Datetime) == 8 bytes ) Date, ///< Precision down to 1 day(sizeof(Date) == 4 bytes ) Blob, ///< Binary large object (see NdbBlob) - Text ///< Text blob + Text, ///< Text blob + Time = 25 ///< Time without date }; /** diff --git a/ndb/include/util/NdbSqlUtil.hpp b/ndb/include/util/NdbSqlUtil.hpp index 47bb2157e1a..10024d9b616 100644 --- a/ndb/include/util/NdbSqlUtil.hpp +++ b/ndb/include/util/NdbSqlUtil.hpp @@ -83,7 +83,8 @@ public: Datetime, // Precision down to 1 sec (size 8 bytes) Date, // Precision down to 1 day (size 4 bytes) Blob, // Blob - Text // Text blob + Text, // Text blob + Time = 25 // Time without date }; Enum m_typeId; Cmp* m_cmp; // comparison method @@ -135,6 +136,7 @@ private: static Cmp cmpDate; static Cmp cmpBlob; static Cmp cmpText; + static Cmp cmpTime; }; #endif diff --git a/ndb/src/common/util/NdbSqlUtil.cpp b/ndb/src/common/util/NdbSqlUtil.cpp index 6f490c7f611..233698ae52b 100644 --- a/ndb/src/common/util/NdbSqlUtil.cpp +++ b/ndb/src/common/util/NdbSqlUtil.cpp @@ -163,6 +163,22 @@ NdbSqlUtil::m_typeList[] = { { Type::Text, cmpText + }, + { + Type::Undefined, // 5.0 Bit + NULL + }, + { + Type::Undefined, // 5.0 Longvarchar + NULL + }, + { + Type::Undefined, // 5.0 Longvarbinary + NULL + }, + { + Type::Time, + cmpTime } }; @@ -559,6 +575,23 @@ NdbSqlUtil::cmpText(const void* info, const Uint32* p1, const Uint32* p2, Uint32 return CmpUnknown; } +int +NdbSqlUtil::cmpTime(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size) +{ + assert(full >= size && size > 0); + union { const Uint32* p; const unsigned char* v; } u1, u2; + u1.p = p1; + u2.p = p2; + // from Field_time::val_int + Int32 j1 = sint3korr(u1.v); + Int32 j2 = sint3korr(u2.v); + if (j1 < j2) + return -1; + if (j1 > j2) + return +1; + return 0; +} + // check charset bool diff --git a/ndb/src/ndbapi/NdbDictionary.cpp b/ndb/src/ndbapi/NdbDictionary.cpp index b47f7d2c15c..0508d8bf277 100644 --- a/ndb/src/ndbapi/NdbDictionary.cpp +++ b/ndb/src/ndbapi/NdbDictionary.cpp @@ -947,6 +947,9 @@ operator<<(NdbOut& out, const NdbDictionary::Column& col) out << "Text(" << col.getInlineSize() << "," << col.getPartSize() << ";" << col.getStripeSize() << ";" << csname << ")"; break; + case NdbDictionary::Column::Time: + out << "Time"; + break; case NdbDictionary::Column::Undefined: out << "Undefined"; break; diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp index 195fdce7e3f..59474943f3b 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -148,6 +148,12 @@ NdbColumnImpl::init(Type t) m_length = 4; m_cs = default_cs; break; + case Time: + m_precision = 0; + m_scale = 0; + m_length = 1; + m_cs = NULL; + break; case Undefined: assert(false); break; @@ -1177,6 +1183,7 @@ columnTypeMapping[] = { { DictTabInfo::ExtDate, NdbDictionary::Column::Date }, { DictTabInfo::ExtBlob, NdbDictionary::Column::Blob }, { DictTabInfo::ExtText, NdbDictionary::Column::Text }, + { DictTabInfo::ExtTime, NdbDictionary::Column::Time }, { -1, -1 } }; diff --git a/ndb/test/include/NdbSchemaOp.hpp b/ndb/test/include/NdbSchemaOp.hpp index b54c011ae8b..e2fb4015b88 100644 --- a/ndb/test/include/NdbSchemaOp.hpp +++ b/ndb/test/include/NdbSchemaOp.hpp @@ -577,6 +577,7 @@ convertColumnTypeToAttrType(NdbDictionary::Column::Type _type) return String; case NdbDictionary::Column::Datetime: case NdbDictionary::Column::Date: + case NdbDictionary::Column::Time: case NdbDictionary::Column::Undefined: default: return NoAttrTypeDef; diff --git a/ndb/tools/restore/consumer.cpp b/ndb/tools/restore/consumer.cpp index dc0567803dd..4d228230423 100644 --- a/ndb/tools/restore/consumer.cpp +++ b/ndb/tools/restore/consumer.cpp @@ -74,6 +74,9 @@ BackupConsumer::create_table_string(const TableS & table, case NdbDictionary::Column::Date: pos += sprintf(buf+pos, "%s", "date"); break; + case NdbDictionary::Column::Time: + pos += sprintf(buf+pos, "%s", "time"); + break; case NdbDictionary::Column::Undefined: // pos += sprintf(buf+pos, "%s", "varchar binary"); return -1; diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index e181b421e29..e4c45490050 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -2264,6 +2264,11 @@ void ha_ndbcluster::print_results() fprintf(DBUG_FILE, "Date\t%llu", value); break; } + case NdbDictionary::Column::Time: { + Uint64 value= (Uint64) *field->ptr; + fprintf(DBUG_FILE, "Time\t%llu", value); + break; + } case NdbDictionary::Column::Blob: { Uint64 len= 0; ndb_blob->getLength(len); @@ -3327,8 +3332,11 @@ static int create_ndb_column(NDBCOL &col, col.setType(NDBCOL::Date); col.setLength(1); break; - case MYSQL_TYPE_DATE: // ? case MYSQL_TYPE_TIME: + col.setType(NDBCOL::Time); + col.setLength(1); + break; + case MYSQL_TYPE_DATE: // ? case MYSQL_TYPE_YEAR: col.setType(NDBCOL::Char); col.setLength(field->pack_length()); |