Commit 3186b340 authored by unknown's avatar unknown

ndb - wl-1442 fix Time ordering


mysql-test/r/ndb_index_ordered.result:
  wl-1442 fix Time.  adds new type id 25
mysql-test/t/ndb_index_ordered.test:
  wl-1442 fix Time.  adds new type id 25
ndb/include/kernel/signaldata/DictTabInfo.hpp:
  wl-1442 fix Time.  adds new type id 25
ndb/include/ndbapi/NdbDictionary.hpp:
  wl-1442 fix Time.  adds new type id 25
ndb/include/util/NdbSqlUtil.hpp:
  wl-1442 fix Time.  adds new type id 25
ndb/src/common/util/NdbSqlUtil.cpp:
  wl-1442 fix Time.  adds new type id 25
ndb/src/ndbapi/NdbDictionary.cpp:
  wl-1442 fix Time.  adds new type id 25
ndb/src/ndbapi/NdbDictionaryImpl.cpp:
  wl-1442 fix Time.  adds new type id 25
ndb/test/include/NdbSchemaOp.hpp:
  wl-1442 fix Time.  adds new type id 25
ndb/tools/restore/consumer.cpp:
  wl-1442 fix Time.  adds new type id 25
sql/ha_ndbcluster.cc:
  wl-1442 fix Time.  adds new type id 25
parent 633ee9b0
...@@ -375,3 +375,48 @@ count(*)-8 ...@@ -375,3 +375,48 @@ count(*)-8
select count(*)-9 from t1 use index (da) where da <= '2055-01-01'; select count(*)-9 from t1 use index (da) where da <= '2055-01-01';
count(*)-9 count(*)-9
0 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
...@@ -217,3 +217,22 @@ select count(*)-5 from t1 use index (da) where da < '1970-03-03'; ...@@ -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(*)-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(*)-8 from t1 use index (da) where da <= '2001-01-02';
select count(*)-9 from t1 use index (da) where da <= '2055-01-01'; 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';
...@@ -310,7 +310,8 @@ public: ...@@ -310,7 +310,8 @@ public:
ExtDatetime = NdbSqlUtil::Type::Datetime, ExtDatetime = NdbSqlUtil::Type::Datetime,
ExtDate = NdbSqlUtil::Type::Date, ExtDate = NdbSqlUtil::Type::Date,
ExtBlob = NdbSqlUtil::Type::Blob, ExtBlob = NdbSqlUtil::Type::Blob,
ExtText = NdbSqlUtil::Type::Text ExtText = NdbSqlUtil::Type::Text,
ExtTime = NdbSqlUtil::Type::Time
}; };
// Attribute data interpretation // Attribute data interpretation
...@@ -440,6 +441,11 @@ public: ...@@ -440,6 +441,11 @@ public:
// head + inline part [ attr precision lower half ] // head + inline part [ attr precision lower half ]
AttributeArraySize = (NDB_BLOB_HEAD_SIZE << 2) + (AttributeExtPrecision & 0xFFFF); AttributeArraySize = (NDB_BLOB_HEAD_SIZE << 2) + (AttributeExtPrecision & 0xFFFF);
return true; return true;
case DictTabInfo::ExtTime:
AttributeType = DictTabInfo::StringType;
AttributeSize = DictTabInfo::an8Bit;
AttributeArraySize = 3 * AttributeExtLength;
return true;
}; };
return false; return false;
} }
......
...@@ -187,7 +187,8 @@ public: ...@@ -187,7 +187,8 @@ public:
Datetime, ///< Precision down to 1 sec (sizeof(Datetime) == 8 bytes ) Datetime, ///< Precision down to 1 sec (sizeof(Datetime) == 8 bytes )
Date, ///< Precision down to 1 day(sizeof(Date) == 4 bytes ) Date, ///< Precision down to 1 day(sizeof(Date) == 4 bytes )
Blob, ///< Binary large object (see NdbBlob) Blob, ///< Binary large object (see NdbBlob)
Text ///< Text blob Text, ///< Text blob
Time = 25 ///< Time without date
}; };
/** /**
......
...@@ -83,7 +83,8 @@ public: ...@@ -83,7 +83,8 @@ public:
Datetime, // Precision down to 1 sec (size 8 bytes) Datetime, // Precision down to 1 sec (size 8 bytes)
Date, // Precision down to 1 day (size 4 bytes) Date, // Precision down to 1 day (size 4 bytes)
Blob, // Blob Blob, // Blob
Text // Text blob Text, // Text blob
Time = 25 // Time without date
}; };
Enum m_typeId; Enum m_typeId;
Cmp* m_cmp; // comparison method Cmp* m_cmp; // comparison method
...@@ -135,6 +136,7 @@ private: ...@@ -135,6 +136,7 @@ private:
static Cmp cmpDate; static Cmp cmpDate;
static Cmp cmpBlob; static Cmp cmpBlob;
static Cmp cmpText; static Cmp cmpText;
static Cmp cmpTime;
}; };
#endif #endif
...@@ -163,6 +163,22 @@ NdbSqlUtil::m_typeList[] = { ...@@ -163,6 +163,22 @@ NdbSqlUtil::m_typeList[] = {
{ {
Type::Text, Type::Text,
cmpText 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 ...@@ -559,6 +575,23 @@ NdbSqlUtil::cmpText(const void* info, const Uint32* p1, const Uint32* p2, Uint32
return CmpUnknown; 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 // check charset
bool bool
......
...@@ -947,6 +947,9 @@ operator<<(NdbOut& out, const NdbDictionary::Column& col) ...@@ -947,6 +947,9 @@ operator<<(NdbOut& out, const NdbDictionary::Column& col)
out << "Text(" << col.getInlineSize() << "," << col.getPartSize() out << "Text(" << col.getInlineSize() << "," << col.getPartSize()
<< ";" << col.getStripeSize() << ";" << csname << ")"; << ";" << col.getStripeSize() << ";" << csname << ")";
break; break;
case NdbDictionary::Column::Time:
out << "Time";
break;
case NdbDictionary::Column::Undefined: case NdbDictionary::Column::Undefined:
out << "Undefined"; out << "Undefined";
break; break;
......
...@@ -148,6 +148,12 @@ NdbColumnImpl::init(Type t) ...@@ -148,6 +148,12 @@ NdbColumnImpl::init(Type t)
m_length = 4; m_length = 4;
m_cs = default_cs; m_cs = default_cs;
break; break;
case Time:
m_precision = 0;
m_scale = 0;
m_length = 1;
m_cs = NULL;
break;
case Undefined: case Undefined:
assert(false); assert(false);
break; break;
...@@ -1177,6 +1183,7 @@ columnTypeMapping[] = { ...@@ -1177,6 +1183,7 @@ columnTypeMapping[] = {
{ DictTabInfo::ExtDate, NdbDictionary::Column::Date }, { DictTabInfo::ExtDate, NdbDictionary::Column::Date },
{ DictTabInfo::ExtBlob, NdbDictionary::Column::Blob }, { DictTabInfo::ExtBlob, NdbDictionary::Column::Blob },
{ DictTabInfo::ExtText, NdbDictionary::Column::Text }, { DictTabInfo::ExtText, NdbDictionary::Column::Text },
{ DictTabInfo::ExtTime, NdbDictionary::Column::Time },
{ -1, -1 } { -1, -1 }
}; };
......
...@@ -577,6 +577,7 @@ convertColumnTypeToAttrType(NdbDictionary::Column::Type _type) ...@@ -577,6 +577,7 @@ convertColumnTypeToAttrType(NdbDictionary::Column::Type _type)
return String; return String;
case NdbDictionary::Column::Datetime: case NdbDictionary::Column::Datetime:
case NdbDictionary::Column::Date: case NdbDictionary::Column::Date:
case NdbDictionary::Column::Time:
case NdbDictionary::Column::Undefined: case NdbDictionary::Column::Undefined:
default: default:
return NoAttrTypeDef; return NoAttrTypeDef;
......
...@@ -74,6 +74,9 @@ BackupConsumer::create_table_string(const TableS & table, ...@@ -74,6 +74,9 @@ BackupConsumer::create_table_string(const TableS & table,
case NdbDictionary::Column::Date: case NdbDictionary::Column::Date:
pos += sprintf(buf+pos, "%s", "date"); pos += sprintf(buf+pos, "%s", "date");
break; break;
case NdbDictionary::Column::Time:
pos += sprintf(buf+pos, "%s", "time");
break;
case NdbDictionary::Column::Undefined: case NdbDictionary::Column::Undefined:
// pos += sprintf(buf+pos, "%s", "varchar binary"); // pos += sprintf(buf+pos, "%s", "varchar binary");
return -1; return -1;
......
...@@ -2264,6 +2264,11 @@ void ha_ndbcluster::print_results() ...@@ -2264,6 +2264,11 @@ void ha_ndbcluster::print_results()
fprintf(DBUG_FILE, "Date\t%llu", value); fprintf(DBUG_FILE, "Date\t%llu", value);
break; break;
} }
case NdbDictionary::Column::Time: {
Uint64 value= (Uint64) *field->ptr;
fprintf(DBUG_FILE, "Time\t%llu", value);
break;
}
case NdbDictionary::Column::Blob: { case NdbDictionary::Column::Blob: {
Uint64 len= 0; Uint64 len= 0;
ndb_blob->getLength(len); ndb_blob->getLength(len);
...@@ -3327,8 +3332,11 @@ static int create_ndb_column(NDBCOL &col, ...@@ -3327,8 +3332,11 @@ static int create_ndb_column(NDBCOL &col,
col.setType(NDBCOL::Date); col.setType(NDBCOL::Date);
col.setLength(1); col.setLength(1);
break; break;
case MYSQL_TYPE_DATE: // ?
case MYSQL_TYPE_TIME: case MYSQL_TYPE_TIME:
col.setType(NDBCOL::Time);
col.setLength(1);
break;
case MYSQL_TYPE_DATE: // ?
case MYSQL_TYPE_YEAR: case MYSQL_TYPE_YEAR:
col.setType(NDBCOL::Char); col.setType(NDBCOL::Char);
col.setLength(field->pack_length()); col.setLength(field->pack_length());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment