summaryrefslogtreecommitdiff
path: root/ndb
diff options
context:
space:
mode:
authorunknown <pekka@mysql.com>2005-01-09 00:45:06 +0100
committerunknown <pekka@mysql.com>2005-01-09 00:45:06 +0100
commitf029af067b5e68222d3b52e5c3c400ba47ef411d (patch)
treef4e1eba2241ebc4cef73aa11e6ed710e36bb2d41 /ndb
parent3fbb1dd5fff45824f25916ad40488592a067ca86 (diff)
parent09a487266171a297db9fab88710c224e7526e8b6 (diff)
downloadmariadb-git-f029af067b5e68222d3b52e5c3c400ba47ef411d.tar.gz
Merge
ndb/src/ndbapi/NdbDictionary.cpp: Auto merged ndb/src/ndbapi/NdbDictionaryImpl.cpp: Auto merged sql/ha_ndbcluster.cc: Auto merged ndb/include/ndb_constants.h: merge 5.0->5.0-ndb ndb/include/kernel/signaldata/DictTabInfo.hpp: merge 5.0->5.0-ndb ndb/include/ndbapi/NdbDictionary.hpp: merge 5.0->5.0-ndb ndb/include/util/NdbSqlUtil.hpp: merge 5.0->5.0-ndb ndb/src/common/util/NdbSqlUtil.cpp: merge 5.0->5.0-ndb
Diffstat (limited to 'ndb')
-rw-r--r--ndb/include/kernel/signaldata/DictTabInfo.hpp13
-rw-r--r--ndb/include/ndb_constants.h10
-rw-r--r--ndb/include/ndbapi/NdbDictionary.hpp5
-rw-r--r--ndb/include/util/NdbSqlUtil.hpp10
-rw-r--r--ndb/src/common/util/NdbSqlUtil.cpp77
-rw-r--r--ndb/src/ndbapi/NdbDictionary.cpp7
-rw-r--r--ndb/src/ndbapi/NdbDictionaryImpl.cpp8
-rw-r--r--ndb/test/include/NdbSchemaOp.hpp3
-rw-r--r--ndb/tools/restore/consumer.cpp5
9 files changed, 109 insertions, 29 deletions
diff --git a/ndb/include/kernel/signaldata/DictTabInfo.hpp b/ndb/include/kernel/signaldata/DictTabInfo.hpp
index cc8a647615c..93ad246a094 100644
--- a/ndb/include/kernel/signaldata/DictTabInfo.hpp
+++ b/ndb/include/kernel/signaldata/DictTabInfo.hpp
@@ -266,12 +266,13 @@ 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,
ExtBit = NdbSqlUtil::Type::Bit,
ExtLongvarchar = NdbSqlUtil::Type::Longvarchar,
- ExtLongvarbinary = NdbSqlUtil::Type::Longvarbinary
+ ExtLongvarbinary = NdbSqlUtil::Type::Longvarbinary,
+ ExtTime = NdbSqlUtil::Type::Time
};
// Attribute data interpretation
@@ -358,10 +359,10 @@ public:
AttributeSize = DictTabInfo::an8Bit;
AttributeArraySize = 8 * AttributeExtLength;
break;
- case DictTabInfo::ExtTimespec:
+ case DictTabInfo::ExtDate:
// to fix
AttributeSize = DictTabInfo::an8Bit;
- AttributeArraySize = 12 * AttributeExtLength;
+ AttributeArraySize = 3 * AttributeExtLength;
break;
case DictTabInfo::ExtBlob:
case DictTabInfo::ExtText:
@@ -380,6 +381,10 @@ public:
AttributeSize = DictTabInfo::an8Bit;
AttributeArraySize = AttributeExtLength + 2;
break;
+ case DictTabInfo::ExtTime:
+ AttributeSize = DictTabInfo::an8Bit;
+ AttributeArraySize = 3 * AttributeExtLength;
+ break;
default:
return false;
};
diff --git a/ndb/include/ndb_constants.h b/ndb/include/ndb_constants.h
index b4e42fb83f5..491d0719a69 100644
--- a/ndb/include/ndb_constants.h
+++ b/ndb/include/ndb_constants.h
@@ -53,17 +53,15 @@
#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_DATETIME 18
+#define NDB_TYPE_DATE 19
#define NDB_TYPE_BLOB 20
#define NDB_TYPE_TEXT 21
#define NDB_TYPE_BIT 22
#define NDB_TYPE_LONG_VARCHAR 23
#define NDB_TYPE_LONG_VARBINARY 24
+#define NDB_TYPE_TIME 25
-// add at next merge 4.1->5.0
-// #define NDB_TYPE_TIME 25
-
-#define NDB_TYPE_MAX 25
+#define NDB_TYPE_MAX 26
#endif
diff --git a/ndb/include/ndbapi/NdbDictionary.hpp b/ndb/include/ndbapi/NdbDictionary.hpp
index ecc34072661..2100260dab3 100644
--- a/ndb/include/ndbapi/NdbDictionary.hpp
+++ b/ndb/include/ndbapi/NdbDictionary.hpp
@@ -190,12 +190,13 @@ public:
Binary = NDB_TYPE_BINARY, ///< Len
Varbinary = NDB_TYPE_VARBINARY, ///< Length bytes: 1, Max: 255
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 )
+ Date = NDB_TYPE_DATE, ///< Precision down to 1 day(sizeof(Date) == 4 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
Longvarchar = NDB_TYPE_LONG_VARCHAR, ///< Length bytes: 2, little-endian
- Longvarbinary = NDB_TYPE_LONG_VARBINARY ///< Length bytes: 2, little-endian
+ Longvarbinary = NDB_TYPE_LONG_VARBINARY, ///< Length bytes: 2, little-endian
+ Time = NDB_TYPE_TIME ///< Time without date
};
/**
diff --git a/ndb/include/util/NdbSqlUtil.hpp b/ndb/include/util/NdbSqlUtil.hpp
index feb2b97c54b..529e02f1d89 100644
--- a/ndb/include/util/NdbSqlUtil.hpp
+++ b/ndb/include/util/NdbSqlUtil.hpp
@@ -86,12 +86,13 @@ public:
Binary = NDB_TYPE_BINARY,
Varbinary = NDB_TYPE_VARBINARY,
Datetime = NDB_TYPE_DATETIME,
- Timespec = NDB_TYPE_TIMESPEC,
+ Date = NDB_TYPE_DATE,
Blob = NDB_TYPE_BLOB,
Text = NDB_TYPE_TEXT,
- Bit = NDB_TYPE_BIT,
+ Bit = NDB_TYPE_BIT
Longvarchar = NDB_TYPE_LONG_VARCHAR,
- Longvarbinary = NDB_TYPE_LONG_VARBINARY
+ Longvarbinary = NDB_TYPE_LONG_VARBINARY,
+ Time = NDB_TYPE_TIME
};
Enum m_typeId; // redundant
Cmp* m_cmp; // comparison method
@@ -153,12 +154,13 @@ private:
static Cmp cmpBinary;
static Cmp cmpVarbinary;
static Cmp cmpDatetime;
- static Cmp cmpTimespec;
+ static Cmp cmpDate;
static Cmp cmpBlob;
static Cmp cmpText;
static Cmp cmpBit;
static Cmp cmpLongvarchar;
static Cmp cmpLongvarbinary;
+ static Cmp cmpTime;
};
#endif
diff --git a/ndb/src/common/util/NdbSqlUtil.cpp b/ndb/src/common/util/NdbSqlUtil.cpp
index fd23781605c..1e280ae0fac 100644
--- a/ndb/src/common/util/NdbSqlUtil.cpp
+++ b/ndb/src/common/util/NdbSqlUtil.cpp
@@ -153,8 +153,8 @@ NdbSqlUtil::m_typeList[] = {
cmpDatetime
},
{
- Type::Timespec,
- NULL // cmpTimespec
+ Type::Date,
+ cmpDate
},
{
Type::Blob,
@@ -175,6 +175,10 @@ NdbSqlUtil::m_typeList[] = {
{
Type::Longvarbinary,
cmpLongvarbinary
+ },
+ {
+ Type::Time,
+ cmpTime
}
};
@@ -507,19 +511,57 @@ NdbSqlUtil::cmpVarbinary(const void* info, const void* p1, unsigned n1, const vo
return CmpUnknown;
}
-// allowed but ordering is wrong before wl-1442 done
int
NdbSqlUtil::cmpDatetime(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2, bool full)
{
- return cmpBinary(info, p1, n1, p2, n2, full);
+ if (n2 >= sizeof(Int64)) {
+ Int64 v1, v2;
+ memcpy(&v1, p1, sizeof(Int64));
+ memcpy(&v2, p2, sizeof(Int64));
+ if (v1 < v2)
+ return -1;
+ if (v1 > v2)
+ return +1;
+ return 0;
+ }
+ assert(! full);
+ return CmpUnknown;
}
-// not used by MySQL or NDB
int
-NdbSqlUtil::cmpTimespec(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2, bool full)
+NdbSqlUtil::cmpDate(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2, bool full)
{
- assert(false);
- return 0;
+#ifdef ndb_date_is_4_byte_native_int
+ if (n2 >= sizeof(Int32)) {
+ Int32 v1, v2;
+ memcpy(&v1, p1, sizeof(Int32));
+ memcpy(&v2, p2, sizeof(Int32));
+ if (v1 < v2)
+ return -1;
+ if (v1 > v2)
+ return +1;
+ return 0;
+ }
+ assert(! full);
+ return CmpUnknown;
+#else
+ if (n2 >= 4) { // may access 4-th byte
+ const uchar* v1 = (const uchar*)p1;
+ const uchar* v2 = (const uchar*)p2;
+ // from Field_newdate::val_int
+ Uint64 j1 = uint3korr(v1);
+ Uint64 j2 = uint3korr(v2);
+ 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;
+ }
+ assert(! full);
+ return CmpUnknown;
+#endif
}
// not supported
@@ -538,6 +580,25 @@ NdbSqlUtil::cmpText(const void* info, const void* p1, unsigned n1, const void* p
return 0;
}
+int
+NdbSqlUtil::cmpTime(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2, bool full)
+{
+ if (n2 >= 4) { // may access 4-th byte
+ const uchar* v1 = (const uchar*)p1;
+ const uchar* v2 = (const uchar*)p2;
+ // from Field_time::val_int
+ Int32 j1 = sint3korr(v1);
+ Int32 j2 = sint3korr(v2);
+ if (j1 < j2)
+ return -1;
+ if (j1 > j2)
+ return +1;
+ return 0;
+ }
+ assert(! full);
+ return CmpUnknown;
+}
+
// not yet
int
NdbSqlUtil::cmpBit(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2, bool full)
diff --git a/ndb/src/ndbapi/NdbDictionary.cpp b/ndb/src/ndbapi/NdbDictionary.cpp
index db912995b5f..4221c22121d 100644
--- a/ndb/src/ndbapi/NdbDictionary.cpp
+++ b/ndb/src/ndbapi/NdbDictionary.cpp
@@ -956,8 +956,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()
@@ -967,6 +967,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 13f9d0c48e1..07a186d8850 100644
--- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp
+++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp
@@ -125,7 +125,7 @@ NdbColumnImpl::init(Type t)
case Binary:
case Varbinary:
case Datetime:
- case Timespec:
+ case Date:
m_precision = 0;
m_scale = 0;
m_length = 1;
@@ -143,6 +143,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 Bit:
m_precision = 0;
m_scale = 0;
diff --git a/ndb/test/include/NdbSchemaOp.hpp b/ndb/test/include/NdbSchemaOp.hpp
index ac859f8abe8..e2fb4015b88 100644
--- a/ndb/test/include/NdbSchemaOp.hpp
+++ b/ndb/test/include/NdbSchemaOp.hpp
@@ -576,7 +576,8 @@ 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::Time:
case NdbDictionary::Column::Undefined:
default:
return NoAttrTypeDef;
diff --git a/ndb/tools/restore/consumer.cpp b/ndb/tools/restore/consumer.cpp
index e94c31b2666..4d228230423 100644
--- a/ndb/tools/restore/consumer.cpp
+++ b/ndb/tools/restore/consumer.cpp
@@ -71,7 +71,10 @@ BackupConsumer::create_table_string(const TableS & table,
case NdbDictionary::Column::Datetime:
pos += sprintf(buf+pos, "%s", "datetime");
break;
- case NdbDictionary::Column::Timespec:
+ 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: