-
Notifications
You must be signed in to change notification settings - Fork 386
Closed
Labels
Description
It is allowed to create intervals with values bigger than int32 for minutes and seconds.
tarantool/src/lua/datetime.lua
Lines 144 to 145 in ff57f99
local MAX_MIN_RANGE = MAX_HOUR_RANGE * 60 | |
local MAX_SEC_RANGE = MAX_DAY_RANGE * SECS_PER_DAY |
Since double
s are used to store values, interval itself can process such big values.
tarantool/src/lib/core/datetime.h
Lines 109 to 128 in 054526a
struct interval { | |
/** Duration in seconds. */ | |
double sec; | |
/** Number of minutes, if specified. */ | |
double min; | |
/** Number of hours, if specified. */ | |
double hour; | |
/** Number of days, if specified. */ | |
double day; | |
/** Number of weeks, if specified. */ | |
int32_t week; | |
/** Number of months, if specified. */ | |
int32_t month; | |
/** Number of years, if specified. */ | |
int32_t year; | |
/** Fraction part of duration in seconds. */ | |
int32_t nsec; | |
/** Adjustment mode for day in month operations, @sa dt_adjust_t */ | |
dt_adjust_t adjust; | |
}; |
Msgpack encoding also succeeds:
tarantool> msgpack.encode(datetime.interval.new{min=6184879877159}):hex()
---
- c70d060205cf000005a007916c270801
...
Yet msgpack decoding fails:
tarantool> msgpack.decode(msgpack.encode(datetime.interval.new{min=6184879877159}))
---
- error: 'msgpack.decode: invalid MsgPack'
...
The reason is that int32 is used to extract the value
tarantool/src/lib/core/mp_interval.c
Line 130 in 054526a
if (mp_read_int32(data, &value) != 0) |
while allowed values are not really restricted to int32. (For example, msgpack above has uint64 value for minutes.)