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 752A26EC55; Mon, 19 Jul 2021 12:16:53 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 752A26EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1626686213; bh=pzlqWfoqdfrxI1gDI873CB/biWPoDY/t8bnfDnFNpHU=; 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=Bk5bGJtkWrAbDK2I49urMUivXEZKne7PAcGi1b0x4pUuWRc3qcexlu+rfE6Rx5hXz MeKid3wFRNcUPyYEikx2DYXe0hxps0CaAkp+gcnyzMRxwFI5ME2FlhBmWa2Q4ClFx3 CaGFvr8U7T9YuEvIZqbc38AQC6aETWPN5qApkBHc= Received: from smtp49.i.mail.ru (smtp49.i.mail.ru [94.100.177.109]) (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 968AC6EC55 for ; Mon, 19 Jul 2021 12:16:45 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 968AC6EC55 Received: by smtp49.i.mail.ru with esmtpa (envelope-from ) id 1m5POH-00032R-0d; Mon, 19 Jul 2021 12:16:45 +0300 To: Cc: References: <517004eb5e026b1fb4157806c3168c75d9b7e91e.1626424203.git.imeevma@gmail.com> In-Reply-To: <517004eb5e026b1fb4157806c3168c75d9b7e91e.1626424203.git.imeevma@gmail.com> Date: Mon, 19 Jul 2021 12:16:41 +0300 Message-ID: <189f01d77c7e$c9c0d3a0$5d427ae0$@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQD0dPzMRKuVIAksNaGzWjRUzQP0JQHUPcNfrQFcqvA= Content-Language: ru X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD941C43E597735A9C30288BCF456A452EC92BAB6D044D5CCDE182A05F538085040771B9C5513C8389B2F3673B1AD23A1219D06703A711131D6891C58007E6289D8 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE700B5EAEB6F2DE1BDEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006375189E43B47FB350A8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8FEA666402B7A3AB1B8164C2A9CF892C9117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF1175FABE1C0F9B6A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD182CC0D3CB04F14752D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE9647ADFADE5905B19935A1E27F592749D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE36089696B24BB1D19AD7EC71F1DB88427C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F790063757B1FBEA53BC6EDBEFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A51C3418DA017FC488247F5E220423505BA07BB4A5C78A7672D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7501A9DF589746230F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D343D1F112031EF3D62C7610D76D5361121250531027672EF9E63C70A4820EABD135709F27C9C1BE5041D7E09C32AA3244C000896FACBF3FF34F18E41FDE54B14D3D9ADFF0C0BDB8D1F729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj+8+KVR9NZrEP4h/AWDT+AA== X-Mailru-Sender: 9B1A9A1451179B430DCE2B318EA4156252AA984F01BBB9B5B2FDF5097D6AF2FF57F1433D693C104B5C2808D6142752370A8ED71B308007E3DC85537438B7E1A423D748DE48713E689437F6177E88F7363CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v2 2/4] sql: allow to bind uuid values 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" LGTM, and one minor comment we need to address eventually.=20 : From: imeevma@tarantool.org : Subject: [PATCH v2 2/4] sql: allow to bind uuid values :=20 : After this patch, uuid values can be bound like any other supported by : SQL values. :=20 : Part of #6164 : --- : diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h : index ef8dcd693..115c52f96 100644 : --- a/src/box/sql/sqlInt.h : +++ b/src/box/sql/sqlInt.h : @@ -326,6 +326,8 @@ struct sql_vfs { : #define SQL_LIMIT_LIKE_PATTERN_LENGTH 8 : #define SQL_LIMIT_TRIGGER_DEPTH 9 :=20 : +struct tt_uuid; : + : enum sql_ret_code { : /** sql_step() has another row ready. */ : SQL_ROW =3D 1, : @@ -634,6 +636,9 @@ int : sql_bind_zeroblob64(sql_stmt *, int, : sql_uint64); :=20 : +int : +sql_bind_uuid(struct sql_stmt *stmt, int i, const struct tt_uuid = *uuid); : + As interface header I'd expect that every function put to sqlInt.h would = be properly documented, and wanted to complain that `sql_bind_uuid()` is = not accompanied with doxygen block ... but then discovered that majority of=20 `sql_bind_*` functions (with exception of `sql_bind_boolean()`) were not = documented at all, and actually this terse introduction looks more = consistent than if it would be documented :( So, it looks like it's ok for today, but eventually we should return = here and make sure it's reasonably documented/commented out.=20 : /** : * Return the number of wildcards that should be bound to. : */ : diff --git a/src/box/sql/vdbeapi.c b/src/box/sql/vdbeapi.c : index aaae12e41..8031ee0dc 100644 : --- a/src/box/sql/vdbeapi.c : +++ b/src/box/sql/vdbeapi.c : @@ -840,6 +840,16 @@ sql_bind_zeroblob64(sql_stmt * pStmt, int i, = sql_uint64 : n) : return sql_bind_zeroblob(pStmt, i, n); : } :=20 : +int : +sql_bind_uuid(struct sql_stmt *stmt, int i, const struct tt_uuid = *uuid) : +{ : + struct Vdbe *p =3D (struct Vdbe *)stmt; : + if (vdbeUnbind(p, i) !=3D 0 || sql_bind_type(p, i, "uuid") !=3D 0) : + return -1; : + mem_set_uuid(&p->aVar[i - 1], uuid); : + return 0; : +} : + : int : sql_bind_parameter_count(const struct sql_stmt *stmt) : { : diff --git a/test/sql-tap/gh-6164-uuid-follow-ups.test.lua b/test/sql- : tap/gh-6164-uuid-follow-ups.test.lua : index a8f662f77..4fc5052d8 100755 : --- a/test/sql-tap/gh-6164-uuid-follow-ups.test.lua : +++ b/test/sql-tap/gh-6164-uuid-follow-ups.test.lua : @@ -1,6 +1,6 @@ : #!/usr/bin/env tarantool : local test =3D require("sqltester") : -test:plan(1) : +test:plan(4) :=20 : -- Make sure that function quote() can work with uuid. : test:do_execsql_test( : @@ -11,4 +11,28 @@ test:do_execsql_test( : '11111111-1111-1111-1111-111111111111' : }) :=20 : +-- Make sure that uuid value can be binded. : +local uuid1 =3D require('uuid').fromstr('11111111-1111-1111-1111- : 111111111111') : +local uuid2 =3D require('uuid').fromstr('11111111-2222-1111-1111- : 111111111111') : +local uuid3 =3D require('uuid').fromstr('11111111-1111-3333-1111- : 111111111111') : +test:do_test( : + "gh-6164-2", : + function() : + return box.execute([[SELECT ?;]], {uuid1}).rows[1][1] : + end, : + uuid1) : +test:do_test( : + "gh-6164-3", : + function() : + return box.execute([[SELECT $2;]], {123, uuid2}).rows[1][1] : + end, : + uuid2) : + : +test:do_test( : + "gh-6164-4", : + function() : + return box.execute([[SELECT :two;]], {{[":two"] =3D : uuid3}}).rows[1][1] : + end, : + uuid3) : + : test:finish_test() : -- : 2.25.1 Regards,Timur