diff options
author | unknown <stewart@mysql.com> | 2005-02-01 11:45:05 +1100 |
---|---|---|
committer | unknown <stewart@mysql.com> | 2005-02-01 11:45:05 +1100 |
commit | 098fc22417ee3431c8c28fba3eebe8450e8f602c (patch) | |
tree | 6ccae14192f06556abbf58565cf1979aca1bc13d /ndb/src/ndbapi | |
parent | ce538ca115a8e4af47845ea384b64a4cae3b595e (diff) | |
parent | cdce11a32b3f7801e942bd14b29f233008e335b9 (diff) | |
download | mariadb-git-098fc22417ee3431c8c28fba3eebe8450e8f602c.tar.gz |
Merge mysql.com:/home/stewart/Documents/MySQL/5.0/ndb
into mysql.com:/home/stewart/Documents/MySQL/5.0/ndb-dynamic-ports-impl5
ndb/src/common/mgmcommon/IPCConfig.cpp:
Auto merged
ndb/src/common/transporter/TransporterRegistry.cpp:
Auto merged
ndb/src/cw/cpcd/main.cpp:
Auto merged
ndb/src/mgmsrv/ConfigInfo.cpp:
Auto merged
ndb/src/mgmsrv/main.cpp:
Auto merged
Diffstat (limited to 'ndb/src/ndbapi')
-rw-r--r-- | ndb/src/ndbapi/NdbDictionary.cpp | 6 | ||||
-rw-r--r-- | ndb/src/ndbapi/NdbDictionaryImpl.cpp | 22 | ||||
-rw-r--r-- | ndb/src/ndbapi/NdbRecAttr.cpp | 99 |
3 files changed, 98 insertions, 29 deletions
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..a089a818fb5 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; @@ -2148,26 +2150,6 @@ NdbDictInterface::createIndex(Ndb & ndb, } attributeList.id[i] = col->m_attrId; } - if (it == DictTabInfo::UniqueHashIndex) { - // Sort index attributes according to primary table (using insertion sort) - for(i = 1; i < attributeList.sz; i++) { - unsigned int temp = attributeList.id[i]; - unsigned int j = i; - while((j > 0) && (attributeList.id[j - 1] > temp)) { - attributeList.id[j] = attributeList.id[j - 1]; - j--; - } - attributeList.id[j] = temp; - } - // Check for illegal duplicate attributes - for(i = 0; i<attributeList.sz; i++) { - if ((i != (attributeList.sz - 1)) && - (attributeList.id[i] == attributeList.id[i+1])) { - m_error.code = 4258; - return -1; - } - } - } LinearSectionPtr ptr[3]; ptr[0].p = (Uint32*)&attributeList; ptr[0].sz = 1 + attributeList.sz; diff --git a/ndb/src/ndbapi/NdbRecAttr.cpp b/ndb/src/ndbapi/NdbRecAttr.cpp index 30ba5c112fa..85b08c0cfa4 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,86 @@ 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: + { + uint32 tmp=(uint32) uint3korr(r.aRef()); + int part; + char buf[40]; + char *pos=(char*) buf+10; + *pos--=0; + part=(int) (tmp & 31); + *pos--= (char) ('0'+part%10); + *pos--= (char) ('0'+part/10); + *pos--= '-'; + part=(int) (tmp >> 5 & 15); + *pos--= (char) ('0'+part%10); + *pos--= (char) ('0'+part/10); + *pos--= '-'; + part=(int) (tmp >> 9); + *pos--= (char) ('0'+part%10); part/=10; + *pos--= (char) ('0'+part%10); part/=10; + *pos--= (char) ('0'+part%10); part/=10; + *pos= (char) ('0'+part); + 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 +325,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 +336,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 << "]"; } |