From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id C35ED6EC58; Mon, 2 Aug 2021 03:41:31 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C35ED6EC58 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1627864891; bh=Z1QNEmezHkAibP0DRDCYEs1uM2xk3KmWAkruvw9AmOw=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=Ekf6L+fc8143dPzLY1ebsNGHzLEUwYXDEV4K/ycpOQ2QP5/c3mZSSjhYUBiKgKOLk sctbqJG26L3loe67xKM+rNa0FdmkYIBIoQKfdxy6FB3vx1vzA6bCrsw5yinl+DHlPP HgVwBFozRmB6u2N7d5qppAIRUV1pybQ82U1mdrVY= Received: from smtp58.i.mail.ru (smtp58.i.mail.ru [217.69.128.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id CB50D6EC58 for ; Mon, 2 Aug 2021 03:41:29 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org CB50D6EC58 Received: by smtp58.i.mail.ru with esmtpa (envelope-from ) id 1mAM1I-0000PY-7v; Mon, 02 Aug 2021 03:41:28 +0300 To: v.shpilevoy@tarantool.org, olegrok@tarantool.org Date: Mon, 2 Aug 2021 03:40:56 +0300 Message-Id: X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD941C43E597735A9C351B198F4576AC7B21928AAE70459C21B182A05F5380850408E7E4103942958D05A38D9A8095FA7129145320360FA0131154925F18E13E842 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7B9FBA884A7C9B8BAEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637B6B039AA0E19584A8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8DF64B3B63ABFD2F516394C3725C4F3E5117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC292D688DDAD4E7BC389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC80839144E5BB460BAF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947CDF046C1992EC065EC0837EA9F3D197644AD6D5ED66289B52698AB9A7B718F8C46E0066C2D8992A16725E5C173C3A84C39B48D55734A730D4BA3038C0950A5D36B5C8C57E37DE458B0BC6067A898B09E46D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE74ABCC139FF3F849B731C566533BA786AA5CC5B56E945C8DA X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458F0AFF96BAACF4158235E5A14AD4A4A4625E192CAD1D9E79DB53CE84373687089762C460A173F5B8D X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C85811CA530B5049129F9104CFE4AA7DEF0163C598BD1D7CA9C2B6934AE262D3EE7EAB7254005DCED41D154D92A01BDF11E0A4E2319210D9B64D260DF9561598F01A9E91200F654B02272C4C079A4C8AD93EDB24507CE13387DFF0A840B692CF8 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3438BC6CF312DA7315A13AAD7883C64368F6FF50E67FA43228CFF5BA9D702B0E5089459BFE7C8F0ED71D7E09C32AA3244CAB6AA199ADAE5B9A04DD7EAC51F4505660759606DA2E136A8D5DD81C2BAB7D1D X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojMCfuYI4PrefqEAKYtdXYxg== X-Mailru-Sender: B5B6A6EBBD94DAD8315E1362B7B20B880BC594E943B4A01080DADE4B61A702D014A4EB82564EB30E5C2808D6142752370A8ED71B308007E3DC85537438B7E1A423D748DE48713E689437F6177E88F7363CDA0F3B3F5B9367 X-Mras: Ok Subject: [Tarantool-patches] [PATCH v3 0/9] Initial datetime support X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Timur Safin via Tarantool-patches Reply-To: Timur Safin Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" * Version #3 changes: - renamed `struct datetime_t` to `struct datetime`, and `struct datetime_interval_t` to `struct datetime_interval`; - significantly reworked arguments checks in module api entries; - fixed datetime comparisons; - changed hints calculation to take into account fractional part; - provided more comments here and there; NB! There are MacOSX problems due to GLIBC specific code used (as Vlad has already pointed out) - so additional patch, making it more cross-compatible coming here soon... * Version #2 changes: - fixed problem with overloaded '-' and '+' operations for datetime arguments; - fixed messagepack serialization problems; - heavily documented MessagePack serialization schema in the code; - introduced working implementation of datetime hints for storage engines; - made interval related names be more consistent, renamed durations and period to intervals, i.e. t_datetime_duration to datetime_interval_t, duration_* to interval_*, period to interval; - properly implemented all reasonable cases of datetime+interval arithmetic; - moved all initialization code to utils.c; - renamed core/mp_datetime.c to core/datetime.c because it makes more sense now; * Version #1 - initial RFC series In brief -------- This patchset implements datetime lua support in box, with serialization to messagepack, yaml, json and lua mode. Also it contains storage engines' indices implementation for datetime type introduced. * Current implementation is heavily influenced by Sci-Lua lua-time module https://github.com/stepelu/lua-time e.g. you could find very similar approach for handling of operations with year or month long intervals (which should be handled differently than usual intervals of seconds, or days). * But internally we actually use Christian Hanson' c-dt module https://github.com/chansen/c-dt (though it has been modified slightly for cleaner integration into cmake build process) Datetime Module API ------------------- We used to have here draft documentation of datetime module api, but for a convenience it has been extracted to the discussion topic there - https://github.com/tarantool/tarantool/discussions/6244#discussioncomment-1043988 Messagepack serialization schema -------------------------------- In short it looks like: - now we introduce new MP_EXT extension type #4; - we may save 1 required and 2 optional fields for datetime field; In all gory details it's explained in MessagePack serialization schema depicted here: https://github.com/tarantool/tarantool/discussions/6244#discussioncomment-1043990 https://github.com/tarantool/tarantool/issues/5941 https://github.com/tarantool/tarantool/issues/5946 https://github.com/tarantool/tarantool/tree/tsafin/gh-5941-datetime-v3 Timur Safin (9): build: add Christian Hansen c-dt to the build lua: built-in module datetime lua, datetime: datetime tests lua, datetime: display datetime box, datetime: messagepack support for datetime box, datetime: datetime comparison for indices lua, datetime: time intervals support datetime: changelog for datetime module lua, box, datetime: rename struct datetime_t .gitmodules | 3 + CMakeLists.txt | 8 + .../gh-5941-datetime-type-support.md | 4 + cmake/BuildCDT.cmake | 6 + src/CMakeLists.txt | 3 + src/box/field_def.c | 52 +- src/box/field_def.h | 4 + src/box/lua/serialize_lua.c | 7 +- src/box/memtx_space.c | 3 +- src/box/msgpack.c | 7 +- src/box/tuple_compare.cc | 76 ++ src/box/vinyl.c | 3 +- src/exports.h | 29 + src/lib/core/CMakeLists.txt | 4 +- src/lib/core/datetime.c | 250 ++++ src/lib/core/datetime.h | 115 ++ src/lib/core/mp_extension_types.h | 1 + src/lib/mpstream/mpstream.c | 10 + src/lib/mpstream/mpstream.h | 3 + src/lua/datetime.lua | 1058 +++++++++++++++++ src/lua/init.c | 4 +- src/lua/msgpack.c | 12 + src/lua/msgpackffi.lua | 18 + src/lua/serializer.c | 4 + src/lua/serializer.h | 2 + src/lua/utils.c | 28 +- src/lua/utils.h | 12 + test/app-tap/datetime.test.lua | 367 ++++++ test/engine/datetime.result | 77 ++ test/engine/datetime.test.lua | 35 + test/unit/CMakeLists.txt | 2 + test/unit/datetime.c | 221 ++++ test/unit/datetime.result | 358 ++++++ third_party/c-dt | 1 + third_party/lua-cjson/lua_cjson.c | 8 + third_party/lua-yaml/lyaml.cc | 6 +- 36 files changed, 2776 insertions(+), 25 deletions(-) create mode 100644 changelogs/unreleased/gh-5941-datetime-type-support.md create mode 100644 cmake/BuildCDT.cmake create mode 100755 src/lib/core/datetime.c create mode 100644 src/lib/core/datetime.h create mode 100644 src/lua/datetime.lua create mode 100755 test/app-tap/datetime.test.lua create mode 100644 test/engine/datetime.result create mode 100644 test/engine/datetime.test.lua create mode 100644 test/unit/datetime.c create mode 100644 test/unit/datetime.result create mode 160000 third_party/c-dt -- 2.29.2