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 546A86EC55; Wed, 28 Jul 2021 13:34:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 546A86EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1627468468; bh=7nwiMQPYL4zgkN1YC06mQ2G6x76a6yMob+8J28Sy9vA=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=o1ZxlEe4BMNQ38ee1S59k7zwkM4MH5u7rAbl30wIE20n7BWUNB2G5WLCgJqeBcyBV UvLCdxtjhMcJwcyneChSz8boetsDFlqhUt8gZ34dV59gs4zzX3lmOiytCOjxJYuYIL Fqi/GdI8NZozOs/989Ne5/gjEtJSwR5cqQvB6O44= Received: from smtp57.i.mail.ru (smtp57.i.mail.ru [217.69.128.37]) (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 1EB3E6EC55 for ; Wed, 28 Jul 2021 13:34:27 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1EB3E6EC55 Received: by smtp57.i.mail.ru with esmtpa (envelope-from ) id 1m8gtN-0008Bz-FI; Wed, 28 Jul 2021 13:34:26 +0300 To: v.shpilevoy@tarantool.org Date: Wed, 28 Jul 2021 13:34:02 +0300 Message-Id: X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-174C08C4: 5188C02AEC42908C481ED7ADC579193296BBA28369E3F2D2713F3D5F7D406D31BCF678C7329BA986 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD941C43E597735A9C3038391AAE5FBFA7682283CBB09BF492D182A05F538085040C769D88B3A1CDF726CBCCF83956B9193B530DF8CC1C09BF13EA3F88DF50F9EA5 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE79145AB6E9E75F07EEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637C8BD49B17AF1FC7C8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8543E208AABA549D1384BA0A747892B26117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC55D5BE2F85BDEC5FA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735201E561CDFBCA1751FF04B652EEC242312D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EEC8105B04EFE07628043FB282AF95FB6BD8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE36633242DC03399506136E347CC761E07C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637B8F435DEDE9E76EBEFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458834459D11680B5057049CD6077D8DC15EC75EF97C2F9661A X-C1DE0DAB: 8BD88D57C5CADBC8B2710865C386751094C72BDDC9A8ED5CA3B1A56EE2B804F6B226C914C996894645FD9D8A29397D6EFF55FE49A3C2BFCFC8C84E951CD0BE2F296C473AB1E14218EA052B563B0B06C67866D6147AF826D8543E208AABA549D1384BA0A747892B26F972CCD2F8FE1EF1CFC4036BBF6A4EA95F8B67CF19E0A9F5CB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D347324AA9FA07FF01E04FC49EC12769F74CC573D1406022281ECB8A51E661A19D13E0B367EFF17A7771D7E09C32AA3244C29CA006C96CA4E4E5428C67E765F6AFF81560E2432555DBB83B48618A63566E0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojiF1u9eOpfTTjvo4oAvVchA== X-Mailru-Sender: B5B6A6EBBD94DAD8C47A93838048902D54E8C5C2A129CF37D06BA010D41F5F76CE636541CB0434121EC9E4A2C82A33BC8C24925A86E657CE0C70AEE3C9A96FBAB3D7EE8ED63280BE112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [PATCH resend v2 00/11] 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 #2: - 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 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 (11): build: add Christian Hansen c-dt to the build lua: built-in module datetime lua, datetime: datetime tests lua, datetime: display datetime box, datetime: add messagepack support for datetime box, datetime: datetime comparison for indices lua, datetime: proper datetime encoding lua, datetime: calculated attributes for datetimes lua, datetime: time intervals support lua, datetime: unixtime, timestamp setters in datetime.lua datetime: changelog for datetime module .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 | 50 + src/box/vinyl.c | 3 +- src/exports.h | 29 + src/lib/core/CMakeLists.txt | 4 +- src/lib/core/datetime.c | 251 ++++ src/lib/core/datetime.h | 114 ++ src/lib/core/mp_extension_types.h | 1 + src/lib/mpstream/mpstream.c | 11 + src/lib/mpstream/mpstream.h | 4 + src/lua/datetime.lua | 1016 +++++++++++++++++ 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 | 220 ++++ 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, 2709 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