From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Tue, 27 Aug 2019 15:25:35 +0300 From: Vladimir Davydov Subject: Re: [tarantool-patches] Re: [PATCH] lua: fix decimal comparison with box.NULL Message-ID: <20190827122535.GO13834@esperanza> References: <20190827112209.43581-1-sergepetrenko@tarantool.org> <20190827120448.GN13834@esperanza> <940F74CC-9A3F-49CE-9B1D-A265D27B08A5@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <940F74CC-9A3F-49CE-9B1D-A265D27B08A5@tarantool.org> To: Serge Petrenko Cc: tarantool-patches@freelists.org List-ID: On Tue, Aug 27, 2019 at 03:10:47PM +0300, Serge Petrenko wrote: > > > 27 авг. 2019 г., в 15:04, Vladimir Davydov написал(а): > > > > On Tue, Aug 27, 2019 at 02:22:09PM +0300, Serge Petrenko wrote: > >> This problem is similar to the one fixed in commit > >> 3c6c1cc96a1a510493c21c472565d4063e403ba2 (lua:fix decimal comparison > >> with nil) > >> We should handle box.NULL the same way. > >> > >> Closes #4454 > >> --- > >> https://github.com/tarantool/tarantool/issues/4454 > >> https://github.com/tarantool/tarantool/tree/sp/gh-4454-decimal-cmp-null > >> > >> src/lua/decimal.c | 3 ++- > >> test/app/decimal.result | 30 ++++++++++++++++++++++++++++++ > >> test/app/decimal.test.lua | 8 ++++++++ > >> 3 files changed, 40 insertions(+), 1 deletion(-) > >> > >> diff --git a/src/lua/decimal.c b/src/lua/decimal.c > >> index 23e50ba68..8905a0b9d 100644 > >> --- a/src/lua/decimal.c > >> +++ b/src/lua/decimal.c > >> @@ -235,7 +235,8 @@ static int > >> ldecimal_eq(struct lua_State *L) > >> { > >> assert(lua_gettop(L) == 2); > >> - if (lua_isnil(L, 1) || lua_isnil(L, 2)) { > >> + if (lua_isnil(L, 1) || lua_isnil(L, 2) || > >> + luaL_isnull(L, 1) || luaL_isnull(L, 2)) { > >> lua_pushboolean(L, false); > >> return 1; > >> } > >> diff --git a/test/app/decimal.result b/test/app/decimal.result > >> index 8251e13d8..90d0984b0 100644 > >> --- a/test/app/decimal.result > >> +++ b/test/app/decimal.result > >> @@ -248,6 +248,36 @@ a <= nil > >> | --- > >> | - error: '[string "return a <= nil "]:1: attempt to compare decimal with nil' > >> | ... > >> +-- and with box.NULL > >> +-- > >> +a == box.NULL > >> + | --- > >> + | - false > >> + | ... > >> +a ~= box.NULL > >> + | --- > >> + | - true > >> + | ... > >> +a > box.NULL > >> + | --- > >> + | - error: '[string "return a > box.NULL "]:1: expected decimal, number or string as > >> + | 1 argument' > >> + | ... > > > > 1 argument? > > 1st argument > > > > >> +a < box.NULL > >> + | --- > >> + | - error: '[string "return a < box.NULL "]:1: expected decimal, number or string as > >> + | 2 argument' > >> + | ... > > > > 2 argument? > > 2nd argument But in both cases box.NULL is the second argument, isn't it? Anyway, looks like it's a different issue, because I get the same confusing error message while trying to compare a decimal with, say, a string. We can fix it in a separate patch if we need to. Pushed the patch to the master branch as is.