Changeset: 76fbad9fff6f for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=76fbad9fff6f
Modified Files:
sql/backends/monet5/sql_result.c
Branch: protocol
Log Message:
Also transfer EC_DATE as miliseconds since epoch.
diffs (89 lines):
diff --git a/sql/backends/monet5/sql_result.c b/sql/backends/monet5/sql_result.c
--- a/sql/backends/monet5/sql_result.c
+++ b/sql/backends/monet5/sql_result.c
@@ -1304,7 +1304,7 @@ static int type_supports_binary_transfer
type->eclass == EC_BLOB ||
type->eclass == EC_FLT ||
type->eclass == EC_NUM ||
-// type->eclass == EC_DATE ||
+ type->eclass == EC_DATE ||
type->eclass == EC_TIME ||
type->eclass == EC_SEC ||
type->eclass == EC_MONTH ||
@@ -1360,8 +1360,8 @@ mvc_export_table_prot10(backend *b, stre
iterators[i] = bat_iterator(b);
- if (type->eclass == EC_TIMESTAMP) {
- // timestamps are converted to Unix Timestamps
+ if (type->eclass == EC_TIMESTAMP || type->eclass == EC_DATE) {
+ // dates and timestamps are converted to Unix Timestamps
mtype = TYPE_lng;
typelen = sizeof(lng);
}
@@ -1547,6 +1547,20 @@ mvc_export_table_prot10(backend *b, stre
bufptr[j] = swap ?
long_long_SWAP(time) : time;
}
atom_size = sizeof(lng);
+ } else if (c->type.type->eclass == EC_DATE) {
+ // convert dates into timestamps since
epoch
+ lng time;
+ timestamp tstamp;
+ size_t j = 0;
+ int swap = mnstr_byteorder(s) != 1234;
+ date *dates = (date*)
Tloc(iterators[i].b, srow);
+ lng *bufptr = (lng*) buf;
+ for(j = 0; j < (row - srow); j++) {
+ tstamp.payload.p_days =
dates[j];
+ MTIMEepoch2lng(&time, &tstamp);
+ bufptr[j] = swap ?
long_long_SWAP(time) : time;
+ }
+ atom_size = sizeof(lng);
} else {
if (mnstr_byteorder(s) != 1234) {
size_t j = 0;
@@ -2028,7 +2042,7 @@ mvc_export_head_prot10(backend *b, strea
}
BBPunfix(b->batCacheid);
- if (type->eclass == EC_TIMESTAMP) {
+ if (type->eclass == EC_TIMESTAMP || type->eclass == EC_DATE) {
// timestamps are converted to Unix Timestamps
mtype = TYPE_lng;
typelen = sizeof(lng);
@@ -2054,10 +2068,11 @@ mvc_export_head_prot10(backend *b, strea
goto cleanup;
}
- if (type->eclass == EC_BLOB) {
+ if ((b->tnil == 0 && b->tnonil == 1) || type->eclass ==
EC_BLOB) {
nil_len = 0;
}
+
// write NULL values for this column to the stream
// NULL values are encoded as [size:int][NULL value] ([size] is
always [typelen] for fixed size columns)
if (!mnstr_writeInt(s, nil_len)) {
@@ -2065,7 +2080,7 @@ mvc_export_head_prot10(backend *b, strea
goto cleanup;
}
// transfer the actual NULL value
- if (type->eclass != EC_BLOB) {
+ if (nil_len > 0) {
switch(nil_type) {
case TYPE_str:
retval = write_str_term(s, str_nil);
@@ -2089,11 +2104,11 @@ mvc_export_head_prot10(backend *b, strea
case TYPE_dbl:
retval = mnstr_writeDbl(s, dbl_nil);
break;
- #ifdef HAVE_HGE
+#ifdef HAVE_HGE
case TYPE_hge:
retval = mnstr_writeHge(s, hge_nil);
break;
- #endif
+#endif
case TYPE_void:
break;
default:
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list