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 178146EC40; Wed, 2 Jun 2021 11:03:50 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 178146EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1622621030; bh=TOQ2D/3NGizaS2vy33A+nGxNPQt22NgAoVyxLP+bOjw=; 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=x3RPQ4vQuLrhcruZd7dK1QhL2M8vzZ6E1ipuRaQJVjFnq/R+D/N1+MgMoPbeyUH/Y miYYEv9QQMhsJSIA9uTDlW/8RHJj9NSEDSwImUsVJaVggEABVg3k2g2E0n5sQ887qx QXNJk4ZJY00v6eLFbI+jAjMVgl9o4at0YELTfoH4= Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (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 00F6D6EC41 for ; Wed, 2 Jun 2021 11:02:51 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 00F6D6EC41 Received: by smtpng2.m.smailru.net with esmtpa (envelope-from ) id 1loLpy-0005kG-Sd; Wed, 02 Jun 2021 11:02:51 +0300 To: tsafin@tarantool.org Cc: tarantool-patches@dev.tarantool.org Date: Wed, 2 Jun 2021 11:02:50 +0300 Message-Id: <8562fcc66ad464231cd916a94a41f556d6e57f38.1622620858.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: 4F1203BC0FB41BD9D5B0DA836B685C540E30C2BDD69416C6E46C178CD572CB10182A05F538085040940E7CFF72F99E7C699C478BA88138EA084A4C1F495586A2EF1CD20BE82D8EC0 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE713069B262EDDB3B7C2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6778DA827A17800CE7923B16447C554B85EA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38BD6CF32B5F8F9D404CFBD520105EC21563750CAC4E5CE2796CC7F00164DA146DAFE8445B8C89999728AA50765F79006377C8EE06721B8D324389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8AC7A5202D916A59BF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA7E827F84554CEF5019E625A9149C048EE9ECD01F8117BC8BEE2021AF6380DFAD18AA50765F790063735872C767BF85DA227C277FBC8AE2E8BDC0F6C5B2EEF3D0C75ECD9A6C639B01B4E70A05D1297E1BBCB5012B2E24CD356 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CDBB9428EB2128D677E4270B67CC01DC87131DC994C78CAF89C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EFD99FB7B2A39B4961699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34D8FD11F74BDD6E8D409FE591F2063061A37446E871D2E212DF92048F5FEE7F0A054E68DF257C7ECB1D7E09C32AA3244CB411779769547FB9F652362FDA3DF662D9ADFF0C0BDB8D1F729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj+mfSpkNmA2rIVrc3RrySvw== X-Mailru-Sender: 689FA8AB762F73936BC43F508A06382262417C758AF7AE6CC7CE9E088807ADA083D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH v2 2/2] sql: introduce SQL built-in function UUID() 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 a new SQL built-in function UUID(). Closes #5886 @TarantoolBot document Title: SQL built-in function UUID() SQL built-in function UUID() takes zero or one argument. If no argument is specified, a UUID v4 is generated. If the version of the UUID to generate is specified as an argument, the function returns the new UUID of the given version. Currently only version 4 of UUID is supported. --- .../unreleased/introduce-uuid-to-sql.md | 3 + src/box/bootstrap.snap | Bin 5991 -> 6016 bytes src/box/lua/upgrade.lua | 19 +++++++ src/box/sql/func.c | 39 +++++++++++++ src/box/sql/parse.y | 2 +- test/box-py/bootstrap.result | 3 +- test/box/access.result | 2 +- test/box/access.test.lua | 2 +- test/box/access_bin.result | 2 +- test/box/access_bin.test.lua | 2 +- test/box/access_sysview.result | 8 +-- test/box/function1.result | 6 +- test/sql-tap/uuid.test.lua | 52 +++++++++++++++++- test/wal_off/func_max.result | 8 +-- 14 files changed, 130 insertions(+), 18 deletions(-) create mode 100644 changelogs/unreleased/introduce-uuid-to-sql.md diff --git a/changelogs/unreleased/introduce-uuid-to-sql.md b/changelogs/unreleased/introduce-uuid-to-sql.md new file mode 100644 index 000000000..642ac94fb --- /dev/null +++ b/changelogs/unreleased/introduce-uuid-to-sql.md @@ -0,0 +1,3 @@ +## feature/core + + * Field type UUID is now available in SQL, and new UUID can be generated using new SQL built-in function uuid() (gh-5886). diff --git a/src/box/bootstrap.snap b/src/box/bootstrap.snap index c4a70297aad138d426a24ee4447af485e3597536..57374decc0f9de140772d9809a227e3ba4ce61eb 100644 GIT binary patch delta 5952 zcmbtzRag@a+%*kSqf?OX7`4$k7$qej1F4NJadeJmgfL3!Zj^3N1O_NL5L7_AQ$R$R zLA?L(dA{5C>OIf7InO!g_q#g#QZdpPW|Wc?P*NTw>F(+RR01g~AY>>F`~m`<{SdCo zJc=#|xQm;cf}|Tr?!OdR0U-&Og)2zPxPX94@*pq*E(fNx*713Y@K)xDh@zzY+E3Mw zVA+WjZA@G`eCv8CIZyN;s2ppxB`^aNgm7XA-m8Xb0CORVO zBN`K;g(KXeh>d)~c!O}GU*LXhLA^F@q;W26TGQRMq% zFIuN$Qnq)r4PRPyf;}Xh6pK-n9JECihJF<3!%`K&7&s#NntX9KG4@x@4G|!67 z3BxZbeoYH-JOs@7)VdpHx4hVCI?RfLT%^jn?vd(FwmzI?eWOred&1EzX?77DWNsOu zmXd8HY}OwBOP~p+fQ0)XUF2nDWI0~SpBv_fmbs+h^>cSRMUApipWW!Qi{ZPSVGzAz zKC!|ecBOWgf!TShg!haxTQ?ZKH30plwvHmJEH;demxhE7LL49GQBHPCpsl;hk4|lz z0Emh4JXpIp*u0_TIScx6pf-`Q_Uz!`Mvs%h$0F zqbh}j_um$$IvhmcOyeqX`?`_%vSNgeJhOxfB8RmiJTHYkoEc1b;`mffL z^@{_ojt*iEHz;|g@6K{p4uTvXLah@~3e{9H-P-bC)13LW{{Yp{= z!2Qu>ldEHOa%n)kKn9=d+U<;_b@%GB`nE}W4Ub8=wT(%^E5@Wwx0qqS7APhD+Kn;a zoJccU51uhu4Yn{@4&p>=%Y(Fd$6g($h`e=>*j(NvVY&gIL+*?fXHj=X^5;Vg#@A&i zEW;f*%WUh8Kl}HPCkcZM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Pkf z*ZVeKPOMD_vQPj3Z`;ies&NA!1R>`APmEqn4ok%B@k&wY5bgwJXRkcxP2M9ZGr6TX zZt@;UnaM59ag+B*%1mylXVP@W<(Hgo4MG1E%gC0H{<@!IRcggH`J4R_ox1Y{u|S_9 XiRzV{$H~qf!X)LlH2ly9)ex=ijTS!2 diff --git a/src/box/lua/upgrade.lua b/src/box/lua/upgrade.lua index 6fba260bd..97afc0b4d 100644 --- a/src/box/lua/upgrade.lua +++ b/src/box/lua/upgrade.lua @@ -1000,6 +1000,24 @@ local function upgrade_to_2_7_1() function_access() end +-------------------------------------------------------------------------------- +-- Tarantool 2.9.1 +-------------------------------------------------------------------------------- +local function sql_builtin_function_uuid() + local _func = box.space._func + local _priv = box.space._priv + local datetime = os.date("%Y-%m-%d %H:%M:%S") + local t = _func:auto_increment({ADMIN, 'UUID', 1, 'SQL_BUILTIN', '', + 'function', {}, 'any', 'none', 'none', + false, false, true, {}, setmap({}), '', + datetime, datetime}) + _priv:replace{ADMIN, PUBLIC, 'function', t.id, box.priv.X} +end + +local function upgrade_to_2_9_1() + sql_builtin_function_uuid() +end + -------------------------------------------------------------------------------- local handlers = { @@ -1015,6 +1033,7 @@ local handlers = { {version = mkversion(2, 3, 0), func = upgrade_to_2_3_0, auto = true}, {version = mkversion(2, 3, 1), func = upgrade_to_2_3_1, auto = true}, {version = mkversion(2, 7, 1), func = upgrade_to_2_7_1, auto = true}, + {version = mkversion(2, 9, 1), func = upgrade_to_2_9_1, auto = true}, } -- Schema version of the snapshot. diff --git a/src/box/sql/func.c b/src/box/sql/func.c index 9c4480a92..f93ae867d 100644 --- a/src/box/sql/func.c +++ b/src/box/sql/func.c @@ -66,6 +66,35 @@ mem_as_bin(struct Mem *mem) return s; } +static void +sql_func_uuid(struct sql_context *ctx, int argc, struct Mem **argv) +{ + if (argc > 1) { + diag_set(ClientError, ER_FUNC_WRONG_ARG_COUNT, "UUID", + "one or zero", argc); + ctx->is_aborted = true; + return; + } + if (argc == 1) { + uint64_t version; + if (mem_get_uint(argv[0], &version) != 0) { + diag_set(ClientError, ER_SQL_TYPE_MISMATCH, + mem_str(argv[0]), "integer"); + ctx->is_aborted = true; + return; + } + if (version != 4) { + diag_set(ClientError, ER_UNSUPPORTED, "Function UUID", + "versions other than 4"); + ctx->is_aborted = true; + return; + } + } + struct tt_uuid uuid; + tt_uuid_create(&uuid); + mem_set_uuid(ctx->pOut, &uuid); +} + /* * Return the collating function associated with a function. */ @@ -2544,6 +2573,16 @@ static struct { .call = UpperICUFunc, .finalize = NULL, .export_to_sql = true, + }, { + .name = "UUID", + .param_count = -1, + .returns = FIELD_TYPE_UUID, + .aggregate = FUNC_AGGREGATE_NONE, + .is_deterministic = false, + .flags = 0, + .call = sql_func_uuid, + .finalize = NULL, + .export_to_sql = true, }, { .name = "VERSION", .param_count = 0, diff --git a/src/box/sql/parse.y b/src/box/sql/parse.y index 4c9cf475e..bd041e862 100644 --- a/src/box/sql/parse.y +++ b/src/box/sql/parse.y @@ -268,7 +268,7 @@ columnlist ::= tcons. CONFLICT DEFERRED END ENGINE FAIL IGNORE INITIALLY INSTEAD NO MATCH PLAN QUERY KEY OFFSET RAISE RELEASE REPLACE RESTRICT - RENAME CTIME_KW IF ENABLE DISABLE + RENAME CTIME_KW IF ENABLE DISABLE UUID . %wildcard ANY. diff --git a/test/box-py/bootstrap.result b/test/box-py/bootstrap.result index ed7accea3..b2328487c 100644 --- a/test/box-py/bootstrap.result +++ b/test/box-py/bootstrap.result @@ -4,7 +4,7 @@ box.internal.bootstrap() box.space._schema:select{} --- - - ['max_id', 511] - - ['version', 2, 7, 1] + - ['version', 2, 9, 1] ... box.space._cluster:select{} --- @@ -242,6 +242,7 @@ box.space._priv:select{} - [1, 2, 'function', 65, 4] - [1, 2, 'function', 66, 4] - [1, 2, 'function', 67, 4] + - [1, 2, 'function', 68, 4] - [1, 2, 'space', 276, 2] - [1, 2, 'space', 277, 1] - [1, 2, 'space', 281, 1] diff --git a/test/box/access.result b/test/box/access.result index 27e636122..1a8730f1a 100644 --- a/test/box/access.result +++ b/test/box/access.result @@ -703,7 +703,7 @@ box.schema.func.exists(1) --- - true ... -box.schema.func.exists(68) +box.schema.func.exists(69) --- - false ... diff --git a/test/box/access.test.lua b/test/box/access.test.lua index a62f87ad8..2bf772b7b 100644 --- a/test/box/access.test.lua +++ b/test/box/access.test.lua @@ -282,7 +282,7 @@ box.schema.user.exists{} box.schema.func.exists('nosuchfunc') box.schema.func.exists('guest') box.schema.func.exists(1) -box.schema.func.exists(68) +box.schema.func.exists(69) box.schema.func.exists('box.schema.user.info') box.schema.func.exists() box.schema.func.exists(nil) diff --git a/test/box/access_bin.result b/test/box/access_bin.result index c58f331d3..aeb8b3bd8 100644 --- a/test/box/access_bin.result +++ b/test/box/access_bin.result @@ -298,7 +298,7 @@ box.schema.user.grant('guest', 'execute', 'universe') function f1() return box.space._func:get(1)[4] end --- ... -function f2() return box.space._func:get(68)[4] end +function f2() return box.space._func:get(69)[4] end --- ... box.schema.func.create('f1') diff --git a/test/box/access_bin.test.lua b/test/box/access_bin.test.lua index 41d5f4245..954266858 100644 --- a/test/box/access_bin.test.lua +++ b/test/box/access_bin.test.lua @@ -112,7 +112,7 @@ test:drop() -- notice that guest can execute stuff, but can't read space _func box.schema.user.grant('guest', 'execute', 'universe') function f1() return box.space._func:get(1)[4] end -function f2() return box.space._func:get(68)[4] end +function f2() return box.space._func:get(69)[4] end box.schema.func.create('f1') box.schema.func.create('f2',{setuid=true}) c = net.connect(box.cfg.listen) diff --git a/test/box/access_sysview.result b/test/box/access_sysview.result index 6468a0709..d7a7b7534 100644 --- a/test/box/access_sysview.result +++ b/test/box/access_sysview.result @@ -258,11 +258,11 @@ box.session.su('guest') ... #box.space._vpriv:select{} --- -- 82 +- 83 ... #box.space._vfunc:select{} --- -- 67 +- 68 ... #box.space._vcollation:select{} --- @@ -290,11 +290,11 @@ box.session.su('guest') ... #box.space._vpriv:select{} --- -- 82 +- 83 ... #box.space._vfunc:select{} --- -- 67 +- 68 ... #box.space._vsequence:select{} --- diff --git a/test/box/function1.result b/test/box/function1.result index 928cd5758..0166c828f 100644 --- a/test/box/function1.result +++ b/test/box/function1.result @@ -97,7 +97,7 @@ box.func["function1.args"] exports: lua: true sql: false - id: 68 + id: 69 setuid: false is_multikey: false is_deterministic: false @@ -593,7 +593,7 @@ func exports: lua: true sql: false - id: 68 + id: 69 setuid: false is_multikey: false is_deterministic: false @@ -665,7 +665,7 @@ func exports: lua: true sql: false - id: 68 + id: 69 setuid: false is_multikey: false is_deterministic: false diff --git a/test/sql-tap/uuid.test.lua b/test/sql-tap/uuid.test.lua index 4287f0921..83fcc3d0e 100755 --- a/test/sql-tap/uuid.test.lua +++ b/test/sql-tap/uuid.test.lua @@ -3,7 +3,7 @@ local build_path = os.getenv("BUILDDIR") package.cpath = build_path..'/test/sql-tap/?.so;'..build_path..'/test/sql-tap/?.dylib;'..package.cpath local test = require("sqltester") -test:plan(139) +test:plan(145) local uuid = require("uuid") local uuid1 = uuid.fromstr("11111111-1111-1111-1111-111111111111") @@ -1266,6 +1266,56 @@ test:do_execsql_test( 3,2,1 }) +-- Check function uuid(). +test:do_execsql_test( + "uuid-16.1", + [[ + SELECT typeof(uuid()); + ]], { + "uuid" + }) + +test:do_execsql_test( + "uuid-16.2", + [[ + SELECT typeof(uuid(4)); + ]], { + "uuid" + }) + +test:do_catchsql_test( + "uuid-16.3", + [[ + SELECT uuid(1); + ]], { + 1, "Function UUID does not support versions other than 4" + }) + +test:do_catchsql_test( + "uuid-16.4", + [[ + SELECT uuid('asd'); + ]], { + 1, "Type mismatch: can not convert asd to integer" + }) + +test:do_catchsql_test( + "uuid-16.5", + [[ + SELECT uuid(4, 5); + ]], { + 1, "Wrong number of arguments is passed to UUID(): expected one or zero, got 2" + }) + +-- Make sure the uuid() function generates a new UUID each time when called. +test:do_execsql_test( + "uuid-16.6", + [[ + SELECT uuid() != uuid(); + ]], { + true + }) + test:execsql([[ DROP TRIGGER t; DROP VIEW v; diff --git a/test/wal_off/func_max.result b/test/wal_off/func_max.result index 78db38d6b..cc5bcc141 100644 --- a/test/wal_off/func_max.result +++ b/test/wal_off/func_max.result @@ -42,11 +42,11 @@ test_run:cmd("setopt delimiter ''"); ... func_limit() --- -- error: 'Failed to create function ''func31934'': function id is too big' +- error: 'Failed to create function ''func31933'': function id is too big' ... drop_limit_func() --- -- error: Function 'func31934' does not exist +- error: Function 'func31933' does not exist ... box.schema.user.create('testuser') --- @@ -62,11 +62,11 @@ session.su('testuser') ... func_limit() --- -- error: 'Failed to create function ''func31934'': function id is too big' +- error: 'Failed to create function ''func31933'': function id is too big' ... drop_limit_func() --- -- error: Function 'func31934' does not exist +- error: Function 'func31933' does not exist ... session.su('admin') --- -- 2.25.1