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 48FF368713; Mon, 1 Feb 2021 11:18:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 48FF368713 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1612167534; bh=/3khggYIINPFwpf5xnwdCLIuQyKEm2pLsmcVSWzmQ+A=; 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=cDqHzDQxDt8qJUko20NvHV/jHqLzpc3EVpL5h/NnC0TjnCMrJlIJjspdpnKMRTuzN 1FbgvVW8l1gcaZDc+DjGSiW9Oe3MxOJ9K1VD5oTAPItQl8LA9DLGneT9+4z9/8tHOw ctVWoaQH5B92EM5S1mUc7fqxkePuQ5h4y/B1r3uQ= Received: from smtp30.i.mail.ru (smtp30.i.mail.ru [94.100.177.90]) (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 AB215632D2 for ; Mon, 1 Feb 2021 11:15:05 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org AB215632D2 Received: by smtp30.i.mail.ru with esmtpa (envelope-from ) id 1l6UMS-0005jw-SM; Mon, 01 Feb 2021 11:15:05 +0300 To: s.ostanevich@corp.mail.ru, tsafin@tarantool.org Cc: tarantool-patches@dev.tarantool.org Date: Mon, 1 Feb 2021 11:15:04 +0300 Message-Id: <6c2ff351a24f14dd47516bdaf20537ae699a5edf.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: 4F1203BC0FB41BD953AC099BC0052A9C4647521586BE7E637AB8B70F7375365A182A05F5380850409DF28C8ABC24441E334AEB9035A2CF964B5968CB9C228EBB920F6CE12BEA7145 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7227E4400968B082FEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006377BA6DB23C50317A38638F802B75D45FF5571747095F342E8C7A0BC55FA0FE5FC632E30DA10E3D6BD5EB0ADFC1C4D5550C0195DF83BC5D685389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C04CF195F1528592878941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B6E5E764EB5D94DBD4CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB8D32BA5DBAC0009BE9E8FC8737B5C224958C95DE054E6A69176E601842F6C81A12EF20D2F80756B5F7E9C4E3C761E06A776E601842F6C81A127C277FBC8AE2E8B73D4B00E7A7DD9B73AA81AA40904B5D9DBF02ECDB25306B2B25CBF701D1BE8734AD6D5ED66289B5278DA827A17800CE7C7AF01494741750667F23339F89546C5A8DF7F3B2552694A6FED454B719173D6725E5C173C3A84C3D703628AB378667775ECD9A6C639B01B4E70A05D1297E1BBC6867C52282FAC85D9B7C4F32B44FF57D4B828FA1BC0F1ACBD9CCCA9EDD067B1EDA766A37F9254B7 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C6FA9FB90A9CF70180D1D3385224FCC587EAEAD09916D04B59C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF31C0090ACECF247D699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D349EC559D073CA5B689EB4D673DC3495A96454E07FBC2C0F153C6443632C2B94D9BE6417084D4355591D7E09C32AA3244C7CE85DC1321DC3312521ACE451F17858853296C06374E602FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojyKiJYJ15DtIBp09E8WYR2g== X-Mailru-Sender: 5C3750E245F362008BC1685FEC6306ED7FFE746DF21F3CF7334AEB9035A2CF96009DB4CE3002C7DB5105BD0848736F9966FEC6BF5C9C28D97E07721503EA2E00ED97202A5A4E92BF7402F9BA4338D657ED14614B50AE0675 X-Mras: Ok Subject: [Tarantool-patches] [PATCH v1 08/10] sql: refactor vdbeapi.c 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" --- src/box/sql/vdbeapi.c | 53 ++++++++++++------------------------------- 1 file changed, 15 insertions(+), 38 deletions(-) diff --git a/src/box/sql/vdbeapi.c b/src/box/sql/vdbeapi.c index 7c59ef83f..54ec113b3 100644 --- a/src/box/sql/vdbeapi.c +++ b/src/box/sql/vdbeapi.c @@ -111,7 +111,7 @@ sql_clear_bindings(sql_stmt * pStmt) Vdbe *p = (Vdbe *) pStmt; for (i = 0; i < p->nVar; i++) { sqlVdbeMemRelease(&p->aVar[i]); - p->aVar[i].flags = MEM_Null; + mem_set_null(&p->aVar[i]); } return rc; } @@ -130,12 +130,12 @@ const void * sql_value_blob(sql_value * pVal) { Mem *p = (Mem *) pVal; - if (p->flags & (MEM_Blob | MEM_Str)) { + if (mem_is_varstring(p)) { if (ExpandBlob(p) != 0) { - assert(p->flags == MEM_Null && p->z == 0); + assert(mem_is_null(p) && p->z == 0); return 0; } - p->flags |= MEM_Blob; + mem_convert_to_binary(p); return p->n ? p->z : 0; } else { return sql_value_text(pVal); @@ -232,7 +232,7 @@ sql_value_dup(const sql_value * pOrig) memcpy(pNew, pOrig, MEMCELLSIZE); pNew->flags &= ~MEM_Dyn; pNew->db = 0; - if (pNew->flags & (MEM_Str | MEM_Blob)) { + if (mem_is_varstring(pNew)) { pNew->flags &= ~(MEM_Static | MEM_Dyn); pNew->flags |= MEM_Ephem; if (sqlVdbeMemMakeWriteable(pNew) != 0) { @@ -588,39 +588,17 @@ sql_data_count(sql_stmt * pStmt) static const Mem * columnNullValue(void) { - /* Even though the Mem structure contains an element - * of type i64, on certain architectures (x86) with certain compiler - * switches (-Os), gcc may align this Mem object on a 4-byte boundary - * instead of an 8-byte one. This all works fine, except that when - * running with SQL_DEBUG defined the sql code sometimes assert()s - * that a Mem structure is located on an 8-byte boundary. To prevent - * these assert()s from failing, when building with SQL_DEBUG defined - * using gcc, we force nullMem to be 8-byte aligned using the magical - * __attribute__((aligned(8))) macro. - */ - static const Mem nullMem #if defined(SQL_DEBUG) && defined(__GNUC__) - __attribute__ ((aligned(8))) -#endif - = { - /* .u = */ { - 0}, - /* .flags = */ (u16) MEM_Null, - /* .eSubtype = */ (u8) 0, - /* .field_type = */ field_type_MAX, - /* .n = */ (int)0, - /* .z = */ (char *)0, - /* .zMalloc = */ (char *)0, - /* .szMalloc = */ (int)0, - /* .uTemp = */ (u32) 0, - /* .db = */ (sql *) 0, - /* .xDel = */ (void (*)(void *))0, -#ifdef SQL_DEBUG - /* .pScopyFrom = */ (Mem *) 0, - /* .pFiller = */ (void *)0, + static struct Mem nullMem __attribute__ ((aligned(8))); +#else + static struct Mem nullMem; #endif - }; - return &nullMem; + static struct Mem *null_mem_ptr = NULL; + if (null_mem_ptr == NULL) { + mem_init(&nullMem); + null_mem_ptr = &nullMem; + } + return null_mem_ptr; } /* @@ -879,8 +857,7 @@ vdbeUnbind(Vdbe * p, int i) i--; pVar = &p->aVar[i]; sqlVdbeMemRelease(pVar); - pVar->flags = MEM_Null; - pVar->field_type = field_type_MAX; + mem_set_null(pVar); return 0; } -- 2.25.1