[Monetdb-developers] M4 Automatic multiplex version of .tostr: weird behavior
Stefan.Manegold at cwi.nl
Sun Feb 1 14:00:57 CET 2009
On Sun, Feb 01, 2009 at 01:03:43PM +0100, Lefteris wrote:
> The following behavior is strange to me, but I am not sure if it is a
> bug or I have done something wrong.
> dayTimeDuration (dtduration) is defined in mil as:
> .ATOM dtduration = lng;
> .FROMSTR = dtduration_fromstr;
> .TOSTR = dtduration_tostr;
> and in c as :
> typedef long long dtduration;
why not "lng" as above?
(well, yes, "lng" is defined as "long long", so it should not make a
difference other than looking more consistent, and hence, being easier to
#define dtduration_nil ((dtduration) int_nil)
should probabaly read
#define dtduration_nil ((dtduration) lng_nil)
> also .tostr has the following sign.
> int dtduration_tostr(str *buf, int *len, dtduration *val)
> you can find all this in MonetDB4/src/modules/plain/monettime.mx
> Now, if I do either:
> I get the correct value printed. But if I create a BAT (void,str):
> var a0006 := new (void,str).seqbase (0 at 0);
> and do:
> It gives back "PT0S", which means 0 duration, and thus the value of
> *val in dtduration_tostr is 0 (I checked that).
a) your example are casting from str to dtduration --- so what has
dtduration_*to*str() to do with this? Typo?
IMHO, casting from str to dtduration should be handled by
... of course, printing then IMHO uses dtduration_*to*str() to turn the
dtduration into a (printable) string, again...
b) hence, you'd need to check all input and output parameters of both
dtduration_tostr and dtduration_fromstr to check whether things might go
... if *val in dtduration_tostr (usd by print) is 0, then the
(multiplxed) cast from a [void,str] BAT to a [void,dtduration] BAT using
dtduration_fromstr might already have introduced the problem ...
> So, could that be some bug with correct dealing of long values in the
> multiplex creation (btw. where is that happening?)
> Or am I missing
> some special case that I should take into consideration with long
> Thank you,
> P.S. yearMonthDuration which is defined as int works like a charm.
check, whether there are more place where the int->lng translation did not
go well like with dtduration_nil above ...
> This SF.net email is sponsored by:
> SourcForge Community
> SourceForge wants to tell your story.
> Monetdb-developers mailing list
> Monetdb-developers at lists.sourceforge.net
| Dr. Stefan Manegold | mailto:Stefan.Manegold at cwi.nl |
| CWI, P.O.Box 94079 | http://www.cwi.nl/~manegold/ |
| 1090 GB Amsterdam | Tel.: +31 (20) 592-4212 |
| The Netherlands | Fax : +31 (20) 592-4312 |
More information about the developers-list