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 47B8D71828; Tue, 23 Mar 2021 12:59:49 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 47B8D71828 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1616493589; bh=U7kV1zf80FkVig+VTFSBRWtUx6SNYAdoQvWOpb4iMSU=; h=To:Cc:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=H7nrfFaU0v0eqRhu3ZShpHoRwLVpksDiJCl2K2TmehZxPrrv+abWzrX6WyH+rItFF hNDb6I9bgUP024ez7+41R99K6qEvLJA4PRdNEZj8IAc9OR9JoXTGO5omaE278n10/6 wXC0d02WhRaHFYgcbWiiMxtEqkwfeP90OpsnQVws= Received: from smtp33.i.mail.ru (smtp33.i.mail.ru [94.100.177.93]) (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 B911068F68 for ; Tue, 23 Mar 2021 12:36:49 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B911068F68 Received: by smtp33.i.mail.ru with esmtpa (envelope-from ) id 1lOdSz-0007vQ-0c; Tue, 23 Mar 2021 12:36:49 +0300 To: v.shpilevoy@tarantool.org, tsafin@tarantool.org Cc: tarantool-patches@dev.tarantool.org Date: Tue, 23 Mar 2021 12:36:48 +0300 Message-Id: <308b482de067625554c844e0104ca56c02890721.1616491731.git.imeevma@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD95D6E7CC48CB1F5F10D3016C09B407F8B1E2E766A3410B623182A05F538085040E012B0E93986EDD3C67AE42E50D44C0F6FF2A68243E33886977EA3587724502C X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7DA1A6500DE61AB7AEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637C05E8F374EA5A79AEA1F7E6F0F101C67CDEEF6D7F21E0D1D174C73DBBBFC7664D54267400E4E38ECA9A8454D6CBD1DD014A9EC0F56A813B7389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C078FCF50C7EAF9C588941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B601F8F2FECC0250C8CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB8D32BA5DBAC0009BE9E8FC8737B5C2249DDD2BCB8FD23BBB876E601842F6C81A12EF20D2F80756B5F7E9C4E3C761E06A776E601842F6C81A127C277FBC8AE2E8B7B56408592A356993AA81AA40904B5D9DBF02ECDB25306B2201CA6A4E26CD07C3BBE47FD9DD3FB595F5C1EE8F4F765FC72CEEB2601E22B091A620F70A64A45A99449624AB7ADAF3735872C767BF85DA29E625A9149C048EE3F735096452955E34DCCFF368A6260CF4AD6D5ED66289B524E70A05D1297E1BB35872C767BF85DA227C277FBC8AE2E8BCFC11AAA4A30FD1F75ECD9A6C639B01B4E70A05D1297E1BBC6867C52282FAC85D9B7C4F32B44FF57D4B828FA1BC0F1ACBD9CCCA9EDD067B1EDA766A37F9254B7 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C686AF563A045C75E5889C2F59768E05336ED260D5607A1F69C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF0417BEADF48D1460699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34E20F2278F74481A1965EB3CA4C2901F00421FE1DBA7FA541A2745EC59752BACDB063C585FF89CB171D7E09C32AA3244CADC820C5E9A658775E307D8C8A0AF4C3A8CE788DE6831205FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojWJZv20R+6UjILTQrtfnBOg== X-Mailru-Sender: 5C3750E245F362008BC1685FEC6306ED7707EAC0A1149579C67AE42E50D44C0F21401CF93FD6FA555105BD0848736F9966FEC6BF5C9C28D97E07721503EA2E00ED97202A5A4E92BF7402F9BA4338D657ED14614B50AE0675 X-Mras: Ok Subject: [Tarantool-patches] [PATCH v4 50/53] sql: introduce mem_get_boolean() 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: Mergen Imeev via Tarantool-patches Reply-To: imeevma@tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This patch introduces mem_get_boolean() which is used to receive boolean value from MEM. Part of #5818 --- src/box/sql/func.c | 16 +++++++++++----- src/box/sql/mem.c | 30 ++++++++++-------------------- src/box/sql/mem.h | 8 +++----- src/box/sql/sqlInt.h | 3 --- src/box/sql/vdbeapi.c | 6 ------ 5 files changed, 24 insertions(+), 39 deletions(-) diff --git a/src/box/sql/func.c b/src/box/sql/func.c index 15fb2f14f..d033dae86 100644 --- a/src/box/sql/func.c +++ b/src/box/sql/func.c @@ -142,9 +142,12 @@ port_vdbemem_dump_lua(struct port *base, struct lua_State *L, bool is_flat) case MP_NIL: lua_pushnil(L); break; - case MP_BOOL: - lua_pushboolean(L, sql_value_boolean(param)); + case MP_BOOL: { + bool b; + mem_get_boolean(param, &b); + lua_pushboolean(L, b); break; + } default: unreachable(); } @@ -206,7 +209,9 @@ port_vdbemem_get_msgpack(struct port *base, uint32_t *size) break; } case MP_BOOL: { - mpstream_encode_bool(&stream, sql_value_boolean(param)); + bool b; + mem_get_boolean(param, &b); + mpstream_encode_bool(&stream, b); break; } default: @@ -1451,8 +1456,9 @@ quoteFunc(sql_context * context, int argc, sql_value ** argv) break; } case MP_BOOL: { - sql_result_text(context, - SQL_TOKEN_BOOLEAN(sql_value_boolean(argv[0])), + bool b; + mem_get_boolean(argv[0], &b); + sql_result_text(context, SQL_TOKEN_BOOLEAN(b), -1, SQL_TRANSIENT); break; } diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c index 8d4f0f92c..90c6ee526 100644 --- a/src/box/sql/mem.c +++ b/src/box/sql/mem.c @@ -1309,6 +1309,16 @@ mem_get_double(const struct Mem *mem, double *d) return -1; } +int +mem_get_boolean(const struct Mem *mem, bool *b) +{ + if ((mem->flags & MEM_Bool) != 0) { + *b = mem->u.b; + return 0; + } + return -1; +} + int mem_copy(struct Mem *to, const struct Mem *from) { @@ -2467,16 +2477,6 @@ releaseMemArray(Mem * p, int N) } } -int -mem_value_bool(const struct Mem *mem, bool *b) -{ - if ((mem->flags & MEM_Bool) != 0) { - *b = mem->u.b; - return 0; - } - return -1; -} - /**************************** sql_value_ ****************************** * The following routines extract information from a Mem or sql_value * structure. @@ -2503,16 +2503,6 @@ sql_value_bytes(sql_value * pVal) return sqlValueBytes(pVal); } -bool -sql_value_boolean(sql_value *val) -{ - bool b = false; - int rc = mem_value_bool((struct Mem *) val, &b); - assert(rc == 0); - (void) rc; - return b; -} - const unsigned char * sql_value_text(sql_value * pVal) { diff --git a/src/box/sql/mem.h b/src/box/sql/mem.h index f9d229baf..8015608fa 100644 --- a/src/box/sql/mem.h +++ b/src/box/sql/mem.h @@ -354,6 +354,9 @@ mem_get_unsigned(const struct Mem *mem, uint64_t *u); int mem_get_double(const struct Mem *mem, double *d); +int +mem_get_boolean(const struct Mem *mem, bool *b); + /** * Simple type to str convertor. It is used to simplify * error reporting. @@ -430,17 +433,12 @@ releaseMemArray(Mem * p, int N); /** Getters. */ -int -mem_value_bool(const struct Mem *mem, bool *b); const void * sql_value_blob(struct Mem *); int sql_value_bytes(struct Mem *); -bool -sql_value_boolean(struct Mem *val); - const unsigned char * sql_value_text(struct Mem *); diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h index 3e2cc4a66..9b4afc3f2 100644 --- a/src/box/sql/sqlInt.h +++ b/src/box/sql/sqlInt.h @@ -442,9 +442,6 @@ sql_column_bytes(sql_stmt *, int iCol); int sql_column_bytes16(sql_stmt *, int iCol); -bool -sql_column_boolean(struct sql_stmt *stmt, int column); - const unsigned char * sql_column_text(sql_stmt *, int iCol); diff --git a/src/box/sql/vdbeapi.c b/src/box/sql/vdbeapi.c index 9a97b2d77..532677b05 100644 --- a/src/box/sql/vdbeapi.c +++ b/src/box/sql/vdbeapi.c @@ -485,12 +485,6 @@ sql_column_bytes(sql_stmt * pStmt, int i) return sql_value_bytes(columnMem(pStmt, i)); } -bool -sql_column_boolean(struct sql_stmt *stmt, int i) -{ - return sql_value_boolean(columnMem(stmt, i)); -} - const unsigned char * sql_column_text(sql_stmt * pStmt, int i) { -- 2.25.1