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 98A826EC55; Tue, 13 Jul 2021 11:52:21 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 98A826EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1626166341; bh=VAENU0uVJ6DBVQJe75Uqn3t7zMHHSxB/j1b1f8/ca6U=; h=To:Cc:References:In-Reply-To:Date:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=a4hObKZGmyi0arFPDsevW6cX6xW8OZjGIdAaj2e2eVEFtkRaEP5pL4tGS99CrPySk pz2m1keUAAhfLVZnKkrVoJFj62841N1+Rg7xWRk7qi6yVq/YM4Kb4b4kmL6bx0xOzj thn6KfLdqCqf2xsUS5S4obZkAc8G0U+6eviBH4kE= Received: from smtp60.i.mail.ru (smtp60.i.mail.ru [217.69.128.40]) (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 EA4306EC55 for ; Tue, 13 Jul 2021 11:51:38 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org EA4306EC55 Received: by smtp60.i.mail.ru with esmtpa (envelope-from ) id 1m3E8g-0003X2-Cm; Tue, 13 Jul 2021 11:51:38 +0300 To: Cc: References: In-Reply-To: Date: Tue, 13 Jul 2021 11:51:32 +0300 Message-ID: <03f701d777c4$47a28e90$d6e7abb0$@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQLLBM4G8PxJWct8/19n8ja8ysZxHgILWHRqqUkbuaA= Content-Language: ru X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD97BB0EF39AD2B33D52181556DE8CA6AFBAFE18027C1DA7DF9182A05F5380850406D5678B30B0719CF2756FBAA99BA81945BC3D525795C18797A318B5FFFF123E2 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7F9D3BE5B596754B8C2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6778DA827A17800CE72407438AC6002944EA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38BBCA57AF85F7723F249C6D82EC5B416388B6925AB79877AB1CC7F00164DA146DAFE8445B8C89999728AA50765F7900637F6B57BC7E64490618DEB871D839B7333395957E7521B51C2DFABB839C843B9C08941B15DA834481F8AA50765F7900637F6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947C6E16326BB14E90379735652A29929C6C4AD6D5ED66289B52698AB9A7B718F8C46E0066C2D8992A16725E5C173C3A84C364B67DBF080BA39BBA3038C0950A5D36B5C8C57E37DE458B0BC6067A898B09E46D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE7E1BCFB2C0BE3F189731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A5BAF9D077DD97FCEE6E620B58E1F52B9070C7973D11E7C1F2D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA753753CEE10E4ED4A7410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34505665BFD4C707053C6EBC2423F7394EDD695B4B07A74E713A47F25788419F52E613B0992614F4901D7E09C32AA3244C3A728988409367C9A4A8C5F7FDD86B843E8609A02908F271729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojAZDAgpmGsvaLm9X91umhGQ== X-Mailru-Sender: B5B6A6EBBD94DAD8F320B9F0F42A6ED16A5F1059E345509F2DEBE7A1A45BA74C58AAF33790AE97B61EC9E4A2C82A33BC8C24925A86E657CE0C70AEE3C9A96FBAB3D7EE8ED63280BE112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v2 4/4] sql: make type mismatch errors more informative 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: Timur Safin via Tarantool-patches Reply-To: Timur Safin Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This is so much clearer now! LGTM (though there is some minor complain) : From: imeevma@tarantool.org : Subject: [PATCH v2 4/4] sql: make type mismatch errors more informative : ... : diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c : index c4375e1ea..cdb55f858 100644 : --- a/src/box/sql/mem.c : +++ b/src/box/sql/mem.c : @@ -78,16 +78,17 @@ mem_str(const struct Mem *mem) : case MEM_TYPE_NULL: : return "NULL"; : case MEM_TYPE_STR: : - if (mem->n > STR_VALUE_MAX_LEN) : - return tt_sprintf("'%.*s...", STR_VALUE_MAX_LEN, mem->z); : - return tt_sprintf("'%.*s'", mem->n, mem->z); : + if (mem->n <= STR_VALUE_MAX_LEN) : + return tt_sprintf("string('%.*s')", mem->n, mem->z); : + return tt_sprintf("string('%.*s...)", STR_VALUE_MAX_LEN, : + mem->z); Hmm, hmm, see my notice below. : case MEM_TYPE_INT: : - return tt_sprintf("%lld", mem->u.i); : + return tt_sprintf("integer(%lld)", mem->u.i); : case MEM_TYPE_UINT: : - return tt_sprintf("%llu", mem->u.u); : + return tt_sprintf("integer(%llu)", mem->u.u); : case MEM_TYPE_DOUBLE: : sql_snprintf(STR_VALUE_MAX_LEN, buf, "%!.15g", mem->u.r); : - return tt_sprintf("%s", buf); : + return tt_sprintf("double(%s)", buf); : case MEM_TYPE_BIN: { : int len = MIN(mem->n, STR_VALUE_MAX_LEN / 2); : for (int i = 0; i < len; ++i) { : @@ -97,22 +98,25 @@ mem_str(const struct Mem *mem) : buf[2 * i + 1] = n < 10 ? ('0' + n) : ('A' + n - 10); : } : if (mem->n > len) : - return tt_sprintf("x'%.*s...", len * 2, buf); : - return tt_sprintf("x'%.*s'", len * 2, buf); : + return tt_sprintf("varbinary(x'%.*s...)", len * 2, buf); : + return tt_sprintf("varbinary(x'%.*s')", len * 2, buf); As for me it makes no much sense to generate not properly quoted literal even if we mean that it's shortened and truncated. IMVHO Though there is no single proper form, because it's simple message, and customer will probably get the reason why it looks so. : } : case MEM_TYPE_MAP: : case MEM_TYPE_ARRAY: { : const char *str = mp_str(mem->z); : - if (strlen(str) <= STR_VALUE_MAX_LEN) : - return str; : - memcpy(buf, str, STR_VALUE_MAX_LEN); : - return tt_sprintf("%.*s...", STR_VALUE_MAX_LEN, buf); : + const char *type = mem_type_to_str(mem); : + uint32_t len = strlen(str); : + uint32_t minlen = MIN(STR_VALUE_MAX_LEN, len); : + memcpy(buf, str, minlen); : + if (len <= STR_VALUE_MAX_LEN) : + return tt_sprintf("%s(%.*s)", type, minlen, buf); : + return tt_sprintf("%s(%.*s...)", type, minlen, buf); : } : case MEM_TYPE_UUID: : tt_uuid_to_string(&mem->u.uuid, buf); : - return tt_sprintf("'%s'", buf); : + return tt_sprintf("uuid('%s')", buf); : case MEM_TYPE_BOOL: : - return mem->u.b ? "TRUE" : "FALSE"; : + return mem->u.b ? "boolean(TRUE)" : "boolean(FALSE)"; : default: : return "unknown"; : } Regards, Timur