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 v1 6/7] sql: disallow concatination for SCALAR Date: Wed, 11 Aug 2021 19:01:51 +0300 [thread overview] Message-ID: <85872088a5f94a22ae327a4c4624bde6fb8c7fe3.1628697448.git.imeevma@gmail.com> (raw) In-Reply-To: <cover.1628697448.git.imeevma@gmail.com> Part of #6221 --- src/box/sql/mem.c | 6 ++++-- test/sql-tap/metatypes.test.lua | 11 ++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c index e34f24c96..732d1b012 100644 --- a/src/box/sql/mem.c +++ b/src/box/sql/mem.c @@ -1552,12 +1552,14 @@ mem_concat(struct Mem *a, struct Mem *b, struct Mem *result) return 0; } /* Concatenation operation can be applied only to strings and blobs. */ - if (((b->type & (MEM_TYPE_STR | MEM_TYPE_BIN)) == 0)) { + if (((b->type & (MEM_TYPE_STR | MEM_TYPE_BIN)) == 0) || + mem_is_metatype(b)) { diag_set(ClientError, ER_INCONSISTENT_TYPES, "string or varbinary", mem_str(b)); return -1; } - if (((a->type & (MEM_TYPE_STR | MEM_TYPE_BIN)) == 0)) { + if (((a->type & (MEM_TYPE_STR | MEM_TYPE_BIN)) == 0) || + mem_is_metatype(a)) { diag_set(ClientError, ER_INCONSISTENT_TYPES, "string or varbinary", mem_str(a)); return -1; diff --git a/test/sql-tap/metatypes.test.lua b/test/sql-tap/metatypes.test.lua index 50d700cc4..b767e3f31 100755 --- a/test/sql-tap/metatypes.test.lua +++ b/test/sql-tap/metatypes.test.lua @@ -1,6 +1,6 @@ #!/usr/bin/env tarantool local test = require("sqltester") -test:plan(12) +test:plan(13) -- Check that SCALAR and NUMBER meta-types works as intended. box.execute([[CREATE TABLE t (i INT PRIMARY KEY, s SCALAR, n NUMBER);]]) @@ -124,6 +124,15 @@ test:do_catchsql_test( 1, "Type mismatch: can not convert scalar(1) to unsigned" }) +-- Check that concatination is prohibited for SCALAR values. +test:do_catchsql_test( + "metatypes-5", + [[ + SELECT CAST('asd' AS SCALAR) || 'dsa'; + ]], { + 1, "Inconsistent types: expected string or varbinary got scalar('asd')" + }) + box.execute([[DROP TABLE t;]]) test:finish_test() -- 2.25.1
next prev parent reply other threads:[~2021-08-11 16:04 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-08-11 16:01 [Tarantool-patches] [PATCH v1 0/7] Rework SCALAR and NUMBER types in SQL Mergen Imeev via Tarantool-patches 2021-08-11 16:01 ` [Tarantool-patches] [PATCH v1 1/7] sql: remove enum field_type from struct Mem Mergen Imeev via Tarantool-patches 2021-08-11 16:01 ` [Tarantool-patches] [PATCH v1 2/7] sql: re-introduce NUMBER and SCALAR meta-types Mergen Imeev via Tarantool-patches 2021-08-12 18:51 ` Vladislav Shpilevoy via Tarantool-patches 2021-08-12 22:22 ` Mergen Imeev via Tarantool-patches 2021-08-11 16:01 ` [Tarantool-patches] [PATCH v1 3/7] sql: disallow implicit cast from NUMBER and SCALAR Mergen Imeev via Tarantool-patches 2021-08-11 16:01 ` [Tarantool-patches] [PATCH v1 4/7] sql: disallow arithmetic for " Mergen Imeev via Tarantool-patches 2021-08-11 16:01 ` [Tarantool-patches] [PATCH v1 5/7] sql: disallow bitwise " Mergen Imeev via Tarantool-patches 2021-08-11 16:01 ` Mergen Imeev via Tarantool-patches [this message] 2021-08-11 16:01 ` [Tarantool-patches] [PATCH v1 7/7] sql: fix comparison with SCALAR value Mergen Imeev via Tarantool-patches 2021-08-12 18:50 ` Vladislav Shpilevoy via Tarantool-patches 2021-08-12 22:23 ` Mergen Imeev via Tarantool-patches 2021-08-13 3:12 [Tarantool-patches] [PATCH v1 0/7] Rework SCALAR and NUMBER types in SQL Mergen Imeev via Tarantool-patches 2021-08-13 3:13 ` [Tarantool-patches] [PATCH v1 6/7] sql: disallow concatination for SCALAR Mergen Imeev 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=85872088a5f94a22ae327a4c4624bde6fb8c7fe3.1628697448.git.imeevma@gmail.com \ --to=tarantool-patches@dev.tarantool.org \ --cc=imeevma@tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v1 6/7] sql: disallow concatination for SCALAR' \ /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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox