From: Mergen Imeev via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: kyukhin@tarantool.org
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH v1 2/3] sql: use field_type_MAX instead of FIELD_TYPE_ANY
Date: Thu, 11 Nov 2021 13:53:38 +0300 [thread overview]
Message-ID: <d0fcf3622b246ed1df1ea7efd306f3d1120d8d48.1636627944.git.imeevma@gmail.com> (raw)
In-Reply-To: <cover.1636627944.git.imeevma@gmail.com>
After this patch, the built-in SQL function implementation definitions
will use field_type_MAX to indicate that they accept values of any type,
instead of FIELD_TYPE_ANY.
Part of #3174
---
src/box/sql/func.c | 22 +++++++++++-----------
src/box/sql/mem.c | 2 +-
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/box/sql/func.c b/src/box/sql/func.c
index 0cf17572b..63d7536d9 100644
--- a/src/box/sql/func.c
+++ b/src/box/sql/func.c
@@ -1937,10 +1937,10 @@ static struct sql_func_definition definitions[] = {
{"CHAR", -1, {FIELD_TYPE_INTEGER}, FIELD_TYPE_STRING, charFunc, NULL},
{"CHAR_LENGTH", 1, {FIELD_TYPE_STRING}, FIELD_TYPE_INTEGER, lengthFunc,
NULL},
- {"COALESCE", -1, {FIELD_TYPE_ANY}, FIELD_TYPE_SCALAR, sql_builtin_stub,
+ {"COALESCE", -1, {field_type_MAX}, FIELD_TYPE_SCALAR, sql_builtin_stub,
NULL},
{"COUNT", 0, {}, FIELD_TYPE_INTEGER, step_count, fin_count},
- {"COUNT", 1, {FIELD_TYPE_ANY}, FIELD_TYPE_INTEGER, step_count,
+ {"COUNT", 1, {field_type_MAX}, FIELD_TYPE_INTEGER, step_count,
fin_count},
{"GREATEST", -1, {FIELD_TYPE_INTEGER}, FIELD_TYPE_INTEGER, minmaxFunc,
@@ -1967,7 +1967,7 @@ static struct sql_func_definition definitions[] = {
FIELD_TYPE_VARBINARY, step_group_concat, NULL},
{"HEX", 1, {FIELD_TYPE_VARBINARY}, FIELD_TYPE_STRING, hexFunc, NULL},
- {"IFNULL", 2, {FIELD_TYPE_ANY, FIELD_TYPE_ANY}, FIELD_TYPE_SCALAR,
+ {"IFNULL", 2, {field_type_MAX, field_type_MAX}, FIELD_TYPE_SCALAR,
sql_builtin_stub, NULL},
{"LEAST", -1, {FIELD_TYPE_INTEGER}, FIELD_TYPE_INTEGER, minmaxFunc,
@@ -1988,9 +1988,9 @@ static struct sql_func_definition definitions[] = {
FIELD_TYPE_BOOLEAN, likeFunc, NULL},
{"LIKE", 3, {FIELD_TYPE_STRING, FIELD_TYPE_STRING, FIELD_TYPE_STRING},
FIELD_TYPE_BOOLEAN, likeFunc, NULL},
- {"LIKELIHOOD", 2, {FIELD_TYPE_ANY, FIELD_TYPE_DOUBLE},
+ {"LIKELIHOOD", 2, {field_type_MAX, FIELD_TYPE_DOUBLE},
FIELD_TYPE_BOOLEAN, sql_builtin_stub, NULL},
- {"LIKELY", 1, {FIELD_TYPE_ANY}, FIELD_TYPE_BOOLEAN, sql_builtin_stub,
+ {"LIKELY", 1, {field_type_MAX}, FIELD_TYPE_BOOLEAN, sql_builtin_stub,
NULL},
{"LOWER", 1, {FIELD_TYPE_STRING}, FIELD_TYPE_STRING, LowerICUFunc,
NULL},
@@ -2013,13 +2013,13 @@ static struct sql_func_definition definitions[] = {
{"MIN", 1, {FIELD_TYPE_STRING}, FIELD_TYPE_STRING, step_minmax, NULL},
{"MIN", 1, {FIELD_TYPE_SCALAR}, FIELD_TYPE_SCALAR, step_minmax, NULL},
- {"NULLIF", 2, {FIELD_TYPE_ANY, FIELD_TYPE_ANY}, FIELD_TYPE_SCALAR,
+ {"NULLIF", 2, {field_type_MAX, field_type_MAX}, FIELD_TYPE_SCALAR,
nullifFunc, NULL},
{"POSITION", 2, {FIELD_TYPE_STRING, FIELD_TYPE_STRING},
FIELD_TYPE_INTEGER, position_func, NULL},
- {"PRINTF", -1, {FIELD_TYPE_ANY}, FIELD_TYPE_STRING, printfFunc,
+ {"PRINTF", -1, {field_type_MAX}, FIELD_TYPE_STRING, printfFunc,
NULL},
- {"QUOTE", 1, {FIELD_TYPE_ANY}, FIELD_TYPE_STRING, quoteFunc, NULL},
+ {"QUOTE", 1, {field_type_MAX}, FIELD_TYPE_STRING, quoteFunc, NULL},
{"RANDOM", 0, {}, FIELD_TYPE_INTEGER, randomFunc, NULL},
{"RANDOMBLOB", 1, {FIELD_TYPE_INTEGER}, FIELD_TYPE_VARBINARY,
randomBlob, NULL},
@@ -2062,10 +2062,10 @@ static struct sql_func_definition definitions[] = {
{FIELD_TYPE_VARBINARY, FIELD_TYPE_INTEGER, FIELD_TYPE_VARBINARY},
FIELD_TYPE_VARBINARY, trim_func, NULL},
- {"TYPEOF", 1, {FIELD_TYPE_ANY}, FIELD_TYPE_STRING, typeofFunc, NULL},
+ {"TYPEOF", 1, {field_type_MAX}, FIELD_TYPE_STRING, typeofFunc, NULL},
{"UNICODE", 1, {FIELD_TYPE_STRING}, FIELD_TYPE_INTEGER, unicodeFunc,
NULL},
- {"UNLIKELY", 1, {FIELD_TYPE_ANY}, FIELD_TYPE_BOOLEAN, sql_builtin_stub,
+ {"UNLIKELY", 1, {field_type_MAX}, FIELD_TYPE_BOOLEAN, sql_builtin_stub,
NULL},
{"UPPER", 1, {FIELD_TYPE_STRING}, FIELD_TYPE_STRING, UpperICUFunc,
NULL},
@@ -2112,7 +2112,7 @@ built_in_func_put(struct sql_func_dictionary *dict)
static inline bool
is_exact(int op, enum field_type a, enum field_type b)
{
- return op == TK_NULL || a == b || a == FIELD_TYPE_ANY ||
+ return op == TK_NULL || a == b || a == field_type_MAX ||
(a == FIELD_TYPE_INTEGER && b == FIELD_TYPE_UNSIGNED);
}
diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c
index dc629aee3..f648c5d62 100644
--- a/src/box/sql/mem.c
+++ b/src/box/sql/mem.c
@@ -1489,7 +1489,7 @@ mem_cast_explicit(struct Mem *mem, enum field_type type)
int
mem_cast_implicit(struct Mem *mem, enum field_type type)
{
- if (mem->type == MEM_TYPE_NULL || type == FIELD_TYPE_ANY)
+ if (mem->type == MEM_TYPE_NULL || type == field_type_MAX)
return 0;
if ((mem->flags & MEM_Scalar) != 0 && type != FIELD_TYPE_SCALAR)
return -1;
--
2.25.1
next prev parent reply other threads:[~2021-11-11 11:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-11 10:53 [Tarantool-patches] [PATCH v1 0/3] Introduce field type ANY to SQL Mergen Imeev via Tarantool-patches
2021-11-11 10:53 ` [Tarantool-patches] [PATCH v1 1/3] sql: properly set INTEGER type in struct Expr Mergen Imeev via Tarantool-patches
2021-11-11 10:53 ` Mergen Imeev via Tarantool-patches [this message]
2021-11-11 10:53 ` [Tarantool-patches] [PATCH v1 3/3] sql: introduce field type ANY Mergen Imeev via Tarantool-patches
2021-11-11 11:30 ` [Tarantool-patches] [PATCH v1 0/3] Introduce field type ANY to SQL Kirill Yukhin via Tarantool-patches
-- strict thread matches above, loose matches on Subject: below --
2021-10-28 10:52 Mergen Imeev via Tarantool-patches
2021-10-28 10:52 ` [Tarantool-patches] [PATCH v1 2/3] sql: use field_type_MAX instead of FIELD_TYPE_ANY 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=d0fcf3622b246ed1df1ea7efd306f3d1120d8d48.1636627944.git.imeevma@gmail.com \
--to=tarantool-patches@dev.tarantool.org \
--cc=imeevma@tarantool.org \
--cc=kyukhin@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH v1 2/3] sql: use field_type_MAX instead of FIELD_TYPE_ANY' \
/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