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 7E06968713; Mon, 1 Feb 2021 11:16:21 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7E06968713 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1612167381; bh=CQTAo3Pw8CUygucqjgl2DxUhUwM9ETm+Zlrn8d7MqCQ=; 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=iU82pLZyMB42L7Hal6JfTCxCFcwma8Dvs8juxWYrP5+cWtq7hnNej9zNoKyTj13xU tJ6czqSWHOFUyl2CEujQkz2L+NRYexds4d0qrmJP1b+F17UBeFVXq3ieF47EHRPCMd UumH5VYlPPUF4Hw9dprIvklyetL8mg2eLXbvpqGQ= Received: from smtp52.i.mail.ru (smtp52.i.mail.ru [94.100.177.112]) (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 CC0D268713 for ; Mon, 1 Feb 2021 11:14:55 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org CC0D268713 Received: by smtp52.i.mail.ru with esmtpa (envelope-from ) id 1l6UMI-0001t9-W5; Mon, 01 Feb 2021 11:14:55 +0300 To: s.ostanevich@corp.mail.ru, tsafin@tarantool.org Cc: tarantool-patches@dev.tarantool.org Date: Mon, 1 Feb 2021 11:14:54 +0300 Message-Id: <9bed6ada44db48b99bf11e7fb632f25d19a11634.1612166870.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: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD953AC099BC0052A9CC9F923E808BA4A11AAD7C69F0036037C182A05F53808504016C24247D4527506B7A65637043E330B80FCD7DED02C0F35F592B29E1144F399 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7495A032B936E882FEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006379A6B93796C91DCB58638F802B75D45FF5571747095F342E8C7A0BC55FA0FE5FC632E30DA10E3D6BD2A7DBD88CE1520887A364B71D7A92C6A389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C04CF195F1528592878941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B6042F1592492B88C6CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB8D32BA5DBAC0009BE9E8FC8737B5C2249E1463053F949B17D3AA81AA40904B5D9CF19DD082D7633A078D18283394535A93AA81AA40904B5D98AA50765F790063717661A470C1DC700EC76A7562686271EEC990983EF5C032935872C767BF85DA29E625A9149C048EE0A3850AC1BE2E73533F64B4C514AF25E4AD6D5ED66289B524E70A05D1297E1BB35872C767BF85DA227C277FBC8AE2E8B94B17FCF2787F215731C566533BA786A40A5AABA2AD371193C9F3DD0FB1AF5EBF64ED337B09931FD27F269C8F02392CD5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C6FA9FB90A9CF7018BF12D837809064082F88423FD51E80D59C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF31C0090ACECF247D699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3480665FBD8F49180C539F264796F75A5E0A4A9A1E869145BE33D30DC697EFC4131D3C666C1EC764FF1D7E09C32AA3244CB78293956F36DAAD68E9A2EAAC74EE7F05AB220A9D022EBCFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojyKiJYJ15DtIgmaazNrOl/A== X-Mailru-Sender: 5C3750E245F362008BC1685FEC6306ED5B4A25E3FFC53323B7A65637043E330B60497F7EF99AAC8F5105BD0848736F9966FEC6BF5C9C28D97E07721503EA2E00ED97202A5A4E92BF7402F9BA4338D657ED14614B50AE0675 X-Mras: Ok Subject: [Tarantool-patches] [PATCH v1 03/10] sql: introduce mem_is_*() functions 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_is_*() functions. These functions are used to check type of MEM content. Part of #4470 --- src/box/sql/vdbeInt.h | 95 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/src/box/sql/vdbeInt.h b/src/box/sql/vdbeInt.h index a24fbfc0e..0bb045170 100644 --- a/src/box/sql/vdbeInt.h +++ b/src/box/sql/vdbeInt.h @@ -618,6 +618,101 @@ mem_set_map(struct Mem *mem, char *value, uint32_t size, int alloc_type); int mem_set_array(struct Mem *mem, char *value, uint32_t size, int alloc_type); +static inline bool +mem_is_null(const struct Mem *mem) +{ + return (mem->flags & MEM_Null) != 0; +} + +static inline bool +mem_is_undefined(const struct Mem *mem) +{ + return (mem->flags & MEM_Undefined) != 0; +} + +static inline bool +mem_is_frame(const struct Mem *mem) +{ + return (mem->flags & MEM_Frame) != 0; +} + +static inline bool +mem_is_neg_int(const struct Mem *mem) +{ + return (mem->flags & MEM_Int) != 0; +} + +static inline bool +mem_is_pos_int(const struct Mem *mem) +{ + return (mem->flags & MEM_UInt) != 0; +} + +static inline bool +mem_is_integer(const struct Mem *mem) +{ + return mem_is_neg_int(mem) || mem_is_pos_int(mem); +} + +static inline bool +mem_is_double(const struct Mem *mem) +{ + return (mem->flags & MEM_Real) != 0; +} + +static inline bool +mem_is_number(const struct Mem *mem) +{ + return mem_is_integer(mem) || mem_is_double(mem); +} + +static inline bool +mem_is_string(const struct Mem *mem) +{ + return (mem->flags & MEM_Str) != 0; +} + +static inline bool +mem_is_binary(const struct Mem *mem) +{ + return (mem->flags & MEM_Blob) != 0; +} + +static inline bool +mem_is_varstring(const struct Mem *mem) +{ + return mem_is_string(mem) || mem_is_binary(mem); +} + +static inline bool +mem_is_map(const struct Mem *mem) +{ + return mem_is_binary(mem) && ((mem->flags & MEM_Subtype) != 0) && + mem->subtype == SQL_SUBTYPE_MSGPACK && + mp_typeof(*mem->z) == MP_MAP; +} + +static inline bool +mem_is_array(const struct Mem *mem) +{ + return mem_is_binary(mem) && ((mem->flags & MEM_Subtype) != 0) && + mem->subtype == SQL_SUBTYPE_MSGPACK && + mp_typeof(*mem->z) == MP_ARRAY; +} + +static inline bool +mem_is_bool(const struct Mem *mem) +{ + return (mem->flags & MEM_Bool) != 0; +} + +static inline bool +mems_have_same_type(const struct Mem *mem1, const struct Mem *mem2) +{ + return (mem1->flags & MEM_PURE_TYPE_MASK) == + (mem2->flags & MEM_PURE_TYPE_MASK); +} + void sqlVdbeMemInit(Mem *, sql *, u32); void sqlVdbeMemSetNull(Mem *); void sqlVdbeMemSetZeroBlob(Mem *, int); -- 2.25.1