From: Mergen Imeev <imeevma@tarantool.org> To: Igor Munkin <imun@tarantool.org> Cc: tarantool-discussions@dev.tarantool.org Subject: Re: [Tarantool-discussions] Addition of NUMBER field type Date: Sat, 21 Dec 2019 19:29:13 +0300 [thread overview] Message-ID: <20191221162913.GA5018@tarantool.org> (raw) In-Reply-To: <20191220143520.GB31304@tarantool.org> On Fri, Dec 20, 2019 at 05:35:20PM +0300, Igor Munkin wrote: > On 19.12.19, Konstantin Osipov wrote: > > * Mergen Imeev <imeevma@tarantool.org> [19/12/19 16:44]: > > > Hi all, > > > I would like to discuss once again the problem of adding a DOUBLE > > > field type. > > > > > > Suppose we have added a DOUBLE field type to which we can insert > > > data of type MP_DOUBLE in the format MsgPack. The problem is that > > > inserting an integer from Lua, we get an error. This is not so bad > > > for integer cdata, but it is bad for integers od Lua type NUMBER. > > > Currently, we have 5 ways to solve the problem: > > > > > <snipped> > > > > > > > 4) Give to user a function to convert a number to DOUBLE in Lua > > > before inserting into space. > > > > > > In this case, the user must convert the number to DOUBLE before > > > inserting. We do not add any implicit cast. Very easy to > > > understand and implement. Although the user may be a little > > > confused that he cannot insert INTEGER/UNSIGNED into a DOUBLE > > > field, but this can be solved by writing about this in the > > > documentation. > > > > > > In addition, if we convert to LuaJIT DOUBLE cdata, then we can use > > > these cdata as the operand of an arithmetic operation. However, > > > arithmetic operations for this type do not work correctly. And it > > > will not be fixed, most likely. It should also be written in the > > > documentation, I think. > > > > > <snipped> > > > > > I like it #4 too - it's cheap & efficient. > > Despite the broken arithmetics and assuming no one need this type in > Lua -- yes, this is a good one. > After discussion, it was decided that the fourth solution is the most suitable, since the main reason for adding this field is the need for a DOUBLE type in SQL. However, most likely, questions will arise about why it works in this way, so we should be able to answer them. In this regard, in order to correctly add this field, we must describe how to work with it in Lua, in the documentation. We must say that any number can be converted to a number that can definitely be inserted using the ffi.cast() function. And so that not any objects of other numeric types can be inserted. > > > > -- > > Konstantin Osipov, Moscow, Russia > > -- > Best regards, > IM
next prev parent reply other threads:[~2019-12-21 16:29 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-12-19 13:43 Mergen Imeev 2019-12-19 14:16 ` Konstantin Osipov 2019-12-20 14:35 ` Igor Munkin 2019-12-21 16:29 ` Mergen Imeev [this message] 2019-12-23 7:18 ` Alexander Turenko
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20191221162913.GA5018@tarantool.org \ --to=imeevma@tarantool.org \ --cc=imun@tarantool.org \ --cc=tarantool-discussions@dev.tarantool.org \ --subject='Re: [Tarantool-discussions] Addition of NUMBER field type' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox