Tarantool development patches archive
 help / color / mirror / Atom feed
From: Mergen Imeev via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: v.shpilevoy@tarantool.org
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH v2 1/4] sql: introduce uuid to quote()
Date: Sat, 10 Jul 2021 17:33:36 +0300
Message-ID: <ec87733ca387c72957ac3202df1a6b0547e20fdc.1625926838.git.imeevma@gmail.com> (raw)
In-Reply-To: <cover.1625926838.git.imeevma@gmail.com>

Hi! Thank you for the review! My answers, diff and new patch below.

On 08.07.2021 00:41, Vladislav Shpilevoy wrote:
> Hi! Thanks for the patch!
>
>> diff --git a/test/sql-tap/gh-6164-uuid-follow-ups.test.lua b/test/sql-tap/gh-6164-uuid-follow-ups.test.lua
>> new file mode 100755
>> index 000000000..d8fa700ea
>> --- /dev/null
>> +++ b/test/sql-tap/gh-6164-uuid-follow-ups.test.lua
>
> 1. The test runs 2 times with 2 engines. Please, make it work only
> once. It does not depend on an engine anyway.
>
Fixed.

>> @@ -0,0 +1,16 @@
>> +#!/usr/bin/env tarantool
>> +local test = require("sqltester")
>> +test:plan(1)
>> +
>> +box.execute([[select quote(cast('11111111-1111-1111-1111-111111111111' as uuid));]])
>
> 2. Why do you need this select? Isn't it exactly the same as the SELECT below?
>
I believe I used it for debug and forgot to remove. Removed.

>> +
>> +-- Make sure that function quote() can work with uuid.
>> +test:do_execsql_test(
>> +    "gh-6164-1",
>> +    [[
>> +        SELECT quote(cast('11111111-1111-1111-1111-111111111111' as uuid));
>> +    ]], {
>> +        '11111111-1111-1111-1111-111111111111'
>> +    })
>> +
>> +test:finish_test()


Diff:

diff --git a/test/sql-tap/engine.cfg b/test/sql-tap/engine.cfg
index 693a477b7..94b0bb1f6 100644
--- a/test/sql-tap/engine.cfg
+++ b/test/sql-tap/engine.cfg
@@ -20,6 +20,9 @@
     "gh-3332-tuple-format-leak.test.lua": {
         "memtx": {"engine": "memtx"}
     },
+    "gh-6164-uuid-follow-ups.test.lua": {
+        "memtx": {"engine": "memtx"}
+    },
     "gh-4077-iproto-execute-no-bind.test.lua": {},
     "*": {
         "memtx": {"engine": "memtx"},
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 d8fa700ea..a8f662f77 100755
--- a/test/sql-tap/gh-6164-uuid-follow-ups.test.lua
+++ b/test/sql-tap/gh-6164-uuid-follow-ups.test.lua
@@ -2,8 +2,6 @@
 local test = require("sqltester")
 test:plan(1)
 
-box.execute([[select quote(cast('11111111-1111-1111-1111-111111111111' as uuid));]])
-
 -- Make sure that function quote() can work with uuid.
 test:do_execsql_test(
     "gh-6164-1",


New patch:

commit ec87733ca387c72957ac3202df1a6b0547e20fdc
Author: Mergen Imeev <imeevma@gmail.com>
Date:   Mon Jul 5 11:09:48 2021 +0300

    sql: introduce uuid to quote()
    
    Prior to this patch, built-in SQL function quote() could not work with
    uuid. It now returns a string representation of the received uuid.
    
    Part of #6164

diff --git a/src/box/sql/func.c b/src/box/sql/func.c
index f93ae867d..aa565277c 100644
--- a/src/box/sql/func.c
+++ b/src/box/sql/func.c
@@ -1098,8 +1098,8 @@ quoteFunc(sql_context * context, int argc, sql_value ** argv)
 {
    assert(argc == 1);
    UNUSED_PARAMETER(argc);
-   switch (sql_value_type(argv[0])) {
-   case MP_DOUBLE:{
+   switch (argv[0]->type) {
+   case MEM_TYPE_DOUBLE:{
            double r1, r2;
            char zBuf[50];
            r1 = mem_get_double_unsafe(argv[0]);
@@ -1113,14 +1113,20 @@ quoteFunc(sql_context * context, int argc, sql_value ** argv)
                        SQL_TRANSIENT);
            break;
        }
-   case MP_UINT:
-   case MP_INT:{
+   case MEM_TYPE_UUID: {
+       char buf[UUID_STR_LEN + 1];
+       tt_uuid_to_string(&argv[0]->u.uuid, &buf[0]);
+       sql_result_text(context, buf, UUID_STR_LEN, SQL_TRANSIENT);
+       break;
+   }
+   case MEM_TYPE_UINT:
+   case MEM_TYPE_INT: {
            sql_result_value(context, argv[0]);
            break;
        }
-   case MP_BIN:
-   case MP_ARRAY:
-   case MP_MAP: {
+   case MEM_TYPE_BIN:
+   case MEM_TYPE_ARRAY:
+   case MEM_TYPE_MAP: {
            char *zText = 0;
            char const *zBlob = mem_as_bin(argv[0]);
            int nBlob = mem_len_unsafe(argv[0]);
@@ -1146,7 +1152,7 @@ quoteFunc(sql_context * context, int argc, sql_value ** argv)
            }
            break;
        }
-   case MP_STR:{
+   case MEM_TYPE_STR: {
            int i, j;
            u64 n;
            const unsigned char *zArg = mem_as_ustr(argv[0]);
@@ -1174,7 +1180,7 @@ quoteFunc(sql_context * context, int argc, sql_value ** argv)
            }
            break;
        }
-   case MP_BOOL: {
+   case MEM_TYPE_BOOL: {
        sql_result_text(context,
                SQL_TOKEN_BOOLEAN(mem_get_bool_unsafe(argv[0])),
                -1, SQL_TRANSIENT);
diff --git a/test/sql-tap/engine.cfg b/test/sql-tap/engine.cfg
index 693a477b7..94b0bb1f6 100644
--- a/test/sql-tap/engine.cfg
+++ b/test/sql-tap/engine.cfg
@@ -20,6 +20,9 @@
     "gh-3332-tuple-format-leak.test.lua": {
         "memtx": {"engine": "memtx"}
     },
+    "gh-6164-uuid-follow-ups.test.lua": {
+        "memtx": {"engine": "memtx"}
+    },
     "gh-4077-iproto-execute-no-bind.test.lua": {},
     "*": {
         "memtx": {"engine": "memtx"},
diff --git a/test/sql-tap/gh-6164-uuid-follow-ups.test.lua b/test/sql-tap/gh-6164-uuid-follow-ups.test.lua
new file mode 100755
index 000000000..a8f662f77
--- /dev/null
+++ b/test/sql-tap/gh-6164-uuid-follow-ups.test.lua
@@ -0,0 +1,14 @@
+#!/usr/bin/env tarantool
+local test = require("sqltester")
+test:plan(1)
+
+-- Make sure that function quote() can work with uuid.
+test:do_execsql_test(
+    "gh-6164-1",
+    [[
+        SELECT quote(cast('11111111-1111-1111-1111-111111111111' as uuid));
+    ]], {
+        '11111111-1111-1111-1111-111111111111'
+    })
+
+test:finish_test()

  reply	other threads:[~2021-07-10 14:34 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-10 14:33 [Tarantool-patches] [PATCH v2 0/4] Follow ups for uuid introduction Mergen Imeev via Tarantool-patches
2021-07-10 14:33 ` Mergen Imeev via Tarantool-patches [this message]
2021-07-10 14:33 ` [Tarantool-patches] [PATCH v2 2/4] sql: allow to bind uuid values Mergen Imeev via Tarantool-patches
2021-07-10 14:33 ` [Tarantool-patches] [PATCH v2 3/4] sql: introduce mem_cmp_scalar() Mergen Imeev via Tarantool-patches
2021-07-11 15:03   ` Vladislav Shpilevoy via Tarantool-patches
2021-07-11 17:51     ` Mergen Imeev via Tarantool-patches
2021-07-12 21:06       ` Vladislav Shpilevoy via Tarantool-patches
2021-07-13  8:04         ` Mergen Imeev via Tarantool-patches
2021-07-10 14:33 ` [Tarantool-patches] [PATCH v2 4/4] sql: introduce mem_cmp_msgpack() Mergen Imeev via Tarantool-patches
2021-07-11 15:05   ` Vladislav Shpilevoy via Tarantool-patches
2021-07-11 17:59     ` Mergen Imeev via Tarantool-patches
2021-07-12 21:09       ` Vladislav Shpilevoy via Tarantool-patches
2021-07-13  8:10         ` Mergen Imeev via Tarantool-patches
2021-07-13 20:39           ` Vladislav Shpilevoy via Tarantool-patches
2021-07-14  6:51             ` Mergen Imeev via Tarantool-patches
2021-07-14 21:53               ` Vladislav Shpilevoy via Tarantool-patches
2021-07-15  6:58                 ` Mergen Imeev via Tarantool-patches
2021-07-15 20:44 ` [Tarantool-patches] [PATCH v2 0/4] Follow ups for uuid introduction Vladislav Shpilevoy via Tarantool-patches
2021-07-16  8:57 Mergen Imeev via Tarantool-patches
2021-07-16  8:57 ` [Tarantool-patches] [PATCH v2 1/4] sql: introduce uuid to quote() Mergen Imeev via Tarantool-patches
2021-07-19  9:16   ` Timur Safin via Tarantool-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ec87733ca387c72957ac3202df1a6b0547e20fdc.1625926838.git.imeevma@gmail.com \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=imeevma@tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Tarantool development patches archive

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://lists.tarantool.org/tarantool-patches/0 tarantool-patches/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 tarantool-patches tarantool-patches/ https://lists.tarantool.org/tarantool-patches \
		tarantool-patches@dev.tarantool.org.
	public-inbox-index tarantool-patches

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git