ndb - wl-1442 fix Date ordering

mysql-test/r/ndb_index_ordered.result:
  wl-1442 fix Date.  reuses old unused Timespec type id
mysql-test/t/ndb_index_ordered.test:
  wl-1442 fix Date.  reuses old unused Timespec type id
ndb/include/kernel/signaldata/DictTabInfo.hpp:
  wl-1442 fix Date.  reuses old unused Timespec type id
ndb/include/ndbapi/NdbDictionary.hpp:
  wl-1442 fix Date.  reuses old unused Timespec type id
ndb/include/util/NdbSqlUtil.hpp:
  wl-1442 fix Date.  reuses old unused Timespec type id
ndb/src/common/util/NdbSqlUtil.cpp:
  wl-1442 fix Date.  reuses old unused Timespec type id
ndb/src/ndbapi/NdbDictionary.cpp:
  wl-1442 fix Date.  reuses old unused Timespec type id
ndb/src/ndbapi/NdbDictionaryImpl.cpp:
  wl-1442 fix Date.  reuses old unused Timespec type id
ndb/test/include/NdbSchemaOp.hpp:
  wl-1442 fix Date.  reuses old unused Timespec type id
ndb/tools/restore/consumer.cpp:
  wl-1442 fix Date.  reuses old unused Timespec type id
sql/ha_ndbcluster.cc:
  wl-1442 fix Date.  reuses old unused Timespec type id
This commit is contained in:
unknown 2005-01-08 16:57:51 +01:00
commit 633ee9b099
11 changed files with 118 additions and 67 deletions

View file

@ -308,7 +308,7 @@ public:
ExtBinary = NdbSqlUtil::Type::Binary,
ExtVarbinary = NdbSqlUtil::Type::Varbinary,
ExtDatetime = NdbSqlUtil::Type::Datetime,
ExtTimespec = NdbSqlUtil::Type::Timespec,
ExtDate = NdbSqlUtil::Type::Date,
ExtBlob = NdbSqlUtil::Type::Blob,
ExtText = NdbSqlUtil::Type::Text
};
@ -428,10 +428,10 @@ public:
AttributeSize = DictTabInfo::an8Bit;
AttributeArraySize = 8 * AttributeExtLength;
return true;
case DictTabInfo::ExtTimespec:
case DictTabInfo::ExtDate:
AttributeType = DictTabInfo::StringType;
AttributeSize = DictTabInfo::an8Bit;
AttributeArraySize = 12 * AttributeExtLength;
AttributeArraySize = 3 * AttributeExtLength;
return true;
case DictTabInfo::ExtBlob:
case DictTabInfo::ExtText:

View file

@ -185,7 +185,7 @@ public:
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 )
Date, ///< Precision down to 1 day(sizeof(Date) == 4 bytes )
Blob, ///< Binary large object (see NdbBlob)
Text ///< Text blob
};

View file

@ -81,7 +81,7 @@ public:
Binary, // Len
Varbinary, // Max len
Datetime, // Precision down to 1 sec (size 8 bytes)
Timespec, // Precision down to 1 nsec (size 12 bytes)
Date, // Precision down to 1 day (size 4 bytes)
Blob, // Blob
Text // Text blob
};
@ -132,7 +132,7 @@ private:
static Cmp cmpBinary;
static Cmp cmpVarbinary;
static Cmp cmpDatetime;
static Cmp cmpTimespec;
static Cmp cmpDate;
static Cmp cmpBlob;
static Cmp cmpText;
};

View file

@ -153,8 +153,8 @@ NdbSqlUtil::m_typeList[] = {
cmpDatetime
},
{
Type::Timespec,
cmpTimespec
Type::Date,
cmpDate
},
{
Type::Blob,
@ -485,36 +485,34 @@ NdbSqlUtil::cmpDatetime(const void* info, const Uint32* p1, const Uint32* p2, Ui
}
int
NdbSqlUtil::cmpTimespec(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
NdbSqlUtil::cmpDate(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size)
{
#ifdef ndb_date_is_4_byte_native_int
assert(full >= size && size > 0);
union { Uint32 p[2]; Int32 v; } u1, u2;
u1.p[0] = p1[0];
u2.p[0] = p2[0];
if (u1.v < u2.v)
return -1;
if (u1.v > u2.v)
return +1;
return 0;
#else
assert(full >= size && size > 0);
/*
* Timespec is CC YY MM DD hh mm ss \0 NN NN NN NN
*
* Not used via MySQL.
*/
union { const Uint32* p; const unsigned char* v; } u1, u2;
u1.p = p1;
u2.p = p2;
// no format check
int k = memcmp(u1.v, u2.v, 4);
if (k != 0)
return k < 0 ? -1 : +1;
if (size >= 2) {
k = memcmp(u1.v + 4, u2.v + 4, 4);
if (k != 0)
return k < 0 ? -1 : +1;
if (size >= 3) {
Uint32 n1 = *(const Uint32*)(u1.v + 8);
Uint32 n2 = *(const Uint32*)(u2.v + 8);
if (n1 < n2)
return -1;
if (n2 > n1)
return +1;
return 0;
}
}
return CmpUnknown;
// from Field_newdate::val_int
Uint64 j1 = uint3korr(u1.v);
Uint64 j2 = uint3korr(u2.v);
j1 = (j1 % 32L)+(j1 / 32L % 16L)*100L + (j1/(16L*32L))*10000L;
j2 = (j2 % 32L)+(j2 / 32L % 16L)*100L + (j2/(16L*32L))*10000L;
if (j1 < j2)
return -1;
if (j1 > j2)
return +1;
return 0;
#endif
}
int

View file

@ -936,8 +936,8 @@ operator<<(NdbOut& out, const NdbDictionary::Column& col)
case NdbDictionary::Column::Datetime:
out << "Datetime";
break;
case NdbDictionary::Column::Timespec:
out << "Timespec";
case NdbDictionary::Column::Date:
out << "Date";
break;
case NdbDictionary::Column::Blob:
out << "Blob(" << col.getInlineSize() << "," << col.getPartSize()

View file

@ -130,7 +130,7 @@ NdbColumnImpl::init(Type t)
case Binary:
case Varbinary:
case Datetime:
case Timespec:
case Date:
m_precision = 0;
m_scale = 0;
m_length = 1;
@ -1174,7 +1174,7 @@ columnTypeMapping[] = {
{ DictTabInfo::ExtBinary, NdbDictionary::Column::Binary },
{ DictTabInfo::ExtVarbinary, NdbDictionary::Column::Varbinary },
{ DictTabInfo::ExtDatetime, NdbDictionary::Column::Datetime },
{ DictTabInfo::ExtTimespec, NdbDictionary::Column::Timespec },
{ DictTabInfo::ExtDate, NdbDictionary::Column::Date },
{ DictTabInfo::ExtBlob, NdbDictionary::Column::Blob },
{ DictTabInfo::ExtText, NdbDictionary::Column::Text },
{ -1, -1 }

View file

@ -576,7 +576,7 @@ convertColumnTypeToAttrType(NdbDictionary::Column::Type _type)
case NdbDictionary::Column::Varbinary:
return String;
case NdbDictionary::Column::Datetime:
case NdbDictionary::Column::Timespec:
case NdbDictionary::Column::Date:
case NdbDictionary::Column::Undefined:
default:
return NoAttrTypeDef;

View file

@ -71,8 +71,8 @@ BackupConsumer::create_table_string(const TableS & table,
case NdbDictionary::Column::Datetime:
pos += sprintf(buf+pos, "%s", "datetime");
break;
case NdbDictionary::Column::Timespec:
pos += sprintf(buf+pos, "%s", "time");
case NdbDictionary::Column::Date:
pos += sprintf(buf+pos, "%s", "date");
break;
case NdbDictionary::Column::Undefined:
// pos += sprintf(buf+pos, "%s", "varchar binary");