From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@dev.tarantool.org, korablev@tarantool.org
Cc: tarantool-patches@freelists.org
Subject: [Tarantool-patches] [PATCH 1/3] sql: LENGTH function accepts boolean
Date: Sun, 27 Oct 2019 22:35:07 +0100 [thread overview]
Message-ID: <1d9e23e51b37ba689da164526807bdab3e097649.1572211914.git.v.shpilevoy@tarantool.org> (raw)
In-Reply-To: <cover.1572211914.git.v.shpilevoy@tarantool.org>
Before the patch LENGTH didn't take boolean argument
into account. Now it does and treats like any other
non-string argument - stringify and calculate length.
It is worth mentioning, that in future LENGTH will
discard any non-string argument, see #3929.
Part of #4462
---
src/box/sql/func.c | 1 +
test/sql/boolean.result | 5 +++--
test/sql/boolean.test.sql | 1 +
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/box/sql/func.c b/src/box/sql/func.c
index d5ea0fe6a..12a4bee04 100644
--- a/src/box/sql/func.c
+++ b/src/box/sql/func.c
@@ -458,6 +458,7 @@ lengthFunc(sql_context * context, int argc, sql_value ** argv)
case MP_BIN:
case MP_INT:
case MP_UINT:
+ case MP_BOOL:
case MP_DOUBLE:{
sql_result_uint(context, sql_value_bytes(argv[0]));
break;
diff --git a/test/sql/boolean.result b/test/sql/boolean.result
index 352649136..ac9f7fcaf 100644
--- a/test/sql/boolean.result
+++ b/test/sql/boolean.result
@@ -311,14 +311,15 @@ SELECT quote(a) FROM t0;
| - ['NULL']
| - ['NULL']
| ...
+-- gh-4462: LENGTH didn't take BOOLEAN arguments.
SELECT length(a) FROM t0;
| ---
| - metadata:
| - name: length(a)
| type: integer
| rows:
- | - [null]
- | - [null]
+ | - [5]
+ | - [4]
| - [null]
| - [null]
| ...
diff --git a/test/sql/boolean.test.sql b/test/sql/boolean.test.sql
index 9d71139fd..68a05852f 100644
--- a/test/sql/boolean.test.sql
+++ b/test/sql/boolean.test.sql
@@ -82,6 +82,7 @@ SELECT abs(a) FROM t0;
SELECT lower(a) FROM t0;
SELECT upper(a) FROM t0;
SELECT quote(a) FROM t0;
+-- gh-4462: LENGTH didn't take BOOLEAN arguments.
SELECT length(a) FROM t0;
SELECT typeof(a) FROM t0;
--
2.21.0 (Apple Git-122)
next prev parent reply other threads:[~2019-10-27 21:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-27 21:35 [Tarantool-patches] [PATCH 0/3] Booleans and lower vs upper Vladislav Shpilevoy
2019-10-27 21:35 ` Vladislav Shpilevoy [this message]
2019-10-27 21:35 ` [Tarantool-patches] [PATCH 2/3] sql: CAST(<boolean> AS TEXT) returns lowercase Vladislav Shpilevoy
2019-10-28 14:08 ` Nikita Pettik
2019-10-28 21:48 ` Vladislav Shpilevoy
2019-10-27 21:35 ` [Tarantool-patches] [PATCH 3/3] sql: make type string case lower everywhere Vladislav Shpilevoy
2019-10-28 14:23 ` Nikita Pettik
2019-10-28 21:45 ` Vladislav Shpilevoy
2019-11-07 12:40 ` Nikita Pettik
2019-10-30 23:28 ` [Tarantool-patches] [PATCH 0/3] Booleans and lower vs upper Nikita Pettik
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=1d9e23e51b37ba689da164526807bdab3e097649.1572211914.git.v.shpilevoy@tarantool.org \
--to=v.shpilevoy@tarantool.org \
--cc=korablev@tarantool.org \
--cc=tarantool-patches@dev.tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='Re: [Tarantool-patches] [PATCH 1/3] sql: LENGTH function accepts boolean' \
/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