summaryrefslogtreecommitdiff
path: root/ndb
diff options
context:
space:
mode:
authorunknown <pekka@mysql.com>2005-01-27 18:41:23 +0100
committerunknown <pekka@mysql.com>2005-01-27 18:41:23 +0100
commit763dfd7b100f69c994700a2753962ff45fa6d43a (patch)
tree893df5cfcf4ca1250e131120d2ce2f251824ffe0 /ndb
parent1c49d54894aec778efa3fef6da5ae992f21b8d1d (diff)
parent965288542f5e30d8f475f97582f123235b275174 (diff)
downloadmariadb-git-763dfd7b100f69c994700a2753962ff45fa6d43a.tar.gz
Merge
mysql-test/r/ndb_index_ordered.result: Auto merged mysql-test/t/ndb_index_ordered.test: Auto merged ndb/src/ndbapi/NdbDictionary.cpp: Auto merged sql/ha_ndbcluster.cc: Auto merged ndb/include/kernel/signaldata/DictTabInfo.hpp: merge ndb/include/ndbapi/NdbDictionary.hpp: merge ndb/include/util/NdbSqlUtil.hpp: merge ndb/src/common/util/NdbSqlUtil.cpp: merge ndb/src/ndbapi/NdbDictionaryImpl.cpp: merge ndb/src/ndbapi/NdbRecAttr.cpp: merge
Diffstat (limited to 'ndb')
-rw-r--r--ndb/include/kernel/signaldata/DictTabInfo.hpp12
-rw-r--r--ndb/include/ndbapi/NdbDictionary.hpp4
-rw-r--r--ndb/include/util/NdbSqlUtil.hpp6
-rw-r--r--ndb/src/common/util/NdbSqlUtil.cpp42
-rw-r--r--ndb/src/ndbapi/NdbDictionary.cpp6
-rw-r--r--ndb/src/ndbapi/NdbDictionaryImpl.cpp2
-rw-r--r--ndb/src/ndbapi/NdbRecAttr.cpp87
-rw-r--r--ndb/test/include/NdbSchemaOp.hpp4
8 files changed, 147 insertions, 16 deletions
diff --git a/ndb/include/kernel/signaldata/DictTabInfo.hpp b/ndb/include/kernel/signaldata/DictTabInfo.hpp
index 6ae8a8a2985..61c043f2998 100644
--- a/ndb/include/kernel/signaldata/DictTabInfo.hpp
+++ b/ndb/include/kernel/signaldata/DictTabInfo.hpp
@@ -276,7 +276,9 @@ public:
ExtBit = NdbSqlUtil::Type::Bit,
ExtLongvarchar = NdbSqlUtil::Type::Longvarchar,
ExtLongvarbinary = NdbSqlUtil::Type::Longvarbinary,
- ExtTime = NdbSqlUtil::Type::Time
+ ExtTime = NdbSqlUtil::Type::Time,
+ ExtYear = NdbSqlUtil::Type::Year,
+ ExtTimestamp = NdbSqlUtil::Type::Timestamp
};
// Attribute data interpretation
@@ -389,6 +391,14 @@ public:
AttributeSize = DictTabInfo::an8Bit;
AttributeArraySize = 3 * AttributeExtLength;
break;
+ case DictTabInfo::ExtYear:
+ AttributeSize = DictTabInfo::an8Bit;
+ AttributeArraySize = 1 * AttributeExtLength;
+ break;
+ case DictTabInfo::ExtTimestamp:
+ AttributeSize = DictTabInfo::an8Bit;
+ AttributeArraySize = 4 * AttributeExtLength;
+ break;
default:
return false;
};
diff --git a/ndb/include/ndbapi/NdbDictionary.hpp b/ndb/include/ndbapi/NdbDictionary.hpp
index 80c0831f675..91cfc0cb22a 100644
--- a/ndb/include/ndbapi/NdbDictionary.hpp
+++ b/ndb/include/ndbapi/NdbDictionary.hpp
@@ -196,7 +196,9 @@ public:
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
- Time = NDB_TYPE_TIME ///< Time without date
+ Time = NDB_TYPE_TIME, ///< Time without date
+ Year = NDB_TYPE_YEAR, ///< Year 1901-2155 (1 byte)
+ Timestamp = NDB_TYPE_TIMESTAMP ///< Unix time
};
/**
diff --git a/ndb/include/util/NdbSqlUtil.hpp b/ndb/include/util/NdbSqlUtil.hpp
index 75e2a819174..a8a2979558a 100644
--- a/ndb/include/util/NdbSqlUtil.hpp
+++ b/ndb/include/util/NdbSqlUtil.hpp
@@ -92,7 +92,9 @@ public:
Bit = NDB_TYPE_BIT,
Longvarchar = NDB_TYPE_LONG_VARCHAR,
Longvarbinary = NDB_TYPE_LONG_VARBINARY,
- Time = NDB_TYPE_TIME
+ Time = NDB_TYPE_TIME,
+ Year = NDB_TYPE_YEAR,
+ Timestamp = NDB_TYPE_TIMESTAMP
};
Enum m_typeId; // redundant
Cmp* m_cmp; // comparison method
@@ -161,6 +163,8 @@ private:
static Cmp cmpLongvarchar;
static Cmp cmpLongvarbinary;
static Cmp cmpTime;
+ static Cmp cmpYear;
+ static Cmp cmpTimestamp;
};
#endif
diff --git a/ndb/src/common/util/NdbSqlUtil.cpp b/ndb/src/common/util/NdbSqlUtil.cpp
index 82f99d0e7fd..d5f06f119ee 100644
--- a/ndb/src/common/util/NdbSqlUtil.cpp
+++ b/ndb/src/common/util/NdbSqlUtil.cpp
@@ -179,6 +179,14 @@ NdbSqlUtil::m_typeList[] = {
{
Type::Time,
cmpTime
+ },
+ {
+ Type::Year,
+ cmpYear
+ },
+ {
+ Type::Timestamp,
+ cmpTimestamp
}
};
@@ -670,6 +678,40 @@ NdbSqlUtil::cmpLongvarbinary(const void* info, const void* p1, unsigned n1, cons
return CmpUnknown;
}
+int
+NdbSqlUtil::cmpYear(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2, bool full)
+{
+ if (n2 >= sizeof(Uint8)) {
+ Uint8 v1, v2;
+ memcpy(&v1, p1, sizeof(Uint8));
+ memcpy(&v2, p2, sizeof(Uint8));
+ if (v1 < v2)
+ return -1;
+ if (v1 > v2)
+ return +1;
+ return 0;
+ }
+ assert(! full);
+ return CmpUnknown;
+}
+
+int
+NdbSqlUtil::cmpTimestamp(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2, bool full)
+{
+ if (n2 >= sizeof(Uint32)) {
+ Uint32 v1, v2;
+ memcpy(&v1, p1, sizeof(Uint32));
+ memcpy(&v2, p2, sizeof(Uint32));
+ if (v1 < v2)
+ return -1;
+ if (v1 > v2)
+ return +1;
+ return 0;
+ }
+ assert(! full);
+ return CmpUnknown;
+}
+
// check charset
bool
diff --git a/ndb/src/ndbapi/NdbDictionary.cpp b/ndb/src/ndbapi/NdbDictionary.cpp
index 93a82e4bc83..346f5de9eb5 100644
--- a/ndb/src/ndbapi/NdbDictionary.cpp
+++ b/ndb/src/ndbapi/NdbDictionary.cpp
@@ -980,6 +980,12 @@ operator<<(NdbOut& out, const NdbDictionary::Column& col)
case NdbDictionary::Column::Time:
out << "Time";
break;
+ case NdbDictionary::Column::Year:
+ out << "Year";
+ break;
+ case NdbDictionary::Column::Timestamp:
+ out << "Timestamp";
+ break;
case NdbDictionary::Column::Undefined:
out << "Undefined";
break;
diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp
index 498c5716c73..ca118cd0994 100644
--- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp
+++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp
@@ -144,6 +144,8 @@ NdbColumnImpl::init(Type t)
m_cs = default_cs;
break;
case Time:
+ case Year:
+ case Timestamp:
m_precision = 0;
m_scale = 0;
m_length = 1;
diff --git a/ndb/src/ndbapi/NdbRecAttr.cpp b/ndb/src/ndbapi/NdbRecAttr.cpp
index 30ba5c112fa..993fc8b6327 100644
--- a/ndb/src/ndbapi/NdbRecAttr.cpp
+++ b/ndb/src/ndbapi/NdbRecAttr.cpp
@@ -178,10 +178,11 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r)
return out;
}
- if (r.arraySize() > 1)
+ uint length = r.getColumn()->getLength();
+ if (length > 1)
out << "[";
- for (Uint32 j = 0; j < r.arraySize(); j++)
+ for (Uint32 j = 0; j < length; j++)
{
if (j > 0)
out << " ";
@@ -221,13 +222,13 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r)
break;
case NdbDictionary::Column::Char:
ndbrecattr_print_string(out,"Char",r.aRef(),r.arraySize());
- j = r.arraySize();
+ j = length;
break;
case NdbDictionary::Column::Varchar:
{
unsigned len = *(const unsigned char*)r.aRef();
ndbrecattr_print_string(out,"Varchar", r.aRef()+1,len);
- j = r.arraySize();
+ j = length;
}
break;
case NdbDictionary::Column::Float:
@@ -236,6 +237,74 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r)
case NdbDictionary::Column::Double:
out << r.double_value();
break;
+ // for dates cut-and-paste from field.cc
+ case NdbDictionary::Column::Datetime:
+ {
+ ulonglong tmp=r.u_64_value();
+ long part1,part2,part3;
+ part1=(long) (tmp/LL(1000000));
+ part2=(long) (tmp - (ulonglong) part1*LL(1000000));
+ char buf[40];
+ char* pos=(char*) buf+19;
+ *pos--=0;
+ *pos--= (char) ('0'+(char) (part2%10)); part2/=10;
+ *pos--= (char) ('0'+(char) (part2%10)); part3= (int) (part2 / 10);
+ *pos--= ':';
+ *pos--= (char) ('0'+(char) (part3%10)); part3/=10;
+ *pos--= (char) ('0'+(char) (part3%10)); part3/=10;
+ *pos--= ':';
+ *pos--= (char) ('0'+(char) (part3%10)); part3/=10;
+ *pos--= (char) ('0'+(char) part3);
+ *pos--= '/';
+ *pos--= (char) ('0'+(char) (part1%10)); part1/=10;
+ *pos--= (char) ('0'+(char) (part1%10)); part1/=10;
+ *pos--= '-';
+ *pos--= (char) ('0'+(char) (part1%10)); part1/=10;
+ *pos--= (char) ('0'+(char) (part1%10)); part3= (int) (part1/10);
+ *pos--= '-';
+ *pos--= (char) ('0'+(char) (part3%10)); part3/=10;
+ *pos--= (char) ('0'+(char) (part3%10)); part3/=10;
+ *pos--= (char) ('0'+(char) (part3%10)); part3/=10;
+ *pos=(char) ('0'+(char) part3);
+ out << buf;
+ }
+ break;
+ case NdbDictionary::Column::Date:
+ {
+ uint tmp=uint3korr(r.aRef());
+ int year=(int) ((uint32) tmp/10000L % 10000);
+ int month=(int) ((uint32) tmp/100 % 100);
+ int day=(int) ((uint32) tmp % 100);
+ char buf[40];
+ sprintf(buf, "%04d-%02d-%02d", year, month, day);
+ out << buf;
+ }
+ break;
+ case NdbDictionary::Column::Time:
+ {
+ long tmp=(long) sint3korr(r.aRef());
+ int hour=(uint) (tmp/10000);
+ int minute=(uint) (tmp/100 % 100);
+ int second=(uint) (tmp % 100);
+ char buf[40];
+ sprintf(buf, "%02d:%02d:%02d", hour, minute, second);
+ out << buf;
+ }
+ break;
+ case NdbDictionary::Column::Year:
+ {
+ uint year = 1900 + r.u_char_value();
+ char buf[40];
+ sprintf(buf, "%04d", year);
+ out << buf;
+ }
+ break;
+ case NdbDictionary::Column::Timestamp:
+ {
+ time_t time = r.u_32_value();
+ out << (uint)time;
+ }
+ break;
case NdbDictionary::Column::Blob:
{
const NdbBlob::Head* h = (const NdbBlob::Head*)r.aRef();
@@ -244,7 +313,7 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r)
unsigned n = r.arraySize() - sizeof(*h);
for (unsigned k = 0; k < n && k < h->length; k++)
out.print("%02X", (int)p[k]);
- j = r.arraySize();
+ j = length;
}
break;
case NdbDictionary::Column::Text:
@@ -255,26 +324,26 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r)
unsigned n = r.arraySize() - sizeof(*h);
for (unsigned k = 0; k < n && k < h->length; k++)
out.print("%c", (int)p[k]);
- j = r.arraySize();
+ j = length;
}
break;
case NdbDictionary::Column::Longvarchar:
{
unsigned len = uint2korr(r.aRef());
ndbrecattr_print_string(out,"Longvarchar", r.aRef()+2,len);
- j = r.arraySize();
+ j = length;
}
break;
default: /* no print functions for the rest, just print type */
out << (int) r.getType();
- j = r.arraySize();
+ j = length;
if (j > 1)
out << " " << j << " times";
break;
}
}
- if (r.arraySize() > 1)
+ if (length > 1)
{
out << "]";
}
diff --git a/ndb/test/include/NdbSchemaOp.hpp b/ndb/test/include/NdbSchemaOp.hpp
index e2fb4015b88..77e704c0e5c 100644
--- a/ndb/test/include/NdbSchemaOp.hpp
+++ b/ndb/test/include/NdbSchemaOp.hpp
@@ -575,10 +575,6 @@ convertColumnTypeToAttrType(NdbDictionary::Column::Type _type)
case NdbDictionary::Column::Binary:
case NdbDictionary::Column::Varbinary:
return String;
- case NdbDictionary::Column::Datetime:
- case NdbDictionary::Column::Date:
- case NdbDictionary::Column::Time:
- case NdbDictionary::Column::Undefined:
default:
return NoAttrTypeDef;
}